Skip to content

Commit 2234953

Browse files
author
Ralph Castain
committed
Fix binding policy bug and support pe=1 modifier
Allow someone to specify the "pe=N" modifier to a mapping policy when N=1. This equates to just "bind-to core", but helps people who use a script to set the PE policy. Fix a bug where setting the binding policy left a lingering "if-supported" flag that shouldn't be there. Signed-off-by: Ralph Castain <[email protected]>
1 parent 578d881 commit 2234953

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

opal/mca/hwloc/hwloc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
33
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
4-
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved.
4+
* Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
55
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
66
* reserved.
77
*
@@ -191,7 +191,7 @@ typedef uint16_t opal_binding_policy_t;
191191
#define OPAL_GET_BINDING_POLICY(pol) \
192192
((pol) & 0x0fff)
193193
#define OPAL_SET_BINDING_POLICY(target, pol) \
194-
(target) = (pol) | (((target) & 0xf000) | OPAL_BIND_GIVEN)
194+
(target) = (pol) | (((target) & 0x2000) | OPAL_BIND_GIVEN)
195195
#define OPAL_SET_DEFAULT_BINDING_POLICY(target, pol) \
196196
do { \
197197
if (!OPAL_BINDING_POLICY_IS_SET((target))) { \

orte/mca/rmaps/base/rmaps_base_frame.c

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
1414
* All rights reserved.
15-
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2014-2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
@@ -149,7 +149,7 @@ static int orte_rmaps_base_register(mca_base_register_flag_t flags)
149149
MCA_BASE_VAR_SCOPE_READONLY, &rmaps_base_bynode);
150150

151151
/* #cpus/rank to use */
152-
orte_rmaps_base.cpus_per_rank = 1;
152+
orte_rmaps_base.cpus_per_rank = 0;
153153
var_id = mca_base_var_register("orte", "rmaps", "base", "cpus_per_proc",
154154
"Number of cpus to use for each rank [1-2**15 (default=1)]",
155155
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
@@ -280,7 +280,7 @@ static int orte_rmaps_base_open(mca_base_open_flag_t flags)
280280
return ORTE_ERR_SILENT;
281281
}
282282
}
283-
if (1 < orte_rmaps_base.cpus_per_rank) {
283+
if (0 < orte_rmaps_base.cpus_per_rank) {
284284
orte_show_help("help-orte-rmaps-base.txt", "deprecated", true,
285285
"--cpus-per-proc, -cpus-per-proc, --cpus-per-rank, -cpus-per-rank",
286286
"--map-by <obj>:PE=N, default <obj>=NUMA",
@@ -376,8 +376,8 @@ static int orte_rmaps_base_open(mca_base_open_flag_t flags)
376376
ORTE_SET_RANKING_DIRECTIVE(orte_rmaps_base.ranking, ORTE_RANKING_GIVEN);
377377
}
378378

379-
if (1 < orte_rmaps_base.cpus_per_rank) {
380-
/* if we were asked for multiple cpus/proc, then we have to
379+
if (0 < orte_rmaps_base.cpus_per_rank) {
380+
/* if we were asked for cpus/proc, then we have to
381381
* bind to those cpus - any other binding policy is an
382382
* error
383383
*/
@@ -403,24 +403,27 @@ static int orte_rmaps_base_open(mca_base_open_flag_t flags)
403403
if (opal_hwloc_use_hwthreads_as_cpus) {
404404
OPAL_SET_BINDING_POLICY(opal_hwloc_binding_policy, OPAL_BIND_TO_HWTHREAD);
405405
} else {
406+
opal_output(0, "SETTING BINDING TO CORE");
406407
OPAL_SET_BINDING_POLICY(opal_hwloc_binding_policy, OPAL_BIND_TO_CORE);
407408
}
408409
}
409-
/* we also need to ensure we are mapping to a high-enough level to have
410-
* multiple cpus beneath it - by default, we'll go to the NUMA level */
411-
if (ORTE_MAPPING_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
412-
if (ORTE_GET_MAPPING_POLICY(orte_rmaps_base.mapping) == ORTE_MAPPING_BYHWTHREAD ||
413-
(ORTE_GET_MAPPING_POLICY(orte_rmaps_base.mapping) == ORTE_MAPPING_BYCORE &&
414-
!opal_hwloc_use_hwthreads_as_cpus)) {
415-
orte_show_help("help-orte-rmaps-base.txt", "mapping-too-low-init", true);
416-
return ORTE_ERR_SILENT;
410+
if (1 < orte_rmaps_base.cpus_per_rank) {
411+
/* we need to ensure we are mapping to a high-enough level to have
412+
* multiple cpus beneath it - by default, we'll go to the NUMA level */
413+
if (ORTE_MAPPING_GIVEN & ORTE_GET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping)) {
414+
if (ORTE_GET_MAPPING_POLICY(orte_rmaps_base.mapping) == ORTE_MAPPING_BYHWTHREAD ||
415+
(ORTE_GET_MAPPING_POLICY(orte_rmaps_base.mapping) == ORTE_MAPPING_BYCORE &&
416+
!opal_hwloc_use_hwthreads_as_cpus)) {
417+
orte_show_help("help-orte-rmaps-base.txt", "mapping-too-low-init", true);
418+
return ORTE_ERR_SILENT;
419+
}
420+
} else {
421+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
422+
"%s rmaps:base pe/rank set - setting mapping to BYNUMA",
423+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
424+
ORTE_SET_MAPPING_POLICY(orte_rmaps_base.mapping, ORTE_MAPPING_BYNUMA);
425+
ORTE_SET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping, ORTE_MAPPING_GIVEN);
417426
}
418-
} else {
419-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
420-
"%s rmaps:base pe/rank set - setting mapping to BYNUMA",
421-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
422-
ORTE_SET_MAPPING_POLICY(orte_rmaps_base.mapping, ORTE_MAPPING_BYNUMA);
423-
ORTE_SET_MAPPING_DIRECTIVE(orte_rmaps_base.mapping, ORTE_MAPPING_GIVEN);
424427
}
425428
}
426429

orte/mca/rmaps/base/rmaps_base_map_job.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
205205
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
206206
"mca:rmaps[%d] binding policy given", __LINE__);
207207
jdata->map->binding = opal_hwloc_binding_policy;
208-
} else if (1 < jdata->map->cpus_per_rank) {
208+
} else if (0 < jdata->map->cpus_per_rank) {
209209
/* bind to cpus */
210210
if (opal_hwloc_use_hwthreads_as_cpus) {
211211
/* if we are using hwthread cpus, then bind to those */

orte/runtime/orte_globals.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ static void orte_job_map_construct(orte_job_map_t* map)
833833
map->ranking = 0;
834834
map->binding = 0;
835835
map->ppr = NULL;
836-
map->cpus_per_rank = 1;
836+
map->cpus_per_rank = 0;
837837
map->display_map = false;
838838
map->num_new_daemons = 0;
839839
map->daemon_vpid_start = ORTE_VPID_INVALID;

0 commit comments

Comments
 (0)