Skip to content

Commit 6311f86

Browse files
author
rhc54
committed
Merge pull request open-mpi#1648 from rhc54/topic/repair
Repair the processing of cmd line options that mapped to MCA params.
2 parents def1b95 + 58dd41f commit 6311f86

File tree

15 files changed

+448
-542
lines changed

15 files changed

+448
-542
lines changed

opal/mca/base/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ OPAL_DECLSPEC int mca_base_is_component_required(opal_list_t *components_availab
156156
/* mca_base_cmd_line.c */
157157

158158
OPAL_DECLSPEC int mca_base_cmd_line_setup(opal_cmd_line_t *cmd);
159-
OPAL_DECLSPEC int mca_base_cmd_line_process_args(char **argv,
159+
OPAL_DECLSPEC int mca_base_cmd_line_process_args(opal_cmd_line_t *cmd,
160160
char ***app_env,
161161
char ***global_env);
162162
OPAL_DECLSPEC void mca_base_cmd_line_wrap_args(char **args);

opal/mca/base/mca_base_cmd_line.c

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,29 @@ int mca_base_cmd_line_setup(opal_cmd_line_t *cmd)
9494
/*
9595
* Look for and handle any -mca options on the command line
9696
*/
97-
int mca_base_cmd_line_process_args(char **argv,
97+
int mca_base_cmd_line_process_args(opal_cmd_line_t *cmd,
9898
char ***context_env, char ***global_env)
9999
{
100-
int i, rc;
100+
int i, num_insts, rc;
101101
char **params;
102102
char **values;
103103

104+
/* If no relevant parameters were given, just return */
105+
106+
if (!opal_cmd_line_is_taken(cmd, OPAL_MCA_CMD_LINE_ID) &&
107+
!opal_cmd_line_is_taken(cmd, "g"OPAL_MCA_CMD_LINE_ID)) {
108+
return OPAL_SUCCESS;
109+
}
110+
111+
/* Handle app context-specific parameters */
112+
113+
num_insts = opal_cmd_line_get_ninsts(cmd, OPAL_MCA_CMD_LINE_ID);
104114
params = values = NULL;
105-
for (i = 0; NULL != argv[i]; ++i) {
106-
if (0 == strcmp("-"OPAL_MCA_CMD_LINE_ID, argv[i]) ||
107-
0 == strcmp("--"OPAL_MCA_CMD_LINE_ID, argv[i])) {
108-
if (NULL == argv[i+1] || NULL == argv[i+2]) {
109-
return OPAL_ERR_BAD_PARAM;
110-
}
111-
if (OPAL_SUCCESS != (rc = process_arg(argv[i+1], argv[i+2],
112-
&params, &values))) {
113-
return rc;
114-
}
115-
i += 2;
115+
for (i = 0; i < num_insts; ++i) {
116+
if (OPAL_SUCCESS != (rc = process_arg(opal_cmd_line_get_param(cmd, OPAL_MCA_CMD_LINE_ID, i, 0),
117+
opal_cmd_line_get_param(cmd, OPAL_MCA_CMD_LINE_ID, i, 1),
118+
&params, &values))) {
119+
return rc;
116120
}
117121
}
118122
if (NULL != params) {
@@ -121,19 +125,15 @@ int mca_base_cmd_line_process_args(char **argv,
121125
opal_argv_free(values);
122126
}
123127

128+
/* Handle global parameters */
124129

130+
num_insts = opal_cmd_line_get_ninsts(cmd, "g"OPAL_MCA_CMD_LINE_ID);
125131
params = values = NULL;
126-
for (i = 0; NULL != argv[i]; ++i) {
127-
if (0 == strcmp("-g"OPAL_MCA_CMD_LINE_ID, argv[i]) ||
128-
0 == strcmp("--g"OPAL_MCA_CMD_LINE_ID, argv[i])) {
129-
if (NULL == argv[i+1] || NULL == argv[i+2]) {
130-
return OPAL_ERR_BAD_PARAM;
131-
}
132-
if (OPAL_SUCCESS != (rc = process_arg(argv[i+1], argv[i+2],
133-
&params, &values))) {
134-
return rc;
135-
}
136-
i += 2;
132+
for (i = 0; i < num_insts; ++i) {
133+
if (OPAL_SUCCESS != (rc = process_arg(opal_cmd_line_get_param(cmd, "g"OPAL_MCA_CMD_LINE_ID, i, 0),
134+
opal_cmd_line_get_param(cmd, "g"OPAL_MCA_CMD_LINE_ID, i, 1),
135+
&params, &values))) {
136+
return rc;
137137
}
138138
}
139139
if (NULL != params) {
@@ -148,6 +148,7 @@ int mca_base_cmd_line_process_args(char **argv,
148148
}
149149

150150

151+
151152
/*
152153
* Process a single MCA argument.
153154
*/

opal/runtime/opal_info_support.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ int opal_info_init(int argc, char **argv,
207207
exit(cmd_error ? 1 : 0);
208208
}
209209

210-
mca_base_cmd_line_process_args(argv, &app_env, &global_env);
210+
mca_base_cmd_line_process_args(opal_info_cmd_line, &app_env, &global_env);
211211

212212

213213
/* set the flags */

orte/mca/rmaps/base/rmaps_base_map_job.c

Lines changed: 35 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
5050
{
5151
orte_job_t *jdata;
52-
orte_job_map_t *map;
5352
orte_node_t *node;
5453
int rc, i;
5554
bool did_map, given;
@@ -113,94 +112,21 @@ void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
113112
}
114113
}
115114

116-
/* NOTE: CHECK FOR JDATA->MAP == NULL. IF IT IS, THEN USE
117-
* THE VALUES THAT WERE READ BY THE LOCAL MCA PARAMS. THE
118-
* PLM PROXY WILL SEND A JOB-OBJECT THAT WILL INCLUDE ANY
119-
* MAPPING DIRECTIVES - OTHERWISE, THAT OBJECT WILL HAVE A
120-
* NULL MAP FIELD
121-
* LONE EXCEPTION - WE COPY DISPLAY MAP ACROSS IF THEY
122-
* DIDN'T SET IT
123-
*/
124-
if (NULL == jdata->map) {
125-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
126-
"mca:rmaps: creating new map for job %s",
127-
ORTE_JOBID_PRINT(jdata->jobid));
128-
/* create a map object where we will store the results */
129-
map = OBJ_NEW(orte_job_map_t);
130-
if (NULL == map) {
131-
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
132-
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
133-
OBJ_RELEASE(caddy);
134-
return;
135-
}
136-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
137-
"mca:rmaps: nprocs %s",
138-
ORTE_VPID_PRINT(nprocs));
115+
116+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
117+
"mca:rmaps: setting mapping policies for job %s",
118+
ORTE_JOBID_PRINT(jdata->jobid));
119+
120+
if (!jdata->map->display_map) {
121+
jdata->map->display_map = orte_rmaps_base.display_map;
122+
}
123+
/* set the default mapping policy IFF it wasn't provided */
124+
if (!ORTE_MAPPING_POLICY_IS_SET(jdata->map->mapping)) {
139125
if (ORTE_MAPPING_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
140126
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
141-
"mca:rmaps mapping given - using default");
142-
map->mapping = orte_rmaps_base.mapping;
127+
"mca:rmaps mapping given by MCA param");
128+
jdata->map->mapping = orte_rmaps_base.mapping;
143129
} else {
144-
/* default based on number of procs */
145-
if (nprocs <= 2) {
146-
if (1 < orte_rmaps_base.cpus_per_rank) {
147-
/* assigning multiple cpus to a rank requires that we map to
148-
* objects that have multiple cpus in them, so default
149-
* to byslot if nothing else was specified by the user.
150-
*/
151-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
152-
"mca:rmaps[%d] mapping not given - using byslot", __LINE__);
153-
ORTE_SET_MAPPING_POLICY(map->mapping, ORTE_MAPPING_BYSLOT);
154-
} else if (opal_hwloc_use_hwthreads_as_cpus) {
155-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
156-
"mca:rmaps[%d] mapping not given - using byhwthread", __LINE__);
157-
ORTE_SET_MAPPING_POLICY(map->mapping, ORTE_MAPPING_BYHWTHREAD);
158-
} else {
159-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
160-
"mca:rmaps[%d] mapping not given - using bycore", __LINE__);
161-
ORTE_SET_MAPPING_POLICY(map->mapping, ORTE_MAPPING_BYCORE);
162-
}
163-
} else {
164-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
165-
"mca:rmaps[%d] mapping not given - using bysocket", __LINE__);
166-
ORTE_SET_MAPPING_POLICY(map->mapping, ORTE_MAPPING_BYSOCKET);
167-
}
168-
/* check for oversubscribe directives */
169-
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping))) {
170-
ORTE_SET_MAPPING_DIRECTIVE(map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
171-
} else {
172-
/* pass along the directive */
173-
if (ORTE_MAPPING_NO_OVERSUBSCRIBE & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
174-
ORTE_SET_MAPPING_DIRECTIVE(map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
175-
} else {
176-
ORTE_UNSET_MAPPING_DIRECTIVE(map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
177-
}
178-
}
179-
/* check for no-use-local directive */
180-
if (ORTE_MAPPING_NO_USE_LOCAL & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
181-
ORTE_SET_MAPPING_DIRECTIVE(map->mapping, ORTE_MAPPING_NO_USE_LOCAL);
182-
}
183-
}
184-
/* ranking was already handled, so just use it here */
185-
map->ranking = orte_rmaps_base.ranking;
186-
187-
if (NULL != orte_rmaps_base.ppr) {
188-
map->ppr = strdup(orte_rmaps_base.ppr);
189-
}
190-
map->cpus_per_rank = orte_rmaps_base.cpus_per_rank;
191-
map->display_map = orte_rmaps_base.display_map;
192-
/* assign the map object to this job */
193-
jdata->map = map;
194-
} else {
195-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
196-
"mca:rmaps: setting mapping policies for job %s",
197-
ORTE_JOBID_PRINT(jdata->jobid));
198-
199-
if (!jdata->map->display_map) {
200-
jdata->map->display_map = orte_rmaps_base.display_map;
201-
}
202-
/* set the default mapping policy IFF it wasn't provided */
203-
if (!ORTE_MAPPING_POLICY_IS_SET(jdata->map->mapping)) {
204130
/* default based on number of procs */
205131
if (nprocs <= 2) {
206132
if (1 < orte_rmaps_base.cpus_per_rank) {
@@ -226,26 +152,33 @@ void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
226152
ORTE_SET_MAPPING_POLICY(jdata->map->mapping, ORTE_MAPPING_BYSOCKET);
227153
}
228154
}
229-
/* check for oversubscribe directives */
230-
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping))) {
155+
}
156+
/* check for oversubscribe directives */
157+
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping))) {
158+
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
159+
} else {
160+
/* pass along the directive */
161+
if (ORTE_MAPPING_NO_OVERSUBSCRIBE & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
231162
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
232163
} else {
233-
/* pass along the directive */
234-
if (ORTE_MAPPING_NO_OVERSUBSCRIBE & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
235-
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
236-
} else {
237-
ORTE_UNSET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
238-
}
239-
}
240-
/* check for no-use-local directive */
241-
if (ORTE_MAPPING_NO_USE_LOCAL & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
242-
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_USE_LOCAL);
243-
}
244-
/* ditto for rank and bind policies */
245-
if (!ORTE_RANKING_POLICY_IS_SET(jdata->map->ranking)) {
246-
jdata->map->ranking = orte_rmaps_base.ranking;
164+
ORTE_UNSET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
247165
}
248166
}
167+
/* check for no-use-local directive */
168+
if (ORTE_MAPPING_NO_USE_LOCAL & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
169+
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_USE_LOCAL);
170+
}
171+
/* ditto for rank policy */
172+
if (!ORTE_RANKING_POLICY_IS_SET(jdata->map->ranking)) {
173+
jdata->map->ranking = orte_rmaps_base.ranking;
174+
}
175+
176+
if (NULL == jdata->map->ppr && NULL != orte_rmaps_base.ppr) {
177+
jdata->map->ppr = strdup(orte_rmaps_base.ppr);
178+
}
179+
if (0 == jdata->map->cpus_per_rank) {
180+
jdata->map->cpus_per_rank = orte_rmaps_base.cpus_per_rank;
181+
}
249182

250183
/* define the binding policy for this job - if the user specified one
251184
* already (e.g., during the call to comm_spawn), then we don't

0 commit comments

Comments
 (0)