Skip to content

Commit f5fb43e

Browse files
author
Ralph Castain
authored
Merge pull request #4120 from bgoglin/master
fixes and debug messages to the hwloc/shmem use
2 parents a3e31fa + 046d870 commit f5fb43e

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

opal/mca/hwloc/base/hwloc_base_util.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,29 @@ int opal_hwloc_base_get_topology(void)
310310
free(shmemfile);
311311
if (0 != hwloc_shmem_topology_adopt(&opal_hwloc_topology, fd,
312312
0, (void*)addr, size, 0)) {
313-
OPAL_ERROR_LOG(OPAL_ERR_FILE_READ_FAILURE);
314-
return OPAL_ERR_FILE_READ_FAILURE;
313+
if (4 < opal_output_get_verbosity(opal_hwloc_base_framework.framework_output)) {
314+
FILE *file = fopen("/proc/self/maps", "r");
315+
if (file) {
316+
char line[256];
317+
opal_output(0, opal_hwloc_base_framework.framework_output,
318+
"Dumping /proc/self/maps");
319+
while (fgets(line, sizeof(line), file) != NULL) {
320+
char *end = strchr(line, '\n');
321+
if (end)
322+
*end = '\0';
323+
opal_output(0, opal_hwloc_base_framework.framework_output,
324+
"%s", line);
325+
}
326+
fclose(file);
327+
}
328+
}
329+
/* failed to adopt from shmem, fallback to other ways to get the topology */
330+
} else {
331+
opal_output_verbose(2, opal_hwloc_base_framework.framework_output,
332+
"hwloc:base: topology in shared memory");
333+
topo_in_shmem = true;
334+
return OPAL_SUCCESS;
315335
}
316-
opal_output_verbose(2, opal_hwloc_base_framework.framework_output,
317-
"hwloc:base: topology in shared memory");
318-
topo_in_shmem = true;
319-
return OPAL_SUCCESS;
320336
}
321337
#endif
322338
/* if that isn't available, then try to retrieve

orte/mca/rtc/hwloc/rtc_hwloc.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
33
* Copyright (c) 2017 Cisco Systems, Inc. All rights reserved
4+
* Copyright (c) 2017 Inria. All rights reserved.
45
* $COPYRIGHT$
56
*
67
* Additional copyrights may follow
@@ -111,6 +112,22 @@ static int init(void)
111112
if (ORTE_SUCCESS != (rc = find_hole(mca_rtc_hwloc_component.kind,
112113
&shmemaddr, shmemsize))) {
113114
/* we couldn't find a hole, so don't use the shmem support */
115+
if (4 < opal_output_get_verbosity(orte_rtc_base_framework.framework_output)) {
116+
FILE *file = fopen("/proc/self/maps", "r");
117+
if (file) {
118+
char line[256];
119+
opal_output(0, orte_rtc_base_framework.framework_output,
120+
"%s Dumping /proc/self/maps", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
121+
while (fgets(line, sizeof(line), file) != NULL) {
122+
char *end = strchr(line, '\n');
123+
if (end)
124+
*end = '\0';
125+
opal_output(0, orte_rtc_base_framework.framework_output,
126+
"%s", line);
127+
}
128+
fclose(file);
129+
}
130+
}
114131
return ORTE_SUCCESS;
115132
}
116133
/* create the shmem file in our session dir so it
@@ -580,7 +597,10 @@ static int find_hole(orte_rtc_hwloc_vm_hole_kind_t hkind,
580597
return use_hole(0, begin, addrp, size);
581598

582599
case VM_HOLE_AFTER_HEAP:
583-
if (prevmkind == VM_MAP_HEAP) {
600+
if (prevmkind == VM_MAP_HEAP && mkind != VM_MAP_HEAP) {
601+
/* only use HEAP when there's no other HEAP after it
602+
* (there can be several of them consecutively).
603+
*/
584604
fclose(file);
585605
return use_hole(prevend, begin-prevend, addrp, size);
586606
}
@@ -594,15 +614,18 @@ static int find_hole(orte_rtc_hwloc_vm_hole_kind_t hkind,
594614
break;
595615

596616
case VM_HOLE_IN_LIBS:
617+
/* see if we are between heap and stack */
597618
if (prevmkind == VM_MAP_HEAP) {
598619
in_libs = 1;
599620
}
600621
if (mkind == VM_MAP_STACK) {
601622
in_libs = 0;
602623
}
603-
if (in_libs) {
624+
if (!in_libs) {
625+
/* we're not in libs, ignore this entry */
604626
break;
605627
}
628+
/* we're in libs, consider this entry for searching the biggest hole below */
606629
/* fallthrough */
607630

608631
case VM_HOLE_BIGGEST:

orte/mca/rtc/hwloc/rtc_hwloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2017 Inria. All rights reserved.
34
* $COPYRIGHT$
45
*
56
* Additional copyrights may follow

orte/mca/rtc/hwloc/rtc_hwloc_component.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* reserved.
66
* Copyright (c) 2017 Research Organization for Information Science
77
* and Technology (RIST). All rights reserved.
8+
* Copyright (c) 2017 Inria. All rights reserved.
89
* $COPYRIGHT$
910
*
1011
* Additional copyrights may follow

0 commit comments

Comments
 (0)