root/opal/mca/compress/zlib/compress_zlib_component.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. compress_zlib_register
  2. compress_zlib_open
  3. compress_zlib_close
  4. opal_compress_zlib_component_query

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2010 The Trustees of Indiana University.
   4  *                         All rights reserved.
   5  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
   6  *                         reserved.
   7  * Copyright (c) 2019      Intel, Inc.  All rights reserved.
   8  * $COPYRIGHT$
   9  *
  10  * Additional copyrights may follow
  11  *
  12  * $HEADER$
  13  */
  14 
  15 #include "opal_config.h"
  16 
  17 #include "opal/constants.h"
  18 #include "opal/mca/compress/compress.h"
  19 #include "opal/mca/compress/base/base.h"
  20 #include "compress_zlib.h"
  21 
  22 /*
  23  * Public string for version number
  24  */
  25 const char *opal_compress_zlib_component_version_string =
  26 "OPAL COMPRESS zlib MCA component version " OPAL_VERSION;
  27 
  28 /*
  29  * Local functionality
  30  */
  31 static int compress_zlib_register (void);
  32 static int compress_zlib_open(void);
  33 static int compress_zlib_close(void);
  34 
  35 /*
  36  * Instantiate the public struct with all of our public information
  37  * and pointer to our public functions in it
  38  */
  39 opal_compress_zlib_component_t mca_compress_zlib_component = {
  40     /* First do the base component stuff */
  41     {
  42         /* Handle the general mca_component_t struct containing
  43          *  meta information about the component itzlib
  44          */
  45         .base_version = {
  46             OPAL_COMPRESS_BASE_VERSION_2_0_0,
  47 
  48             /* Component name and version */
  49             .mca_component_name = "zlib",
  50             MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
  51                                        OPAL_RELEASE_VERSION),
  52 
  53             /* Component open and close functions */
  54             .mca_open_component = compress_zlib_open,
  55             .mca_close_component = compress_zlib_close,
  56             .mca_query_component = opal_compress_zlib_component_query,
  57             .mca_register_component_params = compress_zlib_register
  58         },
  59         .base_data = {
  60             /* The component is checkpoint ready */
  61             MCA_BASE_METADATA_PARAM_CHECKPOINT
  62         },
  63 
  64         .verbose = 0,
  65         .output_handle = -1,
  66     }
  67 };
  68 
  69 /*
  70  * Zlib module
  71  */
  72 static opal_compress_base_module_t loc_module = {
  73     /** Initialization Function */
  74     .init = opal_compress_zlib_module_init,
  75     /** Finalization Function */
  76     .finalize = opal_compress_zlib_module_finalize,
  77 
  78     /** Compress Function */
  79     .compress_block = opal_compress_zlib_compress_block,
  80 
  81     /** Decompress Function */
  82     .decompress_block = opal_compress_zlib_uncompress_block,
  83 };
  84 
  85 static int compress_zlib_register (void)
  86 {
  87     int ret;
  88 
  89     mca_compress_zlib_component.super.priority = 50;
  90     ret = mca_base_component_var_register (&mca_compress_zlib_component.super.base_version,
  91                                            "priority", "Priority of the COMPRESS zlib component "
  92                                            "(default: 50)", MCA_BASE_VAR_TYPE_INT, NULL, 0,
  93                                            MCA_BASE_VAR_FLAG_SETTABLE,
  94                                            OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL_EQ,
  95                                            &mca_compress_zlib_component.super.priority);
  96     if (0 > ret) {
  97         return ret;
  98     }
  99 
 100     mca_compress_zlib_component.super.verbose = 0;
 101     ret = mca_base_component_var_register (&mca_compress_zlib_component.super.base_version,
 102                                            "verbose",
 103                                            "Verbose level for the COMPRESS zlib component",
 104                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 105                                            OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL,
 106                                            &mca_compress_zlib_component.super.verbose);
 107     return (0 > ret) ? ret : OPAL_SUCCESS;
 108 }
 109 
 110 static int compress_zlib_open(void)
 111 {
 112     /* If there is a custom verbose level for this component than use it
 113      * otherwise take our parents level and output channel
 114      */
 115     if ( 0 != mca_compress_zlib_component.super.verbose) {
 116         mca_compress_zlib_component.super.output_handle = opal_output_open(NULL);
 117         opal_output_set_verbosity(mca_compress_zlib_component.super.output_handle,
 118                                   mca_compress_zlib_component.super.verbose);
 119     } else {
 120         mca_compress_zlib_component.super.output_handle = opal_compress_base_framework.framework_output;
 121     }
 122 
 123     /*
 124      * Debug output
 125      */
 126     opal_output_verbose(10, mca_compress_zlib_component.super.output_handle,
 127                         "compress:zlib: open()");
 128     opal_output_verbose(20, mca_compress_zlib_component.super.output_handle,
 129                         "compress:zlib: open: priority = %d",
 130                         mca_compress_zlib_component.super.priority);
 131     opal_output_verbose(20, mca_compress_zlib_component.super.output_handle,
 132                         "compress:zlib: open: verbosity = %d",
 133                         mca_compress_zlib_component.super.verbose);
 134     return OPAL_SUCCESS;
 135 }
 136 
 137 static int compress_zlib_close(void)
 138 {
 139     return OPAL_SUCCESS;
 140 }
 141 
 142 int opal_compress_zlib_component_query(mca_base_module_t **module, int *priority)
 143 {
 144     *module   = (mca_base_module_t *)&loc_module;
 145     *priority = mca_compress_zlib_component.super.priority;
 146 
 147     return OPAL_SUCCESS;
 148 }
 149 

/* [<][>][^][v][top][bottom][index][help] */