Skip to content

Commit

Permalink
xml: add a v2 export flag and enable it by default for now
Browse files Browse the repository at this point in the history
It doesn't do anything yet and it's force-enabled internally for now
so that tests outputs don't change yet.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Jan 25, 2023
1 parent 5016202 commit d1029c3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
10 changes: 8 additions & 2 deletions hwloc/topology-xml.c
Expand Up @@ -3311,11 +3311,14 @@ int hwloc_topology_export_xml(hwloc_topology_t topology, const char *filename, u

assert(hwloc_nolibxml_callbacks); /* the core called components_init() for the topology */

if (flags & ~HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1) {
if (flags & ~(HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1|HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2)) {
errno = EINVAL;
return -1;
}

/* TODO temp */
flags |= HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2;

hwloc_internal_distances_refresh(topology);

hwloc_localeswitch_init();
Expand Down Expand Up @@ -3359,11 +3362,14 @@ int hwloc_topology_export_xmlbuffer(hwloc_topology_t topology, char **xmlbuffer,

assert(hwloc_nolibxml_callbacks); /* the core called components_init() for the topology */

if (flags & ~HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1) {
if (flags & ~(HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1|HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2)) {
errno = EINVAL;
return -1;
}

/* TODO temp */
flags |= HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2;

hwloc_internal_distances_refresh(topology);

hwloc_localeswitch_init();
Expand Down
10 changes: 8 additions & 2 deletions include/hwloc/export.h
@@ -1,5 +1,5 @@
/*
* Copyright © 2009-2018 Inria. All rights reserved.
* Copyright © 2009-2022 Inria. All rights reserved.
* Copyright © 2009-2012 Université Bordeaux
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
Expand Down Expand Up @@ -37,7 +37,13 @@ enum hwloc_topology_export_xml_flags_e {
* However, the export may miss some details about the topology.
* \hideinitializer
*/
HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 = (1UL<<0)
HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 = (1UL<<0),

/** \brief Export XML that is loadable by hwloc v2.x.
* However, the export may miss some details about the topology.
* \hideinitializer
*/
HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2 = (1UL<<1)
};

/** \brief Export the topology into an XML file.
Expand Down
1 change: 1 addition & 0 deletions include/hwloc/rename.h
Expand Up @@ -437,6 +437,7 @@ extern "C" {

#define hwloc_topology_export_xml_flags_e HWLOC_NAME(topology_export_xml_flags_e)
#define HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 HWLOC_NAME_CAPS(TOPOLOGY_EXPORT_XML_FLAG_V1)
#define HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2 HWLOC_NAME_CAPS(TOPOLOGY_EXPORT_XML_FLAG_V2)
#define hwloc_topology_export_xml HWLOC_NAME(topology_export_xml)
#define hwloc_topology_export_xmlbuffer HWLOC_NAME(topology_export_xmlbuffer)
#define hwloc_free_xmlbuffer HWLOC_NAME(free_xmlbuffer)
Expand Down
3 changes: 2 additions & 1 deletion utils/hwloc/misc.h
Expand Up @@ -912,7 +912,8 @@ hwloc_utils_parse_export_synthetic_flags(char * str) {
static __hwloc_inline unsigned long
hwloc_utils_parse_export_xml_flags(char * str) {
struct hwloc_utils_parsing_flag possible_flags[] = {
HWLOC_UTILS_PARSING_FLAG(HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1)
HWLOC_UTILS_PARSING_FLAG(HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1),
HWLOC_UTILS_PARSING_FLAG(HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V2)
};

return hwloc_utils_parse_flags(str, possible_flags, (int) sizeof(possible_flags) / sizeof(possible_flags[0]), "xml");
Expand Down

0 comments on commit d1029c3

Please sign in to comment.