Skip to content

Commit cb221b6

Browse files
author
Ralph Castain
committed
Correct mapping errors
Since we now support the dynamic addition of hosts to the orte_node_pool, there is no longer any reason to require advanced specification of all possible nodes. Instead, use a precedence method to initially allocate only those hosts that were specified in the cmd line: * rankfile, if given, as that will specify the nodes * -host, aggregated across all app_contexts * -hostfile, aggregated across all app_contexts * default hostfile * assign local node Fix slots_inuse accounting so that the nodes are correctly reset upon error termination - e.g., when oversubscribed without permission. Ensure we accurately track the user's specified desires for oversubscribe and no-use-local when dynamically spawning jobs. Signed-off-by: Ralph Castain <[email protected]> (cherry picked from commit c9b3e68)
1 parent 4f13dbc commit cb221b6

File tree

9 files changed

+137
-141
lines changed

9 files changed

+137
-141
lines changed

orte/mca/errmgr/dvm/errmgr_dvm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ static void job_errors(int fd, short args, void *cbdata)
209209
ORTE_JOBID_PRINT(jdata->jobid),
210210
ORTE_NAME_PRINT(&jdata->originator)));
211211
if (0 > (ret = orte_rml.send_buffer_nb(orte_mgmt_conduit,
212-
&jdata->originator, answer,
213-
ORTE_RML_TAG_LAUNCH_RESP,
214-
orte_rml_send_callback, NULL))) {
212+
&jdata->originator, answer,
213+
ORTE_RML_TAG_LAUNCH_RESP,
214+
orte_rml_send_callback, NULL))) {
215215
ORTE_ERROR_LOG(ret);
216216
OBJ_RELEASE(answer);
217217
}

orte/mca/ras/base/ras_base_allocate.c

Lines changed: 97 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -235,79 +235,56 @@ void orte_ras_base_allocate(int fd, short args, void *cbdata)
235235
"%s ras:base:allocate nothing found in module - proceeding to hostfile",
236236
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
237237

238-
/* nothing was found, or no active module was alive. Our next
239-
* option is to look for a hostfile and assign our global
240-
* pool from there.
241-
*
242-
* Individual hostfile names, if given, are included
243-
* in the app_contexts for this job. We therefore need to
244-
* retrieve the app_contexts for the job, and then cycle
245-
* through them to see if anything is there. The parser will
246-
* add the nodes found in each hostfile to our list - i.e.,
247-
* the resulting list contains the UNION of all nodes specified
248-
* in hostfiles from across all app_contexts
249-
*
250-
* We then continue to add any hosts provided by dash-host and
251-
* the default hostfile, if we have it. We will then filter out
252-
* all the non-desired hosts (i.e., those not specified by
253-
* -host and/or -hostfile) when we start the mapping process
254-
*
255-
* Note that any relative node syntax found in the hostfiles will
256-
* generate an error in this scenario, so only non-relative syntax
257-
* can be present
258-
*/
259-
if (NULL != orte_default_hostfile) {
238+
/* nothing was found, or no active module was alive. We first see
239+
* if we were given a rankfile - if so, use it as the hosts will be
240+
* taken from the mapping */
241+
if (NULL != orte_rankfile) {
260242
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
261-
"%s ras:base:allocate parsing default hostfile %s",
243+
"%s ras:base:allocate parsing rankfile %s",
262244
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
263-
orte_default_hostfile));
245+
orte_rankfile));
264246

265-
/* a default hostfile was provided - parse it */
247+
/* a rankfile was provided - parse it */
266248
if (ORTE_SUCCESS != (rc = orte_util_add_hostfile_nodes(&nodes,
267-
orte_default_hostfile))) {
249+
orte_rankfile))) {
268250
OBJ_DESTRUCT(&nodes);
269251
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
270252
OBJ_RELEASE(caddy);
271253
return;
272254
}
273255
}
274256

275-
if (NULL != orte_rankfile) {
276-
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
277-
"%s ras:base:allocate parsing rankfile %s",
278-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
279-
orte_rankfile));
280-
281-
/* a rankfile was provided - parse it */
282-
if (ORTE_SUCCESS != (rc = orte_util_add_hostfile_nodes(&nodes,
283-
orte_rankfile))) {
284-
OBJ_DESTRUCT(&nodes);
257+
/* if something was found in the rankfile, we use that as our global
258+
* pool - set it and we are done
259+
*/
260+
if (!opal_list_is_empty(&nodes)) {
261+
/* store the results in the global resource pool - this removes the
262+
* list items
263+
*/
264+
if (ORTE_SUCCESS != (rc = orte_ras_base_node_insert(&nodes, jdata))) {
265+
ORTE_ERROR_LOG(rc);
285266
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
286267
OBJ_RELEASE(caddy);
287268
return;
288269
}
270+
/* rankfile is considered equivalent to an RM allocation */
271+
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping))) {
272+
ORTE_SET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
273+
}
274+
/* cleanup */
275+
OBJ_DESTRUCT(&nodes);
276+
goto DISPLAY;
289277
}
278+
279+
/* if a dash-host has been provided, aggregate across all the
280+
* app_contexts. Any hosts the user wants to add via comm_spawn
281+
* can be done so using the add_host option */
290282
for (i=0; i < jdata->apps->size; i++) {
291283
if (NULL == (app = (orte_app_context_t*)opal_pointer_array_get_item(jdata->apps, i))) {
292284
continue;
293285
}
294-
if (orte_get_attribute(&app->attributes, ORTE_APP_HOSTFILE, (void**)&hosts, OPAL_STRING)) {
295-
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
296-
"%s ras:base:allocate adding hostfile %s",
297-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), hosts));
298-
299-
/* hostfile was specified - parse it and add it to the list */
300-
if (ORTE_SUCCESS != (rc = orte_util_add_hostfile_nodes(&nodes, hosts))) {
301-
free(hosts);
302-
OBJ_DESTRUCT(&nodes);
303-
/* set an error event */
304-
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
305-
OBJ_RELEASE(caddy);
306-
return;
307-
}
308-
free(hosts);
309-
} else if (!orte_soft_locations &&
310-
orte_get_attribute(&app->attributes, ORTE_APP_DASH_HOST, (void**)&hosts, OPAL_STRING)) {
286+
if (!orte_soft_locations &&
287+
orte_get_attribute(&app->attributes, ORTE_APP_DASH_HOST, (void**)&hosts, OPAL_STRING)) {
311288
/* if we are using soft locations, then any dash-host would
312289
* just include desired nodes and not required. We don't want
313290
* to pick them up here as this would mean the request was
@@ -329,7 +306,7 @@ void orte_ras_base_allocate(int fd, short args, void *cbdata)
329306
}
330307
}
331308

332-
/* if something was found in the hostfile(s), we use that as our global
309+
/* if something was found in the dash-host(s), we use that as our global
333310
* pool - set it and we are done
334311
*/
335312
if (!opal_list_is_empty(&nodes)) {
@@ -347,25 +324,79 @@ void orte_ras_base_allocate(int fd, short args, void *cbdata)
347324
goto DISPLAY;
348325
}
349326

350-
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
351-
"%s ras:base:allocate nothing found in hostfiles - checking for rankfile",
352-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
327+
/* Our next option is to look for a hostfile and assign our global
328+
* pool from there.
329+
*
330+
* Individual hostfile names, if given, are included
331+
* in the app_contexts for this job. We therefore need to
332+
* retrieve the app_contexts for the job, and then cycle
333+
* through them to see if anything is there. The parser will
334+
* add the nodes found in each hostfile to our list - i.e.,
335+
* the resulting list contains the UNION of all nodes specified
336+
* in hostfiles from across all app_contexts
337+
*
338+
* Note that any relative node syntax found in the hostfiles will
339+
* generate an error in this scenario, so only non-relative syntax
340+
* can be present
341+
*/
342+
for (i=0; i < jdata->apps->size; i++) {
343+
if (NULL == (app = (orte_app_context_t*)opal_pointer_array_get_item(jdata->apps, i))) {
344+
continue;
345+
}
346+
if (orte_get_attribute(&app->attributes, ORTE_APP_HOSTFILE, (void**)&hosts, OPAL_STRING)) {
347+
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
348+
"%s ras:base:allocate adding hostfile %s",
349+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), hosts));
350+
351+
/* hostfile was specified - parse it and add it to the list */
352+
if (ORTE_SUCCESS != (rc = orte_util_add_hostfile_nodes(&nodes, hosts))) {
353+
free(hosts);
354+
OBJ_DESTRUCT(&nodes);
355+
/* set an error event */
356+
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
357+
OBJ_RELEASE(caddy);
358+
return;
359+
}
360+
free(hosts);
361+
}
362+
}
353363

354-
/* Our next option is to look for a rankfile - if one was provided, we
355-
* will use its nodes to create a default allocation pool
364+
/* if something was found in the hostfiles(s), we use that as our global
365+
* pool - set it and we are done
356366
*/
357-
if (NULL != orte_rankfile) {
358-
/* check the rankfile for node information */
359-
if (ORTE_SUCCESS != (rc = orte_util_add_hostfile_nodes(&nodes,
360-
orte_rankfile))) {
367+
if (!opal_list_is_empty(&nodes)) {
368+
/* store the results in the global resource pool - this removes the
369+
* list items
370+
*/
371+
if (ORTE_SUCCESS != (rc = orte_ras_base_node_insert(&nodes, jdata))) {
361372
ORTE_ERROR_LOG(rc);
373+
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
374+
OBJ_RELEASE(caddy);
375+
return;
376+
}
377+
/* cleanup */
378+
OBJ_DESTRUCT(&nodes);
379+
goto DISPLAY;
380+
}
381+
382+
/* if nothing was found so far, then look for a default hostfile */
383+
if (NULL != orte_default_hostfile) {
384+
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
385+
"%s ras:base:allocate parsing default hostfile %s",
386+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
387+
orte_default_hostfile));
388+
389+
/* a default hostfile was provided - parse it */
390+
if (ORTE_SUCCESS != (rc = orte_util_add_hostfile_nodes(&nodes,
391+
orte_default_hostfile))) {
362392
OBJ_DESTRUCT(&nodes);
363393
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
364394
OBJ_RELEASE(caddy);
365-
return ;
395+
return;
366396
}
367397
}
368-
/* if something was found in rankfile, we use that as our global
398+
399+
/* if something was found in the default hostfile, we use that as our global
369400
* pool - set it and we are done
370401
*/
371402
if (!opal_list_is_empty(&nodes)) {
@@ -378,18 +409,13 @@ void orte_ras_base_allocate(int fd, short args, void *cbdata)
378409
OBJ_RELEASE(caddy);
379410
return;
380411
}
381-
/* rankfile is considered equivalent to an RM allocation */
382-
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping))) {
383-
ORTE_SET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
384-
}
385412
/* cleanup */
386413
OBJ_DESTRUCT(&nodes);
387414
goto DISPLAY;
388415
}
389416

390-
391417
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
392-
"%s ras:base:allocate nothing found in rankfile - inserting current node",
418+
"%s ras:base:allocate nothing found in hostfiles - inserting current node",
393419
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
394420

395421
addlocal:

orte/mca/rmaps/base/rmaps_base_map_job.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
1414
* All rights reserved.
15-
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2016 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
@@ -190,19 +190,23 @@ void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
190190
}
191191
}
192192
/* check for oversubscribe directives */
193-
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping))) {
194-
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
195-
} else {
196-
/* pass along the directive */
197-
if (ORTE_MAPPING_NO_OVERSUBSCRIBE & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
193+
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(jdata->map->mapping))) {
194+
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping))) {
198195
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
199196
} else {
200-
ORTE_UNSET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
197+
/* pass along the directive */
198+
if (ORTE_MAPPING_NO_OVERSUBSCRIBE & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
199+
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
200+
} else {
201+
ORTE_UNSET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_OVERSUBSCRIBE);
202+
}
201203
}
202204
}
203205
/* check for no-use-local directive */
204-
if (ORTE_MAPPING_NO_USE_LOCAL & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
205-
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_USE_LOCAL);
206+
if (!(ORTE_MAPPING_LOCAL_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(jdata->map->mapping))) {
207+
if (ORTE_MAPPING_NO_USE_LOCAL & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
208+
ORTE_SET_MAPPING_DIRECTIVE(jdata->map->mapping, ORTE_MAPPING_NO_USE_LOCAL);
209+
}
206210
}
207211
/* ditto for rank policy */
208212
if (!ORTE_RANKING_POLICY_IS_SET(jdata->map->ranking)) {

orte/mca/rmaps/base/rmaps_base_support_fns.c

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -190,49 +190,8 @@ int orte_rmaps_base_get_target_nodes(opal_list_t *allocated_nodes, orte_std_cntr
190190
return rc;
191191
}
192192
free(hosts);
193-
} else if (NULL != orte_rankfile) {
194-
/* use the rankfile, if provided */
195-
OPAL_OUTPUT_VERBOSE((5, orte_rmaps_base_framework.framework_output,
196-
"%s using rankfile %s",
197-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
198-
orte_rankfile));
199-
if (ORTE_SUCCESS != (rc = orte_util_add_hostfile_nodes(&nodes,
200-
orte_rankfile))) {
201-
ORTE_ERROR_LOG(rc);
202-
return rc;
203-
}
204-
if (0 == opal_list_get_size(&nodes)) {
205-
OPAL_OUTPUT_VERBOSE((5, orte_rmaps_base_framework.framework_output,
206-
"%s nothing found in given rankfile",
207-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
208-
OBJ_DESTRUCT(&nodes);
209-
return ORTE_ERR_BAD_PARAM;
210-
}
211-
} else if (NULL != orte_default_hostfile) {
212-
/* fall back to the default hostfile, if provided */
213-
OPAL_OUTPUT_VERBOSE((5, orte_rmaps_base_framework.framework_output,
214-
"%s using default hostfile %s",
215-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
216-
orte_default_hostfile));
217-
if (ORTE_SUCCESS != (rc = orte_util_add_hostfile_nodes(&nodes,
218-
orte_default_hostfile))) {
219-
ORTE_ERROR_LOG(rc);
220-
return rc;
221-
}
222-
/* this is a special case - we always install a default
223-
* hostfile, but it is empty. If the user didn't remove it
224-
* or put something into it, then we will have pursued that
225-
* option and found nothing. This isn't an error, we just need
226-
* to add all the known nodes
227-
*/
228-
if (0 == opal_list_get_size(&nodes)) {
229-
OPAL_OUTPUT_VERBOSE((5, orte_rmaps_base_framework.framework_output,
230-
"%s nothing in default hostfile - using known nodes",
231-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
232-
goto addknown;
233-
}
234193
} else {
235-
/* if nothing else was available, then use all known nodes, which
194+
/* if nothing else was specified by the app, then use all known nodes, which
236195
* will include ourselves
237196
*/
238197
OPAL_OUTPUT_VERBOSE((5, orte_rmaps_base_framework.framework_output,
@@ -585,9 +544,7 @@ orte_proc_t* orte_rmaps_base_setup_proc(orte_job_t *jdata,
585544
* available slots - otherwise, it does */
586545
if (!ORTE_FLAG_TEST(jdata, ORTE_JOB_FLAG_DEBUGGER_DAEMON)) {
587546
node->num_procs++;
588-
if (node->slots_inuse < node->slots) {
589-
++node->slots_inuse;
590-
}
547+
++node->slots_inuse;
591548
}
592549
if (0 > (rc = opal_pointer_array_add(node->procs, (void*)proc))) {
593550
ORTE_ERROR_LOG(rc);

orte/mca/rmaps/ppr/rmaps_ppr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
33
* Copyright (c) 2011 Los Alamos National Security, LLC.
44
* All rights reserved.
5-
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
5+
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
66
* Copyright (c) 2015-2017 Research Organization for Information Science
77
* and Technology (RIST). All rights reserved.
88
* $COPYRIGHT$
@@ -357,7 +357,7 @@ static int ppr_mapper(orte_job_t *jdata)
357357
/* if we weren't given a directive either way, then we will error out
358358
* as the #slots were specifically given, either by the host RM or
359359
* via hostfile/dash-host */
360-
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping))) {
360+
if (!(ORTE_MAPPING_SUBSCRIBE_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(jdata->map->mapping))) {
361361
orte_show_help("help-orte-rmaps-base.txt", "orte-rmaps-base:alloc-error",
362362
true, app->num_procs, app->app);
363363
ORTE_UPDATE_EXIT_STATUS(ORTE_ERROR_DEFAULT_EXIT_CODE);

orte/mca/rmaps/rmaps_types.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011-2017 Cisco Systems, Inc. All rights reserved
1313
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
1414
* reserved.
15-
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
1616
* $COPYRIGHT$
1717
*
1818
* Additional copyrights may follow
@@ -89,7 +89,9 @@ ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_job_map_t);
8989
#define ORTE_MAPPING_SUBSCRIBE_GIVEN 0x0400
9090
#define ORTE_MAPPING_SPAN 0x0800
9191
/* an error flag */
92-
#define ORTE_MAPPING_CONFLICTED 0x2000
92+
#define ORTE_MAPPING_CONFLICTED 0x1000
93+
/* directives given */
94+
#define ORTE_MAPPING_LOCAL_GIVEN 0x2000
9395
#define ORTE_MAPPING_GIVEN 0x4000
9496
/* mapping a debugger job */
9597
#define ORTE_MAPPING_DEBUGGER 0x8000

0 commit comments

Comments
 (0)