root/opal/mca/pmix/ext1x/pmix1x_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. external_register
  2. external_open
  3. external_close
  4. external_component_query

   1 /*
   2  * Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
   3  * Copyright (c) 2014-2018 Research Organization for Information Science
   4  *                         and Technology (RIST). All rights reserved.
   5  * Copyright (c) 2016-2018 Cisco Systems, Inc.  All rights reserved
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  *
  12  * These symbols are in a file by themselves to provide nice linker
  13  * semantics.  Since linkers generally pull in symbols by object
  14  * files, keeping these symbols as the only symbols in this file
  15  * prevents utility programs such as "ompi_info" from having to import
  16  * entire components just to query their version and parameters.
  17  */
  18 
  19 #include "opal_config.h"
  20 
  21 #include "opal/constants.h"
  22 #include "opal/class/opal_list.h"
  23 #include "opal/util/proc.h"
  24 #include "opal/util/show_help.h"
  25 #include "opal/mca/pmix/pmix.h"
  26 #include "pmix1x.h"
  27 
  28 /*
  29  * Public string showing the pmix ext1x component version number
  30  */
  31 const char *opal_pmix_ext1x_component_version_string =
  32     "OPAL external pmix1.1.4 MCA component version " OPAL_VERSION;
  33 
  34 /*
  35  * Local function
  36  */
  37 static int external_register(void);
  38 static int external_open(void);
  39 static int external_close(void);
  40 static int external_component_query(mca_base_module_t **module, int *priority);
  41 
  42 /*
  43  * Local variable
  44  */
  45 static char *pmix_library_version = NULL;
  46 
  47 
  48 /*
  49  * Instantiate the public struct with all of our public information
  50  * and pointers to our public functions in it
  51  */
  52 
  53 mca_pmix_ext1x_component_t mca_pmix_ext1x_component = {
  54     {
  55         /* First, the mca_component_t struct containing meta information
  56          * about the component itself */
  57 
  58         .base_version = {
  59            /* Indicate that we are a pmix v1.1.0 component (which also
  60             * implies a specific MCA version) */
  61 
  62             OPAL_PMIX_BASE_VERSION_2_0_0,
  63 
  64             /* Component name and version */
  65 
  66             .mca_component_name = "ext1x",
  67             MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
  68                                   OPAL_RELEASE_VERSION),
  69 
  70             /* Component open and close functions */
  71 
  72            .mca_open_component = external_open,
  73            .mca_close_component = external_close,
  74            .mca_query_component = external_component_query,
  75            .mca_register_component_params = external_register
  76         },
  77         /* Next the MCA v1.0.0 component meta data */
  78         .base_data = {
  79             /* The component is checkpoint ready */
  80             MCA_BASE_METADATA_PARAM_CHECKPOINT
  81         }
  82     },
  83     .native_launch = false
  84 };
  85 
  86 static int external_register(void)
  87 {
  88     mca_base_component_t *component = &mca_pmix_ext1x_component.super.base_version;
  89 
  90     asprintf(&pmix_library_version, "PMIx library version %s", PMIx_Get_version());
  91     (void) mca_base_component_var_register(component, "library_version",
  92                                            "Version of the underlying PMIx library",
  93                                            MCA_BASE_VAR_TYPE_STRING,
  94                                            NULL, 0, 0,
  95                                            OPAL_INFO_LVL_4,
  96                                            MCA_BASE_VAR_SCOPE_CONSTANT,
  97                                            &pmix_library_version);
  98 
  99     return OPAL_SUCCESS;
 100 }
 101 
 102 static int external_open(void)
 103 {
 104     const char *version;
 105 
 106     OBJ_CONSTRUCT(&mca_pmix_ext1x_component.jobids, opal_list_t);
 107     OBJ_CONSTRUCT(&mca_pmix_ext1x_component.values, opal_list_t);
 108 
 109     version = PMIx_Get_version();
 110     if (0 != strncmp(version, "1.2", 3)) {
 111         opal_show_help("help-pmix-base.txt",
 112                        "old-pmix", true, version, "v1.2");
 113         return OPAL_ERROR;
 114     }
 115     return OPAL_SUCCESS;
 116 }
 117 
 118 static int external_close(void)
 119 {
 120     OPAL_LIST_DESTRUCT(&mca_pmix_ext1x_component.jobids);
 121     OPAL_LIST_DESTRUCT(&mca_pmix_ext1x_component.values);
 122     return OPAL_SUCCESS;
 123 }
 124 
 125 
 126 static int external_component_query(mca_base_module_t **module, int *priority)
 127 {
 128     char *t, *id;
 129 
 130     /* see if a PMIx server is present */
 131     if (NULL != (t = getenv("PMIX_SERVER_URI")) ||
 132         NULL != (id = getenv("PMIX_ID"))) {
 133         /* if PMIx is present, then we are a client and need to use it */
 134         *priority = 100;
 135     } else {
 136         /* we could be a server, so we still need to be considered */
 137         *priority = 5;
 138     }
 139     *module = (mca_base_module_t *)&opal_pmix_ext1x_module;
 140     return OPAL_SUCCESS;
 141 }

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