Skip to content

Commit

Permalink
lstopo/core: initialize the topology after parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Aug 10, 2020
1 parent c44a216 commit f160161
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions utils/lstopo/lstopo.c
Expand Up @@ -743,12 +743,6 @@ main (int argc, char *argv[])
if (!loutput.cpubind_set || !loutput.membind_set)
goto out;

err = hwloc_topology_init (&topology);
if (err)
goto out;
hwloc_topology_set_all_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL);
hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_IMPORTANT);

while (argc >= 1)
{
opt = 0;
Expand Down Expand Up @@ -977,7 +971,7 @@ main (int argc, char *argv[])
goto out_usagefailure;
flags = hwloc_utils_parse_topology_flags(argv[1]);
if(flags == (unsigned long)-1)
goto out_with_topology;
goto out;
opt = 1;
}
else if (!strcmp (argv[0], "--restrict")) {
Expand All @@ -996,23 +990,23 @@ main (int argc, char *argv[])
goto out_usagefailure;
restrict_flags = hwloc_utils_parse_restrict_flags(argv[1]);
if(restrict_flags == (unsigned long)-1)
goto out_with_topology;
goto out;
opt = 1;
}
else if (!strcmp (argv[0], "--export-xml-flags")) {
if (argc < 2)
goto out_usagefailure;
loutput.export_xml_flags = hwloc_utils_parse_export_xml_flags(argv[1]);
if(loutput.export_xml_flags == (unsigned long)-1)
goto out_with_topology;
goto out;
opt = 1;
}
else if (!strcmp (argv[0], "--export-synthetic-flags")) {
if (argc < 2)
goto out_usagefailure;
loutput.export_synthetic_flags = hwloc_utils_parse_export_synthetic_flags(argv[1]);
if(loutput.export_synthetic_flags == (unsigned long)-1)
goto out_with_topology;
goto out;
opt = 1;
}
else if (!strcmp (argv[0], "--horiz"))
Expand Down Expand Up @@ -1325,6 +1319,12 @@ main (int argc, char *argv[])
* Configure the topology
*/

err = hwloc_topology_init (&topology);
if (err)
goto out;
hwloc_topology_set_all_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_ALL);
hwloc_topology_set_io_types_filter(topology, HWLOC_TYPE_FILTER_KEEP_IMPORTANT);

err = hwloc_topology_set_flags(topology, flags);
if (err < 0) {
fprintf(stderr, "Failed to set flags %lx (%s).\n", flags, strerror(errno));
Expand Down Expand Up @@ -1505,6 +1505,8 @@ main (int argc, char *argv[])

out_usagefailure:
usage (callname, stderr);
goto out;

out_with_topology:
lstopo_destroy_userdata(hwloc_get_root_obj(topology));
hwloc_topology_destroy(topology);
Expand Down

0 comments on commit f160161

Please sign in to comment.