root/orte/mca/ess/alps/ess_alps_module.c

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

DEFINITIONS

This source file includes following definitions.
  1. rte_init
  2. rte_finalize
  3. alps_set_name

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2011 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2011      Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2011-2013 Los Alamos National Security, LLC.
  14  *                         All rights reserved.
  15  * Copyright (c) 2017-2018 Intel, Inc.  All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  *
  22  */
  23 
  24 #include "orte_config.h"
  25 #include "orte/constants.h"
  26 
  27 #include "orte/util/show_help.h"
  28 #include "opal/util/argv.h"
  29 
  30 #include "orte/util/proc_info.h"
  31 #include "orte/mca/errmgr/base/base.h"
  32 #include "orte/util/name_fns.h"
  33 #include "orte/runtime/orte_globals.h"
  34 
  35 #include "orte/mca/ess/ess.h"
  36 #include "orte/mca/ess/base/base.h"
  37 #include "orte/mca/ess/alps/ess_alps.h"
  38 
  39 #include <errno.h>
  40 
  41 static int alps_set_name(void);
  42 static int rte_init(void);
  43 static int rte_finalize(void);
  44 
  45 orte_ess_base_module_t orte_ess_alps_module = {
  46     rte_init,
  47     rte_finalize,
  48     NULL,
  49     NULL /* ft_event */
  50 };
  51 
  52 /* Local variables */
  53 static orte_vpid_t starting_vpid = 0;
  54 
  55 
  56 static int rte_init(void)
  57 {
  58     int ret;
  59     char *error = NULL;
  60 
  61     OPAL_OUTPUT_VERBOSE((1, orte_ess_base_framework.framework_output,
  62                          "ess:alps in rte_init"));
  63 
  64     /*
  65      * shouldn't have been able to open this ess component if
  66      * process is app proc
  67      */
  68 
  69     if (ORTE_PROC_IS_APP) {
  70         error = "mpi rank invoking alps rte_init";
  71         ret = ORTE_ERR_NOT_SUPPORTED;
  72         goto fn_fail;
  73     }
  74 
  75     /* run the prolog */
  76     if (ORTE_SUCCESS != (ret = orte_ess_base_std_prolog())) {
  77         error = "orte_ess_base_std_prolog";
  78         goto fn_fail;
  79     }
  80 
  81     if (ORTE_SUCCESS != (ret = alps_set_name())) {
  82         error = "alps_set_name";
  83         goto fn_fail;
  84     }
  85 
  86     /*
  87      * if I am a daemon, complete my setup using the
  88      * default procedure
  89      */
  90     if (ORTE_PROC_IS_DAEMON) {
  91         if (ORTE_SUCCESS != (ret = orte_ess_base_orted_setup())) {
  92             ORTE_ERROR_LOG(ret);
  93             error = "orte_ess_base_orted_setup";
  94             goto fn_fail;
  95         }
  96 
  97         /*
  98          * now synchronize with aprun.
  99          */
 100 
 101         if (ORTE_SUCCESS != (ret = orte_ess_alps_sync_start())) {
 102             error = "orte_ess_alps_sync";
 103             goto fn_fail;
 104         }
 105 
 106         ret = ORTE_SUCCESS;
 107         goto fn_exit;
 108     }
 109 
 110     if (ORTE_PROC_IS_TOOL) {
 111         /* otherwise, if I am a tool proc, use that procedure */
 112         if (ORTE_SUCCESS != (ret = orte_ess_base_tool_setup(NULL))) {
 113             ORTE_ERROR_LOG(ret);
 114             error = "orte_ess_base_tool_setup";
 115             goto fn_fail;
 116         }
 117         /* as a tool, I don't need a nidmap - so just return now */
 118         ret = ORTE_SUCCESS;
 119         goto fn_exit;
 120     }
 121 
 122    fn_exit:
 123     return ret;
 124 
 125    fn_fail:
 126     if (ORTE_ERR_SILENT != ret && !orte_report_silent_errors) {
 127         orte_show_help("help-orte-runtime.txt",
 128                        "orte_init:startup:internal-failure",
 129                        true, error, ORTE_ERROR_NAME(ret), ret);
 130     }
 131     goto fn_exit;
 132 }
 133 
 134 static int rte_finalize(void)
 135 {
 136     int ret = ORTE_SUCCESS;
 137 
 138     /* if I am a daemon, finalize using the default procedure */
 139     if (ORTE_PROC_IS_DAEMON) {
 140         if (ORTE_SUCCESS != (ret = orte_ess_base_orted_finalize())) {
 141             ORTE_ERROR_LOG(ret);
 142             goto fn_exit;
 143         }
 144 
 145         /* notify alps that we're done */
 146         if (ORTE_SUCCESS != (ret = orte_ess_alps_sync_complete())) {
 147             ORTE_ERROR_LOG(ret);
 148         }
 149 
 150     } else if (ORTE_PROC_IS_TOOL) {
 151         /* otherwise, if I am a tool proc, use that procedure */
 152         if (ORTE_SUCCESS != (ret = orte_ess_base_tool_finalize())) {
 153             ORTE_ERROR_LOG(ret);
 154         }
 155     }
 156 
 157    fn_exit:
 158     return ret;
 159 }
 160 
 161 static int alps_set_name(void)
 162 {
 163     int rc;
 164     int rank;
 165     orte_jobid_t jobid;
 166 
 167     if (NULL == orte_ess_base_jobid) {
 168         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 169         return ORTE_ERR_NOT_FOUND;
 170     }
 171     if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_jobid(&jobid, orte_ess_base_jobid))) {
 172         ORTE_ERROR_LOG(rc);
 173         return rc;
 174     }
 175 
 176     if (NULL == orte_ess_base_vpid) {
 177         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 178         return ORTE_ERR_NOT_FOUND;
 179     }
 180     if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_vpid(&starting_vpid,
 181                                                                orte_ess_base_vpid))) {
 182         ORTE_ERROR_LOG(rc);
 183         return(rc);
 184     }
 185 
 186     ORTE_PROC_MY_NAME->jobid = jobid;
 187 
 188     if (ORTE_SUCCESS != (rc = orte_ess_alps_get_first_rank_on_node(&rank))) {
 189         ORTE_ERROR_LOG(rc);
 190         return(rc);
 191     }
 192 
 193     ORTE_PROC_MY_NAME->vpid = (orte_vpid_t)rank + starting_vpid;
 194 
 195     /* get the num procs as provided in the cmd line param */
 196     if (ORTE_SUCCESS != (rc = orte_ess_env_get())) {
 197         ORTE_ERROR_LOG(rc);
 198         return rc;
 199     }
 200 
 201     return ORTE_SUCCESS;
 202 }

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