root/oshmem/mca/scoll/mpi/scoll_mpi_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. reg_int
  2. mpi_register
  3. mpi_open
  4. mpi_close

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2011 Mellanox Technologies. All rights reserved.
   4  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
   5  *                         reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 #include <stdio.h>
  13 
  14 #include <dlfcn.h>
  15 #include <libgen.h>
  16 
  17 #include "scoll_mpi.h"
  18 
  19 /*
  20  * Public string showing the oshmem scoll_mpi component version number
  21  */
  22 const char *mca_scoll_mpi_component_version_string =
  23   "OpenSHMEM MPI collective MCA component version " OSHMEM_VERSION;
  24 
  25 
  26 static int mpi_open(void);
  27 static int mpi_close(void);
  28 static int mpi_register(void);
  29 int mca_scoll_mpi_output = -1;
  30 mca_scoll_mpi_component_t mca_scoll_mpi_component = {
  31 
  32     /* First, the mca_component_t struct containing meta information
  33        about the component itfca */
  34     {
  35         .scoll_version = {
  36             MCA_SCOLL_BASE_VERSION_2_0_0,
  37 
  38             /* Component name and version */
  39             .mca_component_name = "mpi",
  40             MCA_BASE_MAKE_VERSION(component, OSHMEM_MAJOR_VERSION, OSHMEM_MINOR_VERSION,
  41                                   OSHMEM_RELEASE_VERSION),
  42 
  43             /* Component open and close functions */
  44             .mca_open_component = mpi_open,
  45             .mca_close_component = mpi_close,
  46             .mca_register_component_params = mpi_register,
  47         },
  48         .scoll_data = {
  49             /* The component is not checkpoint ready */
  50             MCA_BASE_METADATA_PARAM_NONE
  51         },
  52 
  53         /* Initialization / querying functions */
  54 
  55         .scoll_init = mca_scoll_mpi_init_query,
  56         .scoll_query = mca_scoll_mpi_comm_query,
  57     },
  58     77, /* priority */
  59     0,  /* verbose level */
  60     1,   /* mpi_enable */
  61     2   /*mpi_np */
  62 };
  63 
  64 /*
  65  *  * Local flags
  66  *   */
  67 enum {
  68     REGINT_NEG_ONE_OK = 0x01,
  69     REGINT_GE_ZERO = 0x02,
  70     REGINT_GE_ONE = 0x04,
  71     REGINT_NONZERO = 0x08,
  72     REGINT_MAX = 0x88
  73 };
  74 
  75 enum {
  76     REGSTR_EMPTY_OK = 0x01,
  77     REGSTR_MAX = 0x88
  78 };
  79 
  80 
  81 /*
  82  * Utility routine for integer parameter registration
  83  */
  84 static int reg_int(const char* param_name,
  85         const char* deprecated_param_name,
  86         const char* param_desc,
  87         int default_value, int *storage, int flags)
  88 {
  89     int index;
  90 
  91     *storage = default_value;
  92     index = mca_base_component_var_register(
  93             &mca_scoll_mpi_component.super.scoll_version,
  94             param_name, param_desc, MCA_BASE_VAR_TYPE_INT,
  95             NULL, 0, 0,OPAL_INFO_LVL_9,
  96             MCA_BASE_VAR_SCOPE_READONLY, storage);
  97     if (NULL != deprecated_param_name) {
  98         (void) mca_base_var_register_synonym(index,
  99                 "oshmem", "scoll", "mpi", deprecated_param_name,
 100                 MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
 101     }
 102 
 103     if (0 != (flags & REGINT_NEG_ONE_OK) && -1 == *storage) {
 104         return OSHMEM_SUCCESS;
 105     }
 106 
 107     if ((0 != (flags & REGINT_GE_ZERO) && *storage < 0) ||
 108             (0 != (flags & REGINT_GE_ONE) && *storage < 1) ||
 109             (0 != (flags & REGINT_NONZERO) && 0 == *storage)) {
 110         opal_output(0, "Bad parameter value for parameter \"%s\"",
 111                 param_name);
 112         return OSHMEM_ERR_BAD_PARAM;
 113     }
 114 
 115     return OSHMEM_SUCCESS;
 116 }
 117 
 118 
 119 static int mpi_register(void)
 120 {
 121 
 122     int ret, tmp;
 123 
 124     ret = OSHMEM_SUCCESS;
 125 
 126 #define CHECK(expr) do {                        \
 127         tmp = (expr);                           \
 128         if (OSHMEM_SUCCESS != tmp) ret = tmp;     \
 129     } while (0)
 130 
 131 
 132     CHECK(reg_int("priority",NULL,
 133                   "Priority of the mpi coll component",
 134                   mca_scoll_mpi_component.mpi_priority,
 135                   &mca_scoll_mpi_component.mpi_priority,
 136                   0));
 137 
 138     CHECK(reg_int("verbose", NULL,
 139                   "Verbose level of the mpi coll component",
 140                   mca_scoll_mpi_component.mpi_verbose,
 141                   &mca_scoll_mpi_component.mpi_verbose,
 142                   0));
 143 
 144     CHECK(reg_int("enable",NULL,
 145                   "[1|0|] Enable/Disable MPI scoll component",
 146                   mca_scoll_mpi_component.mpi_enable,
 147                   &mca_scoll_mpi_component.mpi_enable,
 148                   0));
 149 
 150     CHECK(reg_int("np",NULL,
 151                   "Minimal number of processes in the communicator"
 152                   " for the corresponding mpi context to be created",
 153                   mca_scoll_mpi_component.mpi_np,
 154                   &mca_scoll_mpi_component.mpi_np,
 155                   0));
 156 
 157     return ret;
 158 }
 159 
 160 static int mpi_open(void)
 161 {
 162     mca_scoll_mpi_component_t *cm;
 163     cm  = &mca_scoll_mpi_component;
 164 
 165     mca_scoll_mpi_output = opal_output_open(NULL);
 166     opal_output_set_verbosity(mca_scoll_mpi_output, cm->mpi_verbose);
 167     return OSHMEM_SUCCESS;
 168 }
 169 
 170 static int mpi_close(void)
 171 {
 172     return OSHMEM_SUCCESS;
 173 }

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