root/opal/mca/compress/bzip/compress_bzip_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. nocompress
  2. nodecompress
  3. compress_bzip_register
  4. compress_bzip_open
  5. compress_bzip_close
  6. opal_compress_bzip_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_bzip.h"
  21 
  22 /*
  23  * Public string for version number
  24  */
  25 const char *opal_compress_bzip_component_version_string =
  26 "OPAL COMPRESS bzip MCA component version " OPAL_VERSION;
  27 
  28 /*
  29  * Local functionality
  30  */
  31 static int compress_bzip_register (void);
  32 static int compress_bzip_open(void);
  33 static int compress_bzip_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_bzip_component_t mca_compress_bzip_component = {
  40     /* First do the base component stuff */
  41     {
  42         /* Handle the general mca_component_t struct containing
  43          *  meta information about the component itbzip
  44          */
  45         .base_version = {
  46             OPAL_COMPRESS_BASE_VERSION_2_0_0,
  47 
  48             /* Component name and version */
  49             .mca_component_name = "bzip",
  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_bzip_open,
  55             .mca_close_component = compress_bzip_close,
  56             .mca_query_component = opal_compress_bzip_component_query,
  57             .mca_register_component_params = compress_bzip_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  * Bzip module
  85  */
  86 static opal_compress_base_module_t loc_module = {
  87     /** Initialization Function */
  88     .init = opal_compress_bzip_module_init,
  89     /** Finalization Function */
  90     .finalize = opal_compress_bzip_module_finalize,
  91 
  92     /** Compress Function */
  93     .compress = opal_compress_bzip_compress,
  94     .compress_nb = opal_compress_bzip_compress_nb,
  95 
  96     /** Decompress Function */
  97     .decompress = opal_compress_bzip_decompress,
  98     .decompress_nb = opal_compress_bzip_decompress_nb,
  99 
 100     .compress_block = nocompress,
 101     .decompress_block = nodecompress
 102 };
 103 
 104 static int compress_bzip_register (void)
 105 {
 106     int ret;
 107 
 108     mca_compress_bzip_component.super.priority = 10;
 109     ret = mca_base_component_var_register (&mca_compress_bzip_component.super.base_version,
 110                                            "priority", "Priority of the COMPRESS bzip component "
 111                                            "(default: 10)", 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_bzip_component.super.priority);
 115     if (0 > ret) {
 116         return ret;
 117     }
 118 
 119     ret = mca_base_component_var_register (&mca_compress_bzip_component.super.base_version,
 120                                            "verbose",
 121                                            "Verbose level for the COMPRESS bzip component",
 122                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 123                                            OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_LOCAL,
 124                                            &mca_compress_bzip_component.super.verbose);
 125     return (0 > ret) ? ret : OPAL_SUCCESS;
 126 }
 127 
 128 static int compress_bzip_open(void)
 129 {
 130     /* If there is a custom verbose level for this component than use it
 131      * otherwise take our parents level and output channel
 132      */
 133     if ( 0 != mca_compress_bzip_component.super.verbose) {
 134         mca_compress_bzip_component.super.output_handle = opal_output_open(NULL);
 135         opal_output_set_verbosity(mca_compress_bzip_component.super.output_handle,
 136                                   mca_compress_bzip_component.super.verbose);
 137     } else {
 138         mca_compress_bzip_component.super.output_handle = opal_compress_base_framework.framework_output;
 139     }
 140 
 141     /*
 142      * Debug output
 143      */
 144     opal_output_verbose(10, mca_compress_bzip_component.super.output_handle,
 145                         "compress:bzip: open()");
 146     opal_output_verbose(20, mca_compress_bzip_component.super.output_handle,
 147                         "compress:bzip: open: priority = %d",
 148                         mca_compress_bzip_component.super.priority);
 149     opal_output_verbose(20, mca_compress_bzip_component.super.output_handle,
 150                         "compress:bzip: open: verbosity = %d",
 151                         mca_compress_bzip_component.super.verbose);
 152     return OPAL_SUCCESS;
 153 }
 154 
 155 static int compress_bzip_close(void)
 156 {
 157     return OPAL_SUCCESS;
 158 }
 159 
 160 int opal_compress_bzip_component_query(mca_base_module_t **module, int *priority)
 161 {
 162     *module   = (mca_base_module_t *)&loc_module;
 163     *priority = mca_compress_bzip_component.super.priority;
 164 
 165     return OPAL_SUCCESS;
 166 }
 167 

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