root/orte/mca/plm/slurm/plm_slurm_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. plm_slurm_register
  2. plm_slurm_open
  3. orte_plm_slurm_component_query
  4. plm_slurm_close

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
  14  *                         reserved.
  15  * Copyright (c) 2017      Intel, Inc. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  *
  22  * These symbols are in a file by themselves to provide nice linker
  23  * semantics.  Since linkers generally pull in symbols by object
  24  * files, keeping these symbols as the only symbols in this file
  25  * prevents utility programs such as "ompi_info" from having to import
  26  * entire components just to query their version and parameters.
  27  */
  28 
  29 #include "orte_config.h"
  30 #include "orte/constants.h"
  31 
  32 #include "opal/util/opal_environ.h"
  33 #include "orte/util/name_fns.h"
  34 #include "orte/util/show_help.h"
  35 #include "orte/runtime/orte_globals.h"
  36 
  37 #include "orte/mca/plm/plm.h"
  38 #include "orte/mca/plm/base/plm_private.h"
  39 #include "plm_slurm.h"
  40 
  41 
  42 /*
  43  * Public string showing the plm ompi_slurm component version number
  44  */
  45 const char *mca_plm_slurm_component_version_string =
  46   "Open MPI slurm plm MCA component version " ORTE_VERSION;
  47 
  48 
  49 /*
  50  * Local functions
  51  */
  52 static int plm_slurm_register(void);
  53 static int plm_slurm_open(void);
  54 static int plm_slurm_close(void);
  55 static int orte_plm_slurm_component_query(mca_base_module_t **module, int *priority);
  56 
  57 
  58 /*
  59  * Instantiate the public struct with all of our public information
  60  * and pointers to our public functions in it
  61  */
  62 
  63 orte_plm_slurm_component_t mca_plm_slurm_component = {
  64 
  65     {
  66         /* First, the mca_component_t struct containing meta
  67            information about the component itself */
  68 
  69         .base_version = {
  70             ORTE_PLM_BASE_VERSION_2_0_0,
  71 
  72             /* Component name and version */
  73             .mca_component_name = "slurm",
  74             MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION,
  75                                   ORTE_RELEASE_VERSION),
  76 
  77             /* Component open and close functions */
  78             .mca_open_component = plm_slurm_open,
  79             .mca_close_component = plm_slurm_close,
  80             .mca_query_component = orte_plm_slurm_component_query,
  81             .mca_register_component_params = plm_slurm_register,
  82         },
  83         .base_data = {
  84             /* The component is checkpoint ready */
  85             MCA_BASE_METADATA_PARAM_CHECKPOINT
  86         },
  87     }
  88 
  89     /* Other orte_plm_slurm_component_t items -- left uninitialized
  90        here; will be initialized in plm_slurm_open() */
  91 };
  92 
  93 
  94 static int plm_slurm_register(void)
  95 {
  96     mca_base_component_t *comp = &mca_plm_slurm_component.super.base_version;
  97 
  98     mca_plm_slurm_component.custom_args = NULL;
  99     (void) mca_base_component_var_register (comp, "args", "Custom arguments to srun",
 100                                             MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
 101                                             OPAL_INFO_LVL_9,
 102                                             MCA_BASE_VAR_SCOPE_READONLY,
 103                                             &mca_plm_slurm_component.custom_args);
 104 
 105     mca_plm_slurm_component.slurm_warning_msg = true;
 106     (void) mca_base_component_var_register (comp, "warning", "Turn off warning message",
 107                                             MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
 108                                             OPAL_INFO_LVL_9,
 109                                             MCA_BASE_VAR_SCOPE_READONLY,
 110                                             &mca_plm_slurm_component.slurm_warning_msg);
 111 
 112     return ORTE_SUCCESS;
 113 }
 114 
 115 static int plm_slurm_open(void)
 116 {
 117     return ORTE_SUCCESS;
 118 }
 119 
 120 static int orte_plm_slurm_component_query(mca_base_module_t **module, int *priority)
 121 {
 122     /* Are we running under a SLURM job? */
 123 
 124     if (NULL != getenv("SLURM_JOBID")) {
 125         *priority = 75;
 126 
 127         OPAL_OUTPUT_VERBOSE((1, orte_plm_base_framework.framework_output,
 128                              "%s plm:slurm: available for selection",
 129                              ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
 130 
 131         *module = (mca_base_module_t *)&orte_plm_slurm_module;
 132         return ORTE_SUCCESS;
 133     }
 134 
 135     /* Sadly, no */
 136     *module = NULL;
 137     return ORTE_ERROR;
 138 }
 139 
 140 
 141 static int plm_slurm_close(void)
 142 {
 143     return ORTE_SUCCESS;
 144 }

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