root/orte/mca/rmaps/rank_file/rmaps_rank_file_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_rmaps_rank_file_register
  2. orte_rmaps_rank_file_open
  3. orte_rmaps_rank_file_query
  4. orte_rmaps_rank_file_close
  5. rf_map_construct
  6. rf_map_destruct

   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) 2008      Voltaire. All rights reserved
  14  * Copyright (c) 2011      Cisco Systems, Inc.  All rights reserved.
  15  * Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
  16  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
  17  *                         reserved.
  18  * Copyright (c) 2019 IBM Corporation. All rights reserved.
  19  * $COPYRIGHT$
  20  *
  21  * Additional copyrights may follow
  22  *
  23  * $HEADER$
  24  */
  25 
  26 #include "orte_config.h"
  27 #include "orte/constants.h"
  28 
  29 #include <string.h>
  30 
  31 #include "opal/mca/base/base.h"
  32 #include "opal/mca/hwloc/base/base.h"
  33 
  34 #include "orte/util/show_help.h"
  35 
  36 #include "orte/mca/rmaps/base/base.h"
  37 #include "orte/mca/rmaps/base/rmaps_private.h"
  38 #include "orte/mca/rmaps/rank_file/rmaps_rank_file.h"
  39 #include "orte/mca/rmaps/rank_file/rmaps_rank_file_lex.h"
  40 
  41 /*
  42  * Local functions
  43  */
  44 
  45 static int orte_rmaps_rank_file_register(void);
  46 static int orte_rmaps_rank_file_open(void);
  47 static int orte_rmaps_rank_file_close(void);
  48 static int orte_rmaps_rank_file_query(mca_base_module_t **module, int *priority);
  49 
  50 static int my_priority;
  51 
  52 orte_rmaps_rf_component_t mca_rmaps_rank_file_component = {
  53     {
  54         /* First, the mca_base_component_t struct containing meta
  55            information about the component itself */
  56 
  57         .base_version = {
  58             ORTE_RMAPS_BASE_VERSION_2_0_0,
  59 
  60             .mca_component_name = "rank_file",
  61             MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION,
  62                                   ORTE_RELEASE_VERSION),
  63             .mca_open_component = orte_rmaps_rank_file_open,
  64             .mca_close_component = orte_rmaps_rank_file_close,
  65             .mca_query_component = orte_rmaps_rank_file_query,
  66             .mca_register_component_params = orte_rmaps_rank_file_register,
  67         },
  68         .base_data = {
  69             /* The component is checkpoint ready */
  70             MCA_BASE_METADATA_PARAM_CHECKPOINT
  71         },
  72     }
  73 };
  74 
  75 /**
  76   * component register/open/close/init function
  77   */
  78 static int orte_rmaps_rank_file_register(void)
  79 {
  80     mca_base_component_t *c = &mca_rmaps_rank_file_component.super.base_version;
  81     int tmp;
  82 
  83     my_priority = 0;
  84     (void) mca_base_component_var_register(c, "priority", "Priority of the rank_file rmaps component",
  85                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
  86                                            OPAL_INFO_LVL_9,
  87                                            MCA_BASE_VAR_SCOPE_READONLY, &my_priority);
  88     orte_rankfile = NULL;
  89     tmp = mca_base_component_var_register(c, "path",
  90                                           "Name of the rankfile to be used for mapping processes (relative or absolute path)",
  91                                           MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
  92                                           OPAL_INFO_LVL_5,
  93                                           MCA_BASE_VAR_SCOPE_READONLY, &orte_rankfile);
  94     (void) mca_base_var_register_synonym(tmp, "orte", "orte", NULL, "rankfile", 0);
  95 
  96     mca_rmaps_rank_file_component.physical = false;
  97     (void) mca_base_component_var_register(c, "physical", "Rankfile contains physical cpu designations",
  98                                            MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
  99                                            OPAL_INFO_LVL_5,
 100                                            MCA_BASE_VAR_SCOPE_READONLY,
 101                                            &mca_rmaps_rank_file_component.physical);
 102 
 103 
 104     return ORTE_SUCCESS;
 105 }
 106 
 107 static int orte_rmaps_rank_file_open(void)
 108 {
 109     /* ensure we flag mapping by user */
 110     if ((OPAL_BIND_TO_CPUSET == OPAL_GET_BINDING_POLICY(opal_hwloc_binding_policy) &&
 111         !OPAL_BIND_ORDERED_REQUESTED(opal_hwloc_binding_policy)) ||
 112         NULL != orte_rankfile) {
 113         if (ORTE_MAPPING_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
 114             /* if a non-default mapping is already specified, then we
 115              * have an error
 116              */
 117             orte_show_help("help-orte-rmaps-base.txt", "redefining-policy", true, "mapping",
 118                            "RANK_FILE", orte_rmaps_base_print_mapping(orte_rmaps_base.mapping));
 119             ORTE_SET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping, ORTE_MAPPING_CONFLICTED);
 120             return ORTE_ERR_SILENT;
 121         }
 122         ORTE_SET_MAPPING_POLICY(orte_rmaps_base.mapping, ORTE_MAPPING_BYUSER);
 123         ORTE_SET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping, ORTE_MAPPING_GIVEN);
 124         /* we are going to bind to cpuset since the user is specifying the cpus */
 125         OPAL_SET_BINDING_POLICY(opal_hwloc_binding_policy, OPAL_BIND_TO_CPUSET);
 126         /* make us first */
 127         my_priority = 10000;
 128     }
 129 
 130     return ORTE_SUCCESS;
 131 }
 132 
 133 static int orte_rmaps_rank_file_query(mca_base_module_t **module, int *priority)
 134 {
 135     *priority = my_priority;
 136     *module = (mca_base_module_t *)&orte_rmaps_rank_file_module;
 137     return ORTE_SUCCESS;
 138 }
 139 
 140 /**
 141  *  Close all subsystems.
 142  */
 143 
 144 static int orte_rmaps_rank_file_close(void)
 145 {
 146     int tmp = mca_base_var_find("orte", "orte", NULL, "rankfile");
 147 
 148     if (0 <= tmp) {
 149         mca_base_var_deregister(tmp);
 150     }
 151 
 152     return ORTE_SUCCESS;
 153 }
 154 
 155 static void rf_map_construct(orte_rmaps_rank_file_map_t *ptr)
 156 {
 157     ptr->node_name = NULL;
 158     memset(ptr->slot_list, (char)0x00, 64);
 159 }
 160 static void rf_map_destruct(orte_rmaps_rank_file_map_t *ptr)
 161 {
 162     if (NULL != ptr->node_name) free(ptr->node_name);
 163 }
 164 OBJ_CLASS_INSTANCE(orte_rmaps_rank_file_map_t,
 165                    opal_object_t,
 166                    rf_map_construct,
 167                    rf_map_destruct);

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