root/orte/mca/ras/slurm/ras_slurm_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. ras_slurm_register
  2. ras_slurm_open
  3. ras_slurm_close
  4. orte_ras_slurm_component_query

   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) 2012-2015 Los Alamos National Security, LLC. All rights
  14  *                         reserved.
  15  * Copyright (c) 2015      Intel, Inc. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "orte_config.h"
  24 #include "orte/constants.h"
  25 
  26 #include "opal/mca/base/base.h"
  27 #include "opal/util/net.h"
  28 #include "opal/opal_socket_errno.h"
  29 
  30 #include "orte/util/name_fns.h"
  31 #include "orte/mca/errmgr/errmgr.h"
  32 #include "orte/runtime/orte_globals.h"
  33 
  34 #include "orte/mca/ras/base/ras_private.h"
  35 #include "ras_slurm.h"
  36 
  37 
  38 /*
  39  * Local functions
  40  */
  41 static int ras_slurm_register(void);
  42 static int ras_slurm_open(void);
  43 static int ras_slurm_close(void);
  44 static int orte_ras_slurm_component_query(mca_base_module_t **module, int *priority);
  45 
  46 
  47 orte_ras_slurm_component_t mca_ras_slurm_component = {
  48     {
  49         /* First, the mca_base_component_t struct containing meta
  50            information about the component itself */
  51 
  52         .base_version = {
  53             ORTE_RAS_BASE_VERSION_2_0_0,
  54 
  55             /* Component name and version */
  56             .mca_component_name = "slurm",
  57             MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION,
  58                                   ORTE_RELEASE_VERSION),
  59 
  60             /* Component open and close functions */
  61             .mca_open_component = ras_slurm_open,
  62             .mca_close_component = ras_slurm_close,
  63             .mca_query_component = orte_ras_slurm_component_query,
  64             .mca_register_component_params = ras_slurm_register
  65         },
  66         .base_data = {
  67             /* The component is checkpoint ready */
  68             MCA_BASE_METADATA_PARAM_CHECKPOINT
  69         },
  70     }
  71 };
  72 
  73 
  74 static int ras_slurm_register(void)
  75 {
  76     mca_base_component_t *component = &mca_ras_slurm_component.super.base_version;
  77 
  78     mca_ras_slurm_component.timeout = 30;
  79     (void) mca_base_component_var_register (component, "dyn_allocate_timeout",
  80                                             "Number of seconds to wait for Slurm dynamic allocation",
  81                                             MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
  82                                             OPAL_INFO_LVL_9,
  83                                             MCA_BASE_VAR_SCOPE_READONLY,
  84                                             &mca_ras_slurm_component.timeout);
  85 
  86     mca_ras_slurm_component.dyn_alloc_enabled = false;
  87     (void) mca_base_component_var_register (component, "enable_dyn_alloc",
  88                                             "Whether or not dynamic allocations are enabled",
  89                                             MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
  90                                             OPAL_INFO_LVL_9,
  91                                             MCA_BASE_VAR_SCOPE_READONLY,
  92                                             &mca_ras_slurm_component.dyn_alloc_enabled);
  93 
  94     mca_ras_slurm_component.config_file = NULL;
  95     (void) mca_base_component_var_register (component, "config_file",
  96                                             "Path to Slurm configuration file",
  97                                             MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
  98                                             OPAL_INFO_LVL_9,
  99                                             MCA_BASE_VAR_SCOPE_READONLY,
 100                                             &mca_ras_slurm_component.config_file);
 101 
 102     mca_ras_slurm_component.rolling_alloc = false;
 103     (void) mca_base_component_var_register (component, "enable_rolling_alloc",
 104                                             "Enable partial dynamic allocations",
 105                                             MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
 106                                             OPAL_INFO_LVL_9,
 107                                             MCA_BASE_VAR_SCOPE_READONLY,
 108                                             &mca_ras_slurm_component.rolling_alloc);
 109 
 110     mca_ras_slurm_component.use_all = false;
 111     (void) mca_base_component_var_register (component, "use_entire_allocation",
 112                                             "Use entire allocation (not just job step nodes) for this application",
 113                                             MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
 114                                             OPAL_INFO_LVL_5,
 115                                             MCA_BASE_VAR_SCOPE_READONLY,
 116                                             &mca_ras_slurm_component.use_all);
 117 
 118     return ORTE_SUCCESS;
 119 }
 120 
 121 static int ras_slurm_open(void)
 122 {
 123     return ORTE_SUCCESS;
 124 }
 125 
 126 static int ras_slurm_close(void)
 127 {
 128     return ORTE_SUCCESS;
 129 }
 130 
 131 static int orte_ras_slurm_component_query(mca_base_module_t **module, int *priority)
 132 {
 133     /* if I built, then slurm support is available. If
 134      * I am not in a Slurm allocation, and dynamic alloc
 135      * is not enabled, then disqualify myself
 136      */
 137     if (NULL == getenv("SLURM_JOBID") &&
 138         !mca_ras_slurm_component.dyn_alloc_enabled) {
 139         /* disqualify ourselves */
 140         *priority = 0;
 141         *module = NULL;
 142         return ORTE_ERROR;
 143     }
 144 
 145     OPAL_OUTPUT_VERBOSE((2, orte_ras_base_framework.framework_output,
 146                          "%s ras:slurm: available for selection",
 147                          ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
 148     /* since only one RM can exist on a cluster, just set
 149      * my priority to something - the other components won't
 150      * be responding anyway
 151      */
 152     *priority = 50;
 153     *module = (mca_base_module_t *) &orte_ras_slurm_module;
 154     return ORTE_SUCCESS;
 155 }

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