root/orte/mca/ess/env/ess_env_module.c

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

DEFINITIONS

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

   1 /*
   2  * Copyright (c) 2004-2010 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-2012 Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2013-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 #include <sys/types.h>
  26 #include <stdio.h>
  27 #ifdef HAVE_FCNTL_H
  28 #include <fcntl.h>
  29 #endif
  30 #ifdef HAVE_UNISTD_H
  31 #include <unistd.h>
  32 #endif
  33 #include <stdlib.h>
  34 
  35 #include "opal/mca/event/event.h"
  36 #include "opal/runtime/opal.h"
  37 
  38 #include "orte/util/show_help.h"
  39 #include "orte/mca/mca.h"
  40 #include "opal/mca/base/base.h"
  41 #include "opal/mca/pmix/pmix.h"
  42 #include "opal/util/output.h"
  43 #include "opal/util/malloc.h"
  44 #include "opal/util/argv.h"
  45 
  46 #include "orte/mca/rml/base/base.h"
  47 #include "orte/mca/rml/rml_types.h"
  48 #include "orte/mca/routed/base/base.h"
  49 #include "orte/mca/routed/routed.h"
  50 #include "orte/mca/errmgr/base/base.h"
  51 #include "orte/mca/grpcomm/base/base.h"
  52 #include "orte/mca/iof/base/base.h"
  53 #include "orte/mca/ess/base/base.h"
  54 #include "orte/mca/ess/ess.h"
  55 #include "orte/mca/ras/base/base.h"
  56 #include "orte/mca/plm/base/base.h"
  57 
  58 #include "orte/mca/rmaps/base/base.h"
  59 #include "orte/mca/filem/base/base.h"
  60 #include "orte/util/proc_info.h"
  61 #include "orte/util/session_dir.h"
  62 #include "orte/util/name_fns.h"
  63 
  64 #include "orte/runtime/runtime.h"
  65 #include "orte/runtime/orte_wait.h"
  66 #include "orte/runtime/orte_globals.h"
  67 
  68 #include "orte/mca/ess/ess.h"
  69 #include "orte/mca/ess/base/base.h"
  70 #include "orte/mca/ess/env/ess_env.h"
  71 
  72 static int env_set_name(void);
  73 
  74 static int rte_init(void);
  75 static int rte_finalize(void);
  76 
  77 orte_ess_base_module_t orte_ess_env_module = {
  78     rte_init,
  79     rte_finalize,
  80     NULL,
  81     NULL
  82 };
  83 
  84 static int rte_init(void)
  85 {
  86     int ret;
  87     char *error = NULL;
  88 
  89     /* run the prolog */
  90     if (ORTE_SUCCESS != (ret = orte_ess_base_std_prolog())) {
  91         error = "orte_ess_base_std_prolog";
  92         goto error;
  93     }
  94 
  95     /* Start by getting a unique name from the enviro */
  96     env_set_name();
  97 
  98     /* if I am a daemon, complete my setup using the
  99      * default procedure
 100      */
 101     if (ORTE_SUCCESS != (ret = orte_ess_base_orted_setup())) {
 102         ORTE_ERROR_LOG(ret);
 103         error = "orte_ess_base_orted_setup";
 104         goto error;
 105     }
 106     return ORTE_SUCCESS;
 107 
 108  error:
 109     if (ORTE_ERR_SILENT != ret && !orte_report_silent_errors) {
 110         orte_show_help("help-orte-runtime.txt",
 111                        "orte_init:startup:internal-failure",
 112                        true, error, ORTE_ERROR_NAME(ret), ret);
 113     }
 114 
 115     return ret;
 116 }
 117 
 118 static int rte_finalize(void)
 119 {
 120     int ret;
 121 
 122     if (ORTE_SUCCESS != (ret = orte_ess_base_orted_finalize())) {
 123         ORTE_ERROR_LOG(ret);
 124     }
 125     return ret;
 126 }
 127 
 128 static int env_set_name(void)
 129 {
 130     int rc;
 131     orte_jobid_t jobid;
 132     orte_vpid_t vpid;
 133 
 134     if (NULL == orte_ess_base_jobid) {
 135         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 136         return ORTE_ERR_NOT_FOUND;
 137     }
 138     if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_jobid(&jobid, orte_ess_base_jobid))) {
 139         ORTE_ERROR_LOG(rc);
 140         return(rc);
 141     }
 142 
 143     if (NULL == orte_ess_base_vpid) {
 144         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 145         return ORTE_ERR_NOT_FOUND;
 146     }
 147     if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_vpid(&vpid, orte_ess_base_vpid))) {
 148         ORTE_ERROR_LOG(rc);
 149         return(rc);
 150     }
 151 
 152     ORTE_PROC_MY_NAME->jobid = jobid;
 153     ORTE_PROC_MY_NAME->vpid = vpid;
 154 
 155     OPAL_OUTPUT_VERBOSE((1, orte_ess_base_framework.framework_output,
 156                          "ess:env set name to %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
 157 
 158     /* get the non-name common environmental variables */
 159     if (ORTE_SUCCESS != (rc = orte_ess_env_get())) {
 160         ORTE_ERROR_LOG(rc);
 161         return rc;
 162     }
 163 
 164     return ORTE_SUCCESS;
 165 }

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