This source file includes following definitions.
- rte_init
- rte_finalize
- slurm_set_name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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/mca/rml/rml.h"
42 #include "orte/util/name_fns.h"
43 #include "orte/runtime/orte_globals.h"
44
45 #include "orte/mca/ess/ess.h"
46 #include "orte/mca/ess/base/base.h"
47 #include "orte/mca/ess/slurm/ess_slurm.h"
48
49 static int slurm_set_name(void);
50
51 static int rte_init(void);
52 static int rte_finalize(void);
53
54 orte_ess_base_module_t orte_ess_slurm_module = {
55 rte_init,
56 rte_finalize,
57 NULL,
58 NULL
59 };
60
61 static int rte_init(void)
62 {
63 int ret;
64 char *error = NULL;
65
66
67 if (ORTE_SUCCESS != (ret = orte_ess_base_std_prolog())) {
68 error = "orte_ess_base_std_prolog";
69 goto error;
70 }
71
72
73 slurm_set_name();
74
75
76
77
78 if (ORTE_PROC_IS_DAEMON) {
79 if (ORTE_SUCCESS != (ret = orte_ess_base_orted_setup())) {
80 ORTE_ERROR_LOG(ret);
81 error = "orte_ess_base_orted_setup";
82 goto error;
83 }
84 return ORTE_SUCCESS;
85 }
86
87 if (ORTE_PROC_IS_TOOL) {
88
89 if (ORTE_SUCCESS != (ret = orte_ess_base_tool_setup(NULL))) {
90 ORTE_ERROR_LOG(ret);
91 error = "orte_ess_base_tool_setup";
92 goto error;
93 }
94 return ORTE_SUCCESS;
95
96 }
97
98
99 error = "ess_error";
100 ret = ORTE_ERROR;
101
102 error:
103 if (ORTE_ERR_SILENT != ret && !orte_report_silent_errors) {
104 orte_show_help("help-orte-runtime.txt",
105 "orte_init:startup:internal-failure",
106 true, error, ORTE_ERROR_NAME(ret), ret);
107 }
108
109 return ret;
110 }
111
112 static int rte_finalize(void)
113 {
114 int ret;
115
116
117 if (ORTE_PROC_IS_DAEMON) {
118 if (ORTE_SUCCESS != (ret = orte_ess_base_orted_finalize())) {
119 ORTE_ERROR_LOG(ret);
120 return ret;
121 }
122 } else if (ORTE_PROC_IS_TOOL) {
123
124 if (ORTE_SUCCESS != (ret = orte_ess_base_tool_finalize())) {
125 ORTE_ERROR_LOG(ret);
126 }
127 return ret;
128 }
129
130 return ORTE_SUCCESS;
131 }
132
133 static int slurm_set_name(void)
134 {
135 int slurm_nodeid;
136 int rc;
137 orte_jobid_t jobid;
138 orte_vpid_t vpid;
139 char *tmp;
140
141 OPAL_OUTPUT_VERBOSE((1, orte_ess_base_framework.framework_output,
142 "ess:slurm setting name"));
143
144 if (NULL == orte_ess_base_jobid) {
145 ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
146 return ORTE_ERR_NOT_FOUND;
147 }
148 if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_jobid(&jobid, orte_ess_base_jobid))) {
149 ORTE_ERROR_LOG(rc);
150 return(rc);
151 }
152
153 if (NULL == orte_ess_base_vpid) {
154 ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
155 return ORTE_ERR_NOT_FOUND;
156 }
157 if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_vpid(&vpid, orte_ess_base_vpid))) {
158 ORTE_ERROR_LOG(rc);
159 return(rc);
160 }
161
162 ORTE_PROC_MY_NAME->jobid = jobid;
163
164
165 slurm_nodeid = atoi(getenv("SLURM_NODEID"));
166 ORTE_PROC_MY_NAME->vpid = vpid + slurm_nodeid;
167
168 OPAL_OUTPUT_VERBOSE((1, orte_ess_base_framework.framework_output,
169 "ess:slurm set name to %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
170
171
172 if (NULL != orte_process_info.nodename) {
173 free(orte_process_info.nodename);
174 }
175 if (NULL == (tmp = getenv("SLURMD_NODENAME"))) {
176 ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
177 return ORTE_ERR_NOT_FOUND;
178 }
179 orte_process_info.nodename = strdup(tmp);
180
181
182 OPAL_OUTPUT_VERBOSE((1, orte_ess_base_framework.framework_output,
183 "ess:slurm set nodename to %s",
184 (NULL == orte_process_info.nodename) ? "NULL" : orte_process_info.nodename));
185
186
187 if (ORTE_SUCCESS != (rc = orte_ess_env_get())) {
188 ORTE_ERROR_LOG(rc);
189 return rc;
190 }
191
192 return ORTE_SUCCESS;
193 }