root/orte/mca/schizo/orte/schizo_orte.c

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

DEFINITIONS

This source file includes following definitions.
  1. check_launch_environment
  2. finalize

   1 /*
   2  * Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
   3  * $COPYRIGHT$
   4  *
   5  * Additional copyrights may follow
   6  *
   7  * $HEADER$
   8  *
   9  */
  10 
  11 #include "orte_config.h"
  12 #include "orte/types.h"
  13 #include "opal/types.h"
  14 
  15 #ifdef HAVE_UNISTD_H
  16 #include <unistd.h>
  17 #endif
  18 #include <ctype.h>
  19 
  20 #include "opal/util/argv.h"
  21 #include "opal/util/basename.h"
  22 #include "opal/util/opal_environ.h"
  23 
  24 #include "orte/runtime/orte_globals.h"
  25 #include "orte/util/name_fns.h"
  26 #include "orte/mca/schizo/base/base.h"
  27 
  28 #include "schizo_orte.h"
  29 
  30 static orte_schizo_launch_environ_t check_launch_environment(void);
  31 static void finalize(void);
  32 
  33 orte_schizo_base_module_t orte_schizo_orte_module = {
  34     .check_launch_environment = check_launch_environment,
  35     .finalize = finalize
  36 };
  37 
  38 static char **pushed_envs = NULL;
  39 static char **pushed_vals = NULL;
  40 static orte_schizo_launch_environ_t myenv;
  41 static bool myenvdefined = false;
  42 
  43 static orte_schizo_launch_environ_t check_launch_environment(void)
  44 {
  45     int i;
  46 
  47     if (myenvdefined) {
  48         return myenv;
  49     }
  50     myenvdefined = true;
  51 
  52     /* we were only selected because we are an app,
  53      * so no need to further check that here. Instead,
  54      * see if we were direct launched vs launched via mpirun */
  55     if (NULL != orte_process_info.my_daemon_uri) {
  56         /* yes we were */
  57         myenv = ORTE_SCHIZO_NATIVE_LAUNCHED;
  58         opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"ess");
  59         opal_argv_append_nosize(&pushed_vals, "pmi");
  60         goto setup;
  61     }
  62 
  63     /* if nobody else has laid claim to this process,
  64      * then it must be a singleton */
  65     myenv = ORTE_SCHIZO_UNMANAGED_SINGLETON;
  66     opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"ess");
  67     opal_argv_append_nosize(&pushed_vals, "singleton");
  68     /* mark that we are in ORTE */
  69     opal_argv_append_nosize(&pushed_envs, "ORTE_SCHIZO_DETECTION");
  70     opal_argv_append_nosize(&pushed_vals, "ORTE");
  71 
  72 
  73   setup:
  74     opal_output_verbose(1, orte_schizo_base_framework.framework_output,
  75                         "schizo:orte DECLARED AS %s", orte_schizo_base_print_env(myenv));
  76     if (NULL != pushed_envs) {
  77         for (i=0; NULL != pushed_envs[i]; i++) {
  78             opal_setenv(pushed_envs[i], pushed_vals[i], true, &environ);
  79         }
  80     }
  81     return myenv;
  82 }
  83 
  84 static void finalize(void)
  85 {
  86     int i;
  87 
  88     if (NULL != pushed_envs) {
  89         for (i=0; NULL != pushed_envs[i]; i++) {
  90             opal_unsetenv(pushed_envs[i], &environ);
  91         }
  92         opal_argv_free(pushed_envs);
  93         opal_argv_free(pushed_vals);
  94     }
  95 }

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