Skip to content

Commit ab3fc05

Browse files
authored
Merge pull request open-mpi#8256 from rhc54/cmr41/fix
v4.1.x: Fix the verbose output in ess base
2 parents 6e2c8cf + 09e9fe0 commit ab3fc05

File tree

1 file changed

+72
-23
lines changed

1 file changed

+72
-23
lines changed

orte/mca/ess/base/ess_base_fns.c

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,43 @@ int orte_ess_base_proc_binding(void)
7474
}
7575
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_CPUSET,
7676
ORTE_PROC_MY_NAME, &orte_process_info.cpuset, OPAL_STRING);
77-
/* try to get our locality as well */
78-
map = NULL;
79-
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_LOCALITY_STRING,
80-
ORTE_PROC_MY_NAME, &map, OPAL_STRING);
81-
if (OPAL_SUCCESS == ret && NULL != map) {
82-
/* we were - no need to pull in the topology */
83-
if (opal_hwloc_report_bindings || 4 < opal_output_get_verbosity(orte_ess_base_framework.framework_output)) {
84-
opal_output(0, "MCW rank %s bound to %s",
85-
ORTE_VPID_PRINT(ORTE_PROC_MY_NAME->vpid), map);
77+
78+
if (opal_hwloc_report_bindings || 4 < opal_output_get_verbosity(orte_ess_base_framework.framework_output)) {
79+
/* try to get our locality as well so we avoid pulling in the hwloc topology tree */
80+
map = NULL;
81+
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_LOCALITY_STRING,
82+
ORTE_PROC_MY_NAME, &map, OPAL_STRING);
83+
if (OPAL_SUCCESS == ret && NULL != map) {
84+
/* we were - no need to pull in the topology */
85+
opal_output(0, "MCW rank %s bound to %s",
86+
ORTE_VPID_PRINT(ORTE_PROC_MY_NAME->vpid), map);
87+
free(map);
88+
} else if (OPAL_SUCCESS == ret && NULL == map) {
89+
opal_output(0, "MCW rank %s not bound", ORTE_VPID_PRINT(ORTE_PROC_MY_NAME->vpid));
90+
} else {
91+
/* they want the binding report, so we will have to obtain the
92+
* topology since locality wasn't given to us */
93+
if (OPAL_SUCCESS != opal_hwloc_base_get_topology()) {
94+
/* there is nothing we can do, so just return */
95+
return ORTE_SUCCESS;
96+
}
97+
mycpus = hwloc_bitmap_alloc();
98+
if (hwloc_get_cpubind(opal_hwloc_topology,
99+
mycpus, HWLOC_CPUBIND_PROCESS) < 0) {
100+
opal_output(0, "MCW rank %d is not bound",
101+
ORTE_PROC_MY_NAME->vpid);
102+
} else {
103+
char tmp1[1024], tmp2[1024];
104+
if (OPAL_ERR_NOT_BOUND == opal_hwloc_base_cset2str(tmp1, sizeof(tmp1), opal_hwloc_topology, mycpus)) {
105+
opal_output(0, "MCW rank %d is not bound (or bound to all available processors)", ORTE_PROC_MY_NAME->vpid);
106+
} else {
107+
opal_hwloc_base_cset2mapstr(tmp2, sizeof(tmp2), opal_hwloc_topology, mycpus);
108+
opal_output(0, "MCW rank %d bound to %s: %s",
109+
ORTE_PROC_MY_NAME->vpid, tmp1, tmp2);
110+
}
111+
}
112+
hwloc_bitmap_free(mycpus);
86113
}
87-
free(map);
88-
} else {
89-
opal_output(0, "MCW rank %s not bound", ORTE_VPID_PRINT(ORTE_PROC_MY_NAME->vpid));
90114
}
91115
return ORTE_SUCCESS;
92116
} else if (NULL != getenv(OPAL_MCA_PREFIX"orte_externally_bound")) {
@@ -99,18 +123,43 @@ int orte_ess_base_proc_binding(void)
99123
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_CPUSET,
100124
ORTE_PROC_MY_NAME, &orte_process_info.cpuset, OPAL_STRING);
101125

102-
/* see if we also have our locality - this is the one we require */
103-
map = NULL;
104-
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_LOCALITY_STRING,
105-
ORTE_PROC_MY_NAME, &map, OPAL_STRING);
106-
if (OPAL_SUCCESS == ret && NULL != map) {
107-
/* we were - no need to pull in the topology */
108-
if (opal_hwloc_report_bindings || 4 < opal_output_get_verbosity(orte_ess_base_framework.framework_output)) {
109-
opal_output(0, "MCW rank %s bound to %s",
110-
ORTE_VPID_PRINT(ORTE_PROC_MY_NAME->vpid), map);
126+
127+
if (opal_hwloc_report_bindings || 4 < opal_output_get_verbosity(orte_ess_base_framework.framework_output)) {
128+
/* try to get our locality as well so we avoid pulling in the hwloc topology tree */
129+
map = NULL;
130+
OPAL_MODEX_RECV_VALUE_OPTIONAL(ret, OPAL_PMIX_LOCALITY_STRING,
131+
ORTE_PROC_MY_NAME, &map, OPAL_STRING);
132+
if (OPAL_SUCCESS == ret && NULL != map) {
133+
/* we were - no need to pull in the topology */
134+
opal_output(0, "MCW rank %s bound to %s",
135+
ORTE_VPID_PRINT(ORTE_PROC_MY_NAME->vpid), map);
136+
free(map);
137+
} else if (OPAL_SUCCESS == ret && NULL == map) {
138+
opal_output(0, "MCW rank %s not bound", ORTE_VPID_PRINT(ORTE_PROC_MY_NAME->vpid));
139+
} else {
140+
/* they want the binding report, so we will have to obtain the
141+
* topology since locality wasn't given to us */
142+
if (OPAL_SUCCESS != opal_hwloc_base_get_topology()) {
143+
/* there is nothing we can do, so just return */
144+
return ORTE_SUCCESS;
145+
}
146+
mycpus = hwloc_bitmap_alloc();
147+
if (hwloc_get_cpubind(opal_hwloc_topology,
148+
mycpus, HWLOC_CPUBIND_PROCESS) < 0) {
149+
opal_output(0, "MCW rank %d is not bound",
150+
ORTE_PROC_MY_NAME->vpid);
151+
} else {
152+
char tmp1[1024], tmp2[1024];
153+
if (OPAL_ERR_NOT_BOUND == opal_hwloc_base_cset2str(tmp1, sizeof(tmp1), opal_hwloc_topology, mycpus)) {
154+
opal_output(0, "MCW rank %d is not bound (or bound to all available processors)", ORTE_PROC_MY_NAME->vpid);
155+
} else {
156+
opal_hwloc_base_cset2mapstr(tmp2, sizeof(tmp2), opal_hwloc_topology, mycpus);
157+
opal_output(0, "MCW rank %d bound to %s: %s",
158+
ORTE_PROC_MY_NAME->vpid, tmp1, tmp2);
159+
}
160+
}
161+
hwloc_bitmap_free(mycpus);
111162
}
112-
free(map);
113-
return ORTE_SUCCESS;
114163
}
115164
/* the topology system will pickup the binding pattern */
116165
}

0 commit comments

Comments
 (0)