1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ 2 /* 3 * Copyright (c) 2015-2017 Intel, Inc. All rights reserved. 4 * Copyright (c) 2015 Los Alamos National Security, LLC. All rights 5 * reserved. 6 * $COPYRIGHT$ 7 * 8 * Additional copyrights may follow 9 * 10 * $HEADER$ 11 */ 12 /** @file: 13 * 14 * The Open RTE Personality Framework (schizo) 15 * 16 * Multi-select framework so that multiple personalities can be 17 * simultaneously supported 18 * 19 */ 20 21 #ifndef ORTE_MCA_SCHIZO_H 22 #define ORTE_MCA_SCHIZO_H 23 24 #include "orte_config.h" 25 #include "orte/types.h" 26 27 #include "orte/mca/mca.h" 28 29 #include "orte/runtime/orte_globals.h" 30 31 32 BEGIN_C_DECLS 33 34 /* 35 * schizo module functions 36 */ 37 38 /** 39 * SCHIZO module functions - the modules are accessed via 40 * the base stub functions 41 */ 42 43 /* initialize the module - allow it to do whatever one-time 44 * things it requires */ 45 typedef int (*orte_schizo_base_module_init_fn_t)(void); 46 47 /* provide an opportunity for components to add personality and/or 48 * environment-specific command line options. The OPAL cli tools 49 * will add provided options to the CLI definition, and so the 50 * resulting CLI array will include the _union_ of options provided 51 * by the various components. Where there is overlap (i.e., an option 52 * is added that was also defined earlier in the stack), then the 53 * first definition is used. This reflects the higher priority of 54 * the original definition - note that this only impacts the help 55 * message that will be displayed */ 56 typedef int (*orte_schizo_base_module_define_cli_fn_t)(opal_cmd_line_t *cli); 57 58 /* parse a tool command line 59 * starting from the given location according to the cmd line options 60 * known to this module's personality. First, of course, check that 61 * this module is included in the base array of personalities, or is 62 * automatically recognizable! */ 63 typedef int (*orte_schizo_base_module_parse_cli_fn_t)(int argc, int start, 64 char **argv); 65 66 /* parse the environment of the 67 * tool to extract any personality-specific envars that need to be 68 * forward to the app's environment upon execution */ 69 typedef int (*orte_schizo_base_module_parse_env_fn_t)(char *path, 70 opal_cmd_line_t *cmd_line, 71 char **srcenv, 72 char ***dstenv); 73 74 /* do whatever preparation work 75 * is required to setup the app for execution. This is intended to be 76 * used by orterun and other launcher tools to, for example, change 77 * an executable's relative-path to an absolute-path, or add a command 78 * required for starting a particular kind of application (e.g., adding 79 * "java" to start a Java application) */ 80 typedef int (*orte_schizo_base_module_setup_app_fn_t)(orte_app_context_t *app); 81 82 /* add any personality-specific envars required at the job level prior 83 * to beginning to execute local procs */ 84 typedef int (*orte_schizo_base_module_setup_fork_fn_t)(orte_job_t *jdata, 85 orte_app_context_t *context); 86 87 /* add any personality-specific envars required for this specific local 88 * proc upon execution */ 89 typedef int (*orte_schizo_base_module_setup_child_fn_t)(orte_job_t *jdata, 90 orte_proc_t *child, 91 orte_app_context_t *app, 92 char ***env); 93 94 95 typedef enum { 96 ORTE_SCHIZO_UNDETERMINED, 97 ORTE_SCHIZO_NATIVE_LAUNCHED, 98 ORTE_SCHIZO_UNMANAGED_SINGLETON, 99 ORTE_SCHIZO_DIRECT_LAUNCHED, 100 ORTE_SCHIZO_MANAGED_SINGLETON 101 } orte_schizo_launch_environ_t; 102 103 104 /* check if this process was directly launched by a managed environment, and 105 * do whatever the module wants to do under those conditions. The module 106 * can push any required envars into the local environment, but must remember 107 * to "unset" them during finalize. The module then returns a flag indicating 108 * the launch environment of the process */ 109 typedef orte_schizo_launch_environ_t (*orte_schizo_base_module_ck_launch_environ_fn_t)(void); 110 111 /* give the component a chance to cleanup */ 112 typedef void (*orte_schizo_base_module_finalize_fn_t)(void); 113 114 115 /* request time remaining in this allocation - only one module 116 * capable of supporting this operation should be available 117 * in a given environment. However, if a module is available 118 * and decides it cannot provide the info in the current situation, 119 * then it can return ORTE_ERR_TAKE_NEXT_OPTION to indicate that 120 * another module should be tried */ 121 typedef int (*orte_schizo_base_module_get_rem_time_fn_t)(uint32_t *timeleft); 122 123 /* 124 * schizo module version 1.3.0 125 */ 126 typedef struct { 127 orte_schizo_base_module_init_fn_t init; 128 orte_schizo_base_module_define_cli_fn_t define_cli; 129 orte_schizo_base_module_parse_cli_fn_t parse_cli; 130 orte_schizo_base_module_parse_env_fn_t parse_env; 131 orte_schizo_base_module_setup_app_fn_t setup_app; 132 orte_schizo_base_module_setup_fork_fn_t setup_fork; 133 orte_schizo_base_module_setup_child_fn_t setup_child; 134 orte_schizo_base_module_ck_launch_environ_fn_t check_launch_environment; 135 orte_schizo_base_module_get_rem_time_fn_t get_remaining_time; 136 orte_schizo_base_module_finalize_fn_t finalize; 137 } orte_schizo_base_module_t; 138 139 ORTE_DECLSPEC extern orte_schizo_base_module_t orte_schizo; 140 141 /* 142 * schizo component 143 */ 144 145 /** 146 * schizo component version 1.3.0 147 */ 148 typedef struct { 149 /** Base MCA structure */ 150 mca_base_component_t base_version; 151 /** Base MCA data */ 152 mca_base_component_data_t base_data; 153 } orte_schizo_base_component_t; 154 155 /** 156 * Macro for use in components that are of type schizo 157 */ 158 #define MCA_SCHIZO_BASE_VERSION_1_0_0 \ 159 ORTE_MCA_BASE_VERSION_2_1_0("schizo", 1, 0, 0) 160 161 162 END_C_DECLS 163 164 #endif