Skip to content

Commit 079ac07

Browse files
committed
lstopo: allow output format/extension v2xml/v3xml
To enforce exporting to v2 XML or not. Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
1 parent 0b80dfd commit 079ac07

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

utils/lstopo/lstopo-no-graphics.1in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ that are passed to \fIhwloc_topology_export_xml()\fR.
7171
Those names may be substrings of actual flag names as long as a single one matches.
7272
A value of \fB2\fR (or \fBv2\fR) reverts to the format of hwloc v2.x.
7373
The default is \fB0\fR (or \fBnone\fR).
74+
75+
Output formats \fBv2xml\fR and \fBv3xml\fR may also be used to specify
76+
which XML version is desired.
7477
.TP
7578
\fB\-\-export\-synthetic\-flags\fR <flags>
7679
Enforce flags when exporting to the synthetic format.
@@ -614,6 +617,9 @@ It may be reused later, even on another machine, with lstopo \-\-input,
614617
the HWLOC_XMLFILE environment variable, or the hwloc_topology_set_xml()
615618
function.
616619

620+
\fBv2xml\fR may also be used to specify that hwloc v2-compatible XML
621+
should be exported.
622+
617623
.PP
618624
The following special names may be used:
619625
.TP

utils/lstopo/lstopo.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ enum output_format {
685685
};
686686

687687
static enum output_format
688-
parse_output_format(const char *name, char *callname __hwloc_attribute_unused)
688+
parse_output_format(const char *name, unsigned long *xml_flags)
689689
{
690690
if (!hwloc_strncasecmp(name, "default", 3))
691691
return LSTOPO_OUTPUT_DEFAULT;
@@ -714,7 +714,13 @@ parse_output_format(const char *name, char *callname __hwloc_attribute_unused)
714714
return LSTOPO_OUTPUT_CAIROSVG;
715715
else if (!strcasecmp(name, "nativesvg") || !strcasecmp(name, "svg(native)"))
716716
return LSTOPO_OUTPUT_NATIVESVG;
717-
else if (!strcasecmp(name, "xml"))
717+
else if (!strcasecmp(name, "v2xml")) {
718+
*xml_flags |= HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2;
719+
return LSTOPO_OUTPUT_XML;
720+
} else if (!strcasecmp(name, "v3xml")) {
721+
*xml_flags &= ~HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2;
722+
return LSTOPO_OUTPUT_XML;
723+
} else if (!strcasecmp(name, "xml"))
718724
return LSTOPO_OUTPUT_XML;
719725
else if (!strcasecmp(name, "shmem"))
720726
return LSTOPO_OUTPUT_SHMEM;
@@ -1472,7 +1478,7 @@ main (int argc, char *argv[])
14721478
} else if (!strcmp (argv[0], "--output-format") || !strcmp (argv[0], "--of")) {
14731479
if (argc < 2)
14741480
goto out_usagefailure;
1475-
output_format = parse_output_format(argv[1], callname);
1481+
output_format = parse_output_format(argv[1], &loutput.export_xml_flags);
14761482
opt = 1;
14771483
} else {
14781484
if (filename) {
@@ -1513,7 +1519,7 @@ main (int argc, char *argv[])
15131519
} else {
15141520
char *dot = strrchr(filename, '.');
15151521
if (dot) {
1516-
output_format = parse_output_format(dot+1, callname);
1522+
output_format = parse_output_format(dot+1, &loutput.export_xml_flags);
15171523
if (dot == filename+1 && filename[0] == '-' && output_format != LSTOPO_OUTPUT_ERROR)
15181524
filename = "-"; /* to simplify things later */
15191525
} else {

utils/lstopo/test-lstopo.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ echo "**** Import from synthetic so that we can check some exact outputs in $fil
123123
echo "** Export synthetic flag extended,attrs,v1..."
124124
$ls -i "node:4 pu:4" -.synthetic --export-synthetic-flags extended,attrs,v1
125125
echo "** Export XML flag v2..."
126-
$ls -i "node:4 pu:4" -.xml --export-xml-flags v2
126+
$ls -i "node:4 pu:4" -.v2xml
127127
echo "** Topology flag disallowed..."
128128
$ls -i "node:4 pu:4" - --allow 0xf --flags disallowed -v
129129
) > "$file"

0 commit comments

Comments
 (0)