Skip to content

Commit f160161

Browse files
committed
lstopo/core: initialize the topology after parsing
Signed-off-by: Brice Goglin <[email protected]>
1 parent c44a216 commit f160161

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

utils/lstopo/lstopo.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,6 @@ main (int argc, char *argv[])
743743
if (!loutput.cpubind_set || !loutput.membind_set)
744744
goto out;
745745

746-
err = hwloc_topology_init (&topology);
747-
if (err)
748-
goto out;
749-
hwloc_topology_set_all_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL);
750-
hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_IMPORTANT);
751-
752746
while (argc >= 1)
753747
{
754748
opt = 0;
@@ -977,7 +971,7 @@ main (int argc, char *argv[])
977971
goto out_usagefailure;
978972
flags = hwloc_utils_parse_topology_flags(argv[1]);
979973
if(flags == (unsigned long)-1)
980-
goto out_with_topology;
974+
goto out;
981975
opt = 1;
982976
}
983977
else if (!strcmp (argv[0], "--restrict")) {
@@ -996,23 +990,23 @@ main (int argc, char *argv[])
996990
goto out_usagefailure;
997991
restrict_flags = hwloc_utils_parse_restrict_flags(argv[1]);
998992
if(restrict_flags == (unsigned long)-1)
999-
goto out_with_topology;
993+
goto out;
1000994
opt = 1;
1001995
}
1002996
else if (!strcmp (argv[0], "--export-xml-flags")) {
1003997
if (argc < 2)
1004998
goto out_usagefailure;
1005999
loutput.export_xml_flags = hwloc_utils_parse_export_xml_flags(argv[1]);
10061000
if(loutput.export_xml_flags == (unsigned long)-1)
1007-
goto out_with_topology;
1001+
goto out;
10081002
opt = 1;
10091003
}
10101004
else if (!strcmp (argv[0], "--export-synthetic-flags")) {
10111005
if (argc < 2)
10121006
goto out_usagefailure;
10131007
loutput.export_synthetic_flags = hwloc_utils_parse_export_synthetic_flags(argv[1]);
10141008
if(loutput.export_synthetic_flags == (unsigned long)-1)
1015-
goto out_with_topology;
1009+
goto out;
10161010
opt = 1;
10171011
}
10181012
else if (!strcmp (argv[0], "--horiz"))
@@ -1325,6 +1319,12 @@ main (int argc, char *argv[])
13251319
* Configure the topology
13261320
*/
13271321

1322+
err = hwloc_topology_init (&topology);
1323+
if (err)
1324+
goto out;
1325+
hwloc_topology_set_all_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL);
1326+
hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_IMPORTANT);
1327+
13281328
err = hwloc_topology_set_flags(topology, flags);
13291329
if (err < 0) {
13301330
fprintf(stderr, "Failed to set flags %lx (%s).\n", flags, strerror(errno));
@@ -1505,6 +1505,8 @@ main (int argc, char *argv[])
15051505

15061506
out_usagefailure:
15071507
usage (callname, stderr);
1508+
goto out;
1509+
15081510
out_with_topology:
15091511
lstopo_destroy_userdata(hwloc_get_root_obj(topology));
15101512
hwloc_topology_destroy(topology);

0 commit comments

Comments
 (0)