root/opal/mca/compress/gzip/compress_gzip_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. nocompress
  2. nodecompress
  3. compress_gzip_register
  4. compress_gzip_open
  5. compress_gzip_close
  6. opal_compress_gzip_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_gzip.h"
  21 
  22 /*
  23  * Public string for version number
  24  */
  25 const char *opal_compress_gzip_component_version_string =
  26 "OPAL COMPRESS gzip MCA component version " OPAL_VERSION;
  27 
  28 /*
  29  * Local functionality
  30  */
  31 static int compress_gzip_register (void);
  32 static int compress_gzip_open(void);
  33 static int compress_gzip_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_gzip_component_t mca_compress_gzip_component = {
  40     /* First do the base component stuff */
  41     {
  42         /* Handle the general mca_component_t struct containing
  43          *  meta information about the component itgzip
  44          */
  45         .base_version = {
  46             OPAL_COMPRESS_BASE_VERSION_2_0_0,
  47 
  48             /* Component name and version */
  49             .mca_component_name = "gzip",
  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_gzip_open,
  55             .mca_close_component = compress_gzip_close,
  56             .mca_query_component = opal_compress_gzip_component_query,
  57             .mca_register_component_params = compress_gzip_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 static bool nocompress(uint8_t *inbytes,
  70                        size_t inlen,
  71                        uint8_t **outbytes,
  72                        size_t *olen)
  73 {
  74     return false;
  75 }
  76 
  77 static bool nodecompress(uint8_t **outbytes, size_t olen,
  78                          uint8_t *inbytes, size_t len)
  79 {
  80     return false;
  81 }
  82 
  83 /*
  84  * Gzip module
  85  */
  86 static opal_compress_base_module_t loc_module = {
  87     /** Initialization Function */
  88     .init = opal_compress_gzip_module_init,
  89     /** Finalization Function */
  90     .finalize = opal_compress_gzip_module_finalize,
  91 
  92     /** Compress Function */
  93     .compress = opal_compress_gzip_compress,
  94     .compress_nb = opal_compress_gzip_compress_nb,
  95 
  96     /** Decompress Function */
  97     .decompress = opal_compress_gzip_decompress,
  98     .decompress_nb = opal_compress_gzip_decompress_nb,
  99 
 100     .compress_block = nocompress,
 101     .decompress_block = nodecompress
 102 };
 103 
 104 static int compress_gzip_register (void)
 105 {
 106     int ret;
 107 
 108     mca_compress_gzip_component.super.priority = 15;
 109     ret = mca_base_component_var_register (&mca_compress_gzip_component.super.base_version,
 110                                            "priority", "Priority of the COMPRESS gzip component "
 111                                            "(default: 15)", MCA_BASE_VAR_TYPE_INT, NULL, 0,
 112                                            MCA_BASE_VAR_FLAG_SETTABLE,
 113                                            OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL_EQ,
 114                                            &mca_compress_gzip_component.super.priority);
 115     if (0 > ret) {
 116         return ret;
 117     }
 118 
 119     mca_compress_gzip_component.super.verbose = 0;
 120     ret = mca_base_component_var_register (&mca_compress_gzip_component.super.base_version,
 121                                            "verbose",
 122                                            "Verbose level for the COMPRESS gzip component",
 123                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 124                                            OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL,
 125                                            &mca_compress_gzip_component.super.verbose);
 126     return (0 > ret) ? ret : OPAL_SUCCESS;
 127 }
 128 
 129 static int compress_gzip_open(void)
 130 {
 131     /* If there is a custom verbose level for this component than use it
 132      * otherwise take our parents level and output channel
 133      */
 134     if ( 0 != mca_compress_gzip_component.super.verbose) {
 135         mca_compress_gzip_component.super.output_handle = opal_output_open(NULL);
 136         opal_output_set_verbosity(mca_compress_gzip_component.super.output_handle,
 137                                   mca_compress_gzip_component.super.verbose);
 138     } else {
 139         mca_compress_gzip_component.super.output_handle = opal_compress_base_framework.framework_output;
 140     }
 141 
 142     /*
 143      * Debug output
 144      */
 145     opal_output_verbose(10, mca_compress_gzip_component.super.output_handle,
 146                         "compress:gzip: open()");
 147     opal_output_verbose(20, mca_compress_gzip_component.super.output_handle,
 148                         "compress:gzip: open: priority = %d",
 149                         mca_compress_gzip_component.super.priority);
 150     opal_output_verbose(20, mca_compress_gzip_component.super.output_handle,
 151                         "compress:gzip: open: verbosity = %d",
 152                         mca_compress_gzip_component.super.verbose);
 153     return OPAL_SUCCESS;
 154 }
 155 
 156 static int compress_gzip_close(void)
 157 {
 158     return OPAL_SUCCESS;
 159 }
 160 
 161 int opal_compress_gzip_component_query(mca_base_module_t **module, int *priority)
 162 {
 163     *module   = (mca_base_module_t *)&loc_module;
 164     *priority = mca_compress_gzip_component.super.priority;
 165 
 166     return OPAL_SUCCESS;
 167 }
 168 

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