root/orte/mca/ess/tm/ess_tm_module.c

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

DEFINITIONS

This source file includes following definitions.
  1. rte_init
  2. rte_finalize
  3. tm_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) 2008-2011 Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2017-2018 Intel, Inc.  All rights reserved.
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  19  *
  20  */
  21 
  22 #include "orte_config.h"
  23 #include "orte/constants.h"
  24 
  25 #ifdef HAVE_UNISTD_H
  26 #include <unistd.h>
  27 #endif  /* HAVE_UNISTD_H */
  28 #include <string.h>
  29 #include <ctype.h>
  30 
  31 
  32 #include "opal/util/opal_environ.h"
  33 #include "opal/util/output.h"
  34 #include "opal/util/argv.h"
  35 #include "opal/class/opal_pointer_array.h"
  36 #include "opal/dss/dss.h"
  37 
  38 #include "orte/util/proc_info.h"
  39 #include "orte/util/show_help.h"
  40 #include "orte/mca/errmgr/errmgr.h"
  41 #include "orte/util/name_fns.h"
  42 #include "orte/runtime/orte_globals.h"
  43 
  44 #include "orte/mca/ess/ess.h"
  45 #include "orte/mca/ess/base/base.h"
  46 #include "orte/mca/ess/tm/ess_tm.h"
  47 
  48 static int tm_set_name(void);
  49 
  50 static int rte_init(void);
  51 static int rte_finalize(void);
  52 
  53 orte_ess_base_module_t orte_ess_tm_module = {
  54     rte_init,
  55     rte_finalize,
  56     NULL,
  57     NULL /* ft_event */
  58 };
  59 
  60 /*
  61  * Local variables
  62  */
  63 
  64 
  65 static int rte_init(void)
  66 {
  67     int ret;
  68     char *error = NULL;
  69 
  70     /* run the prolog */
  71     if (ORTE_SUCCESS != (ret = orte_ess_base_std_prolog())) {
  72         error = "orte_ess_base_std_prolog";
  73         goto error;
  74     }
  75 
  76     /* Start by getting a unique name */
  77     tm_set_name();
  78 
  79     /* if I am a daemon, complete my setup using the
  80      * default procedure
  81      */
  82     if (ORTE_PROC_IS_DAEMON) {
  83         if (ORTE_SUCCESS != (ret = orte_ess_base_orted_setup())) {
  84             ORTE_ERROR_LOG(ret);
  85             error = "orte_ess_base_orted_setup";
  86             goto error;
  87         }
  88         return ORTE_SUCCESS;
  89     }
  90 
  91     if (ORTE_PROC_IS_TOOL) {
  92         /* otherwise, if I am a tool proc, use that procedure */
  93         if (ORTE_SUCCESS != (ret = orte_ess_base_tool_setup(NULL))) {
  94             ORTE_ERROR_LOG(ret);
  95             error = "orte_ess_base_tool_setup";
  96             goto error;
  97         }
  98         return ORTE_SUCCESS;
  99 
 100     }
 101 
 102     /* no other options are supported! */
 103     error = "ess_error";
 104     ret = ORTE_ERROR;
 105 
 106   error:
 107     if (ORTE_ERR_SILENT != ret && !orte_report_silent_errors) {
 108         orte_show_help("help-orte-runtime.txt",
 109                        "orte_init:startup:internal-failure",
 110                        true, error, ORTE_ERROR_NAME(ret), ret);
 111     }
 112 
 113     return ret;
 114 }
 115 
 116 static int rte_finalize(void)
 117 {
 118     int ret;
 119 
 120     /* if I am a daemon, finalize using the default procedure */
 121     if (ORTE_PROC_IS_DAEMON) {
 122         if (ORTE_SUCCESS != (ret = orte_ess_base_orted_finalize())) {
 123             ORTE_ERROR_LOG(ret);
 124             return ret;
 125         }
 126     } else if (ORTE_PROC_IS_TOOL) {
 127         /* otherwise, if I am a tool proc, use that procedure */
 128         if (ORTE_SUCCESS != (ret = orte_ess_base_tool_finalize())) {
 129             ORTE_ERROR_LOG(ret);
 130         }
 131         return ret;
 132     }
 133 
 134     return ORTE_SUCCESS;
 135 }
 136 
 137 static int tm_set_name(void)
 138 {
 139     int rc;
 140     orte_jobid_t jobid;
 141     orte_vpid_t vpid;
 142 
 143     OPAL_OUTPUT_VERBOSE((1, orte_ess_base_framework.framework_output,
 144                          "ess:tm setting name"));
 145     if (NULL == orte_ess_base_jobid) {
 146         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 147         return ORTE_ERR_NOT_FOUND;
 148     }
 149     if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_jobid(&jobid, orte_ess_base_jobid))) {
 150         ORTE_ERROR_LOG(rc);
 151         return(rc);
 152     }
 153 
 154     if (NULL == orte_ess_base_vpid) {
 155         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 156         return ORTE_ERR_NOT_FOUND;
 157     }
 158     if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_vpid(&vpid, orte_ess_base_vpid))) {
 159         ORTE_ERROR_LOG(rc);
 160         return(rc);
 161     }
 162 
 163     ORTE_PROC_MY_NAME->jobid = jobid;
 164     ORTE_PROC_MY_NAME->vpid = vpid;
 165 
 166     OPAL_OUTPUT_VERBOSE((1, orte_ess_base_framework.framework_output,
 167                          "ess:tm set name to %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
 168 
 169     /* get the non-name common environmental variables */
 170     if (ORTE_SUCCESS != (rc = orte_ess_env_get())) {
 171         ORTE_ERROR_LOG(rc);
 172         return rc;
 173     }
 174 
 175     return ORTE_SUCCESS;
 176 }

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