root/orte/mca/schizo/flux/schizo_flux.c

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

DEFINITIONS

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

   1 /*
   2  * Copyright (c) 2016      Intel, Inc.  All rights reserved.
   3  * Copyright (c) 2016      Mellanox Technologies Ltd.  All rights reserved.
   4  * $COPYRIGHT$
   5  *
   6  * Additional copyrights may follow
   7  *
   8  * $HEADER$
   9  *
  10  */
  11 
  12 #include "orte_config.h"
  13 #include "orte/types.h"
  14 #include "opal/types.h"
  15 
  16 #ifdef HAVE_UNISTD_H
  17 #include <unistd.h>
  18 #endif
  19 #include <ctype.h>
  20 
  21 #include "opal/util/argv.h"
  22 #include "opal/util/basename.h"
  23 #include "opal/util/opal_environ.h"
  24 
  25 #include "orte/runtime/orte_globals.h"
  26 #include "orte/util/name_fns.h"
  27 #include "orte/mca/schizo/base/base.h"
  28 
  29 #include "schizo_flux.h"
  30 
  31 static orte_schizo_launch_environ_t check_launch_environment(void);
  32 static void finalize(void);
  33 
  34 orte_schizo_base_module_t orte_schizo_flux_module = {
  35     .check_launch_environment = check_launch_environment,
  36     .finalize = finalize
  37 };
  38 
  39 static char **pushed_envs = NULL;
  40 static char **pushed_vals = NULL;
  41 static orte_schizo_launch_environ_t myenv;
  42 static bool myenvdefined = false;
  43 
  44 static orte_schizo_launch_environ_t check_launch_environment(void)
  45 {
  46     int i;
  47 
  48     if (myenvdefined) {
  49         return myenv;
  50     }
  51     myenvdefined = true;
  52 
  53     /* we were only selected because FLUX was detected
  54      * and we are an app, so no need to further check
  55      * that here. Instead, see if we were direct launched
  56      * vs launched via mpirun */
  57     if (NULL != orte_process_info.my_daemon_uri) {
  58         /* nope */
  59         myenv = ORTE_SCHIZO_NATIVE_LAUNCHED;
  60         opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"ess");
  61         opal_argv_append_nosize(&pushed_vals, "pmi");
  62         goto setup;
  63     }
  64 
  65     myenv = ORTE_SCHIZO_DIRECT_LAUNCHED;
  66     opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"ess");
  67     opal_argv_append_nosize(&pushed_vals, "pmi");
  68 
  69     /* if we are direct launched by FLUX, then we want
  70      * to ensure that we do not override their binding
  71      * options, so set that envar */
  72     opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"hwloc_base_binding_policy");
  73     opal_argv_append_nosize(&pushed_vals, "none");
  74     /* indicate we are externally bound so we won't try to do it ourselves */
  75     opal_argv_append_nosize(&pushed_envs, OPAL_MCA_PREFIX"orte_externally_bound");
  76     opal_argv_append_nosize(&pushed_vals, "1");
  77 
  78   setup:
  79       opal_output_verbose(1, orte_schizo_base_framework.framework_output,
  80                           "schizo:flux DECLARED AS %s", orte_schizo_base_print_env(myenv));
  81     if (NULL != pushed_envs) {
  82         for (i=0; NULL != pushed_envs[i]; i++) {
  83             opal_setenv(pushed_envs[i], pushed_vals[i], true, &environ);
  84         }
  85     }
  86     return myenv;
  87 }
  88 
  89 static void finalize(void)
  90 {
  91     int i;
  92 
  93     if (NULL != pushed_envs) {
  94         for (i=0; NULL != pushed_envs[i]; i++) {
  95             opal_unsetenv(pushed_envs[i], &environ);
  96         }
  97         opal_argv_free(pushed_envs);
  98         opal_argv_free(pushed_vals);
  99     }
 100 }

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