Removed built-in hwloc for MSVC; new xmrig-deps required (msvc2026\x64, dev-branch).
What changed, and why it matters
This commit removes the bundled copy of the hwloc library that XMRig previously shipped for Microsoft Visual C++ (MSVC) builds. It is a build-system cleanup: developers using MSVC will now need to download a separate dependency package (xmrig-deps) instead of getting hwloc automatically from XMRig's own source tree. There is no change to mining logic, no bug fix, and no security patch in the code itself.
No security action required. Developers building XMRig with MSVC should update to the new xmrig-deps package as instructed in the commit message. Users of pre-built binaries are unaffected.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes the entire src/3rdparty/hwloc subtree (headers, source files, CMakeLists.txt, AUTHORS, COPYING, README, VERSION) and updates src/backend/cpu/cpu.cmake to stop building that bundled copy for MSVC. The project will now rely on an external hwloc provided by the xmrig-deps package. The diff is almost entirely deletions of third-party library code; no functional XMRig code is modified and no vulnerability is addressed.
Changed components
src/3rdparty/hwloc (removed)src/backend/cpu/cpu.cmakeInspect captured patch +3 / −42670
### src/3rdparty/hwloc/AUTHORS
@@ -1,45 +0,0 @@
-hwloc Authors
-=============
-
-The following cumulative list contains the names of most individuals
-who have committed code to the hwloc repository
-(either directly or through a third party).
-
-Name Affiliation(s)
---------------------------- --------------------
-Grzegorz Andrejczuk Intel
-Cédric Augonnet University of Bordeaux
-Guillaume Beauchamp Inria
-Ahmad Boissetri Binzagr Inria
-Cyril Bordage Inria
-Nicholas Buroker UWL
-Christopher M. Cantalupo Intel
-Jérôme Clet-Ortega University of Bordeaux
-Ludovic Courtès Inria
-Clément Foyer Inria
-Nathalie Furmento CNRS
-Bryon Gloden
-Brice Goglin Inria
-Gilles Gouaillardet RIST
-Valentin Hoyet Inria
-Joshua Hursey UWL
-Alexey Kardashevskiy IBM
-Rob Latham ANL
-Douglas MacFarland UWL
-Marc Marí BSC
-Jonathan L Peyton Intel
-Piotr Luc Intel
-Antoine Rougier intern from University of Bordeaux
-Jeff Squyres Cisco
-Samuel Thibault University of Bordeaux
-Jean-Yves VET DDN
-Benjamin Worpitz
-Jeff Zhao Zhaoxin
-
-Affiliaion abbreviations:
--------------------------
-ANL = Argonne National Lab
-BSC = Barcelona Supercomputing Center
-Cisco = Cisco Systems, Inc.
-CNRS = Centre national de la recherche scientifique (France)
-UWL = University of Wisconsin-La Crosse
### src/3rdparty/hwloc/CMakeLists.txt
@@ -1,40 +0,0 @@
-cmake_minimum_required(VERSION 3.10)
-project (hwloc C)
-
-include_directories(include)
-include_directories(src)
-
-add_definitions(/D_CRT_SECURE_NO_WARNINGS)
-set(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG")
-
-set(HEADERS
- include/hwloc.h
- src/static-components.h
- )
-
-set(SOURCES
- src/base64.c
- src/bind.c
- src/bitmap.c
- src/components.c
- src/diff.c
- src/distances.c
- src/misc.c
- src/pci-common.c
- src/shmem.c
- src/topology.c
- src/topology-noos.c
- src/topology-synthetic.c
- src/topology-windows.c
- src/topology-x86.c
- src/topology-xml.c
- src/topology-xml-nolibxml.c
- src/traversal.c
- src/memattrs.c
- src/cpukinds.c
- )
-
-add_library(hwloc STATIC
- ${HEADERS}
- ${SOURCES}
- )
### src/3rdparty/hwloc/COPYING
@@ -1,39 +0,0 @@
-Copyright © 2004-2006 The Trustees of Indiana University and Indiana University Research and Technology Corporation. All rights reserved.
-Copyright © 2004-2005 The University of Tennessee and The University of Tennessee Research Foundation. All rights reserved.
-Copyright © 2004-2005 High Performance Computing Center Stuttgart, University of Stuttgart. All rights reserved.
-Copyright © 2004-2005 The Regents of the University of California. All rights reserved.
-Copyright © 2009 CNRS
-Copyright © 2009-2016 Inria. All rights reserved.
-Copyright © 2009-2015 Université Bordeaux
-Copyright © 2009-2015 Cisco Systems, Inc. All rights reserved.
-Copyright © 2009-2012 Oracle and/or its affiliates. All rights reserved.
-Copyright © 2010 IBM
-Copyright © 2010 Jirka Hladky
-Copyright © 2012 Aleksej Saushev, The NetBSD Foundation
-Copyright © 2012 Blue Brain Project, EPFL. All rights reserved.
-Copyright © 2013-2014 University of Wisconsin-La Crosse. All rights reserved.
-Copyright © 2015 Research Organization for Information Science and Technology (RIST). All rights reserved.
-Copyright © 2015-2016 Intel, Inc. All rights reserved.
-See COPYING in top-level directory.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
### src/3rdparty/hwloc/NEWS
[binary or diff unavailable]
### src/3rdparty/hwloc/README
@@ -1,487 +0,0 @@
-This is a truncated and poorly-formatted version of the documentation main page.
-See https://www.open-mpi.org/projects/hwloc/doc/ for more.
-
-
-hwloc Overview
-
-The Hardware Locality (hwloc) software project aims at easing the process of
-discovering hardware resources in parallel architectures. It offers
-command-line tools and a C API for consulting these resources, their locality,
-attributes, and interconnection. hwloc primarily aims at helping
-high-performance computing (HPC) applications, but is also applicable to any
-project seeking to exploit code and/or data locality on modern computing
-platforms.
-
-hwloc provides command line tools and a C API to obtain the hierarchical map of
-key computing elements within a node, such as: NUMA memory nodes, shared
-caches, processor packages, dies and cores, processing units (logical
-processors or "threads") and even I/O devices. hwloc also gathers various
-attributes such as cache and memory information, and is portable across a
-variety of different operating systems and platforms.
-
-hwloc primarily aims at helping high-performance computing (HPC) applications,
-but is also applicable to any project seeking to exploit code and/or data
-locality on modern computing platforms.
-
-hwloc supports the following operating systems:
-
- * Linux (with knowledge of cgroups and cpusets, memory targets/initiators,
- etc.) on all supported hardware, including Intel Xeon Phi, ScaleMP vSMP,
- and NumaScale NumaConnect.
- * Solaris (with support for processor sets and logical domains)
- * AIX
- * Darwin / OS X
- * FreeBSD and its variants (such as kFreeBSD/GNU)
- * NetBSD
- * HP-UX
- * Microsoft Windows
- * IBM BlueGene/Q Compute Node Kernel (CNK)
-
-Since it uses standard Operating System information, hwloc's support is mostly
-independant from the processor type (x86, powerpc, ...) and just relies on the
-Operating System support. The main exception is BSD operating systems (NetBSD,
-FreeBSD, etc.) because they do not provide support topology information, hence
-hwloc uses an x86-only CPUID-based backend (which can be used for other OSes
-too, see the Components and plugins section).
-
-To check whether hwloc works on a particular machine, just try to build it and
-run lstopo or lstopo-no-graphics. If some things do not look right (e.g. bogus
-or missing cache information), see Questions and Bugs.
-
-hwloc only reports the number of processors on unsupported operating systems;
-no topology information is available.
-
-For development and debugging purposes, hwloc also offers the ability to work
-on "fake" topologies:
-
- * Symmetrical tree of resources generated from a list of level arities, see
- Synthetic topologies.
- * Remote machine simulation through the gathering of topology as XML files,
- see Importing and exporting topologies from/to XML files.
-
-hwloc can display the topology in a human-readable format, either in graphical
-mode (X11), or by exporting in one of several different formats, including:
-plain text, LaTeX tikzpicture, PDF, PNG, and FIG (see Command-line Examples
-below). Note that some of the export formats require additional support
-libraries.
-
-hwloc offers a programming interface for manipulating topologies and objects.
-It also brings a powerful CPU bitmap API that is used to describe topology
-objects location on physical/logical processors. See the Programming Interface
-below. It may also be used to binding applications onto certain cores or memory
-nodes. Several utility programs are also provided to ease command-line
-manipulation of topology objects, binding of processes, and so on.
-
-Bindings for several other languages are available from the project website.
-
-Command-line Examples
-
-On a 4-package 2-core machine with hyper-threading, the lstopo tool may show
-the following graphical output:
-
-[dudley]
-
-Here's the equivalent output in textual form:
-
-Machine
- NUMANode L#0 (P#0)
- Package L#0 + L3 L#0 (4096KB)
- L2 L#0 (1024KB) + L1 L#0 (16KB) + Core L#0
- PU L#0 (P#0)
- PU L#1 (P#8)
- L2 L#1 (1024KB) + L1 L#1 (16KB) + Core L#1
- PU L#2 (P#4)
- PU L#3 (P#12)
- Package L#1 + L3 L#1 (4096KB)
- L2 L#2 (1024KB) + L1 L#2 (16KB) + Core L#2
- PU L#4 (P#1)
- PU L#5 (P#9)
- L2 L#3 (1024KB) + L1 L#3 (16KB) + Core L#3
- PU L#6 (P#5)
- PU L#7 (P#13)
- Package L#2 + L3 L#2 (4096KB)
- L2 L#4 (1024KB) + L1 L#4 (16KB) + Core L#4
- PU L#8 (P#2)
- PU L#9 (P#10)
- L2 L#5 (1024KB) + L1 L#5 (16KB) + Core L#5
- PU L#10 (P#6)
- PU L#11 (P#14)
- Package L#3 + L3 L#3 (4096KB)
- L2 L#6 (1024KB) + L1 L#6 (16KB) + Core L#6
- PU L#12 (P#3)
- PU L#13 (P#11)
- L2 L#7 (1024KB) + L1 L#7 (16KB) + Core L#7
- PU L#14 (P#7)
- PU L#15 (P#15)
-
-Note that there is also an equivalent output in XML that is meant for exporting
-/importing topologies but it is hardly readable to human-beings (see Importing
-and exporting topologies from/to XML files for details).
-
-On a 4-package 2-core Opteron NUMA machine (with two core cores disallowed by
-the administrator), the lstopo tool may show the following graphical output
-(with --disallowed for displaying disallowed objects):
-
-[hagrid]
-
-Here's the equivalent output in textual form:
-
-Machine (32GB total)
- Package L#0
- NUMANode L#0 (P#0 8190MB)
- L2 L#0 (1024KB) + L1 L#0 (64KB) + Core L#0 + PU L#0 (P#0)
- L2 L#1 (1024KB) + L1 L#1 (64KB) + Core L#1 + PU L#1 (P#1)
- Package L#1
- NUMANode L#1 (P#1 8192MB)
- L2 L#2 (1024KB) + L1 L#2 (64KB) + Core L#2 + PU L#2 (P#2)
- L2 L#3 (1024KB) + L1 L#3 (64KB) + Core L#3 + PU L#3 (P#3)
- Package L#2
- NUMANode L#2 (P#2 8192MB)
- L2 L#4 (1024KB) + L1 L#4 (64KB) + Core L#4 + PU L#4 (P#4)
- L2 L#5 (1024KB) + L1 L#5 (64KB) + Core L#5 + PU L#5 (P#5)
- Package L#3
- NUMANode L#3 (P#3 8192MB)
- L2 L#6 (1024KB) + L1 L#6 (64KB) + Core L#6 + PU L#6 (P#6)
- L2 L#7 (1024KB) + L1 L#7 (64KB) + Core L#7 + PU L#7 (P#7)
-
-On a 2-package quad-core Xeon (pre-Nehalem, with 2 dual-core dies into each
-package):
-
-[emmett]
-
-Here's the same output in textual form:
-
-Machine (total 16GB)
- NUMANode L#0 (P#0 16GB)
- Package L#0
- L2 L#0 (4096KB)
- L1 L#0 (32KB) + Core L#0 + PU L#0 (P#0)
- L1 L#1 (32KB) + Core L#1 + PU L#1 (P#4)
- L2 L#1 (4096KB)
- L1 L#2 (32KB) + Core L#2 + PU L#2 (P#2)
- L1 L#3 (32KB) + Core L#3 + PU L#3 (P#6)
- Package L#1
- L2 L#2 (4096KB)
- L1 L#4 (32KB) + Core L#4 + PU L#4 (P#1)
- L1 L#5 (32KB) + Core L#5 + PU L#5 (P#5)
- L2 L#3 (4096KB)
- L1 L#6 (32KB) + Core L#6 + PU L#6 (P#3)
- L1 L#7 (32KB) + Core L#7 + PU L#7 (P#7)
-
-Programming Interface
-
-The basic interface is available in hwloc.h. Some higher-level functions are
-available in hwloc/helper.h to reduce the need to manually manipulate objects
-and follow links between them. Documentation for all these is provided later in
-this document. Developers may also want to look at hwloc/inlines.h which
-contains the actual inline code of some hwloc.h routines, and at this document,
-which provides good higher-level topology traversal examples.
-
-To precisely define the vocabulary used by hwloc, a Terms and Definitions
-section is available and should probably be read first.
-
-Each hwloc object contains a cpuset describing the list of processing units
-that it contains. These bitmaps may be used for CPU binding and Memory binding.
-hwloc offers an extensive bitmap manipulation interface in hwloc/bitmap.h.
-
-Moreover, hwloc also comes with additional helpers for interoperability with
-several commonly used environments. See the Interoperability With Other
-Software section for details.
-
-The complete API documentation is available in a full set of HTML pages, man
-pages, and self-contained PDF files (formatted for both both US letter and A4
-formats) in the source tarball in doc/doxygen-doc/.
-
-NOTE: If you are building the documentation from a Git clone, you will need to
-have Doxygen and pdflatex installed -- the documentation will be built during
-the normal "make" process. The documentation is installed during "make install"
-to $prefix/share/doc/hwloc/ and your systems default man page tree (under
-$prefix, of course).
-
-Portability
-
-Operating System have varying support for CPU and memory binding, e.g. while
-some Operating Systems provide interfaces for all kinds of CPU and memory
-bindings, some others provide only interfaces for a limited number of kinds of
-CPU and memory binding, and some do not provide any binding interface at all.
-Hwloc's binding functions would then simply return the ENOSYS error (Function
-not implemented), meaning that the underlying Operating System does not provide
-any interface for them. CPU binding and Memory binding provide more information
-on which hwloc binding functions should be preferred because interfaces for
-them are usually available on the supported Operating Systems.
-
-Similarly, the ability of reporting topology information varies from one
-platform to another. As shown in Command-line Examples, hwloc can obtain
-information on a wide variety of hardware topologies. However, some platforms
-and/or operating system versions will only report a subset of this information.
-For example, on an PPC64-based system with 8 cores (each with 2 hardware
-threads) running a default 2.6.18-based kernel from RHEL 5.4, hwloc is only
-able to glean information about NUMA nodes and processor units (PUs). No
-information about caches, packages, or cores is available.
-
-Here's the graphical output from lstopo on this platform when Simultaneous
-Multi-Threading (SMT) is enabled:
-
-[ppc64-with]
-
-And here's the graphical output from lstopo on this platform when SMT is
-disabled:
-
-[ppc64-with]
-
-Notice that hwloc only sees half the PUs when SMT is disabled. PU L#6, for
-example, seems to change location from NUMA node #0 to #1. In reality, no PUs
-"moved" -- they were simply re-numbered when hwloc only saw half as many (see
-also Logical index in Indexes and Sets). Hence, PU L#6 in the SMT-disabled
-picture probably corresponds to PU L#12 in the SMT-enabled picture.
-
-This same "PUs have disappeared" effect can be seen on other platforms -- even
-platforms / OSs that provide much more information than the above PPC64 system.
-This is an unfortunate side-effect of how operating systems report information
-to hwloc.
-
-Note that upgrading the Linux kernel on the same PPC64 system mentioned above
-to 2.6.34, hwloc is able to discover all the topology information. The
-following picture shows the entire topology layout when SMT is enabled:
-
-[ppc64-full]
-
-Developers using the hwloc API or XML output for portable applications should
-therefore be extremely careful to not make any assumptions about the structure
-of data that is returned. For example, per the above reported PPC topology, it
-is not safe to assume that PUs will always be descendants of cores.
-
-Additionally, future hardware may insert new topology elements that are not
-available in this version of hwloc. Long-lived applications that are meant to
-span multiple different hardware platforms should also be careful about making
-structure assumptions. For example, a new element may someday exist between a
-core and a PU.
-
-API Example
-
-The following small C example (available in the source tree as ``doc/examples/
-hwloc-hello.c'') prints the topology of the machine and performs some thread
-and memory binding. More examples are available in the doc/examples/ directory
-of the source tree.
-
-/* Example hwloc API program.
-*
-* See other examples under doc/examples/ in the source tree
-* for more details.
-*
-* Copyright (c) 2009-2016 Inria. All rights reserved.
-* Copyright (c) 2009-2011 Universit?eacute; Bordeaux
-* Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
-* See COPYING in top-level directory.
-*
-* hwloc-hello.c
-*/
-#include "hwloc.h"
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-static void print_children(hwloc_topology_t topology, hwloc_obj_t obj,
-int depth)
-{
-char type[32], attr[1024];
-unsigned i;
-hwloc_obj_type_snprintf(type, sizeof(type), obj, 0);
-printf("%*s%s", 2*depth, "", type);
-if (obj->os_index != (unsigned) -1)
-printf("#%u", obj->os_index);
-hwloc_obj_attr_snprintf(attr, sizeof(attr), obj, " ", 0);
-if (*attr)
-printf("(%s)", attr);
-printf("\n");
-for (i = 0; i < obj->arity; i++) {
-print_children(topology, obj->children[i], depth + 1);
-}
-}
-int main(void)
-{
-int depth;
-unsigned i, n;
-unsigned long size;
-int levels;
-char string[128];
-int topodepth;
-void *m;
-hwloc_topology_t topology;
-hwloc_cpuset_t cpuset;
-hwloc_obj_t obj;
-/* Allocate and initialize topology object. */
-hwloc_topology_init(&topology);
-/* ... Optionally, put detection configuration here to ignore
-some objects types, define a synthetic topology, etc....
-The default is to detect all the objects of the machine that
-the caller is allowed to access. See Configure Topology
-Detection. */
-/* Perform the topology detection. */
-hwloc_topology_load(topology);
-/* Optionally, get some additional topology information
-in case we need the topology depth later. */
-topodepth = hwloc_topology_get_depth(topology);
-/*****************************************************************
-* First example:
-* Walk the topology with an array style, from level 0 (always
-* the system level) to the lowest level (always the proc level).
-*****************************************************************/
-for (depth = 0; depth < topodepth; depth++) {
-printf("*** Objects at level %d\n", depth);
-for (i = 0; i < hwloc_get_nbobjs_by_depth(topology, depth);
-i++) {
-hwloc_obj_type_snprintf(string, sizeof(string),
-hwloc_get_obj_by_depth(topology, depth, i), 0);
-printf("Index %u: %s\n", i, string);
-}
-}
-/*****************************************************************
-* Second example:
-* Walk the topology with a tree style.
-*****************************************************************/
-printf("*** Printing overall tree\n");
-print_children(topology, hwloc_get_root_obj(topology), 0);
-/*****************************************************************
-* Third example:
-* Print the number of packages.
-*****************************************************************/
-depth = hwloc_get_type_depth(topology, HWLOC_OBJ_PACKAGE);
-if (depth == HWLOC_TYPE_DEPTH_UNKNOWN) {
-printf("*** The number of packages is unknown\n");
-} else {
-printf("*** %u package(s)\n",
-hwloc_get_nbobjs_by_depth(topology, depth));
-}
-/*****************************************************************
-* Fourth example:
-* Compute the amount of cache that the first logical processor
-* has above it.
-*****************************************************************/
-levels = 0;
-size = 0;
-for (obj = hwloc_get_obj_by_type(topology, HWLOC_OBJ_PU, 0);
-obj;
-obj = obj->parent)
-if (hwloc_obj_type_is_cache(obj->type)) {
-levels++;
-size += obj->attr->cache.size;
-}
-printf("*** Logical processor 0 has %d caches totaling %luKB\n",
-levels, size / 1024);
-/*****************************************************************
-* Fifth example:
-* Bind to only one thread of the last core of the machine.
-*
-* First find out where cores are, or else smaller sets of CPUs if
-* the OS doesn't have the notion of a "core".
-*****************************************************************/
-depth = hwloc_get_type_or_below_depth(topology, HWLOC_OBJ_CORE);
-/* Get last core. */
-obj = hwloc_get_obj_by_depth(topology, depth,
-hwloc_get_nbobjs_by_depth(topology, depth) - 1);
-if (obj) {
-/* Get a copy of its cpuset that we may modify. */
-cpuset = hwloc_bitmap_dup(obj->cpuset);
-/* Get only one logical processor (in case the core is
-SMT/hyper-threaded). */
-hwloc_bitmap_singlify(cpuset);
-/* And try to bind ourself there. */
-if (hwloc_set_cpubind(topology, cpuset, 0)) {
-char *str;
-int error = errno;
-hwloc_bitmap_asprintf(&str, obj->cpuset);
-printf("Couldn't bind to cpuset %s: %s\n", str, strerror(error));
-free(str);
-}
-/* Free our cpuset copy */
-hwloc_bitmap_free(cpuset);
-}
-/*****************************************************************
-* Sixth example:
-* Allocate some memory on the last NUMA node, bind some existing
-* memory to the last NUMA node.
-*****************************************************************/
-/* Get last node. There's always at least one. */
-n = hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_NUMANODE);
-obj = hwloc_get_obj_by_type(topology, HWLOC_OBJ_NUMANODE, n - 1);
-size = 1024*1024;
-m = hwloc_alloc_membind(topology, size, obj->nodeset,
-HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_BYNODESET);
-hwloc_free(topology, m, size);
-m = malloc(size);
-hwloc_set_area_membind(topology, m, size, obj->nodeset,
-HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_BYNODESET);
-free(m);
-/* Destroy topology object. */
-hwloc_topology_destroy(topology);
-return 0;
-}
-
-hwloc provides a pkg-config executable to obtain relevant compiler and linker
-flags. See Compiling software on top of hwloc's C API for details on building
-program on top of hwloc's API using GNU Make or CMake.
-
-On a machine 2 processor packages -- each package of which has two processing
-cores -- the output from running hwloc-hello could be something like the
-following:
-
-shell$ ./hwloc-hello
-*** Objects at level 0
-Index 0: Machine
-*** Objects at level 1
-Index 0: Package#0
-Index 1: Package#1
-*** Objects at level 2
-Index 0: Core#0
-Index 1: Core#1
-Index 2: Core#3
-Index 3: Core#2
-*** Objects at level 3
-Index 0: PU#0
-Index 1: PU#1
-Index 2: PU#2
-Index 3: PU#3
-*** Printing overall tree
-Machine
- Package#0
- Core#0
- PU#0
- Core#1
- PU#1
- Package#1
- Core#3
- PU#2
- Core#2
- PU#3
-*** 2 package(s)
-*** Logical processor 0 has 0 caches totaling 0KB
-shell$
-
-Questions and Bugs
-
-Bugs should be reported in the tracker (https://github.com/open-mpi/hwloc/
-issues). Opening a new issue automatically displays lots of hints about how to
-debug and report issues.
-
-Questions may be sent to the users or developers mailing lists (https://
-www.open-mpi.org/community/lists/hwloc.php).
-
-There is also a #hwloc IRC channel on Libera Chat (irc.libera.chat).
-
-History / Credits
-
-hwloc is the evolution and merger of the libtopology project and the Portable
-Linux Processor Affinity (PLPA) (https://www.open-mpi.org/projects/plpa/)
-project. Because of functional and ideological overlap, these two code bases
-and ideas were merged and released under the name "hwloc" as an Open MPI
-sub-project.
-
-libtopology was initially developed by the Inria Runtime Team-Project. PLPA was
-initially developed by the Open MPI development team as a sub-project. Both are
-now deprecated in favor of hwloc, which is distributed as an Open MPI
-sub-project.
-
-
-
-See https://www.open-mpi.org/projects/hwloc/doc/ for more hwloc documentation,
-actual links to related pages, images, etc.
### src/3rdparty/hwloc/VERSION
@@ -1,46 +0,0 @@
-# This is the VERSION file for hwloc, describing the precise version
-# of hwloc in this distribution. The various components of the version
-# number below are combined to form a single version number string.
-
-# major, minor, and release are generally combined in the form
-# <major>.<minor>.<release>. If release is zero, then it is omitted.
-
-# Please update HWLOC_VERSION* in contrib/windows/hwloc_config.h too.
-
-major=2
-minor=12
-release=1
-
-# greek is used for alpha or beta release tags. If it is non-empty,
-# it will be appended to the version number. It does not have to be
-# numeric. Common examples include a1 (alpha release 1), b1 (beta
-# release 1), sc2005 (Super Computing 2005 release). The only
-# requirement is that it must be entirely printable ASCII characters
-# and have no white space.
-
-greek=
-
-# The date when this release was created
-
-date="May 12, 2025"
-
-# If snapshot=1, then use the value from snapshot_version as the
-# entire hwloc version (i.e., ignore major, minor, release, and
-# greek). This is only set to 1 when making snapshot tarballs.
-snapshot=0
-snapshot_version=${major}.${minor}.${release}${greek}-git
-
-# The shared library version of hwloc's public library. This version
-# is maintained in accordance with the "Library Interface Versions"
-# chapter from the GNU Libtool documentation. Notes:
-
-# 1. Since version numbers are associated with *releases*, the version
-# number maintained on the hwloc git master (and developer branches)
-# is always 0:0:0.
-
-# 2. Version numbers are described in the Libtool current:revision:age
-# format.
-
-libhwloc_so_version=25:0:10
-
-# Please also update the <TargetName> lines in contrib/windows/libhwloc.vcxproj
### src/3rdparty/hwloc/include/hwloc.h
[binary or diff unavailable]
### src/3rdparty/hwloc/include/hwloc/autogen/config.h
@@ -1,59 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2025 Inria. All rights reserved.
- * Copyright © 2009-2012 Université Bordeaux
- * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/* The configuration file */
-
-#ifndef HWLOC_CONFIG_H
-#define HWLOC_CONFIG_H
-
-#define HWLOC_VERSION "2.12.1"
-#define HWLOC_VERSION_MAJOR 2
-#define HWLOC_VERSION_MINOR 12
-#define HWLOC_VERSION_RELEASE 1
-#define HWLOC_VERSION_GREEK ""
-
-#define __hwloc_restrict
-#define __hwloc_inline __inline
-
-#define __hwloc_attribute_unused
-#define __hwloc_attribute_malloc
-#define __hwloc_attribute_const
-#define __hwloc_attribute_pure
-#define __hwloc_attribute_deprecated
-#define __hwloc_attribute_may_alias
-#define __hwloc_attribute_warn_unused_result
-
-/* Defined to 1 if you have the `windows.h' header. */
-#define HWLOC_HAVE_WINDOWS_H 1
-#define hwloc_pid_t HANDLE
-#define hwloc_thread_t HANDLE
-
-#include <windows.h>
-#include <BaseTsd.h>
-typedef DWORDLONG hwloc_uint64_t;
-
-#if defined( _USRDLL ) /* dynamic linkage */
-#if defined( DECLSPEC_EXPORTS )
-#define HWLOC_DECLSPEC __declspec(dllexport)
-#else
-#define HWLOC_DECLSPEC __declspec(dllimport)
-#endif
-#else /* static linkage */
-#define HWLOC_DECLSPEC
-#endif
-
-/* Whether we need to re-define all the hwloc public symbols or not */
-#define HWLOC_SYM_TRANSFORM 0
-
-/* The hwloc symbol prefix */
-#define HWLOC_SYM_PREFIX hwloc_
-
-/* The hwloc symbol prefix in all caps */
-#define HWLOC_SYM_PREFIX_CAPS HWLOC_
-
-#endif /* HWLOC_CONFIG_H */
### src/3rdparty/hwloc/include/hwloc/bitmap.h
@@ -1,568 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2024 Inria. All rights reserved.
- * Copyright © 2009-2012 Université Bordeaux
- * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief The bitmap API, for use in hwloc itself.
- */
-
-#ifndef HWLOC_BITMAP_H
-#define HWLOC_BITMAP_H
-
-#include "hwloc/autogen/config.h"
-
-#include <assert.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_bitmap The bitmap API
- *
- * The ::hwloc_bitmap_t type represents a set of integers (positive or null).
- * A bitmap may be of infinite size (all bits are set after some point).
- * A bitmap may even be full if all bits are set.
- *
- * Bitmaps are used by hwloc for sets of OS processors
- * (which may actually be hardware threads) as by ::hwloc_cpuset_t
- * (a typedef for ::hwloc_bitmap_t), or sets of NUMA memory nodes
- * as ::hwloc_nodeset_t (also a typedef for ::hwloc_bitmap_t).
- * Those are used for cpuset and nodeset fields in the ::hwloc_obj structure,
- * see \ref hwlocality_object_sets.
- *
- * <em>Both CPU and node sets are always indexed by OS physical number.</em>
- * However users should usually not build CPU and node sets manually
- * (e.g. with hwloc_bitmap_set()).
- * One should rather use existing object sets and combine them with
- * hwloc_bitmap_or(), etc.
- * For instance, binding the current thread on a pair of cores may be performed with:
- * \code
- * hwloc_obj_t core1 = ... , core2 = ... ;
- * hwloc_bitmap_t set = hwloc_bitmap_alloc();
- * hwloc_bitmap_or(set, core1->cpuset, core2->cpuset);
- * hwloc_set_cpubind(topology, set, HWLOC_CPUBIND_THREAD);
- * hwloc_bitmap_free(set);
- * \endcode
- *
- * \note Most functions below return 0 on success and -1 on error.
- * The usual error case would be an internal failure to realloc/extend
- * the storage of the bitmap (\p errno would be set to \c ENOMEM).
- * See also \ref hwlocality_api_error_reporting.
- *
- * \note Several examples of using the bitmap API are available under the
- * doc/examples/ directory in the source tree.
- * Regression tests such as tests/hwloc/hwloc_bitmap*.c also make intensive use
- * of this API.
- * @{
- */
-
-
-/** \brief
- * Set of bits represented as an opaque pointer to an internal bitmap.
- */
-typedef struct hwloc_bitmap_s * hwloc_bitmap_t;
-/** \brief a non-modifiable ::hwloc_bitmap_t */
-typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t;
-
-
-/*
- * Bitmap allocation, freeing and copying.
- */
-
-/** \brief Allocate a new empty bitmap.
- *
- * \returns A valid bitmap or \c NULL.
- *
- * The bitmap should be freed by a corresponding call to
- * hwloc_bitmap_free().
- */
-HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc(void) __hwloc_attribute_malloc;
-
-/** \brief Allocate a new full bitmap.
- *
- * \returns A valid bitmap or \c NULL.
- *
- * The bitmap should be freed by a corresponding call to
- * hwloc_bitmap_free().
- */
-HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc_full(void) __hwloc_attribute_malloc;
-
-/** \brief Free bitmap \p bitmap.
- *
- * If \p bitmap is \c NULL, no operation is performed.
- */
-HWLOC_DECLSPEC void hwloc_bitmap_free(hwloc_bitmap_t bitmap);
-
-/** \brief Duplicate bitmap \p bitmap by allocating a new bitmap and copying \p bitmap contents.
- *
- * If \p bitmap is \c NULL, \c NULL is returned.
- */
-HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap) __hwloc_attribute_malloc;
-
-/** \brief Copy the contents of bitmap \p src into the already allocated bitmap \p dst */
-HWLOC_DECLSPEC int hwloc_bitmap_copy(hwloc_bitmap_t dst, hwloc_const_bitmap_t src);
-
-
-/*
- * Bitmap/String Conversion
- */
-
-/** \brief Stringify a bitmap in the default hwloc format.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, it contains physical indexes.</b>
- *
- * Print the bits set inside a bitmap as a comma-separated list of hexadecimal 32-bit blocks.
- * A bitmap containing bits 1, 33, 34, and all from 64 to 95 is printed as <tt>"0xffffffff,0x00000006,0x00000002"</tt>.
- *
- * Up to \p buflen characters may be written in buffer \p buf.
- *
- * If \p buflen is 0, \p buf may safely be \c NULL.
- *
- * \return the number of characters that were actually written if not truncating,
- * or that would have been written (not including the ending \c \0).
- * \return -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
-
-/** \brief Stringify a bitmap into a newly allocated string in the default hwloc format.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, it contains physical indexes.</b>
- *
- * Print the bits set inside a bitmap as a comma-separated list of hexadecimal 32-bit blocks.
- * A bitmap containing bits 1, 33, 34, and all from 64 to 95 is printed as <tt>"0xffffffff,0x00000006,0x00000002"</tt>.
- *
- * \return the number of characters that were written (not including the ending \c \0).
- * \return -1 on error, for instance with \p errno set to \c ENOMEM on failure to allocate the output string.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
-
-/** \brief Parse a bitmap string as the default hwloc format and stores it in bitmap \p bitmap.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, the input string must contain physical indexes.</b>
- *
- * The input string should be a comma-separared list of hexadecimal 32-bit blocks.
- * String <tt>"0xffffffff,0x6,0x2"</tt> is parsed as a bitmap containing all bits between 64 and 95,
- * and bits 33, 34 and 1.
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
-
-/** \brief Stringify a bitmap in the list format.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, it contains physical indexes.</b>
- *
- * Lists are comma-separated indexes or ranges.
- * Ranges are dash separated indexes.
- * A bitmap containing bits 1, 33, 34, and all from 64 to 95 is printed as <tt>"1,33-34,64-95"</tt>.
- * The last range may not have an ending index if the bitmap is infinitely set.
- *
- * Up to \p buflen characters may be written in buffer \p buf.
- *
- * If \p buflen is 0, \p buf may safely be \c NULL.
- *
- * \return the number of characters that were actually written if not truncating,
- * or that would have been written (not including the ending \c \0).
- * \return -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_list_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
-
-/** \brief Stringify a bitmap into a newly allocated list string.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, it contains physical indexes.</b>
- *
- * Lists are comma-separated indexes or ranges.
- * Ranges are dash separated indexes.
- * A bitmap containing bits 1, 33, 34, and all from 64 to 95 is printed as <tt>"1,33-34,64-95"</tt>.
- * The last range may not have an ending index if the bitmap is infinitely set.
- *
- * \return the number of characters that were written (not including the ending \c \0).
- * \return -1 on error, for instance with \p errno set to \c ENOMEM on failure to allocate the output string.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_list_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
-
-/** \brief Parse a list string and stores it in bitmap \p bitmap.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, the input string must contain physical indexes.</b>
- *
- * Lists are comma-separated indexes or ranges.
- * Ranges are dash separated indexes.
- * String <tt>"1,33-34,64-95"</tt> is parsed as a bitmap containing bits 1, 33, 34, and all from 64 to 95.
- * The last range may not have an ending index if the bitmap is infinitely set.
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_list_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
-
-/** \brief Stringify a bitmap in the taskset-specific format.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, it contains physical indexes.</b>
- *
- * The taskset program manipulates bitmap strings that contain a single
- * (possible very long) hexadecimal number starting with 0x.
- * A bitmap containing bits 1, 33, 34, and all from 64 to 95 is printed as </tt>"0xffffffff0000000600000002"</tt>.
- *
- * Up to \p buflen characters may be written in buffer \p buf.
- *
- * If \p buflen is 0, \p buf may safely be \c NULL.
- *
- * \return the number of characters that were actually written if not truncating,
- * or that would have been written (not including the ending \c \0).
- * \return -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_taskset_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
-
-/** \brief Stringify a bitmap into a newly allocated taskset-specific string.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, it contains physical indexes.</b>
- *
- * The taskset program manipulates bitmap strings that contain a single
- * (possible very long) hexadecimal number starting with 0x.
- * A bitmap containing bits 1, 33, 34, and all from 64 to 95 is printed as <tt>"0xffffffff0000000600000002"</tt>.
- *
- * \return the number of characters that were written (not including the ending \c \0).
- * \return -1 on error, for instance with \p errno set to \c ENOMEM on failure to allocate the output string.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
-
-/** \brief Parse a taskset-specific bitmap string and stores it in bitmap \p bitmap.
- *
- * <b>Note that if the bitmap is a CPU or nodeset, the input string must contain physical indexes.</b>
- *
- * The taskset program manipulates bitmap strings that contain a single
- * (possible very long) hexadecimal number starting with 0x.
- * String <tt>"0xffffffff0000000600000002"</tt> is parsed as a bitmap containing all bits between 64 and 95,
- * and bits 33, 34 and 1.
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
-
-
-/*
- * Building bitmaps.
- */
-
-/** \brief Empty the bitmap \p bitmap */
-HWLOC_DECLSPEC void hwloc_bitmap_zero(hwloc_bitmap_t bitmap);
-
-/** \brief Fill bitmap \p bitmap with all possible indexes (even if those objects don't exist or are otherwise unavailable) */
-HWLOC_DECLSPEC void hwloc_bitmap_fill(hwloc_bitmap_t bitmap);
-
-/** \brief Empty the bitmap \p bitmap and add bit \p id */
-HWLOC_DECLSPEC int hwloc_bitmap_only(hwloc_bitmap_t bitmap, unsigned id);
-
-/** \brief Fill the bitmap \p and clear the index \p id */
-HWLOC_DECLSPEC int hwloc_bitmap_allbut(hwloc_bitmap_t bitmap, unsigned id);
-
-/** \brief Setup bitmap \p bitmap from unsigned long \p mask */
-HWLOC_DECLSPEC int hwloc_bitmap_from_ulong(hwloc_bitmap_t bitmap, unsigned long mask);
-
-/** \brief Setup bitmap \p bitmap from unsigned long \p mask used as \p i -th subset */
-HWLOC_DECLSPEC int hwloc_bitmap_from_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
-
-/** \brief Setup bitmap \p bitmap from unsigned longs \p masks used as first \p nr subsets */
-HWLOC_DECLSPEC int hwloc_bitmap_from_ulongs(hwloc_bitmap_t bitmap, unsigned nr, const unsigned long *masks);
-
-
-/*
- * Modifying bitmaps.
- */
-
-/** \brief Add index \p id in bitmap \p bitmap */
-HWLOC_DECLSPEC int hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id);
-
-/** \brief Add indexes from \p begin to \p end in bitmap \p bitmap.
- *
- * If \p end is \c -1, the range is infinite.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_set_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
-
-/** \brief Replace \p i -th subset of bitmap \p bitmap with unsigned long \p mask */
-HWLOC_DECLSPEC int hwloc_bitmap_set_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
-
-/** \brief Remove index \p id from bitmap \p bitmap */
-HWLOC_DECLSPEC int hwloc_bitmap_clr(hwloc_bitmap_t bitmap, unsigned id);
-
-/** \brief Remove indexes from \p begin to \p end in bitmap \p bitmap.
- *
- * If \p end is \c -1, the range is infinite.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_clr_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
-
-/** \brief Keep a single index among those set in bitmap \p bitmap
- *
- * May be useful before binding so that the process does not
- * have a chance of migrating between multiple processors
- * in the original mask.
- * Instead of running the task on any PU inside the given CPU set,
- * the operating system scheduler will be forced to run it on a single
- * of these PUs.
- * It avoids a migration overhead and cache-line ping-pongs between PUs.
- *
- * \note This function is NOT meant to distribute multiple processes
- * within a single CPU set. It always return the same single bit when
- * called multiple times on the same input set. hwloc_distrib() may
- * be used for generating CPU sets to distribute multiple tasks below
- * a single multi-PU object.
- *
- * \note This function cannot be applied to an object set directly. It
- * should be applied to a copy (which may be obtained with hwloc_bitmap_dup()).
- */
-HWLOC_DECLSPEC int hwloc_bitmap_singlify(hwloc_bitmap_t bitmap);
-
-
-/*
- * Consulting bitmaps.
- */
-
-/** \brief Convert the beginning part of bitmap \p bitmap into unsigned long \p mask */
-HWLOC_DECLSPEC unsigned long hwloc_bitmap_to_ulong(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Convert the \p i -th subset of bitmap \p bitmap into unsigned long mask */
-HWLOC_DECLSPEC unsigned long hwloc_bitmap_to_ith_ulong(hwloc_const_bitmap_t bitmap, unsigned i) __hwloc_attribute_pure;
-
-/** \brief Convert the first \p nr subsets of bitmap \p bitmap into the array of \p nr unsigned long \p masks
- *
- * \p nr may be determined earlier with hwloc_bitmap_nr_ulongs().
- *
- * \return 0
- */
-HWLOC_DECLSPEC int hwloc_bitmap_to_ulongs(hwloc_const_bitmap_t bitmap, unsigned nr, unsigned long *masks);
-
-/** \brief Return the number of unsigned longs required for storing bitmap \p bitmap entirely
- *
- * This is the number of contiguous unsigned longs from the very first bit of the bitmap
- * (even if unset) up to the last set bit.
- * This is useful for knowing the \p nr parameter to pass to hwloc_bitmap_to_ulongs()
- * (or which calls to hwloc_bitmap_to_ith_ulong() are needed)
- * to entirely convert a bitmap into multiple unsigned longs.
- *
- * When called on the output of hwloc_topology_get_topology_cpuset(),
- * the returned number is large enough for all cpusets of the topology.
- *
- * \return the number of unsigned longs required.
- * \return -1 if \p bitmap is infinite.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_nr_ulongs(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Test whether index \p id is part of bitmap \p bitmap.
- *
- * \return 1 if the bit at index \p id is set in bitmap \p bitmap, 0 otherwise.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id) __hwloc_attribute_pure;
-
-/** \brief Test whether bitmap \p bitmap is empty
- *
- * \return 1 if bitmap is empty, 0 otherwise.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Test whether bitmap \p bitmap is completely full
- *
- * \return 1 if bitmap is full, 0 otherwise.
- *
- * \note A full bitmap is always infinitely set.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Compute the first index (least significant bit) in bitmap \p bitmap
- *
- * \return the first index set in \p bitmap.
- * \return -1 if \p bitmap is empty.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Compute the next index in bitmap \p bitmap which is after index \p prev
- *
- * \return the first index set in \p bitmap if \p prev is \c -1.
- * \return the next index set in \p bitmap if \p prev is not \c -1.
- * \return -1 if no index with higher index is set in \p bitmap.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, int prev) __hwloc_attribute_pure;
-
-/** \brief Compute the last index (most significant bit) in bitmap \p bitmap
- *
- * \return the last index set in \p bitmap.
- * \return -1 if \p bitmap is empty, or if \p bitmap is infinitely set.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Compute the "weight" of bitmap \p bitmap (i.e., number of
- * indexes that are in the bitmap).
- *
- * \return the number of indexes that are in the bitmap.
- * \return -1 if \p bitmap is infinitely set.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Compute the first unset index (least significant bit) in bitmap \p bitmap
- *
- * \return the first unset index in \p bitmap.
- * \return -1 if \p bitmap is full.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_first_unset(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Compute the next unset index in bitmap \p bitmap which is after index \p prev
- *
- * \return the first index unset in \p bitmap if \p prev is \c -1.
- * \return the next index unset in \p bitmap if \p prev is not \c -1.
- * \return -1 if no index with higher index is unset in \p bitmap.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_next_unset(hwloc_const_bitmap_t bitmap, int prev) __hwloc_attribute_pure;
-
-/** \brief Compute the last unset index (most significant bit) in bitmap \p bitmap
- *
- * \return the last index unset in \p bitmap.
- * \return -1 if \p bitmap is full, or if \p bitmap is not infinitely set.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_last_unset(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
-
-/** \brief Loop macro iterating on bitmap \p bitmap
- *
- * The loop must start with hwloc_bitmap_foreach_begin() and end
- * with hwloc_bitmap_foreach_end() followed by a terminating ';'.
- *
- * \p id is the loop variable; it should be an unsigned int. The
- * first iteration will set \p id to the lowest index in the bitmap.
- * Successive iterations will iterate through, in order, all remaining
- * indexes set in the bitmap. To be specific: each iteration will return a
- * value for \p id such that hwloc_bitmap_isset(bitmap, id) is true.
- *
- * The assert prevents the loop from being infinite if the bitmap is infinitely set.
- *
- * \hideinitializer
- */
-#define hwloc_bitmap_foreach_begin(id, bitmap) \
-do { \
- assert(hwloc_bitmap_weight(bitmap) != -1); \
- for (id = hwloc_bitmap_first(bitmap); \
- (unsigned) id != (unsigned) -1; \
- id = hwloc_bitmap_next(bitmap, id)) {
-
-/** \brief End of loop macro iterating on a bitmap.
- *
- * Needs a terminating ';'.
- *
- * \sa hwloc_bitmap_foreach_begin()
- * \hideinitializer
- */
-#define hwloc_bitmap_foreach_end() \
- } \
-} while (0)
-
-
-/*
- * Combining bitmaps.
- */
-
-/** \brief Or bitmaps \p bitmap1 and \p bitmap2 and store the result in bitmap \p res
- *
- * \p res can be the same as \p bitmap1 or \p bitmap2
- */
-HWLOC_DECLSPEC int hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
-
-/** \brief And bitmaps \p bitmap1 and \p bitmap2 and store the result in bitmap \p res
- *
- * \p res can be the same as \p bitmap1 or \p bitmap2
- */
-HWLOC_DECLSPEC int hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
-
-/** \brief And bitmap \p bitmap1 and the negation of \p bitmap2 and store the result in bitmap \p res
- *
- * \p res can be the same as \p bitmap1 or \p bitmap2
- */
-HWLOC_DECLSPEC int hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
-
-/** \brief Xor bitmaps \p bitmap1 and \p bitmap2 and store the result in bitmap \p res
- *
- * \p res can be the same as \p bitmap1 or \p bitmap2
- */
-HWLOC_DECLSPEC int hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
-
-/** \brief Negate bitmap \p bitmap and store the result in bitmap \p res
- *
- * \p res can be the same as \p bitmap
- */
-HWLOC_DECLSPEC int hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap);
-
-
-/*
- * Comparing bitmaps.
- */
-
-/** \brief Test whether bitmaps \p bitmap1 and \p bitmap2 intersects.
- *
- * \return 1 if bitmaps intersect, 0 otherwise.
- *
- * \note The empty bitmap does not intersect any other bitmap.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
-
-/** \brief Test whether bitmap \p sub_bitmap is part of bitmap \p super_bitmap.
- *
- * \return 1 if \p sub_bitmap is included in \p super_bitmap, 0 otherwise.
- *
- * \note The empty bitmap is considered included in any other bitmap.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) __hwloc_attribute_pure;
-
-/** \brief Test whether bitmap \p bitmap1 is equal to bitmap \p bitmap2.
- *
- * \return 1 if bitmaps are equal, 0 otherwise.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
-
-/** \brief Compare bitmaps \p bitmap1 and \p bitmap2 using their lowest index.
- *
- * A bitmap is considered smaller if its least significant bit is smaller.
- * The empty bitmap is considered higher than anything (because its least significant bit does not exist).
- *
- * \return -1 if \p bitmap1 is considered smaller than \p bitmap2.
- * \return 1 if \p bitmap1 is considered larger than \p bitmap2.
- *
- * For instance comparing binary bitmaps 0011 and 0110 returns -1
- * (hence 0011 is considered smaller than 0110)
- * because least significant bit of 0011 (0001) is smaller than least significant bit of 0110 (0010).
- * Comparing 01001 and 00110 would also return -1 for the same reason.
- *
- * \return 0 if bitmaps are considered equal, even if they are not strictly equal.
- * They just need to have the same least significant bit.
- * For instance, comparing binary bitmaps 0010 and 0110 returns 0 because they have the same least significant bit.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_compare_first(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
-
-/** \brief Compare bitmaps \p bitmap1 and \p bitmap2 in lexicographic order.
- *
- * Lexicographic comparison of bitmaps, starting for their highest indexes.
- * Compare last indexes first, then second, etc.
- * The empty bitmap is considered lower than anything.
- *
- * \return -1 if \p bitmap1 is considered smaller than \p bitmap2.
- * \return 1 if \p bitmap1 is considered larger than \p bitmap2.
- * \return 0 if bitmaps are equal (contrary to hwloc_bitmap_compare_first()).
- *
- * For instance comparing binary bitmaps 0011 and 0110 returns -1
- * (hence 0011 is considered smaller than 0110).
- * Comparing 00101 and 01010 returns -1 too.
- *
- * \note This is different from the non-existing hwloc_bitmap_compare_last()
- * which would only compare the highest index of each bitmap.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_compare(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_BITMAP_H */
### src/3rdparty/hwloc/include/hwloc/cpukinds.h
@@ -1,193 +0,0 @@
-/*
- * Copyright © 2020-2021 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Kinds of CPU cores.
- */
-
-#ifndef HWLOC_CPUKINDS_H
-#define HWLOC_CPUKINDS_H
-
-#include "hwloc.h"
-
-#ifdef __cplusplus
-extern "C" {
-#elif 0
-}
-#endif
-
-/** \defgroup hwlocality_cpukinds Kinds of CPU cores
- *
- * Platforms with heterogeneous CPUs may have some cores with
- * different features or frequencies.
- * This API exposes identical PUs in sets called CPU kinds.
- * Each PU of the topology may only be in a single kind.
- *
- * The number of kinds may be obtained with hwloc_cpukinds_get_nr().
- * If the platform is homogeneous, there may be a single kind
- * with all PUs.
- * If the platform or operating system does not expose any
- * information about CPU cores, there may be no kind at all.
- *
- * The index of the kind that describes a given CPU set
- * (if any, and not partially)
- * may be obtained with hwloc_cpukinds_get_by_cpuset().
- *
- * From the index of a kind, it is possible to retrieve information
- * with hwloc_cpukinds_get_info():
- * an abstracted efficiency value,
- * and an array of info attributes
- * (for instance the "CoreType" and "FrequencyMaxMHz",
- * see \ref topoattrs_cpukinds).
- *
- * A higher efficiency value means greater intrinsic performance
- * (and possibly less performance/power efficiency).
- * Kinds with lower efficiency values are ranked first:
- * Passing 0 as \p kind_index to hwloc_cpukinds_get_info() will
- * return information about the CPU kind with lower performance
- * but higher energy-efficiency.
- * Higher \p kind_index values would rather return information
- * about power-hungry high-performance cores.
- *
- * When available, efficiency values are gathered from the operating system.
- * If so, \p cpukind_efficiency is set in the struct hwloc_topology_discovery_support array.
- * This is currently available on Windows 10, Mac OS X (Darwin),
- * and on some Linux platforms where core "capacity" is exposed in sysfs.
- *
- * If the operating system does not expose core efficiencies natively,
- * hwloc tries to compute efficiencies by comparing CPU kinds using
- * frequencies (on ARM), or core types and frequencies (on other architectures).
- * The environment variable HWLOC_CPUKINDS_RANKING may be used
- * to change this heuristics, see \ref envvar.
- *
- * If hwloc fails to rank any kind, for instance because the operating
- * system does not expose efficiencies and core frequencies,
- * all kinds will have an unknown efficiency (\c -1),
- * and they are not indexed/ordered in any specific way.
- *
- * @{
- */
-
-/** \brief Get the number of different kinds of CPU cores in the topology.
- *
- * \p flags must be \c 0 for now.
- *
- * \return The number of CPU kinds (positive integer) on success.
- * \return \c 0 if no information about kinds was found.
- * \return \c -1 with \p errno set to \c EINVAL if \p flags is invalid.
- */
-HWLOC_DECLSPEC int
-hwloc_cpukinds_get_nr(hwloc_topology_t topology,
- unsigned long flags);
-
-/** \brief Get the index of the CPU kind that contains CPUs listed in \p cpuset.
- *
- * \p flags must be \c 0 for now.
- *
- * \return The index of the CPU kind (positive integer or 0) on success.
- * \return \c -1 with \p errno set to \c EXDEV if \p cpuset is
- * only partially included in the some kind.
- * \return \c -1 with \p errno set to \c ENOENT if \p cpuset is
- * not included in any kind, even partially.
- * \return \c -1 with \p errno set to \c EINVAL if parameters are invalid.
- */
-HWLOC_DECLSPEC int
-hwloc_cpukinds_get_by_cpuset(hwloc_topology_t topology,
- hwloc_const_bitmap_t cpuset,
- unsigned long flags);
-
-/** \brief Get the CPU set and infos about a CPU kind in the topology.
- *
- * \p kind_index identifies one kind of CPU between 0 and the number
- * of kinds returned by hwloc_cpukinds_get_nr() minus 1.
- *
- * If not \c NULL, the bitmap \p cpuset will be filled with
- * the set of PUs of this kind.
- *
- * The integer pointed by \p efficiency, if not \c NULL will, be filled
- * with the ranking of this kind of CPU in term of efficiency (see above).
- * It ranges from \c 0 to the number of kinds
- * (as reported by hwloc_cpukinds_get_nr()) minus 1.
- *
- * Kinds with lower efficiency are reported first.
- *
- * If there is a single kind in the topology, its efficiency \c 0.
- * If the efficiency of some kinds of cores is unknown,
- * the efficiency of all kinds is set to \c -1,
- * and kinds are reported in no specific order.
- *
- * The array of info attributes (for instance the "CoreType",
- * "FrequencyMaxMHz" or "FrequencyBaseMHz", see \ref topoattrs_cpukinds)
- * and its length are returned in \p infos or \p nr_infos.
- * The array belongs to the topology, it should not be freed or modified.
- *
- * If \p nr_infos or \p infos is \c NULL, no info is returned.
- *
- * \p flags must be \c 0 for now.
- *
- * \return \c 0 on success.
- * \return \c -1 with \p errno set to \c ENOENT if \p kind_index does not match any CPU kind.
- * \return \c -1 with \p errno set to \c EINVAL if parameters are invalid.
- */
-HWLOC_DECLSPEC int
-hwloc_cpukinds_get_info(hwloc_topology_t topology,
- unsigned kind_index,
- hwloc_bitmap_t cpuset,
- int *efficiency,
- unsigned *nr_infos, struct hwloc_info_s **infos,
- unsigned long flags);
-
-/** \brief Register a kind of CPU in the topology.
- *
- * Mark the PUs listed in \p cpuset as being of the same kind
- * with respect to the given attributes.
- *
- * \p forced_efficiency should be \c -1 if unknown.
- * Otherwise it is an abstracted efficiency value to enforce
- * the ranking of all kinds if all of them have valid (and
- * different) efficiencies.
- *
- * The array \p infos of size \p nr_infos may be used to provide
- * info names and values describing this kind of PUs.
- *
- * \p flags must be \c 0 for now.
- *
- * Parameters \p cpuset and \p infos will be duplicated internally,
- * the caller is responsible for freeing them.
- *
- * If \p cpuset overlaps with some existing kinds, those might get
- * modified or split. For instance if existing kind A contains
- * PUs 0 and 1, and one registers another kind for PU 1 and 2,
- * there will be 3 resulting kinds:
- * existing kind A is restricted to only PU 0;
- * new kind B contains only PU 1 and combines information from A
- * and from the newly-registered kind;
- * new kind C contains only PU 2 and only gets information from
- * the newly-registered kind.
- *
- * \note The efficiency \p forced_efficiency provided to this function
- * may be different from the one reported later by hwloc_cpukinds_get_info()
- * because hwloc will scale efficiency values down to
- * between 0 and the number of kinds minus 1.
- *
- * \return \c 0 on success.
- * \return \c -1 with \p errno set to \c EINVAL if some parameters are invalid,
- * for instance if \p cpuset is \c NULL or empty.
- */
-HWLOC_DECLSPEC int
-hwloc_cpukinds_register(hwloc_topology_t topology,
- hwloc_bitmap_t cpuset,
- int forced_efficiency,
- unsigned nr_infos, struct hwloc_info_s *infos,
- unsigned long flags);
-
-/** @} */
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_CPUKINDS_H */
### src/3rdparty/hwloc/include/hwloc/cuda.h
@@ -1,226 +0,0 @@
-/*
- * Copyright © 2010-2023 Inria. All rights reserved.
- * Copyright © 2010-2011 Université Bordeaux
- * Copyright © 2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and the CUDA Driver API.
- *
- * Applications that use both hwloc and the CUDA Driver API may want to
- * include this file so as to get topology information for CUDA devices.
- *
- */
-
-#ifndef HWLOC_CUDA_H
-#define HWLOC_CUDA_H
-
-#include "hwloc.h"
-#include "hwloc/autogen/config.h"
-#include "hwloc/helper.h"
-#ifdef HWLOC_LINUX_SYS
-#include "hwloc/linux.h"
-#endif
-
-#include <cuda.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_cuda Interoperability with the CUDA Driver API
- *
- * This interface offers ways to retrieve topology information about
- * CUDA devices when using the CUDA Driver API.
- *
- * @{
- */
-
-/** \brief Return the domain, bus and device IDs of the CUDA device \p cudevice.
- *
- * Device \p cudevice must match the local machine.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_cuda_get_device_pci_ids(hwloc_topology_t topology __hwloc_attribute_unused,
- CUdevice cudevice, int *domain, int *bus, int *dev)
-{
- CUresult cres;
-
-#if CUDA_VERSION >= 4000
- cres = cuDeviceGetAttribute(domain, CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, cudevice);
- if (cres != CUDA_SUCCESS) {
- errno = ENOSYS;
- return -1;
- }
-#else
- *domain = 0;
-#endif
- cres = cuDeviceGetAttribute(bus, CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, cudevice);
- if (cres != CUDA_SUCCESS) {
- errno = ENOSYS;
- return -1;
- }
- cres = cuDeviceGetAttribute(dev, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, cudevice);
- if (cres != CUDA_SUCCESS) {
- errno = ENOSYS;
- return -1;
- }
-
- return 0;
-}
-
-/** \brief Get the CPU set of processors that are physically
- * close to device \p cudevice.
- *
- * Store in \p set the CPU-set describing the locality of the CUDA device \p cudevice.
- *
- * Topology \p topology and device \p cudevice must match the local machine.
- * I/O devices detection and the CUDA component are not needed in the topology.
- *
- * The function only returns the locality of the device.
- * If more information about the device is needed, OS objects should
- * be used instead, see hwloc_cuda_get_device_osdev()
- * and hwloc_cuda_get_device_osdev_by_index().
- *
- * This function is currently only implemented in a meaningful way for
- * Linux; other systems will simply get a full cpuset.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_cuda_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
- CUdevice cudevice, hwloc_cpuset_t set)
-{
-#ifdef HWLOC_LINUX_SYS
- /* If we're on Linux, use the sysfs mechanism to get the local cpus */
-#define HWLOC_CUDA_DEVICE_SYSFS_PATH_MAX 128
- char path[HWLOC_CUDA_DEVICE_SYSFS_PATH_MAX];
- int domainid, busid, deviceid;
-
- if (hwloc_cuda_get_device_pci_ids(topology, cudevice, &domainid, &busid, &deviceid))
- return -1;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return -1;
- }
-
- sprintf(path, "/sys/bus/pci/devices/%04x:%02x:%02x.0/local_cpus", domainid, busid, deviceid);
- if (hwloc_linux_read_path_as_cpumask(path, set) < 0
- || hwloc_bitmap_iszero(set))
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#else
- /* Non-Linux systems simply get a full cpuset */
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#endif
- return 0;
-}
-
-/** \brief Get the hwloc PCI device object corresponding to the
- * CUDA device \p cudevice.
- *
- * \return The hwloc PCI device object describing the CUDA device \p cudevice.
- * \return \c NULL if none could be found.
- *
- * Topology \p topology and device \p cudevice must match the local machine.
- * I/O devices detection must be enabled in topology \p topology.
- * The CUDA component is not needed in the topology.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_cuda_get_device_pcidev(hwloc_topology_t topology, CUdevice cudevice)
-{
- int domain, bus, dev;
-
- if (hwloc_cuda_get_device_pci_ids(topology, cudevice, &domain, &bus, &dev))
- return NULL;
-
- return hwloc_get_pcidev_by_busid(topology, domain, bus, dev, 0);
-}
-
-/** \brief Get the hwloc OS device object corresponding to CUDA device \p cudevice.
- *
- * \return The hwloc OS device object that describes the given CUDA device \p cudevice.
- * \return \c NULL if none could be found.
- *
- * Topology \p topology and device \p cudevice must match the local machine.
- * I/O devices detection and the CUDA component must be enabled in the topology.
- * If not, the locality of the object may still be found using
- * hwloc_cuda_get_device_cpuset().
- *
- * \note This function cannot work if PCI devices are filtered out.
- *
- * \note The corresponding hwloc PCI device may be found by looking
- * at the result parent pointer (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_cuda_get_device_osdev(hwloc_topology_t topology, CUdevice cudevice)
-{
- hwloc_obj_t osdev = NULL;
- int domain, bus, dev;
-
- if (hwloc_cuda_get_device_pci_ids(topology, cudevice, &domain, &bus, &dev))
- return NULL;
-
- osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- hwloc_obj_t pcidev = osdev->parent;
- if (strncmp(osdev->name, "cuda", 4))
- continue;
- if (pcidev
- && pcidev->type == HWLOC_OBJ_PCI_DEVICE
- && (int) pcidev->attr->pcidev.domain == domain
- && (int) pcidev->attr->pcidev.bus == bus
- && (int) pcidev->attr->pcidev.dev == dev
- && pcidev->attr->pcidev.func == 0)
- return osdev;
- /* if PCI are filtered out, we need a info attr to match on */
- }
-
- return NULL;
-}
-
-/** \brief Get the hwloc OS device object corresponding to the
- * CUDA device whose index is \p idx.
- *
- * \return The hwloc OS device object describing the CUDA device whose index is \p idx.
- * \return \c NULL if none could be found.
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection and the CUDA component must be enabled in the topology.
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object (unless PCI devices are filtered out).
- *
- * \note This function is identical to hwloc_cudart_get_device_osdev_by_index().
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_cuda_get_device_osdev_by_index(hwloc_topology_t topology, unsigned idx)
-{
- hwloc_obj_t osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- if (HWLOC_OBJ_OSDEV_COPROC == osdev->attr->osdev.type
- && osdev->name
- && !strncmp("cuda", osdev->name, 4)
- && atoi(osdev->name + 4) == (int) idx)
- return osdev;
- }
- return NULL;
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_CUDA_H */
### src/3rdparty/hwloc/include/hwloc/cudart.h
@@ -1,183 +0,0 @@
-/*
- * Copyright © 2010-2023 Inria. All rights reserved.
- * Copyright © 2010-2011 Université Bordeaux
- * Copyright © 2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and the CUDA Runtime API.
- *
- * Applications that use both hwloc and the CUDA Runtime API may want to
- * include this file so as to get topology information for CUDA devices.
- *
- */
-
-#ifndef HWLOC_CUDART_H
-#define HWLOC_CUDART_H
-
-#include "hwloc.h"
-#include "hwloc/autogen/config.h"
-#include "hwloc/helper.h"
-#ifdef HWLOC_LINUX_SYS
-#include "hwloc/linux.h"
-#endif
-
-#include <cuda.h> /* for CUDA_VERSION */
-#include <cuda_runtime_api.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_cudart Interoperability with the CUDA Runtime API
- *
- * This interface offers ways to retrieve topology information about
- * CUDA devices when using the CUDA Runtime API.
- *
- * @{
- */
-
-/** \brief Return the domain, bus and device IDs of the CUDA device whose index is \p idx.
- *
- * Device index \p idx must match the local machine.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_cudart_get_device_pci_ids(hwloc_topology_t topology __hwloc_attribute_unused,
- int idx, int *domain, int *bus, int *dev)
-{
- cudaError_t cerr;
- struct cudaDeviceProp prop;
-
- cerr = cudaGetDeviceProperties(&prop, idx);
- if (cerr) {
- errno = ENOSYS;
- return -1;
- }
-
-#if CUDA_VERSION >= 4000
- *domain = prop.pciDomainID;
-#else
- *domain = 0;
-#endif
-
- *bus = prop.pciBusID;
- *dev = prop.pciDeviceID;
-
- return 0;
-}
-
-/** \brief Get the CPU set of processors that are physically
- * close to device \p idx.
- *
- * Store in \p set the CPU-set describing the locality of the CUDA device
- * whose index is \p idx.
- *
- * Topology \p topology and device \p idx must match the local machine.
- * I/O devices detection and the CUDA component are not needed in the topology.
- *
- * The function only returns the locality of the device.
- * If more information about the device is needed, OS objects should
- * be used instead, see hwloc_cudart_get_device_osdev_by_index().
- *
- * This function is currently only implemented in a meaningful way for
- * Linux; other systems will simply get a full cpuset.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_cudart_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
- int idx, hwloc_cpuset_t set)
-{
-#ifdef HWLOC_LINUX_SYS
- /* If we're on Linux, use the sysfs mechanism to get the local cpus */
-#define HWLOC_CUDART_DEVICE_SYSFS_PATH_MAX 128
- char path[HWLOC_CUDART_DEVICE_SYSFS_PATH_MAX];
- int domain, bus, dev;
-
- if (hwloc_cudart_get_device_pci_ids(topology, idx, &domain, &bus, &dev))
- return -1;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return -1;
- }
-
- sprintf(path, "/sys/bus/pci/devices/%04x:%02x:%02x.0/local_cpus", (unsigned) domain, (unsigned) bus, (unsigned) dev);
- if (hwloc_linux_read_path_as_cpumask(path, set) < 0
- || hwloc_bitmap_iszero(set))
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#else
- /* Non-Linux systems simply get a full cpuset */
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#endif
- return 0;
-}
-
-/** \brief Get the hwloc PCI device object corresponding to the
- * CUDA device whose index is \p idx.
- *
- * \return The hwloc PCI device object describing the CUDA device whose index is \p idx.
- * \return \c NULL if none could be found.
- *
- * Topology \p topology and device \p idx must match the local machine.
- * I/O devices detection must be enabled in topology \p topology.
- * The CUDA component is not needed in the topology.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_cudart_get_device_pcidev(hwloc_topology_t topology, int idx)
-{
- int domain, bus, dev;
-
- if (hwloc_cudart_get_device_pci_ids(topology, idx, &domain, &bus, &dev))
- return NULL;
-
- return hwloc_get_pcidev_by_busid(topology, domain, bus, dev, 0);
-}
-
-/** \brief Get the hwloc OS device object corresponding to the
- * CUDA device whose index is \p idx.
- *
- * \return The hwloc OS device object describing the CUDA device whose index is \p idx.
- * \return \c NULL if none could be found.
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection and the CUDA component must be enabled in the topology.
- * If not, the locality of the object may still be found using
- * hwloc_cudart_get_device_cpuset().
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object (unless PCI devices are filtered out).
- *
- * \note This function is identical to hwloc_cuda_get_device_osdev_by_index().
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_cudart_get_device_osdev_by_index(hwloc_topology_t topology, unsigned idx)
-{
- hwloc_obj_t osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- if (HWLOC_OBJ_OSDEV_COPROC == osdev->attr->osdev.type
- && osdev->name
- && !strncmp("cuda", osdev->name, 4)
- && atoi(osdev->name + 4) == (int) idx)
- return osdev;
- }
- return NULL;
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_CUDART_H */
### src/3rdparty/hwloc/include/hwloc/deprecated.h
@@ -1,217 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2022 Inria. All rights reserved.
- * Copyright © 2009-2012 Université Bordeaux
- * Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/**
- * This file contains the inline code of functions declared in hwloc.h
- */
-
-#ifndef HWLOC_DEPRECATED_H
-#define HWLOC_DEPRECATED_H
-
-#ifndef HWLOC_H
-#error Please include the main hwloc.h instead
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* backward compat with v2.0 before WHOLE_SYSTEM renaming */
-#define HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED
-/* backward compat with v1.11 before System removal */
-#define HWLOC_OBJ_SYSTEM HWLOC_OBJ_MACHINE
-/* backward compat with v1.10 before Socket->Package renaming */
-#define HWLOC_OBJ_SOCKET HWLOC_OBJ_PACKAGE
-/* backward compat with v1.10 before Node->NUMANode clarification */
-#define HWLOC_OBJ_NODE HWLOC_OBJ_NUMANODE
-
-/** \brief Add a distances structure.
- *
- * Superseded by hwloc_distances_add_create()+hwloc_distances_add_values()+hwloc_distances_add_commit()
- * in v2.5.
- */
-HWLOC_DECLSPEC int hwloc_distances_add(hwloc_topology_t topology,
- unsigned nbobjs, hwloc_obj_t *objs, hwloc_uint64_t *values,
- unsigned long kind, unsigned long flags) __hwloc_attribute_deprecated;
-
-/** \brief Insert a misc object by parent.
- *
- * Identical to hwloc_topology_insert_misc_object().
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name) __hwloc_attribute_deprecated;
-static __hwloc_inline hwloc_obj_t
-hwloc_topology_insert_misc_object_by_parent(hwloc_topology_t topology, hwloc_obj_t parent, const char *name)
-{
- return hwloc_topology_insert_misc_object(topology, parent, name);
-}
-
-/** \brief Stringify the cpuset containing a set of objects.
- *
- * If \p size is 0, \p string may safely be \c NULL.
- *
- * \return the number of characters that were actually written if not truncating,
- * or that would have been written (not including the ending \\0).
- */
-static __hwloc_inline int
-hwloc_obj_cpuset_snprintf(char *str, size_t size, size_t nobj, struct hwloc_obj * const *objs) __hwloc_attribute_deprecated;
-static __hwloc_inline int
-hwloc_obj_cpuset_snprintf(char *str, size_t size, size_t nobj, struct hwloc_obj * const *objs)
-{
- hwloc_bitmap_t set = hwloc_bitmap_alloc();
- int res;
- unsigned i;
-
- hwloc_bitmap_zero(set);
- for(i=0; i<nobj; i++)
- if (objs[i]->cpuset)
- hwloc_bitmap_or(set, set, objs[i]->cpuset);
-
- res = hwloc_bitmap_snprintf(str, size, set);
- hwloc_bitmap_free(set);
- return res;
-}
-
-/** \brief Convert a type string into a type and some attributes.
- *
- * Deprecated by hwloc_type_sscanf()
- */
-static __hwloc_inline int
-hwloc_obj_type_sscanf(const char *string, hwloc_obj_type_t *typep, int *depthattrp, void *typeattrp, size_t typeattrsize) __hwloc_attribute_deprecated;
-static __hwloc_inline int
-hwloc_obj_type_sscanf(const char *string, hwloc_obj_type_t *typep, int *depthattrp, void *typeattrp, size_t typeattrsize)
-{
- union hwloc_obj_attr_u attr;
- int err = hwloc_type_sscanf(string, typep, &attr, sizeof(attr));
- if (err < 0)
- return err;
- if (hwloc_obj_type_is_cache(*typep)) {
- if (depthattrp)
- *depthattrp = (int) attr.cache.depth;
- if (typeattrp && typeattrsize >= sizeof(hwloc_obj_cache_type_t))
- memcpy(typeattrp, &attr.cache.type, sizeof(hwloc_obj_cache_type_t));
- } else if (*typep == HWLOC_OBJ_GROUP) {
- if (depthattrp)
- *depthattrp = (int) attr.group.depth;
- }
- return 0;
-}
-
-/** \brief Set the default memory binding policy of the current
- * process or thread to prefer the NUMA node(s) specified by physical \p nodeset
- */
-static __hwloc_inline int
-hwloc_set_membind_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_deprecated;
-static __hwloc_inline int
-hwloc_set_membind_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- return hwloc_set_membind(topology, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
-}
-
-/** \brief Query the default memory binding policy and physical locality of the
- * current process or thread.
- */
-static __hwloc_inline int
-hwloc_get_membind_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags) __hwloc_attribute_deprecated;
-static __hwloc_inline int
-hwloc_get_membind_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
-{
- return hwloc_get_membind(topology, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
-}
-
-/** \brief Set the default memory binding policy of the specified
- * process to prefer the NUMA node(s) specified by physical \p nodeset
- */
-static __hwloc_inline int
-hwloc_set_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_deprecated;
-static __hwloc_inline int
-hwloc_set_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- return hwloc_set_proc_membind(topology, pid, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
-}
-
-/** \brief Query the default memory binding policy and physical locality of the
- * specified process.
- */
-static __hwloc_inline int
-hwloc_get_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags) __hwloc_attribute_deprecated;
-static __hwloc_inline int
-hwloc_get_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
-{
- return hwloc_get_proc_membind(topology, pid, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
-}
-
-/** \brief Bind the already-allocated memory identified by (addr, len)
- * to the NUMA node(s) in physical \p nodeset.
- */
-static __hwloc_inline int
-hwloc_set_area_membind_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_deprecated;
-static __hwloc_inline int
-hwloc_set_area_membind_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- return hwloc_set_area_membind(topology, addr, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
-}
-
-/** \brief Query the physical NUMA node(s) and binding policy of the memory
- * identified by (\p addr, \p len ).
- */
-static __hwloc_inline int
-hwloc_get_area_membind_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags) __hwloc_attribute_deprecated;
-static __hwloc_inline int
-hwloc_get_area_membind_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
-{
- return hwloc_get_area_membind(topology, addr, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
-}
-
-/** \brief Allocate some memory on the given physical nodeset \p nodeset
- */
-static __hwloc_inline void *
-hwloc_alloc_membind_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_malloc __hwloc_attribute_deprecated;
-static __hwloc_inline void *
-hwloc_alloc_membind_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- return hwloc_alloc_membind(topology, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
-}
-
-/** \brief Allocate some memory on the given nodeset \p nodeset.
- */
-static __hwloc_inline void *
-hwloc_alloc_membind_policy_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags) __hwloc_attribute_malloc __hwloc_attribute_deprecated;
-static __hwloc_inline void *
-hwloc_alloc_membind_policy_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- return hwloc_alloc_membind_policy(topology, len, nodeset, policy, flags | HWLOC_MEMBIND_BYNODESET);
-}
-
-/** \brief Convert a CPU set into a NUMA node set and handle non-NUMA cases
- */
-static __hwloc_inline void
-hwloc_cpuset_to_nodeset_strict(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset) __hwloc_attribute_deprecated;
-static __hwloc_inline void
-hwloc_cpuset_to_nodeset_strict(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
-{
- hwloc_cpuset_to_nodeset(topology, _cpuset, nodeset);
-}
-
-/** \brief Convert a NUMA node set into a CPU set and handle non-NUMA cases
- */
-static __hwloc_inline void
-hwloc_cpuset_from_nodeset_strict(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset) __hwloc_attribute_deprecated;
-static __hwloc_inline void
-hwloc_cpuset_from_nodeset_strict(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
-{
- hwloc_cpuset_from_nodeset(topology, _cpuset, nodeset);
-}
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_DEPRECATED_H */
### src/3rdparty/hwloc/include/hwloc/diff.h
@@ -1,304 +0,0 @@
-/*
- * Copyright © 2013-2024 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Topology differences.
- */
-
-#ifndef HWLOC_DIFF_H
-#define HWLOC_DIFF_H
-
-#ifndef HWLOC_H
-#error Please include the main hwloc.h instead
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#elif 0
-}
-#endif
-
-
-/** \defgroup hwlocality_diff Topology differences
- *
- * Applications that manipulate many similar topologies, for instance
- * one for each node of a homogeneous cluster, may want to compress
- * topologies to reduce the memory footprint.
- *
- * This file offers a way to manipulate the difference between topologies
- * and export/import it to/from XML.
- * Compression may therefore be achieved by storing one topology
- * entirely while the others are only described by their differences
- * with the former.
- * The actual topology can be reconstructed when actually needed by
- * applying the precomputed difference to the reference topology.
- *
- * This interface targets very similar nodes.
- * Only very simple differences between topologies are actually
- * supported, for instance a change in the memory size, the name
- * of the object, or some info attribute.
- * More complex differences such as adding or removing objects cannot
- * be represented in the difference structures and therefore return
- * errors.
- * Differences between object sets or topology-wide allowed sets,
- * cannot be represented either.
- *
- * It means that there is no need to apply the difference when
- * looking at the tree organization (how many levels, how many
- * objects per level, what kind of objects, CPU and node sets, etc)
- * and when binding to objects.
- * However the difference must be applied when looking at object
- * attributes such as the name, the memory size or info attributes.
- *
- * @{
- */
-
-
-/** \brief Type of one object attribute difference.
- */
-typedef enum hwloc_topology_diff_obj_attr_type_e {
- /** \brief The object local memory is modified.
- * The union is a hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_uint64_s
- * (and the index field is ignored).
- */
- HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_SIZE,
-
- /** \brief The object name is modified.
- * The union is a hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_string_s
- * (and the name field is ignored).
- */
-
- HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_NAME,
- /** \brief the value of an info attribute is modified.
- * The union is a hwloc_topology_diff_obj_attr_u::hwloc_topology_diff_obj_attr_string_s.
- */
- HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO
-} hwloc_topology_diff_obj_attr_type_t;
-
-/** \brief One object attribute difference.
- */
-union hwloc_topology_diff_obj_attr_u {
- struct hwloc_topology_diff_obj_attr_generic_s {
- /* each part of the union must start with these */
- hwloc_topology_diff_obj_attr_type_t type;
- } generic;
-
- /** \brief Integer attribute modification with an optional index. */
- struct hwloc_topology_diff_obj_attr_uint64_s {
- /* used for storing integer attributes */
- hwloc_topology_diff_obj_attr_type_t type;
- hwloc_uint64_t index; /* not used for SIZE */
- hwloc_uint64_t oldvalue;
- hwloc_uint64_t newvalue;
- } uint64;
-
- /** \brief String attribute modification with an optional name */
- struct hwloc_topology_diff_obj_attr_string_s {
- /* used for storing name and info pairs */
- hwloc_topology_diff_obj_attr_type_t type;
- char *name; /* not used for NAME */
- char *oldvalue;
- char *newvalue;
- } string;
-};
-
-
-/** \brief Type of one element of a difference list.
- */
-typedef enum hwloc_topology_diff_type_e {
- /** \brief An object attribute was changed.
- * The union is a hwloc_topology_diff_u::hwloc_topology_diff_obj_attr_s.
- */
- HWLOC_TOPOLOGY_DIFF_OBJ_ATTR,
-
- /** \brief The difference is too complex,
- * it cannot be represented. The difference below
- * this object has not been checked.
- * hwloc_topology_diff_build() will return 1.
- *
- * The union is a hwloc_topology_diff_u::hwloc_topology_diff_too_complex_s.
- */
- HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX
-} hwloc_topology_diff_type_t;
-
-/** \brief One element of a difference list between two topologies.
- */
-typedef union hwloc_topology_diff_u {
- struct hwloc_topology_diff_generic_s {
- /* each part of the union must start with these */
- hwloc_topology_diff_type_t type;
- union hwloc_topology_diff_u * next; /* pointer to the next element of the list, or NULL */
- } generic;
-
- /* A difference in an object attribute. */
- struct hwloc_topology_diff_obj_attr_s {
- hwloc_topology_diff_type_t type; /* must be ::HWLOC_TOPOLOGY_DIFF_OBJ_ATTR */
- union hwloc_topology_diff_u * next;
- /* List of attribute differences for a single object */
- int obj_depth;
- unsigned obj_index;
- union hwloc_topology_diff_obj_attr_u diff;
- } obj_attr;
-
- /* A difference that is too complex. */
- struct hwloc_topology_diff_too_complex_s {
- hwloc_topology_diff_type_t type; /* must be ::HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX */
- union hwloc_topology_diff_u * next;
- /* Where we had to stop computing the diff in the first topology */
- int obj_depth;
- unsigned obj_index;
- } too_complex;
-} * hwloc_topology_diff_t;
-
-
-/** \brief Compute the difference between 2 topologies.
- *
- * The difference is stored as a list of ::hwloc_topology_diff_t entries
- * starting at \p diff.
- * It is computed by doing a depth-first traversal of both topology trees
- * simultaneously.
- *
- * If the difference between 2 objects is too complex to be represented
- * (for instance if some objects have different types, or different numbers
- * of children), a special diff entry of type ::HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX
- * is queued.
- * The computation of the diff does not continue below these objects.
- * So each such diff entry means that the difference between two subtrees
- * could not be computed.
- *
- * \return 0 if the difference can be represented properly.
- *
- * \return 0 with \p diff pointing to NULL if there is no difference
- * between the topologies.
- *
- * \return 1 if the difference is too complex (see above). Some entries in
- * the list will be of type ::HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX.
- *
- * \return -1 on any other error.
- *
- * \note \p flags is currently not used. It should be 0.
- *
- * \note The output diff has to be freed with hwloc_topology_diff_destroy().
- *
- * \note The output diff can only be exported to XML or passed to
- * hwloc_topology_diff_apply() if 0 was returned, i.e. if no entry of type
- * ::HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX is listed.
- *
- * \note The output diff may be modified by removing some entries from
- * the list. The removed entries should be freed by passing them to
- * to hwloc_topology_diff_destroy() (possible as another list).
-*/
-HWLOC_DECLSPEC int hwloc_topology_diff_build(hwloc_topology_t topology, hwloc_topology_t newtopology, unsigned long flags, hwloc_topology_diff_t *diff);
-
-/** \brief Flags to be given to hwloc_topology_diff_apply().
- */
-enum hwloc_topology_diff_apply_flags_e {
- /** \brief Apply topology diff in reverse direction.
- * \hideinitializer
- */
- HWLOC_TOPOLOGY_DIFF_APPLY_REVERSE = (1UL<<0)
-};
-
-/** \brief Apply a topology diff to an existing topology.
- *
- * \p flags is an OR'ed set of ::hwloc_topology_diff_apply_flags_e.
- *
- * The new topology is modified in place. hwloc_topology_dup()
- * may be used to duplicate it before patching.
- *
- * If the difference cannot be applied entirely, all previous applied
- * elements are unapplied before returning.
- *
- * \return 0 on success.
- *
- * \return -N if applying the difference failed while trying
- * to apply the N-th part of the difference. For instance -1
- * is returned if the very first difference element could not
- * be applied.
- */
-HWLOC_DECLSPEC int hwloc_topology_diff_apply(hwloc_topology_t topology, hwloc_topology_diff_t diff, unsigned long flags);
-
-/** \brief Destroy a list of topology differences.
- *
- * \return 0.
- */
-HWLOC_DECLSPEC int hwloc_topology_diff_destroy(hwloc_topology_diff_t diff);
-
-/** \brief Load a list of topology differences from a XML file.
- *
- * If not \c NULL, \p refname will be filled with the identifier
- * string of the reference topology for the difference file,
- * if any was specified in the XML file.
- * This identifier is usually the name of the other XML file
- * that contains the reference topology.
- *
- * \return 0 on success, -1 on error.
- *
- * \note the pointer returned in refname should later be freed
- * by the caller.
- */
-HWLOC_DECLSPEC int hwloc_topology_diff_load_xml(const char *xmlpath, hwloc_topology_diff_t *diff, char **refname);
-
-/** \brief Export a list of topology differences to a XML file.
- *
- * If not \c NULL, \p refname defines an identifier string
- * for the reference topology which was used as a base when
- * computing this difference.
- * This identifier is usually the name of the other XML file
- * that contains the reference topology.
- * This attribute is given back when reading the diff from XML.
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_topology_diff_export_xml(hwloc_topology_diff_t diff, const char *refname, const char *xmlpath);
-
-/** \brief Load a list of topology differences from a XML buffer.
- *
- * Build a list of differences from the XML memory buffer given
- * at \p xmlbuffer and of length \p buflen (including an ending \c \0).
- * This buffer may have been filled earlier with
- * hwloc_topology_diff_export_xmlbuffer().
- *
- * If not \c NULL, \p refname will be filled with the identifier
- * string of the reference topology for the difference file,
- * if any was specified in the XML file.
- * This identifier is usually the name of the other XML file
- * that contains the reference topology.
- *
- * \return 0 on success, -1 on error.
- *
- * \note the pointer returned in refname should later be freed
- * by the caller.
- */
-HWLOC_DECLSPEC int hwloc_topology_diff_load_xmlbuffer(const char *xmlbuffer, int buflen, hwloc_topology_diff_t *diff, char **refname);
-
-/** \brief Export a list of topology differences to a XML buffer.
- *
- * If not \c NULL, \p refname defines an identifier string
- * for the reference topology which was used as a base when
- * computing this difference.
- * This identifier is usually the name of the other XML file
- * that contains the reference topology.
- * This attribute is given back when reading the diff from XML.
- *
- * The returned buffer ends with a \c \0 that is included in the returned
- * length.
- *
- * \return 0 on success, -1 on error.
- *
- * \note The XML buffer should later be freed with hwloc_free_xmlbuffer().
- */
-HWLOC_DECLSPEC int hwloc_topology_diff_export_xmlbuffer(hwloc_topology_diff_t diff, const char *refname, char **xmlbuffer, int *buflen);
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_DIFF_H */
### src/3rdparty/hwloc/include/hwloc/distances.h
@@ -1,506 +0,0 @@
-/*
- * Copyright © 2010-2025 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Object distances.
- */
-
-#ifndef HWLOC_DISTANCES_H
-#define HWLOC_DISTANCES_H
-
-#ifndef HWLOC_H
-#error Please include the main hwloc.h instead
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#elif 0
-}
-#endif
-
-
-/** \defgroup hwlocality_distances_get Retrieve distances between objects
- * @{
- */
-
-/** \brief Matrix of distances between a set of objects.
- *
- * The most common matrix contains latencies between NUMA nodes
- * (as reported in the System Locality Distance Information Table (SLIT)
- * in the ACPI specification), which may or may not be physically accurate.
- * It corresponds to the latency for accessing the memory of one node
- * from a core in another node.
- * The corresponding kind is ::HWLOC_DISTANCES_KIND_MEANS_LATENCY | ::HWLOC_DISTANCES_KIND_FROM_USER.
- * The name of this distances structure is "NUMALatency".
- *
- * The matrix may also contain bandwidths between random sets of objects,
- * possibly provided by the user, as specified in the \p kind attribute.
- * Others common distance structures include and "XGMIBandwidth", "XGMIHops",
- * "XeLinkBandwidth" and "NVLinkBandwidth".
- *
- * Pointers \p objs and \p values should not be replaced, reallocated, freed, etc.
- * However callers are allowed to modify \p kind as well as the contents
- * of \p objs and \p values arrays.
- * For instance, if there is a single NUMA node per Package,
- * hwloc_get_obj_with_same_locality() may be used to convert between them
- * and replace NUMA nodes in the \p objs array with the corresponding Packages.
- * See also hwloc_distances_transform() for applying some transformations
- * to the structure.
- */
-struct hwloc_distances_s {
- unsigned nbobjs; /**< \brief Number of objects described by the distance matrix. */
- hwloc_obj_t *objs; /**< \brief Array of objects described by the distance matrix.
- * These objects are not in any particular order,
- * see hwloc_distances_obj_index() and hwloc_distances_obj_pair_values()
- * for easy ways to find objects in this array and their corresponding values.
- */
- unsigned long kind; /**< \brief OR'ed set of ::hwloc_distances_kind_e. */
- hwloc_uint64_t *values; /**< \brief Matrix of distances between objects, stored as a one-dimension array.
- *
- * Distance from i-th to j-th object is stored in slot i*nbobjs+j.
- * The meaning of the value depends on the \p kind attribute.
- */
-};
-
-/** \brief Kinds of distance matrices.
- *
- * The \p kind attribute of struct hwloc_distances_s is a OR'ed set
- * of kinds.
- *
- * Each distance matrix may have only one kind among HWLOC_DISTANCES_KIND_FROM_*
- * specifying where distance information comes from,
- * and one kind among HWLOC_DISTANCES_KIND_MEANS_* specifying
- * whether values are latencies or bandwidths.
- */
-enum hwloc_distances_kind_e {
- /** \brief These distances were obtained from the operating system or hardware.
- * \hideinitializer
- */
- HWLOC_DISTANCES_KIND_FROM_OS = (1UL<<0),
- /** \brief These distances were provided by the user.
- * \hideinitializer
- */
- HWLOC_DISTANCES_KIND_FROM_USER = (1UL<<1),
-
- /** \brief Distance values are similar to latencies between objects.
- * Values are smaller for closer objects, hence minimal on the diagonal
- * of the matrix (distance between an object and itself).
- * It could also be the number of network hops between objects, etc.
- * \hideinitializer
- */
- HWLOC_DISTANCES_KIND_MEANS_LATENCY = (1UL<<2),
- /** \brief Distance values are similar to bandwidths between objects.
- * Values are higher for closer objects, hence maximal on the diagonal
- * of the matrix (distance between an object and itself).
- * Such values are currently ignored for distance-based grouping.
- * \hideinitializer
- */
- HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH = (1UL<<3),
-
- /** \brief This distances structure covers objects of different types.
- * This may apply to the "NVLinkBandwidth" structure in presence
- * of a NVSwitch or POWER processor NVLink port.
- * \hideinitializer
- */
- HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES = (1UL<<4)
-};
-
-/** \brief Retrieve distance matrices.
- *
- * Retrieve distance matrices from the topology into the \p distances array.
- *
- * \p flags is currently unused, should be \c 0.
- *
- * \p kind serves as a filter. If \c 0, all distance matrices are returned.
- * If it contains some HWLOC_DISTANCES_KIND_FROM_*, only distance matrices
- * whose kind matches one of these are returned.
- * If it contains some HWLOC_DISTANCES_KIND_MEANS_*, only distance matrices
- * whose kind matches one of these are returned.
- *
- * On input, \p nr points to the number of distance matrices that may be stored
- * in \p distances.
- * On output, \p nr points to the number of distance matrices that were actually
- * found, even if some of them couldn't be stored in \p distances.
- * Distance matrices that couldn't be stored are ignored, but the function still
- * returns success (\c 0). The caller may find out by comparing the value pointed
- * by \p nr before and after the function call.
- *
- * Each distance matrix returned in the \p distances array should be released
- * by the caller using hwloc_distances_release().
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int
-hwloc_distances_get(hwloc_topology_t topology,
- unsigned *nr, struct hwloc_distances_s **distances,
- unsigned long kind, unsigned long flags);
-
-/** \brief Retrieve distance matrices for object at a specific depth in the topology.
- *
- * Identical to hwloc_distances_get() with the additional \p depth filter.
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int
-hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth,
- unsigned *nr, struct hwloc_distances_s **distances,
- unsigned long kind, unsigned long flags);
-
-/** \brief Retrieve distance matrices for object of a specific type.
- *
- * Identical to hwloc_distances_get() with the additional \p type filter.
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int
-hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type,
- unsigned *nr, struct hwloc_distances_s **distances,
- unsigned long kind, unsigned long flags);
-
-/** \brief Retrieve a distance matrix with the given name.
- *
- * Usually only one distances structure may match a given name.
- *
- * The name of the most common structure is "NUMALatency".
- * Others include "XGMIBandwidth", "XGMIHops", "XeLinkBandwidth",
- * and "NVLinkBandwidth".
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int
-hwloc_distances_get_by_name(hwloc_topology_t topology, const char *name,
- unsigned *nr, struct hwloc_distances_s **distances,
- unsigned long flags);
-
-/** \brief Get a description of what a distances structure contains.
- *
- * For instance "NUMALatency" for hardware-provided NUMA distances (ACPI SLIT),
- * or \c NULL if unknown.
- *
- * \return the constant string with the name of the distance structure.
- *
- * \note The returned name should not be freed by the caller,
- * it belongs to the hwloc library.
- */
-HWLOC_DECLSPEC const char *
-hwloc_distances_get_name(hwloc_topology_t topology, struct hwloc_distances_s *distances);
-
-/** \brief Release a distance matrix structure previously returned by hwloc_distances_get().
- *
- * \note This function is not required if the structure is removed with hwloc_distances_release_remove().
- */
-HWLOC_DECLSPEC void
-hwloc_distances_release(hwloc_topology_t topology, struct hwloc_distances_s *distances);
-
-/** \brief Transformations of distances structures. */
-enum hwloc_distances_transform_e {
- /** \brief Remove \c NULL objects from the distances structure.
- *
- * Every object that was replaced with \c NULL in the \p objs array
- * is removed and the \p values array is updated accordingly.
- *
- * At least \c 2 objects must remain, otherwise hwloc_distances_transform()
- * will return \c -1 with \p errno set to \c EINVAL.
- *
- * \p kind will be updated with or without ::HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES
- * according to the remaining objects.
- *
- * \hideinitializer
- */
- HWLOC_DISTANCES_TRANSFORM_REMOVE_NULL = 0,
-
- /** \brief Replace bandwidth values with a number of links.
- *
- * Usually all values will be either \c 0 (no link) or \c 1 (one link).
- * However some matrices could get larger values if some pairs of
- * peers are connected by different numbers of links.
- *
- * Values on the diagonal are set to \c 0.
- *
- * This transformation only applies to bandwidth matrices.
- *
- * \hideinitializer
- */
- HWLOC_DISTANCES_TRANSFORM_LINKS = 1,
-
- /** \brief Merge switches with multiple ports into a single object.
- *
- * This currently only applies to NVSwitches where GPUs seem connected
- * to different switch ports. Switch ports must be objects with subtype
- * "NVSwitch" as in the NVLinkBandwidth matrix.
- *
- * This transformation will replace all ports with only the first one,
- * now connected to all GPUs. Other ports are removed by applying
- * ::HWLOC_DISTANCES_TRANSFORM_REMOVE_NULL internally.
- * \hideinitializer
- */
- HWLOC_DISTANCES_TRANSFORM_MERGE_SWITCH_PORTS = 2,
-
- /** \brief Apply a transitive closure to the matrix to connect objects across switches.
- *
- * All pairs of GPUs will be reported as directly connected instead GPUs being
- * only connected to switches.
- *
- * Switch ports must be objects with subtype "NVSwitch" as in the NVLinkBandwidth matrix.
- * \hideinitializer
- */
- HWLOC_DISTANCES_TRANSFORM_TRANSITIVE_CLOSURE = 3
-};
-
-/** \brief Apply a transformation to a distances structure.
- *
- * Modify a distances structure that was previously obtained with
- * hwloc_distances_get() or one of its variants.
- *
- * This modifies the local copy of the distances structures but does
- * not modify the distances information stored inside the topology
- * (retrieved by another call to hwloc_distances_get() or exported to XML).
- * To do so, one should add a new distances structure with same
- * name, kind, objects and values (see \ref hwlocality_distances_add)
- * and then remove this old one with hwloc_distances_release_remove().
- *
- * \p transform must be one of the transformations listed
- * in ::hwloc_distances_transform_e.
- *
- * These transformations may modify the contents of the \p objs or \p values arrays.
- *
- * \p transform_attr must be \c NULL for now.
- *
- * \p flags must be \c 0 for now.
- *
- * \return 0 on success, -1 on error for instance if flags are invalid.
- *
- * \note Objects in distances array \p objs may be directly modified
- * in place without using hwloc_distances_transform().
- * One may use hwloc_get_obj_with_same_locality() to easily convert
- * between similar objects of different types.
- */
-HWLOC_DECLSPEC int hwloc_distances_transform(hwloc_topology_t topology, struct hwloc_distances_s *distances,
- enum hwloc_distances_transform_e transform,
- void *transform_attr,
- unsigned long flags);
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_distances_consult Helpers for consulting distance matrices
- * @{
- */
-
-/** \brief Find the index of an object in a distances structure.
- *
- * \return the index of the object in the distances structure if any.
- * \return -1 if object \p obj is not involved in structure \p distances.
- */
-static __hwloc_inline int
-hwloc_distances_obj_index(struct hwloc_distances_s *distances, hwloc_obj_t obj)
-{
- unsigned i;
- for(i=0; i<distances->nbobjs; i++)
- if (distances->objs[i] == obj)
- return (int)i;
- return -1;
-}
-
-/** \brief Find the values between two objects in a distance matrices.
- *
- * The distance from \p obj1 to \p obj2 is stored in the value pointed by
- * \p value1to2 and reciprocally.
- *
- * \return 0 on success.
- * \return -1 if object \p obj1 or \p obj2 is not involved in structure \p distances.
- */
-static __hwloc_inline int
-hwloc_distances_obj_pair_values(struct hwloc_distances_s *distances,
- hwloc_obj_t obj1, hwloc_obj_t obj2,
- hwloc_uint64_t *value1to2, hwloc_uint64_t *value2to1)
-{
- int i1 = hwloc_distances_obj_index(distances, obj1);
- int i2 = hwloc_distances_obj_index(distances, obj2);
- if (i1 < 0 || i2 < 0)
- return -1;
- *value1to2 = distances->values[i1 * distances->nbobjs + i2];
- *value2to1 = distances->values[i2 * distances->nbobjs + i1];
- return 0;
-}
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_distances_add Add distances between objects
- *
- * The usual way to add distances is:
- * \code
- * hwloc_distances_add_handle_t handle;
- * int err = -1;
- * handle = hwloc_distances_add_create(topology, "name", kind, 0);
- * if (handle) {
- * err = hwloc_distances_add_values(topology, handle, nbobjs, objs, values, 0);
- * if (!err)
- * err = hwloc_distances_add_commit(topology, handle, flags);
- * }
- * \endcode
- * If \p err is \c 0 at the end, then addition was successful.
- *
- * @{
- */
-
-/** \brief Handle to a new distances structure during its addition to the topology. */
-typedef void * hwloc_distances_add_handle_t;
-
-/** \brief Create a new empty distances structure.
- *
- * Create an empty distances structure
- * to be filled with hwloc_distances_add_values()
- * and then committed with hwloc_distances_add_commit().
- *
- * Parameter \p name is optional, it may be \c NULL.
- * Otherwise, it will be copied internally and may later be freed by the caller.
- *
- * \p kind specifies the kind of distance as a OR'ed set of ::hwloc_distances_kind_e.
- * Only one kind of meaning and one kind of provenance may be given if appropriate
- * (e.g. ::HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH and ::HWLOC_DISTANCES_KIND_FROM_USER).
- * Kind ::HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES will be automatically set
- * according to objects having different types in hwloc_distances_add_values().
- *
- * \p flags must be \c 0 for now.
- *
- * \return A hwloc_distances_add_handle_t that should then be passed
- * to hwloc_distances_add_values() and hwloc_distances_add_commit().
- *
- * \return \c NULL on error.
- */
-HWLOC_DECLSPEC hwloc_distances_add_handle_t
-hwloc_distances_add_create(hwloc_topology_t topology,
- const char *name, unsigned long kind,
- unsigned long flags);
-
-/** \brief Specify the objects and values in a new empty distances structure.
- *
- * Specify the objects and values for a new distances structure
- * that was returned as a handle by hwloc_distances_add_create().
- * The structure must then be committed with hwloc_distances_add_commit().
- *
- * The number of objects is \p nbobjs and the array of objects is \p objs.
- * Distance values are stored as a one-dimension array in \p values.
- * The distance from object i to object j is in slot i*nbobjs+j.
- *
- * \p nbobjs must be at least 2.
- *
- * Arrays \p objs and \p values will be copied internally,
- * they may later be freed by the caller.
- *
- * On error, the temporary distances structure and its content are destroyed.
- *
- * \p flags must be \c 0 for now.
- *
- * \return 0 on success.
- * \return -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_distances_add_values(hwloc_topology_t topology,
- hwloc_distances_add_handle_t handle,
- unsigned nbobjs, hwloc_obj_t *objs,
- hwloc_uint64_t *values,
- unsigned long flags);
-
-/** \brief Flags for adding a new distances to a topology. */
-enum hwloc_distances_add_flag_e {
- /** \brief Try to group objects based on the newly provided distance information.
- * Grouping is only performed when the distances structure contains latencies,
- * and when all objects are of the same type.
- * \hideinitializer
- */
- HWLOC_DISTANCES_ADD_FLAG_GROUP = (1UL<<0),
- /** \brief If grouping, consider the distance values as inaccurate and relax the
- * comparisons during the grouping algorithms. The actual accuracy may be modified
- * through the HWLOC_GROUPING_ACCURACY environment variable (see \ref envvar).
- * \hideinitializer
- */
- HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE = (1UL<<1)
-};
-
-/** \brief Commit a new distances structure.
- *
- * This function finalizes the distances structure and inserts in it the topology.
- *
- * Parameter \p handle was previously returned by hwloc_distances_add_create().
- * Then objects and values were specified with hwloc_distances_add_values().
- *
- * \p flags configures the behavior of the function using an optional OR'ed set of
- * ::hwloc_distances_add_flag_e.
- * It may be used to request the grouping of existing objects based on distances.
- *
- * On error, the temporary distances structure and its content are destroyed.
- *
- * \return 0 on success.
- * \return -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_distances_add_commit(hwloc_topology_t topology,
- hwloc_distances_add_handle_t handle,
- unsigned long flags);
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_distances_remove Remove distances between objects
- * @{
- */
-
-/** \brief Remove all distance matrices from a topology.
- *
- * Remove all distance matrices, either provided by the user or
- * gathered through the OS.
- *
- * If these distances were used to group objects, these additional
- * Group objects are not removed from the topology.
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_distances_remove(hwloc_topology_t topology);
-
-/** \brief Remove distance matrices for objects at a specific depth in the topology.
- *
- * Identical to hwloc_distances_remove() but only applies to one level of the topology.
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_distances_remove_by_depth(hwloc_topology_t topology, int depth);
-
-/** \brief Remove distance matrices for objects of a specific type in the topology.
- *
- * Identical to hwloc_distances_remove() but only applies to one level of the topology.
- *
- * \return 0 on success, -1 on error.
- */
-static __hwloc_inline int
-hwloc_distances_remove_by_type(hwloc_topology_t topology, hwloc_obj_type_t type)
-{
- int depth = hwloc_get_type_depth(topology, type);
- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
- return 0;
- return hwloc_distances_remove_by_depth(topology, depth);
-}
-
-/** \brief Release and remove the given distance matrice from the topology.
- *
- * This function includes a call to hwloc_distances_release().
- *
- * \return 0 on success, -1 on error.
- */
-HWLOC_DECLSPEC int hwloc_distances_release_remove(hwloc_topology_t topology, struct hwloc_distances_s *distances);
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_DISTANCES_H */
### src/3rdparty/hwloc/include/hwloc/export.h
@@ -1,286 +0,0 @@
-/*
- * Copyright © 2009-2018 Inria. All rights reserved.
- * Copyright © 2009-2012 Université Bordeaux
- * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Exporting Topologies to XML or to Synthetic strings.
- */
-
-#ifndef HWLOC_EXPORT_H
-#define HWLOC_EXPORT_H
-
-#ifndef HWLOC_H
-#error Please include the main hwloc.h instead
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#elif 0
-}
-#endif
-
-
-/** \defgroup hwlocality_xmlexport Exporting Topologies to XML
- * @{
- */
-
-/** \brief Flags for exporting XML topologies.
- *
- * Flags to be given as a OR'ed set to hwloc_topology_export_xml().
- */
-enum hwloc_topology_export_xml_flags_e {
- /** \brief Export XML that is loadable by hwloc v1.x.
- * However, the export may miss some details about the topology.
- * \hideinitializer
- */
- HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 = (1UL<<0)
-};
-
-/** \brief Export the topology into an XML file.
- *
- * This file may be loaded later through hwloc_topology_set_xml().
- *
- * By default, the latest export format is used, which means older hwloc
- * releases (e.g. v1.x) will not be able to import it.
- * Exporting to v1.x specific XML format is possible using flag
- * ::HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 but it may miss some details
- * about the topology.
- * If there is any chance that the exported file may ever be imported
- * back by a process using hwloc 1.x, one should consider detecting
- * it at runtime and using the corresponding export format.
- *
- * \p flags is a OR'ed set of ::hwloc_topology_export_xml_flags_e.
- *
- * \return 0 on success, or -1 on error.
- *
- * \note See also hwloc_topology_set_userdata_export_callback()
- * for exporting application-specific object userdata.
- *
- * \note The topology-specific userdata pointer is ignored when exporting to XML.
- *
- * \note Only printable characters may be exported to XML string attributes.
- * Any other character, especially any non-ASCII character, will be silently
- * dropped.
- *
- * \note If \p name is "-", the XML output is sent to the standard output.
- */
-HWLOC_DECLSPEC int hwloc_topology_export_xml(hwloc_topology_t topology, const char *xmlpath, unsigned long flags);
-
-/** \brief Export the topology into a newly-allocated XML memory buffer.
- *
- * \p xmlbuffer is allocated by the callee and should be freed with
- * hwloc_free_xmlbuffer() later in the caller.
- *
- * This memory buffer may be loaded later through hwloc_topology_set_xmlbuffer().
- *
- * By default, the latest export format is used, which means older hwloc
- * releases (e.g. v1.x) will not be able to import it.
- * Exporting to v1.x specific XML format is possible using flag
- * ::HWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 but it may miss some details
- * about the topology.
- * If there is any chance that the exported buffer may ever be imported
- * back by a process using hwloc 1.x, one should consider detecting
- * it at runtime and using the corresponding export format.
- *
- * The returned buffer ends with a \0 that is included in the returned
- * length.
- *
- * \p flags is a OR'ed set of ::hwloc_topology_export_xml_flags_e.
- *
- * \return 0 on success, or -1 on error.
- *
- * \note See also hwloc_topology_set_userdata_export_callback()
- * for exporting application-specific object userdata.
- *
- * \note The topology-specific userdata pointer is ignored when exporting to XML.
- *
- * \note Only printable characters may be exported to XML string attributes.
- * Any other character, especially any non-ASCII character, will be silently
- * dropped.
- */
-HWLOC_DECLSPEC int hwloc_topology_export_xmlbuffer(hwloc_topology_t topology, char **xmlbuffer, int *buflen, unsigned long flags);
-
-/** \brief Free a buffer allocated by hwloc_topology_export_xmlbuffer() */
-HWLOC_DECLSPEC void hwloc_free_xmlbuffer(hwloc_topology_t topology, char *xmlbuffer);
-
-/** \brief Set the application-specific callback for exporting object userdata
- *
- * The object userdata pointer is not exported to XML by default because hwloc
- * does not know what it contains.
- *
- * This function lets applications set \p export_cb to a callback function
- * that converts this opaque userdata into an exportable string.
- *
- * \p export_cb is invoked during XML export for each object whose
- * \p userdata pointer is not \c NULL.
- * The callback should use hwloc_export_obj_userdata() or
- * hwloc_export_obj_userdata_base64() to actually export
- * something to XML (possibly multiple times per object).
- *
- * \p export_cb may be set to \c NULL if userdata should not be exported to XML.
- *
- * \note The topology-specific userdata pointer is ignored when exporting to XML.
- */
-HWLOC_DECLSPEC void hwloc_topology_set_userdata_export_callback(hwloc_topology_t topology,
- void (*export_cb)(void *reserved, hwloc_topology_t topology, hwloc_obj_t obj));
-
-/** \brief Export some object userdata to XML
- *
- * This function may only be called from within the export() callback passed
- * to hwloc_topology_set_userdata_export_callback().
- * It may be invoked one of multiple times to export some userdata to XML.
- * The \p buffer content of length \p length is stored with optional name
- * \p name.
- *
- * When importing this XML file, the import() callback (if set) will be
- * called exactly as many times as hwloc_export_obj_userdata() was called
- * during export(). It will receive the corresponding \p name, \p buffer
- * and \p length arguments.
- *
- * \p reserved, \p topology and \p obj must be the first three parameters
- * that were given to the export callback.
- *
- * Only printable characters may be exported to XML string attributes.
- *
- * If exporting binary data, the application should first encode into
- * printable characters only (or use hwloc_export_obj_userdata_base64()).
- * It should also take care of portability issues if the export may
- * be reimported on a different architecture.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c EINVAL if a non-printable character is
- * passed in \p name or \b buffer.
- */
-HWLOC_DECLSPEC int hwloc_export_obj_userdata(void *reserved, hwloc_topology_t topology, hwloc_obj_t obj, const char *name, const void *buffer, size_t length);
-
-/** \brief Encode and export some object userdata to XML
- *
- * This function is similar to hwloc_export_obj_userdata() but it encodes
- * the input buffer into printable characters before exporting.
- * On import, decoding is automatically performed before the data is given
- * to the import() callback if any.
- *
- * This function may only be called from within the export() callback passed
- * to hwloc_topology_set_userdata_export_callback().
- *
- * The name must be made of printable characters for export to XML string attributes.
- *
- * The function does not take care of portability issues if the export
- * may be reimported on a different architecture.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c EINVAL if a non-printable character is
- * passed in \p name.
- */
-HWLOC_DECLSPEC int hwloc_export_obj_userdata_base64(void *reserved, hwloc_topology_t topology, hwloc_obj_t obj, const char *name, const void *buffer, size_t length);
-
-/** \brief Set the application-specific callback for importing userdata
- *
- * On XML import, userdata is ignored by default because hwloc does not know
- * how to store it in memory.
- *
- * This function lets applications set \p import_cb to a callback function
- * that will get the XML-stored userdata and store it in the object as expected
- * by the application.
- *
- * \p import_cb is called during hwloc_topology_load() as many times as
- * hwloc_export_obj_userdata() was called during export. The topology
- * is not entirely setup yet. Object attributes are ready to consult,
- * but links between objects are not.
- *
- * \p import_cb may be \c NULL if userdata should be ignored during import.
- *
- * \note \p buffer contains \p length characters followed by a null byte ('\0').
- *
- * \note This function should be called before hwloc_topology_load().
- *
- * \note The topology-specific userdata pointer is ignored when importing from XML.
- */
-HWLOC_DECLSPEC void hwloc_topology_set_userdata_import_callback(hwloc_topology_t topology,
- void (*import_cb)(hwloc_topology_t topology, hwloc_obj_t obj, const char *name, const void *buffer, size_t length));
-
-/** @} */
-
-
-/** \defgroup hwlocality_syntheticexport Exporting Topologies to Synthetic
- * @{
- */
-
-/** \brief Flags for exporting synthetic topologies.
- *
- * Flags to be given as a OR'ed set to hwloc_topology_export_synthetic().
- */
-enum hwloc_topology_export_synthetic_flags_e {
- /** \brief Export extended types such as L2dcache as basic types such as Cache.
- *
- * This is required if loading the synthetic description with hwloc < 1.9.
- * \hideinitializer
- */
- HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_NO_EXTENDED_TYPES = (1UL<<0),
-
- /** \brief Do not export level attributes.
- *
- * Ignore level attributes such as memory/cache sizes or PU indexes.
- * This is required if loading the synthetic description with hwloc < 1.10.
- * \hideinitializer
- */
- HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_NO_ATTRS = (1UL<<1),
-
- /** \brief Export the memory hierarchy as expected in hwloc 1.x.
- *
- * Instead of attaching memory children to levels, export single NUMA node child
- * as normal intermediate levels, when possible.
- * This is required if loading the synthetic description with hwloc 1.x.
- * However this may fail if some objects have multiple local NUMA nodes.
- * \hideinitializer
- */
- HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_V1 = (1UL<<2),
-
- /** \brief Do not export memory information.
- *
- * Only export the actual hierarchy of normal CPU-side objects and ignore
- * where memory is attached.
- * This is useful for when the hierarchy of CPUs is what really matters,
- * but it behaves as if there was a single machine-wide NUMA node.
- * \hideinitializer
- */
- HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_IGNORE_MEMORY = (1UL<<3)
-};
-
-/** \brief Export the topology as a synthetic string.
- *
- * At most \p buflen characters will be written in \p buffer,
- * including the terminating \0.
- *
- * This exported string may be given back to hwloc_topology_set_synthetic().
- *
- * \p flags is a OR'ed set of ::hwloc_topology_export_synthetic_flags_e.
- *
- * \return The number of characters that were written,
- * not including the terminating \0.
- *
- * \return -1 if the topology could not be exported,
- * for instance if it is not symmetric.
- *
- * \note I/O and Misc children are ignored, the synthetic string only
- * describes normal children.
- *
- * \note A 1024-byte buffer should be large enough for exporting
- * topologies in the vast majority of cases.
- */
- HWLOC_DECLSPEC int hwloc_topology_export_synthetic(hwloc_topology_t topology, char *buffer, size_t buflen, unsigned long flags);
-
-/** @} */
-
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_EXPORT_H */
### src/3rdparty/hwloc/include/hwloc/gl.h
@@ -1,137 +0,0 @@
-/*
- * Copyright © 2012 Blue Brain Project, EPFL. All rights reserved.
- * Copyright © 2012-2023 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and OpenGL displays.
- *
- * Applications that use both hwloc and OpenGL may want to include
- * this file so as to get topology information for OpenGL displays.
- */
-
-#ifndef HWLOC_GL_H
-#define HWLOC_GL_H
-
-#include "hwloc.h"
-
-#include <stdio.h>
-#include <string.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_gl Interoperability with OpenGL displays
- *
- * This interface offers ways to retrieve topology information about
- * OpenGL displays.
- *
- * Only the NVIDIA display locality information is currently available,
- * using the NV-CONTROL X11 extension and the NVCtrl library.
- *
- * @{
- */
-
-/** \brief Get the hwloc OS device object corresponding to the
- * OpenGL display given by port and device index.
- *
- * \return The hwloc OS device object describing the OpenGL display
- * whose port (server) is \p port and device (screen) is \p device.
- * \return \c NULL if none could be found.
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection and the GL component must be enabled in the topology.
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_gl_get_display_osdev_by_port_device(hwloc_topology_t topology,
- unsigned port, unsigned device)
-{
- unsigned x = (unsigned) -1, y = (unsigned) -1;
- hwloc_obj_t osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- if (HWLOC_OBJ_OSDEV_GPU == osdev->attr->osdev.type
- && osdev->name
- && sscanf(osdev->name, ":%u.%u", &x, &y) == 2
- && port == x && device == y)
- return osdev;
- }
- errno = EINVAL;
- return NULL;
-}
-
-/** \brief Get the hwloc OS device object corresponding to the
- * OpenGL display given by name.
- *
- * \return The hwloc OS device object describing the OpenGL display
- * whose name is \p name, built as ":port.device" such as ":0.0" .
- * \return \c NULL if none could be found.
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection and the GL component must be enabled in the topology.
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_gl_get_display_osdev_by_name(hwloc_topology_t topology,
- const char *name)
-{
- hwloc_obj_t osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- if (HWLOC_OBJ_OSDEV_GPU == osdev->attr->osdev.type
- && osdev->name
- && !strcmp(name, osdev->name))
- return osdev;
- }
- errno = EINVAL;
- return NULL;
-}
-
-/** \brief Get the OpenGL display port and device corresponding
- * to the given hwloc OS object.
- *
- * Retrieves the OpenGL display port (server) in \p port and device (screen)
- * in \p screen that correspond to the given hwloc OS device object.
- *
- * \return 0 on success.
- * \return -1 if none could be found.
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection and the GL component must be enabled in the topology.
- */
-static __hwloc_inline int
-hwloc_gl_get_display_by_osdev(hwloc_topology_t topology __hwloc_attribute_unused,
- hwloc_obj_t osdev,
- unsigned *port, unsigned *device)
-{
- unsigned x = -1, y = -1;
- if (HWLOC_OBJ_OSDEV_GPU == osdev->attr->osdev.type
- && sscanf(osdev->name, ":%u.%u", &x, &y) == 2) {
- *port = x;
- *device = y;
- return 0;
- }
- errno = EINVAL;
- return -1;
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_GL_H */
-
### src/3rdparty/hwloc/include/hwloc/glibc-sched.h
@@ -1,133 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2023 Inria. All rights reserved.
- * Copyright © 2009-2011 Université Bordeaux
- * Copyright © 2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and glibc scheduling routines.
- *
- * Applications that use both hwloc and glibc scheduling routines such as
- * sched_getaffinity() or pthread_attr_setaffinity_np() may want to include
- * this file so as to ease conversion between their respective types.
- */
-
-#ifndef HWLOC_GLIBC_SCHED_H
-#define HWLOC_GLIBC_SCHED_H
-
-#include "hwloc.h"
-#include "hwloc/helper.h"
-
-#include <assert.h>
-
-#if !defined _GNU_SOURCE || (!defined _SCHED_H && !defined _SCHED_H_) || (!defined CPU_SETSIZE && !defined sched_priority)
-#error Please make sure to include sched.h before including glibc-sched.h, and define _GNU_SOURCE before any inclusion of sched.h
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef HWLOC_HAVE_CPU_SET
-
-
-/** \defgroup hwlocality_glibc_sched Interoperability with glibc sched affinity
- *
- * This interface offers ways to convert between hwloc cpusets and glibc cpusets
- * such as those manipulated by sched_getaffinity() or pthread_attr_setaffinity_np().
- *
- * \note Topology \p topology must match the current machine.
- *
- * @{
- */
-
-
-/** \brief Convert hwloc CPU set \p toposet into glibc sched affinity CPU set \p schedset
- *
- * This function may be used before calling sched_setaffinity or any other function
- * that takes a cpu_set_t as input parameter.
- *
- * \p schedsetsize should be sizeof(cpu_set_t) unless \p schedset was dynamically allocated with CPU_ALLOC
- *
- * \return 0.
- */
-static __hwloc_inline int
-hwloc_cpuset_to_glibc_sched_affinity(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t hwlocset,
- cpu_set_t *schedset, size_t schedsetsize)
-{
-#ifdef CPU_ZERO_S
- unsigned cpu;
- CPU_ZERO_S(schedsetsize, schedset);
- hwloc_bitmap_foreach_begin(cpu, hwlocset)
- CPU_SET_S(cpu, schedsetsize, schedset);
- hwloc_bitmap_foreach_end();
-#else /* !CPU_ZERO_S */
- unsigned cpu;
- CPU_ZERO(schedset);
- assert(schedsetsize == sizeof(cpu_set_t));
- hwloc_bitmap_foreach_begin(cpu, hwlocset)
- CPU_SET(cpu, schedset);
- hwloc_bitmap_foreach_end();
-#endif /* !CPU_ZERO_S */
- return 0;
-}
-
-/** \brief Convert glibc sched affinity CPU set \p schedset into hwloc CPU set
- *
- * This function may be used before calling sched_setaffinity or any other function
- * that takes a cpu_set_t as input parameter.
- *
- * \p schedsetsize should be sizeof(cpu_set_t) unless \p schedset was dynamically allocated with CPU_ALLOC
- *
- * \return 0 on success.
- * \return -1 with errno set to \c ENOMEM if some internal reallocation failed.
- */
-static __hwloc_inline int
-hwloc_cpuset_from_glibc_sched_affinity(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_cpuset_t hwlocset,
- const cpu_set_t *schedset, size_t schedsetsize)
-{
- int cpu;
-#ifdef CPU_ZERO_S
- int count;
-#endif
- hwloc_bitmap_zero(hwlocset);
-#ifdef CPU_ZERO_S
- count = CPU_COUNT_S(schedsetsize, schedset);
- cpu = 0;
- while (count) {
- if (CPU_ISSET_S(cpu, schedsetsize, schedset)) {
- if (hwloc_bitmap_set(hwlocset, cpu) < 0)
- return -1;
- count--;
- }
- cpu++;
- }
-#else /* !CPU_ZERO_S */
- /* sched.h does not support dynamic cpu_set_t (introduced in glibc 2.7),
- * assume we have a very old interface without CPU_COUNT (added in 2.6)
- */
- assert(schedsetsize == sizeof(cpu_set_t));
- for(cpu=0; cpu<CPU_SETSIZE; cpu++)
- if (CPU_ISSET(cpu, schedset))
- if (hwloc_bitmap_set(hwlocset, cpu) < 0)
- return -1;
-#endif /* !CPU_ZERO_S */
- return 0;
-}
-
-/** @} */
-
-
-#endif /* CPU_SET */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_GLIBC_SCHED_H */
### src/3rdparty/hwloc/include/hwloc/helper.h
@@ -1,1331 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2024 Inria. All rights reserved.
- * Copyright © 2009-2012 Université Bordeaux
- * Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief High-level hwloc traversal helpers.
- */
-
-#ifndef HWLOC_HELPER_H
-#define HWLOC_HELPER_H
-
-#ifndef HWLOC_H
-#error Please include the main hwloc.h instead
-#endif
-
-#include <stdlib.h>
-#include <errno.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_helper_types Kinds of object Type
- * @{
- *
- * Each object type is
- * either Normal (i.e. hwloc_obj_type_is_normal() returns 1),
- * or Memory (i.e. hwloc_obj_type_is_memory() returns 1)
- * or I/O (i.e. hwloc_obj_type_is_io() returns 1)
- * or Misc (i.e. equal to ::HWLOC_OBJ_MISC).
- * It cannot be of more than one of these kinds.
- *
- * See also Object Kind in \ref termsanddefs.
- */
-
-/** \brief Check whether an object type is Normal.
- *
- * Normal objects are objects of the main CPU hierarchy
- * (Machine, Package, Core, PU, CPU caches, etc.),
- * but they are not NUMA nodes, I/O devices or Misc objects.
- *
- * They are attached to parent as Normal children,
- * not as Memory, I/O or Misc children.
- *
- * \return 1 if an object of type \p type is a Normal object, 0 otherwise.
- */
-HWLOC_DECLSPEC int
-hwloc_obj_type_is_normal(hwloc_obj_type_t type);
-
-/** \brief Check whether an object type is I/O.
- *
- * I/O objects are objects attached to their parents
- * in the I/O children list.
- * This current includes Bridges, PCI and OS devices.
- *
- * \return 1 if an object of type \p type is a I/O object, 0 otherwise.
- */
-HWLOC_DECLSPEC int
-hwloc_obj_type_is_io(hwloc_obj_type_t type);
-
-/** \brief Check whether an object type is Memory.
- *
- * Memory objects are objects attached to their parents
- * in the Memory children list.
- * This current includes NUMA nodes and Memory-side caches.
- *
- * \return 1 if an object of type \p type is a Memory object, 0 otherwise.
- */
-HWLOC_DECLSPEC int
-hwloc_obj_type_is_memory(hwloc_obj_type_t type);
-
-/** \brief Check whether an object type is a CPU Cache (Data, Unified or Instruction).
- *
- * Memory-side caches are not CPU caches.
- *
- * \return 1 if an object of type \p type is a Cache, 0 otherwise.
- */
-HWLOC_DECLSPEC int
-hwloc_obj_type_is_cache(hwloc_obj_type_t type);
-
-/** \brief Check whether an object type is a CPU Data or Unified Cache.
- *
- * Memory-side caches are not CPU caches.
- *
- * \return 1 if an object of type \p type is a CPU Data or Unified Cache, 0 otherwise.
- */
-HWLOC_DECLSPEC int
-hwloc_obj_type_is_dcache(hwloc_obj_type_t type);
-
-/** \brief Check whether an object type is a CPU Instruction Cache,
- *
- * Memory-side caches are not CPU caches.
- *
- * \return 1 if an object of type \p type is a CPU Instruction Cache, 0 otherwise.
- */
-HWLOC_DECLSPEC int
-hwloc_obj_type_is_icache(hwloc_obj_type_t type);
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_helper_find_inside Finding Objects inside a CPU set
- * @{
- */
-
-/** \brief Get the first largest object included in the given cpuset \p set.
- *
- * \return the first object that is included in \p set and whose parent is not.
- * \return \c NULL if no such object exists.
- *
- * This is convenient for iterating over all largest objects within a CPU set
- * by doing a loop getting the first largest object and clearing its CPU set
- * from the remaining CPU set.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_first_largest_obj_inside_cpuset(hwloc_topology_t topology, hwloc_const_cpuset_t set)
-{
- hwloc_obj_t obj = hwloc_get_root_obj(topology);
- if (!hwloc_bitmap_intersects(obj->cpuset, set))
- return NULL;
- while (!hwloc_bitmap_isincluded(obj->cpuset, set)) {
- /* while the object intersects without being included, look at its children */
- hwloc_obj_t child = obj->first_child;
- while (child) {
- if (hwloc_bitmap_intersects(child->cpuset, set))
- break;
- child = child->next_sibling;
- }
- if (!child)
- /* no child intersects, return their father */
- return obj;
- /* found one intersecting child, look at its children */
- obj = child;
- }
- /* obj is included, return it */
- return obj;
-}
-
-/** \brief Get the set of largest objects covering exactly a given cpuset \p set
- *
- * \return the number of objects returned in \p objs.
- * \return -1 if no set of objects may cover that cpuset.
- */
-HWLOC_DECLSPEC int hwloc_get_largest_objs_inside_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- hwloc_obj_t * __hwloc_restrict objs, int max);
-
-/** \brief Return the next object at depth \p depth included in CPU set \p set.
- *
- * The next invokation should pass the previous return value in \p prev
- * so as to obtain the next object in \p set.
- *
- * \return the first object at depth \p depth included in \p set if \p prev is \c NULL.
- * \return the next object at depth \p depth included in \p set if \p prev is not \c NULL.
- * \return \c NULL if there is no next object.
- *
- * \note Objects with empty CPU sets are ignored
- * (otherwise they would be considered included in any given set).
- *
- * \note This function cannot work if objects at the given depth do
- * not have CPU sets (I/O or Misc objects).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- int depth, hwloc_obj_t prev)
-{
- hwloc_obj_t next = hwloc_get_next_obj_by_depth(topology, depth, prev);
- if (!next)
- return NULL;
- while (next && (hwloc_bitmap_iszero(next->cpuset) || !hwloc_bitmap_isincluded(next->cpuset, set)))
- next = next->next_cousin;
- return next;
-}
-
-/** \brief Return the next object of type \p type included in CPU set \p set.
- *
- * The next invokation should pass the previous return value in \p prev
- * so as to obtain the next object in \p set.
- *
- * \return the first object of type \p type included in \p set if \p prev is \c NULL.
- * \return the next object of type \p type included in \p set if \p prev is not \c NULL.
- * \return \c NULL if there is no next object.
- * \return \c NULL if there is no depth for the given type.
- * \return \c NULL if there are multiple depths for the given type,
- * the caller should fallback to hwloc_get_next_obj_inside_cpuset_by_depth().
- *
- * \note Objects with empty CPU sets are ignored
- * (otherwise they would be considered included in any given set).
- *
- * \note This function cannot work if objects of the given type do
- * not have CPU sets (I/O or Misc objects).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- hwloc_obj_type_t type, hwloc_obj_t prev)
-{
- int depth = hwloc_get_type_depth(topology, type);
- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
- return NULL;
- return hwloc_get_next_obj_inside_cpuset_by_depth(topology, set, depth, prev);
-}
-
-/** \brief Return the (logically) \p idx -th object at depth \p depth included in CPU set \p set.
- *
- * \return the object if any, \c NULL otherwise.
- *
- * \note Objects with empty CPU sets are ignored
- * (otherwise they would be considered included in any given set).
- *
- * \note This function cannot work if objects at the given depth do
- * not have CPU sets (I/O or Misc objects).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- int depth, unsigned idx) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- int depth, unsigned idx)
-{
- hwloc_obj_t obj = hwloc_get_obj_by_depth (topology, depth, 0);
- unsigned count = 0;
- if (!obj)
- return NULL;
- while (obj) {
- if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set)) {
- if (count == idx)
- return obj;
- count++;
- }
- obj = obj->next_cousin;
- }
- return NULL;
-}
-
-/** \brief Return the \p idx -th object of type \p type included in CPU set \p set.
- *
- * \return the object if any.
- * \return \c NULL if there is no such object.
- * \return \c NULL if there is no depth for given type.
- * \return \c NULL if there are multiple depths for given type,
- * the caller should fallback to hwloc_get_obj_inside_cpuset_by_depth().
- *
- * \note Objects with empty CPU sets are ignored
- * (otherwise they would be considered included in any given set).
- *
- * \note This function cannot work if objects of the given type do
- * not have CPU sets (I/O or Misc objects).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- hwloc_obj_type_t type, unsigned idx) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- hwloc_obj_type_t type, unsigned idx)
-{
- int depth = hwloc_get_type_depth(topology, type);
- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
- return NULL;
- return hwloc_get_obj_inside_cpuset_by_depth(topology, set, depth, idx);
-}
-
-/** \brief Return the number of objects at depth \p depth included in CPU set \p set.
- *
- * \return the number of objects.
- * \return 0 if the depth is invalid.
- *
- * \note Objects with empty CPU sets are ignored
- * (otherwise they would be considered included in any given set).
- *
- * \note This function cannot work if objects at the given depth do
- * not have CPU sets (I/O or Misc objects).
- */
-static __hwloc_inline unsigned
-hwloc_get_nbobjs_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- int depth) __hwloc_attribute_pure;
-static __hwloc_inline unsigned
-hwloc_get_nbobjs_inside_cpuset_by_depth (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- int depth)
-{
- hwloc_obj_t obj = hwloc_get_obj_by_depth (topology, depth, 0);
- unsigned count = 0;
- if (!obj)
- return 0;
- while (obj) {
- if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set))
- count++;
- obj = obj->next_cousin;
- }
- return count;
-}
-
-/** \brief Return the number of objects of type \p type included in CPU set \p set.
- *
- * \return the number of objects.
- * \return 0 if there are no objects of that type in the topology.
- * \return -1 if there are multiple levels of objects of that type,
- * the caller should fallback to hwloc_get_nbobjs_inside_cpuset_by_depth().
- *
- * \note Objects with empty CPU sets are ignored
- * (otherwise they would be considered included in any given set).
- *
- * \note This function cannot work if objects of the given type do
- * not have CPU sets (I/O objects).
- */
-static __hwloc_inline int
-hwloc_get_nbobjs_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- hwloc_obj_type_t type) __hwloc_attribute_pure;
-static __hwloc_inline int
-hwloc_get_nbobjs_inside_cpuset_by_type (hwloc_topology_t topology, hwloc_const_cpuset_t set,
- hwloc_obj_type_t type)
-{
- int depth = hwloc_get_type_depth(topology, type);
- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
- return 0;
- if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
- return -1; /* FIXME: agregate nbobjs from different levels? */
- return (int) hwloc_get_nbobjs_inside_cpuset_by_depth(topology, set, depth);
-}
-
-/** \brief Return the logical index among the objects included in CPU set \p set.
- *
- * Consult all objects in the same level as \p obj and inside CPU set \p set
- * in the logical order, and return the index of \p obj within them.
- * If \p set covers the entire topology, this is the logical index of \p obj.
- * Otherwise, this is similar to a logical index within the part of the topology
- * defined by CPU set \p set.
- *
- * \return the logical index among the objects included in the set if any.
- * \return -1 if the object is not included in the set.
- *
- * \note Objects with empty CPU sets are ignored
- * (otherwise they would be considered included in any given set).
- *
- * \note This function cannot work if obj does not have CPU sets (I/O objects).
- */
-static __hwloc_inline int
-hwloc_get_obj_index_inside_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
- hwloc_obj_t obj) __hwloc_attribute_pure;
-static __hwloc_inline int
-hwloc_get_obj_index_inside_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
- hwloc_obj_t obj)
-{
- int idx = 0;
- if (!hwloc_bitmap_isincluded(obj->cpuset, set))
- return -1;
- /* count how many objects are inside the cpuset on the way from us to the beginning of the level */
- while ((obj = obj->prev_cousin) != NULL)
- if (!hwloc_bitmap_iszero(obj->cpuset) && hwloc_bitmap_isincluded(obj->cpuset, set))
- idx++;
- return idx;
-}
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_helper_find_covering Finding Objects covering at least CPU set
- * @{
- */
-
-/** \brief Get the child covering at least CPU set \p set.
- *
- * \return the child that covers the set entirely.
- * \return \c NULL if no child matches or if \p set is empty.
- *
- * \note This function cannot work if parent does not have a CPU set (I/O or Misc objects).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_child_covering_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
- hwloc_obj_t parent) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_child_covering_cpuset (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_cpuset_t set,
- hwloc_obj_t parent)
-{
- hwloc_obj_t child;
- if (hwloc_bitmap_iszero(set))
- return NULL;
- child = parent->first_child;
- while (child) {
- if (child->cpuset && hwloc_bitmap_isincluded(set, child->cpuset))
- return child;
- child = child->next_sibling;
- }
- return NULL;
-}
-
-/** \brief Get the lowest object covering at least CPU set \p set
- *
- * \return the lowest object covering the set entirely.
- * \return \c NULL if no object matches or if \p set is empty.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set)
-{
- struct hwloc_obj *current = hwloc_get_root_obj(topology);
- if (hwloc_bitmap_iszero(set) || !hwloc_bitmap_isincluded(set, current->cpuset))
- return NULL;
- while (1) {
- hwloc_obj_t child = hwloc_get_child_covering_cpuset(topology, set, current);
- if (!child)
- return current;
- current = child;
- }
-}
-
-/** \brief Iterate through same-depth objects covering at least CPU set \p set
- *
- * The next invokation should pass the previous return value in \p prev so as
- * to obtain the next object covering at least another part of \p set.
- *
- * \return the first object at depth \p depth covering at least part of CPU set \p set
- * if object \p prev is \c NULL.
- * \return the next one if \p prev is not \c NULL.
- * \return \c NULL if there is no next object.
- *
- * \note This function cannot work if objects at the given depth do
- * not have CPU sets (I/O or Misc objects).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_obj_covering_cpuset_by_depth(hwloc_topology_t topology, hwloc_const_cpuset_t set,
- int depth, hwloc_obj_t prev)
-{
- hwloc_obj_t next = hwloc_get_next_obj_by_depth(topology, depth, prev);
- if (!next)
- return NULL;
- while (next && !hwloc_bitmap_intersects(set, next->cpuset))
- next = next->next_cousin;
- return next;
-}
-
-/** \brief Iterate through same-type objects covering at least CPU set \p set
- *
- * The next invokation should pass the previous return value in \p prev so as to obtain
- * the next object of type \p type covering at least another part of \p set.
- *
- * \return the first object of type \p type covering at least part of CPU set \p set
- * if object \p prev is \c NULL.
- * \return the next one if \p prev is not \c NULL.
- * \return \c NULL if there is no next object.
- * \return \c NULL if there is no depth for the given type.
- * \return \c NULL if there are multiple depths for the given type,
- * the caller should fallback to hwloc_get_next_obj_covering_cpuset_by_depth().
- *
- * \note This function cannot work if objects of the given type do
- * not have CPU sets (I/O or Misc objects).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_obj_covering_cpuset_by_type(hwloc_topology_t topology, hwloc_const_cpuset_t set,
- hwloc_obj_type_t type, hwloc_obj_t prev)
-{
- int depth = hwloc_get_type_depth(topology, type);
- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
- return NULL;
- return hwloc_get_next_obj_covering_cpuset_by_depth(topology, set, depth, prev);
-}
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_helper_ancestors Looking at Ancestor and Child Objects
- * @{
- *
- * Be sure to see the figure in \ref termsanddefs that shows a
- * complete topology tree, including depths, child/sibling/cousin
- * relationships, and an example of an asymmetric topology where one
- * package has fewer caches than its peers.
- */
-
-/** \brief Returns the ancestor object of \p obj at depth \p depth.
- *
- * \return the ancestor if any.
- * \return \c NULL if no such ancestor exists.
- *
- * \note \p depth should not be the depth of PU or NUMA objects
- * since they are ancestors of no objects (except Misc or I/O).
- * This function rather expects an intermediate level depth,
- * such as the depth of Packages, Cores, or Caches.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_ancestor_obj_by_depth (hwloc_topology_t topology __hwloc_attribute_unused, int depth, hwloc_obj_t obj) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_ancestor_obj_by_depth (hwloc_topology_t topology __hwloc_attribute_unused, int depth, hwloc_obj_t obj)
-{
- hwloc_obj_t ancestor = obj;
- if (obj->depth < depth)
- return NULL;
- while (ancestor && ancestor->depth > depth)
- ancestor = ancestor->parent;
- return ancestor;
-}
-
-/** \brief Returns the ancestor object of \p obj with type \p type.
- *
- * \return the ancestor if any.
- * \return \c NULL if no such ancestor exists.
- *
- * \note if multiple matching ancestors exist (e.g. multiple levels of ::HWLOC_OBJ_GROUP)
- * the lowest one is returned.
- *
- * \note \p type should not be ::HWLOC_OBJ_PU or ::HWLOC_OBJ_NUMANODE
- * since these objects are ancestors of no objects (except Misc or I/O).
- * This function rather expects an intermediate object type,
- * such as ::HWLOC_OBJ_PACKAGE, ::HWLOC_OBJ_CORE, etc.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_ancestor_obj_by_type (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_type_t type, hwloc_obj_t obj) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_ancestor_obj_by_type (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_type_t type, hwloc_obj_t obj)
-{
- hwloc_obj_t ancestor = obj->parent;
- while (ancestor && ancestor->type != type)
- ancestor = ancestor->parent;
- return ancestor;
-}
-
-/** \brief Returns the common parent object to objects \p obj1 and \p obj2.
- *
- * \return the common ancestor.
- *
- * \note This function cannot return \c NULL.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_common_ancestor_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj1, hwloc_obj_t obj2) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_common_ancestor_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj1, hwloc_obj_t obj2)
-{
- /* the loop isn't so easy since intermediate ancestors may have
- * different depth, causing us to alternate between using obj1->parent
- * and obj2->parent. Also, even if at some point we find ancestors of
- * of the same depth, their ancestors may have different depth again.
- */
- while (obj1 != obj2) {
- while (obj1->depth > obj2->depth)
- obj1 = obj1->parent;
- while (obj2->depth > obj1->depth)
- obj2 = obj2->parent;
- if (obj1 != obj2 && obj1->depth == obj2->depth) {
- obj1 = obj1->parent;
- obj2 = obj2->parent;
- }
- }
- return obj1;
-}
-
-/** \brief Returns true if \p obj is inside the subtree beginning with ancestor object \p subtree_root.
- *
- * \return 1 is the object is in the subtree, 0 otherwise.
- *
- * \note This function cannot work if \p obj and \p subtree_root objects do
- * not have CPU sets (I/O or Misc objects).
- */
-static __hwloc_inline int
-hwloc_obj_is_in_subtree (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj, hwloc_obj_t subtree_root) __hwloc_attribute_pure;
-static __hwloc_inline int
-hwloc_obj_is_in_subtree (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj, hwloc_obj_t subtree_root)
-{
- return obj->cpuset && subtree_root->cpuset && hwloc_bitmap_isincluded(obj->cpuset, subtree_root->cpuset);
-}
-
-/** \brief Return the next child.
- *
- * Return the next child among the normal children list,
- * then among the memory children list, then among the I/O
- * children list, then among the Misc children list.
- *
- * \return the first child if \p prev is \c NULL.
- * \return the next child if \p prev is not \c NULL.
- * \return \c NULL when there is no next child.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_child (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t parent, hwloc_obj_t prev)
-{
- hwloc_obj_t obj;
- int state = 0;
- if (prev) {
- if (prev->type == HWLOC_OBJ_MISC)
- state = 3;
- else if (hwloc_obj_type_is_io(prev->type))
- state = 2;
- else if (hwloc_obj_type_is_memory(prev->type))
- state = 1;
- obj = prev->next_sibling;
- } else {
- obj = parent->first_child;
- }
- if (!obj && state == 0) {
- obj = parent->memory_first_child;
- state = 1;
- }
- if (!obj && state == 1) {
- obj = parent->io_first_child;
- state = 2;
- }
- if (!obj && state == 2) {
- obj = parent->misc_first_child;
- state = 3;
- }
- return obj;
-}
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_helper_find_cache Looking at Cache Objects
- * @{
- */
-
-/** \brief Find the depth of cache objects matching cache level and type.
- *
- * Return the depth of the topology level that contains cache objects
- * whose attributes match \p cachelevel and \p cachetype.
-
- * This function is identical to calling hwloc_get_type_depth() with the
- * corresponding type such as ::HWLOC_OBJ_L1ICACHE, except that it may
- * also return a Unified cache when looking for an instruction cache.
- *
- * \return the depth of the unique matching unified cache level is returned
- * if \p cachetype is ::HWLOC_OBJ_CACHE_UNIFIED.
- *
- * \return the depth of either a matching cache level or a unified cache level
- * if \p cachetype is ::HWLOC_OBJ_CACHE_DATA or ::HWLOC_OBJ_CACHE_INSTRUCTION.
- *
- * \return the depth of the matching level
- * if \p cachetype is \c -1 but only one level matches.
- *
- * \return ::HWLOC_TYPE_DEPTH_MULTIPLE
- * if \p cachetype is \c -1 but multiple levels match.
- *
- * \return ::HWLOC_TYPE_DEPTH_UNKNOWN if no cache level matches.
- */
-static __hwloc_inline int
-hwloc_get_cache_type_depth (hwloc_topology_t topology,
- unsigned cachelevel, hwloc_obj_cache_type_t cachetype)
-{
- int depth;
- int found = HWLOC_TYPE_DEPTH_UNKNOWN;
- for (depth=0; ; depth++) {
- hwloc_obj_t obj = hwloc_get_obj_by_depth(topology, depth, 0);
- if (!obj)
- break;
- if (!hwloc_obj_type_is_dcache(obj->type) || obj->attr->cache.depth != cachelevel)
- /* doesn't match, try next depth */
- continue;
- if (cachetype == (hwloc_obj_cache_type_t) -1) {
- if (found != HWLOC_TYPE_DEPTH_UNKNOWN) {
- /* second match, return MULTIPLE */
- return HWLOC_TYPE_DEPTH_MULTIPLE;
- }
- /* first match, mark it as found */
- found = depth;
- continue;
- }
- if (obj->attr->cache.type == cachetype || obj->attr->cache.type == HWLOC_OBJ_CACHE_UNIFIED)
- /* exact match (either unified is alone, or we match instruction or data), return immediately */
- return depth;
- }
- /* went to the bottom, return what we found */
- return found;
-}
-
-/** \brief Get the first data (or unified) cache covering a cpuset \p set
- *
- * \return a covering cache, or \c NULL if no cache matches.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_cache_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_cache_covering_cpuset (hwloc_topology_t topology, hwloc_const_cpuset_t set)
-{
- hwloc_obj_t current = hwloc_get_obj_covering_cpuset(topology, set);
- while (current) {
- if (hwloc_obj_type_is_dcache(current->type))
- return current;
- current = current->parent;
- }
- return NULL;
-}
-
-/** \brief Get the first data (or unified) cache shared between an object and somebody else.
- *
- * \return a shared cache.
- * \return \c NULL if no cache matches or if an invalid object is given (e.g. I/O object).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_shared_cache_covering_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_shared_cache_covering_obj (hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj)
-{
- hwloc_obj_t current = obj->parent;
- if (!obj->cpuset)
- return NULL;
- while (current) {
- if (!hwloc_bitmap_isequal(current->cpuset, obj->cpuset)
- && hwloc_obj_type_is_dcache(current->type))
- return current;
- current = current->parent;
- }
- return NULL;
-}
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_helper_find_misc Finding objects, miscellaneous helpers
- * @{
- *
- * Be sure to see the figure in \ref termsanddefs that shows a
- * complete topology tree, including depths, child/sibling/cousin
- * relationships, and an example of an asymmetric topology where one
- * package has fewer caches than its peers.
- */
-
-/** \brief Remove simultaneous multithreading PUs from a CPU set.
- *
- * For each core in \p topology, if \p cpuset contains some PUs of that core,
- * modify \p cpuset to only keep a single PU for that core.
- *
- * \p which specifies which PU will be kept.
- * PU are considered in physical index order.
- * If 0, for each core, the function keeps the first PU that was originally set in \p cpuset.
- *
- * If \p which is larger than the number of PUs in a core there were originally set in \p cpuset,
- * no PU is kept for that core.
- *
- * \return 0.
- *
- * \note PUs that are not below a Core object are ignored
- * (for instance if the topology does not contain any Core object).
- * None of them is removed from \p cpuset.
- */
-HWLOC_DECLSPEC int hwloc_bitmap_singlify_per_core(hwloc_topology_t topology, hwloc_bitmap_t cpuset, unsigned which);
-
-/** \brief Returns the object of type ::HWLOC_OBJ_PU with \p os_index.
- *
- * This function is useful for converting a CPU set into the PU
- * objects it contains.
- * When retrieving the current binding (e.g. with hwloc_get_cpubind()),
- * one may iterate over the bits of the resulting CPU set with
- * hwloc_bitmap_foreach_begin(), and find the corresponding PUs
- * with this function.
- *
- * \return the PU object, or \c NULL if none matches.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_pu_obj_by_os_index(hwloc_topology_t topology, unsigned os_index) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_pu_obj_by_os_index(hwloc_topology_t topology, unsigned os_index)
-{
- hwloc_obj_t obj = NULL;
- while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_PU, obj)) != NULL)
- if (obj->os_index == os_index)
- return obj;
- return NULL;
-}
-
-/** \brief Returns the object of type ::HWLOC_OBJ_NUMANODE with \p os_index.
- *
- * This function is useful for converting a nodeset into the NUMA node
- * objects it contains.
- * When retrieving the current binding (e.g. with hwloc_get_membind() with HWLOC_MEMBIND_BYNODESET),
- * one may iterate over the bits of the resulting nodeset with
- * hwloc_bitmap_foreach_begin(), and find the corresponding NUMA nodes
- * with this function.
- *
- * \return the NUMA node object, or \c NULL if none matches.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_numanode_obj_by_os_index(hwloc_topology_t topology, unsigned os_index) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_numanode_obj_by_os_index(hwloc_topology_t topology, unsigned os_index)
-{
- hwloc_obj_t obj = NULL;
- while ((obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_NUMANODE, obj)) != NULL)
- if (obj->os_index == os_index)
- return obj;
- return NULL;
-}
-
-/** \brief Do a depth-first traversal of the topology to find and sort
- *
- * all objects that are at the same depth than \p src.
- * Report in \p objs up to \p max physically closest ones to \p src.
- *
- * \return the number of objects returned in \p objs.
- *
- * \return 0 if \p src is an I/O object.
- *
- * \note This function requires the \p src object to have a CPU set.
- */
-/* TODO: rather provide an iterator? Provide a way to know how much should be allocated? By returning the total number of objects instead? */
-HWLOC_DECLSPEC unsigned hwloc_get_closest_objs (hwloc_topology_t topology, hwloc_obj_t src, hwloc_obj_t * __hwloc_restrict objs, unsigned max);
-
-/** \brief Find an object below another object, both specified by types and indexes.
- *
- * Start from the top system object and find object of type \p type1
- * and logical index \p idx1. Then look below this object and find another
- * object of type \p type2 and logical index \p idx2. Indexes are specified
- * within the parent, not withing the entire system.
- *
- * For instance, if type1 is PACKAGE, idx1 is 2, type2 is CORE and idx2
- * is 3, return the fourth core object below the third package.
- *
- * \return a matching object if any, \c NULL otherwise.
- *
- * \note This function requires these objects to have a CPU set.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_below_by_type (hwloc_topology_t topology,
- hwloc_obj_type_t type1, unsigned idx1,
- hwloc_obj_type_t type2, unsigned idx2) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_below_by_type (hwloc_topology_t topology,
- hwloc_obj_type_t type1, unsigned idx1,
- hwloc_obj_type_t type2, unsigned idx2)
-{
- hwloc_obj_t obj;
- obj = hwloc_get_obj_by_type (topology, type1, idx1);
- if (!obj)
- return NULL;
- return hwloc_get_obj_inside_cpuset_by_type(topology, obj->cpuset, type2, idx2);
-}
-
-/** \brief Find an object below a chain of objects specified by types and indexes.
- *
- * This is a generalized version of hwloc_get_obj_below_by_type().
- *
- * Arrays \p typev and \p idxv must contain \p nr types and indexes.
- *
- * Start from the top system object and walk the arrays \p typev and \p idxv.
- * For each type and logical index couple in the arrays, look under the previously found
- * object to find the index-th object of the given type.
- * Indexes are specified within the parent, not withing the entire system.
- *
- * For instance, if nr is 3, typev contains NODE, PACKAGE and CORE,
- * and idxv contains 0, 1 and 2, return the third core object below
- * the second package below the first NUMA node.
- *
- * \return a matching object if any, \c NULL otherwise.
- *
- * \note This function requires all these objects and the root object
- * to have a CPU set.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_below_array_by_type (hwloc_topology_t topology, int nr, hwloc_obj_type_t *typev, unsigned *idxv) __hwloc_attribute_pure;
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_below_array_by_type (hwloc_topology_t topology, int nr, hwloc_obj_type_t *typev, unsigned *idxv)
-{
- hwloc_obj_t obj = hwloc_get_root_obj(topology);
- int i;
- for(i=0; i<nr; i++) {
- if (!obj)
- return NULL;
- obj = hwloc_get_obj_inside_cpuset_by_type(topology, obj->cpuset, typev[i], idxv[i]);
- }
- return obj;
-}
-
-/** \brief Return an object of a different type with same locality.
- *
- * If the source object \p src is a normal or memory type,
- * this function returns an object of type \p type with same
- * CPU and node sets, either below or above in the hierarchy.
- *
- * If the source object \p src is a PCI or an OS device within a PCI
- * device, the function may either return that PCI device, or another
- * OS device in the same PCI parent.
- * This may for instance be useful for converting between OS devices
- * such as "nvml0" or "rsmi1" used in distance structures into the
- * the PCI device, or the CUDA or OpenCL OS device that correspond
- * to the same physical card.
- *
- * If not \c NULL, parameter \p subtype only select objects whose
- * subtype attribute exists and is \p subtype (case-insensitively),
- * for instance "OpenCL" or "CUDA".
- *
- * If not \c NULL, parameter \p nameprefix only selects objects whose
- * name attribute exists and starts with \p nameprefix (case-insensitively),
- * for instance "rsmi" for matching "rsmi0".
- *
- * If multiple objects match, the first one is returned.
- *
- * This function will not walk the hierarchy across bridges since
- * the PCI locality may become different.
- * This function cannot also convert between normal/memory objects
- * and I/O or Misc objects.
- *
- * \p flags must be \c 0 for now.
- *
- * \return An object with identical locality,
- * matching \p subtype and \p nameprefix if any.
- *
- * \return \c NULL if no matching object could be found,
- * or if the source object and target type are incompatible,
- * for instance if converting between CPU and I/O objects.
- */
-HWLOC_DECLSPEC hwloc_obj_t
-hwloc_get_obj_with_same_locality(hwloc_topology_t topology, hwloc_obj_t src,
- hwloc_obj_type_t type, const char *subtype, const char *nameprefix,
- unsigned long flags);
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_helper_distribute Distributing items over a topology
- * @{
- */
-
-/** \brief Flags to be given to hwloc_distrib().
- */
-enum hwloc_distrib_flags_e {
- /** \brief Distrib in reverse order, starting from the last objects.
- * \hideinitializer
- */
- HWLOC_DISTRIB_FLAG_REVERSE = (1UL<<0)
-};
-
-/** \brief Distribute \p n items over the topology under \p roots
- *
- * Array \p set will be filled with \p n cpusets recursively distributed
- * linearly over the topology under objects \p roots, down to depth \p until
- * (which can be INT_MAX to distribute down to the finest level).
- *
- * \p n_roots is usually 1 and \p roots only contains the topology root object
- * so as to distribute over the entire topology.
- *
- * This is typically useful when an application wants to distribute \p n
- * threads over a machine, giving each of them as much private cache as
- * possible and keeping them locally in number order.
- *
- * The caller may typically want to also call hwloc_bitmap_singlify()
- * before binding a thread so that it does not move at all.
- *
- * \p flags should be 0 or a OR'ed set of ::hwloc_distrib_flags_e.
- *
- * \return 0 on success, -1 on error.
- *
- * \note On hybrid CPUs (or asymmetric platforms), distribution may be suboptimal
- * since the number of cores or PUs inside packages or below caches may vary
- * (the top-down recursive partitioning ignores these numbers until reaching their levels).
- * Hence it is recommended to distribute only inside a single homogeneous domain.
- * For instance on a CPU with energy-efficient E-cores and high-performance P-cores,
- * one should distribute separately N tasks on E-cores and M tasks on P-cores
- * instead of trying to distribute directly M+N tasks on the entire CPUs.
- *
- * \note This function requires the \p roots objects to have a CPU set.
- */
-static __hwloc_inline int
-hwloc_distrib(hwloc_topology_t topology,
- hwloc_obj_t *roots, unsigned n_roots,
- hwloc_cpuset_t *set,
- unsigned n,
- int until, unsigned long flags)
-{
- unsigned i;
- unsigned tot_weight;
- unsigned given, givenweight;
- hwloc_cpuset_t *cpusetp = set;
-
- if (!n || (flags & ~HWLOC_DISTRIB_FLAG_REVERSE)) {
- errno = EINVAL;
- return -1;
- }
-
- tot_weight = 0;
- for (i = 0; i < n_roots; i++)
- tot_weight += (unsigned) hwloc_bitmap_weight(roots[i]->cpuset);
-
- for (i = 0, given = 0, givenweight = 0; i < n_roots; i++) {
- unsigned chunk, weight;
- hwloc_obj_t root = roots[flags & HWLOC_DISTRIB_FLAG_REVERSE ? n_roots-1-i : i];
- hwloc_cpuset_t cpuset = root->cpuset;
- while (!hwloc_obj_type_is_normal(root->type))
- /* If memory/io/misc, walk up to normal parent */
- root = root->parent;
- weight = (unsigned) hwloc_bitmap_weight(cpuset);
- if (!weight)
- continue;
- /* Give to root a chunk proportional to its weight.
- * If previous chunks got rounded-up, we may get a bit less. */
- chunk = (( (givenweight+weight) * n + tot_weight-1) / tot_weight)
- - (( givenweight * n + tot_weight-1) / tot_weight);
- if (!root->arity || chunk <= 1 || root->depth >= until) {
- /* We can't split any more, put everything there. */
- if (chunk) {
- /* Fill cpusets with ours */
- unsigned j;
- for (j=0; j < chunk; j++)
- cpusetp[j] = hwloc_bitmap_dup(cpuset);
- } else {
- /* We got no chunk, just merge our cpuset to a previous one
- * (the first chunk cannot be empty)
- * so that this root doesn't get ignored.
- */
- assert(given);
- hwloc_bitmap_or(cpusetp[-1], cpusetp[-1], cpuset);
- }
- } else {
- /* Still more to distribute, recurse into children */
- hwloc_distrib(topology, root->children, root->arity, cpusetp, chunk, until, flags);
- }
- cpusetp += chunk;
- given += chunk;
- givenweight += weight;
- }
-
- return 0;
-}
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_helper_topology_sets CPU and node sets of entire topologies
- * @{
- */
-
-/** \brief Get complete CPU set
- *
- * \return the complete CPU set of processors of the system.
- *
- * \note This function cannot return \c NULL.
- *
- * \note The returned cpuset is not newly allocated and should thus not be
- * changed or freed; hwloc_bitmap_dup() must be used to obtain a local copy.
- *
- * \note This is equivalent to retrieving the root object complete CPU-set.
- */
-HWLOC_DECLSPEC hwloc_const_cpuset_t
-hwloc_topology_get_complete_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
-
-/** \brief Get topology CPU set
- *
- * \return the CPU set of processors of the system for which hwloc
- * provides topology information. This is equivalent to the cpuset of the
- * system object.
- *
- * \note This function cannot return \c NULL.
- *
- * \note The returned cpuset is not newly allocated and should thus not be
- * changed or freed; hwloc_bitmap_dup() must be used to obtain a local copy.
- *
- * \note This is equivalent to retrieving the root object CPU-set.
- */
-HWLOC_DECLSPEC hwloc_const_cpuset_t
-hwloc_topology_get_topology_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
-
-/** \brief Get allowed CPU set
- *
- * \return the CPU set of allowed processors of the system.
- *
- * \note This function cannot return \c NULL.
- *
- * \note If the topology flag ::HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED was not set,
- * this is identical to hwloc_topology_get_topology_cpuset(), which means
- * all PUs are allowed.
- *
- * \note If ::HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED was set, applying
- * hwloc_bitmap_intersects() on the result of this function and on an object
- * cpuset checks whether there are allowed PUs inside that object.
- * Applying hwloc_bitmap_and() returns the list of these allowed PUs.
- *
- * \note The returned cpuset is not newly allocated and should thus not be
- * changed or freed, hwloc_bitmap_dup() must be used to obtain a local copy.
- */
-HWLOC_DECLSPEC hwloc_const_cpuset_t
-hwloc_topology_get_allowed_cpuset(hwloc_topology_t topology) __hwloc_attribute_pure;
-
-/** \brief Get complete node set
- *
- * \return the complete node set of memory of the system.
- *
- * \note This function cannot return \c NULL.
- *
- * \note The returned nodeset is not newly allocated and should thus not be
- * changed or freed; hwloc_bitmap_dup() must be used to obtain a local copy.
- *
- * \note This is equivalent to retrieving the root object complete nodeset.
- */
-HWLOC_DECLSPEC hwloc_const_nodeset_t
-hwloc_topology_get_complete_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
-
-/** \brief Get topology node set
- *
- * \return the node set of memory of the system for which hwloc
- * provides topology information. This is equivalent to the nodeset of the
- * system object.
- *
- * \note This function cannot return \c NULL.
- *
- * \note The returned nodeset is not newly allocated and should thus not be
- * changed or freed; hwloc_bitmap_dup() must be used to obtain a local copy.
- *
- * \note This is equivalent to retrieving the root object nodeset.
- */
-HWLOC_DECLSPEC hwloc_const_nodeset_t
-hwloc_topology_get_topology_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
-
-/** \brief Get allowed node set
- *
- * \return the node set of allowed memory of the system.
- *
- * \note This function cannot return \c NULL.
- *
- * \note If the topology flag ::HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED was not set,
- * this is identical to hwloc_topology_get_topology_nodeset(), which means
- * all NUMA nodes are allowed.
- *
- * \note If ::HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED was set, applying
- * hwloc_bitmap_intersects() on the result of this function and on an object
- * nodeset checks whether there are allowed NUMA nodes inside that object.
- * Applying hwloc_bitmap_and() returns the list of these allowed NUMA nodes.
- *
- * \note The returned nodeset is not newly allocated and should thus not be
- * changed or freed, hwloc_bitmap_dup() must be used to obtain a local copy.
- */
-HWLOC_DECLSPEC hwloc_const_nodeset_t
-hwloc_topology_get_allowed_nodeset(hwloc_topology_t topology) __hwloc_attribute_pure;
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_helper_nodeset_convert Converting between CPU sets and node sets
- *
- * @{
- */
-
-/** \brief Convert a CPU set into a NUMA node set
- *
- * For each PU included in the input \p _cpuset, set the corresponding
- * local NUMA node(s) in the output \p nodeset.
- *
- * If some NUMA nodes have no CPUs at all, this function never sets their
- * indexes in the output node set, even if a full CPU set is given in input.
- *
- * Hence the entire topology CPU set is converted into the set of all nodes
- * that have some local CPUs.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c ENOMEM on internal reallocation failure.
- */
-static __hwloc_inline int
-hwloc_cpuset_to_nodeset(hwloc_topology_t topology, hwloc_const_cpuset_t _cpuset, hwloc_nodeset_t nodeset)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- hwloc_obj_t obj = NULL;
- assert(depth != HWLOC_TYPE_DEPTH_UNKNOWN);
- hwloc_bitmap_zero(nodeset);
- while ((obj = hwloc_get_next_obj_covering_cpuset_by_depth(topology, _cpuset, depth, obj)) != NULL)
- if (hwloc_bitmap_set(nodeset, obj->os_index) < 0)
- return -1;
- return 0;
-}
-
-/** \brief Convert a NUMA node set into a CPU set
- *
- * For each NUMA node included in the input \p nodeset, set the corresponding
- * local PUs in the output \p _cpuset.
- *
- * If some CPUs have no local NUMA nodes, this function never sets their
- * indexes in the output CPU set, even if a full node set is given in input.
- *
- * Hence the entire topology node set is converted into the set of all CPUs
- * that have some local NUMA nodes.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c ENOMEM on internal reallocation failure.
- */
-static __hwloc_inline int
-hwloc_cpuset_from_nodeset(hwloc_topology_t topology, hwloc_cpuset_t _cpuset, hwloc_const_nodeset_t nodeset)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- hwloc_obj_t obj = NULL;
- assert(depth != HWLOC_TYPE_DEPTH_UNKNOWN);
- hwloc_bitmap_zero(_cpuset);
- while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) {
- if (hwloc_bitmap_isset(nodeset, obj->os_index))
- /* no need to check obj->cpuset because objects in levels always have a cpuset */
- if (hwloc_bitmap_or(_cpuset, _cpuset, obj->cpuset) < 0)
- return -1;
- }
- return 0;
-}
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_advanced_io Finding I/O objects
- * @{
- */
-
-/** \brief Get the first non-I/O ancestor object.
- *
- * Given the I/O object \p ioobj, find the smallest non-I/O ancestor
- * object. This object (normal or memory) may then be used for binding
- * because it has non-NULL CPU and node sets
- * and because its locality is the same as \p ioobj.
- *
- * \return a non-I/O object.
- *
- * \note This function cannot return \c NULL.
- *
- * \note The resulting object is usually a normal object but it could also
- * be a memory object (e.g. NUMA node) in future platforms if I/O objects
- * ever get attached to memory instead of CPUs.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_non_io_ancestor_obj(hwloc_topology_t topology __hwloc_attribute_unused,
- hwloc_obj_t ioobj)
-{
- hwloc_obj_t obj = ioobj;
- while (obj && !obj->cpuset) {
- obj = obj->parent;
- }
- return obj;
-}
-
-/** \brief Get the next PCI device in the system.
- *
- * \return the first PCI device if \p prev is \c NULL.
- * \return the next PCI device if \p prev is not \c NULL.
- * \return \c NULL if there is no next PCI device.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_pcidev(hwloc_topology_t topology, hwloc_obj_t prev)
-{
- return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_PCI_DEVICE, prev);
-}
-
-/** \brief Find the PCI device object matching the PCI bus id
- * given domain, bus device and function PCI bus id.
- *
- * \return a matching PCI device object if any, \c NULL otherwise.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_pcidev_by_busid(hwloc_topology_t topology,
- unsigned domain, unsigned bus, unsigned dev, unsigned func)
-{
- hwloc_obj_t obj = NULL;
- while ((obj = hwloc_get_next_pcidev(topology, obj)) != NULL) {
- if (obj->attr->pcidev.domain == domain
- && obj->attr->pcidev.bus == bus
- && obj->attr->pcidev.dev == dev
- && obj->attr->pcidev.func == func)
- return obj;
- }
- return NULL;
-}
-
-/** \brief Find the PCI device object matching the PCI bus id
- * given as a string xxxx:yy:zz.t or yy:zz.t.
- *
- * \return a matching PCI device object if any, \c NULL otherwise.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_pcidev_by_busidstring(hwloc_topology_t topology, const char *busid)
-{
- unsigned domain = 0; /* default */
- unsigned bus, dev, func;
-
- if (sscanf(busid, "%x:%x.%x", &bus, &dev, &func) != 3
- && sscanf(busid, "%x:%x:%x.%x", &domain, &bus, &dev, &func) != 4) {
- errno = EINVAL;
- return NULL;
- }
-
- return hwloc_get_pcidev_by_busid(topology, domain, bus, dev, func);
-}
-
-/** \brief Get the next OS device in the system.
- *
- * \return the first OS device if \p prev is \c NULL.
- * \return the next OS device if \p prev is not \c NULL.
- * \return \c NULL if there is no next OS device.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_osdev(hwloc_topology_t topology, hwloc_obj_t prev)
-{
- return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_OS_DEVICE, prev);
-}
-
-/** \brief Get the next bridge in the system.
- *
- * \return the first bridge if \p prev is \c NULL.
- * \return the next bridge if \p prev is not \c NULL.
- * \return \c NULL if there is no next bridge.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_bridge(hwloc_topology_t topology, hwloc_obj_t prev)
-{
- return hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_BRIDGE, prev);
-}
-
-/* \brief Checks whether a given bridge covers a given PCI bus.
- *
- * \return 1 if it covers, 0 if not.
- */
-static __hwloc_inline int
-hwloc_bridge_covers_pcibus(hwloc_obj_t bridge,
- unsigned domain, unsigned bus)
-{
- return bridge->type == HWLOC_OBJ_BRIDGE
- && bridge->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI
- && bridge->attr->bridge.downstream.pci.domain == domain
- && bridge->attr->bridge.downstream.pci.secondary_bus <= bus
- && bridge->attr->bridge.downstream.pci.subordinate_bus >= bus;
-}
-
-/** @} */
-
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_HELPER_H */
### src/3rdparty/hwloc/include/hwloc/inlines.h
@@ -1,146 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2018 Inria. All rights reserved.
- * Copyright © 2009-2012 Université Bordeaux
- * Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/**
- * This file contains the inline code of functions declared in hwloc.h
- */
-
-#ifndef HWLOC_INLINES_H
-#define HWLOC_INLINES_H
-
-#ifndef HWLOC_H
-#error Please include the main hwloc.h instead
-#endif
-
-#include <stdlib.h>
-#include <errno.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static __hwloc_inline int
-hwloc_get_type_or_below_depth (hwloc_topology_t topology, hwloc_obj_type_t type)
-{
- int depth = hwloc_get_type_depth(topology, type);
-
- if (depth != HWLOC_TYPE_DEPTH_UNKNOWN)
- return depth;
-
- /* find the highest existing level with type order >= */
- for(depth = hwloc_get_type_depth(topology, HWLOC_OBJ_PU); ; depth--)
- if (hwloc_compare_types(hwloc_get_depth_type(topology, depth), type) < 0)
- return depth+1;
-
- /* Shouldn't ever happen, as there is always a Machine level with lower order and known depth. */
- /* abort(); */
-}
-
-static __hwloc_inline int
-hwloc_get_type_or_above_depth (hwloc_topology_t topology, hwloc_obj_type_t type)
-{
- int depth = hwloc_get_type_depth(topology, type);
-
- if (depth != HWLOC_TYPE_DEPTH_UNKNOWN)
- return depth;
-
- /* find the lowest existing level with type order <= */
- for(depth = 0; ; depth++)
- if (hwloc_compare_types(hwloc_get_depth_type(topology, depth), type) > 0)
- return depth-1;
-
- /* Shouldn't ever happen, as there is always a PU level with higher order and known depth. */
- /* abort(); */
-}
-
-static __hwloc_inline int
-hwloc_get_nbobjs_by_type (hwloc_topology_t topology, hwloc_obj_type_t type)
-{
- int depth = hwloc_get_type_depth(topology, type);
- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
- return 0;
- if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
- return -1; /* FIXME: agregate nbobjs from different levels? */
- return (int) hwloc_get_nbobjs_by_depth(topology, depth);
-}
-
-static __hwloc_inline hwloc_obj_t
-hwloc_get_obj_by_type (hwloc_topology_t topology, hwloc_obj_type_t type, unsigned idx)
-{
- int depth = hwloc_get_type_depth(topology, type);
- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
- return NULL;
- if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
- return NULL;
- return hwloc_get_obj_by_depth(topology, depth, idx);
-}
-
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_obj_by_depth (hwloc_topology_t topology, int depth, hwloc_obj_t prev)
-{
- if (!prev)
- return hwloc_get_obj_by_depth (topology, depth, 0);
- if (prev->depth != depth)
- return NULL;
- return prev->next_cousin;
-}
-
-static __hwloc_inline hwloc_obj_t
-hwloc_get_next_obj_by_type (hwloc_topology_t topology, hwloc_obj_type_t type,
- hwloc_obj_t prev)
-{
- int depth = hwloc_get_type_depth(topology, type);
- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
- return NULL;
- return hwloc_get_next_obj_by_depth (topology, depth, prev);
-}
-
-static __hwloc_inline hwloc_obj_t
-hwloc_get_root_obj (hwloc_topology_t topology)
-{
- return hwloc_get_obj_by_depth (topology, 0, 0);
-}
-
-static __hwloc_inline const char *
-hwloc_obj_get_info_by_name(hwloc_obj_t obj, const char *name)
-{
- unsigned i;
- for(i=0; i<obj->infos_count; i++) {
- struct hwloc_info_s *info = &obj->infos[i];
- if (!strcmp(info->name, name))
- return info->value;
- }
- return NULL;
-}
-
-static __hwloc_inline void *
-hwloc_alloc_membind_policy(hwloc_topology_t topology, size_t len, hwloc_const_cpuset_t set, hwloc_membind_policy_t policy, int flags)
-{
- void *p = hwloc_alloc_membind(topology, len, set, policy, flags);
- if (p)
- return p;
-
- if (hwloc_set_membind(topology, set, policy, flags) < 0)
- /* hwloc_set_membind() takes care of ignoring errors if non-STRICT */
- return NULL;
-
- p = hwloc_alloc(topology, len);
- if (p && policy != HWLOC_MEMBIND_FIRSTTOUCH)
- /* Enforce the binding by touching the data */
- memset(p, 0, len);
- return p;
-}
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_INLINES_H */
### src/3rdparty/hwloc/include/hwloc/levelzero.h
@@ -1,298 +0,0 @@
-/*
- * Copyright © 2021-2024 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and the oneAPI Level Zero interface.
- *
- * Applications that use both hwloc and Level Zero may want to
- * include this file so as to get topology information for L0 devices.
- */
-
-#ifndef HWLOC_LEVELZERO_H
-#define HWLOC_LEVELZERO_H
-
-#include "hwloc.h"
-#include "hwloc/autogen/config.h"
-#include "hwloc/helper.h"
-#ifdef HWLOC_LINUX_SYS
-#include "hwloc/linux.h"
-#endif
-
-#include <level_zero/ze_api.h>
-#include <level_zero/zes_api.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_levelzero Interoperability with the oneAPI Level Zero interface.
- *
- * This interface offers ways to retrieve topology information about
- * devices managed by the Level Zero API, both for main Core devices (ZE API)
- * and the Sysman devices (ZES API).
- *
- * @{
- */
-
-/** \brief Get the CPU set of logical processors that are physically
- * close to the Level Zero device \p device
- *
- * Store in \p set the CPU-set describing the locality of
- * the Level Zero device \p device.
- *
- * Topology \p topology and device \p device must match the local machine.
- * The Level Zero library must have been initialized with zeInit().
- * I/O devices detection and the Level Zero component are not needed in the
- * topology.
- *
- * The function only returns the locality of the device.
- * If more information about the device is needed, OS objects should
- * be used instead, see hwloc_levelzero_get_device_osdev().
- *
- * This function is currently only implemented in a meaningful way for
- * Linux; other systems will simply get a full cpuset.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- *
- * \note zeDevicePciGetPropertiesExt() must be supported, or the entire machine
- * locality will be returned.
- */
-static __hwloc_inline int
-hwloc_levelzero_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
- ze_device_handle_t device, hwloc_cpuset_t set)
-{
-#ifdef HWLOC_LINUX_SYS
- /* If we're on Linux, use the sysfs mechanism to get the local cpus */
-#define HWLOC_LEVELZERO_DEVICE_SYSFS_PATH_MAX 128
- char path[HWLOC_LEVELZERO_DEVICE_SYSFS_PATH_MAX];
- ze_pci_ext_properties_t pci;
- ze_result_t res;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return -1;
- }
-
- pci.stype = ZE_STRUCTURE_TYPE_PCI_EXT_PROPERTIES;
- pci.pNext = NULL;
- res = zeDevicePciGetPropertiesExt(device, &pci);
- if (res != ZE_RESULT_SUCCESS) {
- errno = EINVAL;
- return -1;
- }
-
- sprintf(path, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/local_cpus",
- pci.address.domain, pci.address.bus, pci.address.device, pci.address.function);
- if (hwloc_linux_read_path_as_cpumask(path, set) < 0
- || hwloc_bitmap_iszero(set))
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#else
- /* Non-Linux systems simply get a full cpuset */
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#endif
- return 0;
-}
-
-/** \brief Get the CPU set of logical processors that are physically
- * close to the Level Zero Sysman device \p device
- *
- * Store in \p set the CPU-set describing the locality of
- * the Level Zero device \p device.
- *
- * Topology \p topology and device \p device must match the local machine.
- * The Level Zero library must have been initialized with Sysman enabled
- * with zesInit().
- * I/O devices detection and the Level Zero component are not needed in the
- * topology.
- *
- * The function only returns the locality of the device.
- * If more information about the device is needed, OS objects should
- * be used instead, see hwloc_levelzero_get_device_osdev().
- *
- * This function is currently only implemented in a meaningful way for
- * Linux; other systems will simply get a full cpuset.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_levelzero_get_sysman_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
- zes_device_handle_t device, hwloc_cpuset_t set)
-{
-#ifdef HWLOC_LINUX_SYS
- /* If we're on Linux, use the sysfs mechanism to get the local cpus */
-#define HWLOC_LEVELZERO_DEVICE_SYSFS_PATH_MAX 128
- char path[HWLOC_LEVELZERO_DEVICE_SYSFS_PATH_MAX];
- zes_pci_properties_t pci;
- ze_result_t res;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return -1;
- }
-
- res = zesDevicePciGetProperties(device, &pci);
- if (res != ZE_RESULT_SUCCESS) {
- errno = EINVAL;
- return -1;
- }
-
- sprintf(path, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/local_cpus",
- pci.address.domain, pci.address.bus, pci.address.device, pci.address.function);
- if (hwloc_linux_read_path_as_cpumask(path, set) < 0
- || hwloc_bitmap_iszero(set))
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#else
- /* Non-Linux systems simply get a full cpuset */
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#endif
- return 0;
-}
-
-/** \brief Get the hwloc OS device object corresponding to Level Zero device
- * \p device.
- *
- * \return The hwloc OS device object that describes the given Level Zero device \p device.
- * \return \c NULL if none could be found.
- *
- * Topology \p topology and device \p dv_ind must match the local machine.
- * The Level Zero library must have been initialized with zeInit().
- * I/O devices detection and the Level Zero component must be enabled in the
- * topology. If not, the locality of the object may still be found using
- * hwloc_levelzero_get_device_cpuset().
- *
- * \note If the input ZE device is actually a subdevice, then its parent
- * (root device) is actually translated, i.e. the main hwloc OS device
- * is returned instead of one of its children.
- *
- * \note The corresponding hwloc PCI device may be found by looking
- * at the result parent pointer (unless PCI devices are filtered out).
- *
- * \note zeDevicePciGetPropertiesExt() must be supported.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_levelzero_get_device_osdev(hwloc_topology_t topology, ze_device_handle_t device)
-{
- ze_pci_ext_properties_t pci;
- ze_result_t res;
- hwloc_obj_t osdev;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return NULL;
- }
-
- pci.stype = ZE_STRUCTURE_TYPE_PCI_EXT_PROPERTIES;
- pci.pNext = NULL;
- res = zeDevicePciGetPropertiesExt(device, &pci);
- if (res != ZE_RESULT_SUCCESS) {
- errno = EINVAL;
- return NULL;
- }
-
- osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- hwloc_obj_t pcidev;
-
- if (strncmp(osdev->name, "ze", 2))
- continue;
-
- pcidev = osdev;
- while (pcidev && pcidev->type != HWLOC_OBJ_PCI_DEVICE)
- pcidev = pcidev->parent;
- if (!pcidev)
- continue;
-
- if (pcidev
- && pcidev->type == HWLOC_OBJ_PCI_DEVICE
- && pcidev->attr->pcidev.domain == pci.address.domain
- && pcidev->attr->pcidev.bus == pci.address.bus
- && pcidev->attr->pcidev.dev == pci.address.device
- && pcidev->attr->pcidev.func == pci.address.function)
- return osdev;
-
- /* FIXME: when we'll have serialnumber, try it in case PCI is filtered-out */
- }
-
- return NULL;
-}
-
-/** \brief Get the hwloc OS device object corresponding to Level Zero Sysman device
- * \p device.
- *
- * \return The hwloc OS device object that describes the given Level Zero device \p device.
- * \return \c NULL if none could be found.
- *
- * Topology \p topology and device \p dv_ind must match the local machine.
- * The Level Zero library must have been initialized with Sysman enabled
- * with zesInit().
- * I/O devices detection and the Level Zero component must be enabled in the
- * topology. If not, the locality of the object may still be found using
- * hwloc_levelzero_get_device_cpuset().
- *
- * \note If the input ZES device is actually a subdevice, then its parent
- * (root device) is actually translated, i.e. the main hwloc OS device
- * is returned instead of one of its children.
- *
- * \note The corresponding hwloc PCI device may be found by looking
- * at the result parent pointer (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_levelzero_get_sysman_device_osdev(hwloc_topology_t topology, zes_device_handle_t device)
-{
- zes_pci_properties_t pci;
- ze_result_t res;
- hwloc_obj_t osdev;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return NULL;
- }
-
- res = zesDevicePciGetProperties(device, &pci);
- if (res != ZE_RESULT_SUCCESS) {
- errno = EINVAL;
- return NULL;
- }
-
- osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- hwloc_obj_t pcidev;
-
- if (strncmp(osdev->name, "ze", 2))
- continue;
-
- pcidev = osdev;
- while (pcidev && pcidev->type != HWLOC_OBJ_PCI_DEVICE)
- pcidev = pcidev->parent;
- if (!pcidev)
- continue;
-
- if (pcidev
- && pcidev->type == HWLOC_OBJ_PCI_DEVICE
- && pcidev->attr->pcidev.domain == pci.address.domain
- && pcidev->attr->pcidev.bus == pci.address.bus
- && pcidev->attr->pcidev.dev == pci.address.device
- && pcidev->attr->pcidev.func == pci.address.function)
- return osdev;
-
- /* FIXME: when we'll have serialnumber, try it in case PCI is filtered-out */
- }
-
- return NULL;
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_LEVELZERO_H */
### src/3rdparty/hwloc/include/hwloc/linux-libnuma.h
@@ -1,294 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2023 Inria. All rights reserved.
- * Copyright © 2009-2010, 2012 Université Bordeaux
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and Linux libnuma.
- *
- * Applications that use both Linux libnuma and hwloc may want to
- * include this file so as to ease conversion between their respective types.
-*/
-
-#ifndef HWLOC_LINUX_LIBNUMA_H
-#define HWLOC_LINUX_LIBNUMA_H
-
-#include "hwloc.h"
-
-#include <numa.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_linux_libnuma_ulongs Interoperability with Linux libnuma unsigned long masks
- *
- * This interface helps converting between Linux libnuma unsigned long masks
- * and hwloc cpusets and nodesets.
- *
- * \note Topology \p topology must match the current machine.
- *
- * \note The behavior of libnuma is undefined if the kernel is not NUMA-aware.
- * (when CONFIG_NUMA is not set in the kernel configuration).
- * This helper and libnuma may thus not be strictly compatible in this case,
- * which may be detected by checking whether numa_available() returns -1.
- *
- * @{
- */
-
-
-/** \brief Convert hwloc CPU set \p cpuset into the array of unsigned long \p mask
- *
- * \p mask is the array of unsigned long that will be filled.
- * \p maxnode contains the maximal node number that may be stored in \p mask.
- * \p maxnode will be set to the maximal node number that was found, plus one.
- *
- * This function may be used before calling set_mempolicy, mbind, migrate_pages
- * or any other function that takes an array of unsigned long and a maximal
- * node number as input parameter.
- *
- * \return 0.
- */
-static __hwloc_inline int
-hwloc_cpuset_to_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_const_cpuset_t cpuset,
- unsigned long *mask, unsigned long *maxnode)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- unsigned long outmaxnode = -1;
- hwloc_obj_t node = NULL;
-
- /* round-up to the next ulong and clear all bytes */
- *maxnode = (*maxnode + 8*sizeof(*mask) - 1) & ~(8*sizeof(*mask) - 1);
- memset(mask, 0, *maxnode/8);
-
- while ((node = hwloc_get_next_obj_covering_cpuset_by_depth(topology, cpuset, depth, node)) != NULL) {
- if (node->os_index >= *maxnode)
- continue;
- mask[node->os_index/sizeof(*mask)/8] |= 1UL << (node->os_index % (sizeof(*mask)*8));
- if (outmaxnode == (unsigned long) -1 || outmaxnode < node->os_index)
- outmaxnode = node->os_index;
- }
-
- *maxnode = outmaxnode+1;
- return 0;
-}
-
-/** \brief Convert hwloc NUMA node set \p nodeset into the array of unsigned long \p mask
- *
- * \p mask is the array of unsigned long that will be filled.
- * \p maxnode contains the maximal node number that may be stored in \p mask.
- * \p maxnode will be set to the maximal node number that was found, plus one.
- *
- * This function may be used before calling set_mempolicy, mbind, migrate_pages
- * or any other function that takes an array of unsigned long and a maximal
- * node number as input parameter.
- *
- * \return 0.
- */
-static __hwloc_inline int
-hwloc_nodeset_to_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset,
- unsigned long *mask, unsigned long *maxnode)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- unsigned long outmaxnode = -1;
- hwloc_obj_t node = NULL;
-
- /* round-up to the next ulong and clear all bytes */
- *maxnode = (*maxnode + 8*sizeof(*mask) - 1) & ~(8*sizeof(*mask) - 1);
- memset(mask, 0, *maxnode/8);
-
- while ((node = hwloc_get_next_obj_by_depth(topology, depth, node)) != NULL) {
- if (node->os_index >= *maxnode)
- continue;
- if (!hwloc_bitmap_isset(nodeset, node->os_index))
- continue;
- mask[node->os_index/sizeof(*mask)/8] |= 1UL << (node->os_index % (sizeof(*mask)*8));
- if (outmaxnode == (unsigned long) -1 || outmaxnode < node->os_index)
- outmaxnode = node->os_index;
- }
-
- *maxnode = outmaxnode+1;
- return 0;
-}
-
-/** \brief Convert the array of unsigned long \p mask into hwloc CPU set
- *
- * \p mask is a array of unsigned long that will be read.
- * \p maxnode contains the maximal node number that may be read in \p mask.
- *
- * This function may be used after calling get_mempolicy or any other function
- * that takes an array of unsigned long as output parameter (and possibly
- * a maximal node number as input parameter).
- *
- * \return 0 on success.
- * \return -1 on error, for instance if failing an internal reallocation.
- */
-static __hwloc_inline int
-hwloc_cpuset_from_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_cpuset_t cpuset,
- const unsigned long *mask, unsigned long maxnode)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- hwloc_obj_t node = NULL;
- hwloc_bitmap_zero(cpuset);
- while ((node = hwloc_get_next_obj_by_depth(topology, depth, node)) != NULL)
- if (node->os_index < maxnode
- && (mask[node->os_index/sizeof(*mask)/8] & (1UL << (node->os_index % (sizeof(*mask)*8)))))
- if (hwloc_bitmap_or(cpuset, cpuset, node->cpuset) < 0)
- return -1;
- return 0;
-}
-
-/** \brief Convert the array of unsigned long \p mask into hwloc NUMA node set
- *
- * \p mask is a array of unsigned long that will be read.
- * \p maxnode contains the maximal node number that may be read in \p mask.
- *
- * This function may be used after calling get_mempolicy or any other function
- * that takes an array of unsigned long as output parameter (and possibly
- * a maximal node number as input parameter).
- *
- * \return 0 on success.
- * \return -1 with errno set to \c ENOMEM if some internal reallocation failed.
- */
-static __hwloc_inline int
-hwloc_nodeset_from_linux_libnuma_ulongs(hwloc_topology_t topology, hwloc_nodeset_t nodeset,
- const unsigned long *mask, unsigned long maxnode)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- hwloc_obj_t node = NULL;
- hwloc_bitmap_zero(nodeset);
- while ((node = hwloc_get_next_obj_by_depth(topology, depth, node)) != NULL)
- if (node->os_index < maxnode
- && (mask[node->os_index/sizeof(*mask)/8] & (1UL << (node->os_index % (sizeof(*mask)*8)))))
- if (hwloc_bitmap_set(nodeset, node->os_index) < 0)
- return -1;
- return 0;
-}
-
-/** @} */
-
-
-
-/** \defgroup hwlocality_linux_libnuma_bitmask Interoperability with Linux libnuma bitmask
- *
- * This interface helps converting between Linux libnuma bitmasks
- * and hwloc cpusets and nodesets.
- *
- * \note Topology \p topology must match the current machine.
- *
- * \note The behavior of libnuma is undefined if the kernel is not NUMA-aware.
- * (when CONFIG_NUMA is not set in the kernel configuration).
- * This helper and libnuma may thus not be strictly compatible in this case,
- * which may be detected by checking whether numa_available() returns -1.
- *
- * @{
- */
-
-
-/** \brief Convert hwloc CPU set \p cpuset into the returned libnuma bitmask
- *
- * The returned bitmask should later be freed with numa_bitmask_free.
- *
- * This function may be used before calling many numa_ functions
- * that use a struct bitmask as an input parameter.
- *
- * \return newly allocated struct bitmask, or \c NULL on error.
- */
-static __hwloc_inline struct bitmask *
-hwloc_cpuset_to_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_const_cpuset_t cpuset) __hwloc_attribute_malloc;
-static __hwloc_inline struct bitmask *
-hwloc_cpuset_to_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_const_cpuset_t cpuset)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- hwloc_obj_t node = NULL;
- struct bitmask *bitmask = numa_allocate_cpumask();
- if (!bitmask)
- return NULL;
- while ((node = hwloc_get_next_obj_covering_cpuset_by_depth(topology, cpuset, depth, node)) != NULL)
- if (node->attr->numanode.local_memory)
- numa_bitmask_setbit(bitmask, node->os_index);
- return bitmask;
-}
-
-/** \brief Convert hwloc NUMA node set \p nodeset into the returned libnuma bitmask
- *
- * The returned bitmask should later be freed with numa_bitmask_free.
- *
- * This function may be used before calling many numa_ functions
- * that use a struct bitmask as an input parameter.
- *
- * \return newly allocated struct bitmask, or \c NULL on error.
- */
-static __hwloc_inline struct bitmask *
-hwloc_nodeset_to_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset) __hwloc_attribute_malloc;
-static __hwloc_inline struct bitmask *
-hwloc_nodeset_to_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- hwloc_obj_t node = NULL;
- struct bitmask *bitmask = numa_allocate_cpumask();
- if (!bitmask)
- return NULL;
- while ((node = hwloc_get_next_obj_by_depth(topology, depth, node)) != NULL)
- if (hwloc_bitmap_isset(nodeset, node->os_index) && node->attr->numanode.local_memory)
- numa_bitmask_setbit(bitmask, node->os_index);
- return bitmask;
-}
-
-/** \brief Convert libnuma bitmask \p bitmask into hwloc CPU set \p cpuset
- *
- * This function may be used after calling many numa_ functions
- * that use a struct bitmask as an output parameter.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c ENOMEM if some internal reallocation failed.
- */
-static __hwloc_inline int
-hwloc_cpuset_from_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_cpuset_t cpuset,
- const struct bitmask *bitmask)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- hwloc_obj_t node = NULL;
- hwloc_bitmap_zero(cpuset);
- while ((node = hwloc_get_next_obj_by_depth(topology, depth, node)) != NULL)
- if (numa_bitmask_isbitset(bitmask, node->os_index))
- if (hwloc_bitmap_or(cpuset, cpuset, node->cpuset) < 0)
- return -1;
- return 0;
-}
-
-/** \brief Convert libnuma bitmask \p bitmask into hwloc NUMA node set \p nodeset
- *
- * This function may be used after calling many numa_ functions
- * that use a struct bitmask as an output parameter.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c ENOMEM if some internal reallocation failed.
- */
-static __hwloc_inline int
-hwloc_nodeset_from_linux_libnuma_bitmask(hwloc_topology_t topology, hwloc_nodeset_t nodeset,
- const struct bitmask *bitmask)
-{
- int depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NUMANODE);
- hwloc_obj_t node = NULL;
- hwloc_bitmap_zero(nodeset);
- while ((node = hwloc_get_next_obj_by_depth(topology, depth, node)) != NULL)
- if (numa_bitmask_isbitset(bitmask, node->os_index))
- if (hwloc_bitmap_set(nodeset, node->os_index) < 0)
- return -1;
- return 0;
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_LINUX_NUMA_H */
### src/3rdparty/hwloc/include/hwloc/linux.h
@@ -1,95 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2023 Inria. All rights reserved.
- * Copyright © 2009-2011 Université Bordeaux
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and Linux.
- *
- * Applications that use hwloc on Linux may want to include this file
- * if using some low-level Linux features.
- */
-
-#ifndef HWLOC_LINUX_H
-#define HWLOC_LINUX_H
-
-#include "hwloc.h"
-
-#include <stdio.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_linux Linux-specific helpers
- *
- * This includes helpers for manipulating Linux kernel cpumap files, and hwloc
- * equivalents of the Linux sched_setaffinity and sched_getaffinity system calls.
- *
- * @{
- */
-
-/** \brief Bind a thread \p tid on cpus given in cpuset \p set
- *
- * The behavior is exactly the same as the Linux sched_setaffinity system call,
- * but uses a hwloc cpuset.
- *
- * \return 0 on success, -1 on error.
- *
- * \note This is equivalent to calling hwloc_set_proc_cpubind() with
- * HWLOC_CPUBIND_THREAD as flags.
- */
-HWLOC_DECLSPEC int hwloc_linux_set_tid_cpubind(hwloc_topology_t topology, pid_t tid, hwloc_const_cpuset_t set);
-
-/** \brief Get the current binding of thread \p tid
- *
- * The CPU-set \p set (previously allocated by the caller)
- * is filled with the list of PUs which the thread
- * was last bound to.
- *
- * The behavior is exactly the same as the Linux sched_getaffinity system call,
- * but uses a hwloc cpuset.
- *
- * \return 0 on success, -1 on error.
- *
- * \note This is equivalent to calling hwloc_get_proc_cpubind() with
- * ::HWLOC_CPUBIND_THREAD as flags.
- */
-HWLOC_DECLSPEC int hwloc_linux_get_tid_cpubind(hwloc_topology_t topology, pid_t tid, hwloc_cpuset_t set);
-
-/** \brief Get the last physical CPU where thread \p tid ran.
- *
- * The CPU-set \p set (previously allocated by the caller)
- * is filled with the PU which the thread last ran on.
- *
- * \return 0 on success, -1 on error.
- *
- * \note This is equivalent to calling hwloc_get_proc_last_cpu_location() with
- * ::HWLOC_CPUBIND_THREAD as flags.
- */
-HWLOC_DECLSPEC int hwloc_linux_get_tid_last_cpu_location(hwloc_topology_t topology, pid_t tid, hwloc_bitmap_t set);
-
-/** \brief Convert a linux kernel cpumask file \p path into a hwloc bitmap \p set.
- *
- * Might be used when reading CPU set from sysfs attributes such as topology
- * and caches for processors, or local_cpus for devices.
- *
- * \return 0 on success, -1 on error.
- *
- * \note This function ignores the HWLOC_FSROOT environment variable.
- */
-HWLOC_DECLSPEC int hwloc_linux_read_path_as_cpumask(const char *path, hwloc_bitmap_t set);
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_LINUX_H */
### src/3rdparty/hwloc/include/hwloc/memattrs.h
@@ -1,671 +0,0 @@
-/*
- * Copyright © 2019-2025 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Memory node attributes.
- */
-
-#ifndef HWLOC_MEMATTR_H
-#define HWLOC_MEMATTR_H
-
-#include "hwloc.h"
-
-#ifdef __cplusplus
-extern "C" {
-#elif 0
-}
-#endif
-
-/** \defgroup hwlocality_memattrs Comparing memory node attributes for finding where to allocate on
- *
- * Platforms with heterogeneous memory require ways to decide whether
- * a buffer should be allocated on "fast" memory (such as HBM),
- * "normal" memory (DDR) or even "slow" but large-capacity memory
- * (non-volatile memory).
- * These memory nodes are called "Targets" while the CPU accessing them
- * is called the "Initiator". Access performance depends on their
- * locality (NUMA platforms) as well as the intrinsic performance
- * of the targets (heterogeneous platforms).
- *
- * The following attributes describe the performance of memory accesses
- * from an Initiator to a memory Target, for instance their latency
- * or bandwidth.
- * Initiators performing these memory accesses are usually some PUs or Cores
- * (described as a CPU set).
- * Hence a Core may choose where to allocate a memory buffer by comparing
- * the attributes of different target memory nodes nearby.
- *
- * There are also some attributes that are system-wide.
- * Their value does not depend on a specific initiator performing
- * an access.
- * The memory node Capacity is an example of such attribute without
- * initiator.
- *
- * One way to use this API is to start with a cpuset describing the Cores where
- * a program is bound. The best target NUMA node for allocating memory in this
- * program on these Cores may be obtained by passing this cpuset as an initiator
- * to hwloc_memattr_get_best_target() with the relevant memory attribute.
- * For instance, if the code is latency limited, use the Latency attribute.
- *
- * A more flexible approach consists in getting the list of local NUMA nodes
- * by passing this cpuset to hwloc_get_local_numanode_objs().
- * Attribute values for these nodes, if any, may then be obtained with
- * hwloc_memattr_get_value() and manually compared with the desired criteria.
- *
- * Memory attributes are also used internally to build Memory Tiers which provide
- * an easy way to distinguish NUMA nodes of different kinds, as explained
- * in \ref heteromem.
- *
- * Beside tiers, hwloc defines a set of "default" nodes where normal memory
- * allocations should be made from (see hwloc_topology_get_default_nodeset()).
- * This is also useful for dividing the machine into a set of non-overlapping
- * NUMA domains, for instance for binding tasks per domain.
- *
- * \sa An example is available in doc/examples/memory-attributes.c in the source tree.
- *
- * \note The API also supports specific objects as initiator,
- * but it is currently not used internally by hwloc.
- * Users may for instance use it to provide custom performance
- * values for host memory accesses performed by GPUs.
- *
- * \note The interface actually also accepts targets that are not NUMA nodes.
- * @{
- */
-
-/** \brief Predefined memory attribute IDs.
- * See ::hwloc_memattr_id_t for the generic definition of IDs
- * for predefined or custom attributes.
- */
-enum hwloc_memattr_id_e {
- /** \brief
- * The \"Capacity\" is returned in bytes (local_memory attribute in objects).
- *
- * Best capacity nodes are nodes with <b>higher capacity</b>.
- *
- * No initiator is involved when looking at this attribute.
- * The corresponding attribute flags are ::HWLOC_MEMATTR_FLAG_HIGHER_FIRST.
- *
- * Capacity values may not be modified using hwloc_memattr_set_value().
- * \hideinitializer
- */
- HWLOC_MEMATTR_ID_CAPACITY = 0,
-
- /** \brief
- * The \"Locality\" is returned as the number of PUs in that locality
- * (e.g. the weight of its cpuset).
- *
- * Best locality nodes are nodes with <b>smaller locality</b>
- * (nodes that are local to very few PUs).
- * Poor locality nodes are nodes with larger locality
- * (nodes that are local to the entire machine).
- *
- * No initiator is involved when looking at this attribute.
- * The corresponding attribute flags are ::HWLOC_MEMATTR_FLAG_HIGHER_FIRST.
-
- * Locality values may not be modified using hwloc_memattr_set_value().
- * \hideinitializer
- */
- HWLOC_MEMATTR_ID_LOCALITY = 1,
-
- /** \brief
- * The \"Bandwidth\" is returned in MiB/s, as seen from the given initiator location.
- *
- * Best bandwidth nodes are nodes with <b>higher bandwidth</b>.
- *
- * The corresponding attribute flags are ::HWLOC_MEMATTR_FLAG_HIGHER_FIRST
- * and ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR.
- *
- * This is the average bandwidth for read and write accesses. If the platform
- * provides individual read and write bandwidths but no explicit average value,
- * hwloc computes and returns the average.
- * \hideinitializer
- */
- HWLOC_MEMATTR_ID_BANDWIDTH = 2,
-
- /** \brief
- * The \"ReadBandwidth\" is returned in MiB/s, as seen from the given initiator location.
- *
- * Best bandwidth nodes are nodes with <b>higher bandwidth</b>.
- *
- * The corresponding attribute flags are ::HWLOC_MEMATTR_FLAG_HIGHER_FIRST
- * and ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR.
- * \hideinitializer
- */
- HWLOC_MEMATTR_ID_READ_BANDWIDTH = 4,
-
- /** \brief
- * The \"WriteBandwidth\" is returned in MiB/s, as seen from the given initiator location.
- *
- * Best bandwidth nodes are nodes with <b>higher bandwidth</b>.
- *
- * The corresponding attribute flags are ::HWLOC_MEMATTR_FLAG_HIGHER_FIRST
- * and ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR.
- * \hideinitializer
- */
- HWLOC_MEMATTR_ID_WRITE_BANDWIDTH = 5,
-
- /** \brief
- * The \"Latency\" is returned as nanoseconds, as seen from the given initiator location.
- *
- * Best latency nodes are nodes with <b>smaller latency</b>.
- *
- * The corresponding attribute flags are ::HWLOC_MEMATTR_FLAG_LOWER_FIRST
- * and ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR.
- *
- * This is the average latency for read and write accesses. If the platform
- * provides individual read and write latencies but no explicit average value,
- * hwloc computes and returns the average.
- * \hideinitializer
- */
- HWLOC_MEMATTR_ID_LATENCY = 3,
-
- /** \brief
- * The \"ReadLatency\" is returned as nanoseconds, as seen from the given initiator location.
- *
- * Best latency nodes are nodes with <b>smaller latency</b>.
- *
- * The corresponding attribute flags are ::HWLOC_MEMATTR_FLAG_LOWER_FIRST
- * and ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR.
- * \hideinitializer
- */
- HWLOC_MEMATTR_ID_READ_LATENCY = 6,
-
- /** \brief
- * The \"WriteLatency\" is returned as nanoseconds, as seen from the given initiator location.
- *
- * Best latency nodes are nodes with <b>smaller latency</b>.
- *
- * The corresponding attribute flags are ::HWLOC_MEMATTR_FLAG_LOWER_FIRST
- * and ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR.
- * \hideinitializer
- */
- HWLOC_MEMATTR_ID_WRITE_LATENCY = 7,
-
- /* TODO persistence? */
-
- HWLOC_MEMATTR_ID_MAX /**< \private
- * Sentinel value for predefined attributes.
- * Dynamically registered custom attributes start here.
- */
-};
-
-/** \brief A memory attribute identifier.
- *
- * hwloc predefines some commonly-used attributes in ::hwloc_memattr_id_e.
- * One may then dynamically register custom ones with hwloc_memattr_register(),
- * they will be assigned IDs immediately after the predefined ones.
- * See \ref hwlocality_memattrs_manage for more information about
- * existing attribute IDs.
- */
-typedef unsigned hwloc_memattr_id_t;
-
-/** \brief Return the identifier of the memory attribute with the given name.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c EINVAL if no such attribute exists.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_get_by_name(hwloc_topology_t topology,
- const char *name,
- hwloc_memattr_id_t *id);
-
-
-/** \brief Type of location. */
-enum hwloc_location_type_e {
- /** \brief Location is given as a cpuset, in the location cpuset union field. \hideinitializer */
- HWLOC_LOCATION_TYPE_CPUSET = 1,
- /** \brief Location is given as an object, in the location object union field. \hideinitializer */
- HWLOC_LOCATION_TYPE_OBJECT = 0
-};
-
-/** \brief Where to measure attributes from. */
-struct hwloc_location {
- /** \brief Type of location. */
- enum hwloc_location_type_e type;
- /** \brief Actual location. */
- union hwloc_location_u {
- /** \brief Location as a cpuset, when the location type is ::HWLOC_LOCATION_TYPE_CPUSET. */
- hwloc_cpuset_t cpuset;
- /** \brief Location as an object, when the location type is ::HWLOC_LOCATION_TYPE_OBJECT. */
- hwloc_obj_t object;
- } location;
-};
-
-
-/** \brief Flags for selecting target NUMA nodes. */
-enum hwloc_local_numanode_flag_e {
- /** \brief Select NUMA nodes whose locality is larger than the given cpuset.
- * For instance, if a single PU (or its cpuset) is given in \p initiator,
- * select all nodes close to the package that contains this PU.
- * \hideinitializer
- */
- HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY = (1UL<<0),
-
- /** \brief Select NUMA nodes whose locality is smaller than the given cpuset.
- * For instance, if a package (or its cpuset) is given in \p initiator,
- * also select nodes that are attached to only a half of that package.
- * \hideinitializer
- */
- HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY = (1UL<<1),
-
- /** \breif Select NUMA nodes whose locality intersects the given cpuset.
- * This includes larger and smaller localities as well as localities
- * that are partially included.
- * For instance, if the locality is one core of both packages, a NUMA node
- * local to one package is neither larger nor smaller than this locality,
- * but it intersects it.
- * \hideinitializer
- */
- HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY = (1UL<<3),
-
- /** \brief Select all NUMA nodes in the topology.
- * The initiator \p initiator is ignored.
- * \hideinitializer
- */
- HWLOC_LOCAL_NUMANODE_FLAG_ALL = (1UL<<2)
-};
-
-/** \brief Return an array of local NUMA nodes.
- *
- * By default only select the NUMA nodes whose locality is exactly
- * the given \p location. More nodes may be selected if additional flags
- * are given as a OR'ed set of ::hwloc_local_numanode_flag_e.
- *
- * If \p location is given as an explicit object, its CPU set is used
- * to find NUMA nodes with the corresponding locality.
- * If the object does not have a CPU set (e.g. I/O object), the CPU
- * parent (where the I/O object is attached) is used.
- *
- * On input, \p nr points to the number of nodes that may be stored
- * in the \p nodes array.
- * On output, \p nr will be changed to the number of stored nodes,
- * or the number of nodes that would have been stored if there were
- * enough room.
- *
- * \return 0 on success or -1 on error.
- *
- * \note Some of these NUMA nodes may not have any memory attribute
- * values and hence not be reported as actual targets in other functions.
- *
- * \note The number of NUMA nodes in the topology (obtained by
- * hwloc_bitmap_weight() on the root object nodeset) may be used
- * to allocate the \p nodes array.
- *
- * \note When an object CPU set is given as locality, for instance a Package,
- * and when flags contain both ::HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY
- * and ::HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY,
- * the returned array corresponds to the nodeset of that object.
- */
-HWLOC_DECLSPEC int
-hwloc_get_local_numanode_objs(hwloc_topology_t topology,
- struct hwloc_location *location,
- unsigned *nr,
- hwloc_obj_t *nodes,
- unsigned long flags);
-
-/** \brief Return the set of default NUMA nodes
- *
- * In machines with heterogeneous memory, some NUMA nodes are considered
- * the default ones, i.e. where basic allocations should be made from.
- * These are usually DRAM nodes.
- *
- * Other nodes may be reserved for specific use (I/O device memory, e.g. GPU memory),
- * small but high performance (HBM), large but slow memory (NVM), etc.
- * Buffers should usually not be allocated from there unless explicitly required.
- *
- * This function fills \p nodeset with the bits of NUMA nodes considered default.
- *
- * It is guaranteed that these nodes have non-intersecting CPU sets,
- * i.e. cores may not have multiple local NUMA nodes anymore.
- * Hence this may be used to iterate over the platform divided into separate
- * NUMA localities, for instance for binding one task per NUMA domain.
- *
- * Any core that had some local NUMA node(s) in the initial topology should
- * still have one in the default nodeset. Corner cases where this would be
- * wrong consist in asymmetric platforms with missing DRAM nodes, or topologies
- * that were already restricted to less NUMA nodes.
- *
- * The returned nodeset may be passed to hwloc_topology_restrict() with
- * ::HWLOC_RESTRICT_FLAG_BYNODESET to remove all non-default nodes from
- * the topology. The resulting topology will be easier to use when iterating
- * over (now homogeneous) NUMA nodes.
- *
- * The heuristics for finding default nodes relies on memory tiers and subtypes
- * (see \ref heteromem) as well as the assumption that hardware vendors list
- * default nodes first in hardware tables.
- *
- * \p flags must be \c 0 for now.
- *
- * \return 0 on success.
- * \return -1 on error.
- *
- * \note The returned nodeset usually contains all nodes from a single memory
- * tier, likely the DRAM one.
- *
- * \note The returned nodeset is included in the list of available nodes
- * returned by hwloc_topology_get_topology_nodeset(). It is strictly smaller
- * if the machine has heterogeneous memory.
- *
- * \note The heuristics may return a suboptimal set of nodes if hwloc could
- * not guess memory types and/or if some default nodes were removed earlier
- * from the topology (e.g. with hwloc_topology_restrict()).
- */
-HWLOC_DECLSPEC int
-hwloc_topology_get_default_nodeset(hwloc_topology_t topology,
- hwloc_nodeset_t nodeset,
- unsigned long flags);
-
-/** \brief Return an attribute value for a specific target NUMA node.
- *
- * If the attribute does not relate to a specific initiator
- * (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
- * location \p initiator is ignored and may be \c NULL.
- *
- * \p target_node cannot be \c NULL. If \p attribute is ::HWLOC_MEMATTR_ID_CAPACITY,
- * \p target_node must be a NUMA node. If it is ::HWLOC_MEMATTR_ID_LOCALITY,
- * \p target_node must have a CPU set.
- *
- * \p flags must be \c 0 for now.
- *
- * \return 0 on success.
- * \return -1 on error, for instance with errno set to \c EINVAL if flags
- * are invalid or no such attribute exists.
- *
- * \note The initiator \p initiator should be of type ::HWLOC_LOCATION_TYPE_CPUSET
- * when refering to accesses performed by CPU cores.
- * ::HWLOC_LOCATION_TYPE_OBJECT is currently unused internally by hwloc,
- * but users may for instance use it to provide custom information about
- * host memory accesses performed by GPUs.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_get_value(hwloc_topology_t topology,
- hwloc_memattr_id_t attribute,
- hwloc_obj_t target_node,
- struct hwloc_location *initiator,
- unsigned long flags,
- hwloc_uint64_t *value);
-
-/** \brief Return the best target NUMA node for the given attribute and initiator.
- *
- * If the attribute does not relate to a specific initiator
- * (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
- * location \p initiator is ignored and may be \c NULL.
- *
- * If \p value is non \c NULL, the corresponding value is returned there.
- *
- * If multiple targets have the same attribute values, only one is
- * returned (and there is no way to clarify how that one is chosen).
- * Applications that want to detect targets with identical/similar
- * values, or that want to look at values for multiple attributes,
- * should rather get all values using hwloc_memattr_get_value()
- * and manually select the target they consider the best.
- *
- * \p flags must be \c 0 for now.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c ENOENT if there are no matching targets.
- * \return -1 with errno set to \c EINVAL if flags are invalid,
- * or no such attribute exists.
- *
- * \note The initiator \p initiator should be of type ::HWLOC_LOCATION_TYPE_CPUSET
- * when refering to accesses performed by CPU cores.
- * ::HWLOC_LOCATION_TYPE_OBJECT is currently unused internally by hwloc,
- * but users may for instance use it to provide custom information about
- * host memory accesses performed by GPUs.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_get_best_target(hwloc_topology_t topology,
- hwloc_memattr_id_t attribute,
- struct hwloc_location *initiator,
- unsigned long flags,
- hwloc_obj_t *best_target, hwloc_uint64_t *value);
-
-/** \brief Return the best initiator for the given attribute and target NUMA node.
- *
- * If \p value is non \c NULL, the corresponding value is returned there.
- *
- * If multiple initiators have the same attribute values, only one is
- * returned (and there is no way to clarify how that one is chosen).
- * Applications that want to detect initiators with identical/similar
- * values, or that want to look at values for multiple attributes,
- * should rather get all values using hwloc_memattr_get_value()
- * and manually select the initiator they consider the best.
- *
- * The returned initiator should not be modified or freed,
- * it belongs to the topology.
- *
- * \p target_node cannot be \c NULL.
- *
- * \p flags must be \c 0 for now.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c ENOENT if there are no matching initiators.
- * \return -1 with errno set to \c EINVAL if the attribute does not relate to a specific initiator
- * (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR).
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_get_best_initiator(hwloc_topology_t topology,
- hwloc_memattr_id_t attribute,
- hwloc_obj_t target_node,
- unsigned long flags,
- struct hwloc_location *best_initiator, hwloc_uint64_t *value);
-
-/** \brief Return the target NUMA nodes that have some values for a given attribute.
- *
- * Return targets for the given attribute in the \p targets array
- * (for the given initiator if any).
- * If \p values is not \c NULL, the corresponding attribute values
- * are stored in the array it points to.
- *
- * On input, \p nr points to the number of targets that may be stored
- * in the array \p targets (and \p values).
- * On output, \p nr points to the number of targets (and values) that
- * were actually found, even if some of them couldn't be stored in the array.
- * Targets that couldn't be stored are ignored, but the function still
- * returns success (\c 0). The caller may find out by comparing the value pointed
- * by \p nr before and after the function call.
- *
- * The returned targets should not be modified or freed,
- * they belong to the topology.
- *
- * Argument \p initiator is ignored if the attribute does not relate to a specific
- * initiator (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR).
- * Otherwise \p initiator may be non \c NULL to report only targets
- * that have a value for that initiator.
- *
- * \p flags must be \c 0 for now.
- *
- * \note This function is meant for tools and debugging (listing internal information)
- * rather than for application queries. Applications should rather select useful
- * NUMA nodes with hwloc_get_local_numanode_objs() and then look at their attribute
- * values.
- *
- * \return 0 on success or -1 on error.
- *
- * \note The initiator \p initiator should be of type ::HWLOC_LOCATION_TYPE_CPUSET
- * when referring to accesses performed by CPU cores.
- * ::HWLOC_LOCATION_TYPE_OBJECT is currently unused internally by hwloc,
- * but users may for instance use it to provide custom information about
- * host memory accesses performed by GPUs.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_get_targets(hwloc_topology_t topology,
- hwloc_memattr_id_t attribute,
- struct hwloc_location *initiator,
- unsigned long flags,
- unsigned *nr, hwloc_obj_t *targets, hwloc_uint64_t *values);
-
-/** \brief Return the initiators that have values for a given attribute for a specific target NUMA node.
- *
- * Return initiators for the given attribute and target node in the
- * \p initiators array.
- * If \p values is not \c NULL, the corresponding attribute values
- * are stored in the array it points to.
- *
- * On input, \p nr points to the number of initiators that may be stored
- * in the array \p initiators (and \p values).
- * On output, \p nr points to the number of initiators (and values) that
- * were actually found, even if some of them couldn't be stored in the array.
- * Initiators that couldn't be stored are ignored, but the function still
- * returns success (\c 0). The caller may find out by comparing the value pointed
- * by \p nr before and after the function call.
- *
- * The returned initiators should not be modified or freed,
- * they belong to the topology.
- *
- * \p target_node cannot be \c NULL.
- *
- * \p flags must be \c 0 for now.
- *
- * If the attribute does not relate to a specific initiator
- * (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
- * no initiator is returned.
- *
- * \return 0 on success or -1 on error.
- *
- * \note This function is meant for tools and debugging (listing internal information)
- * rather than for application queries. Applications should rather select useful
- * NUMA nodes with hwloc_get_local_numanode_objs() and then look at their attribute
- * values for some relevant initiators.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_get_initiators(hwloc_topology_t topology,
- hwloc_memattr_id_t attribute,
- hwloc_obj_t target_node,
- unsigned long flags,
- unsigned *nr, struct hwloc_location *initiators, hwloc_uint64_t *values);
-
-/** @} */
-
-
-/** \defgroup hwlocality_memattrs_manage Managing memory attributes
- *
- * Memory attribues are identified by an ID (::hwloc_memattr_id_t)
- * and a name. hwloc_memattr_get_name() and hwloc_memattr_get_by_name()
- * convert between them (or return error if the attribute does not exist).
- *
- * The set of valid ::hwloc_memattr_id_t is a contigous set starting at \c 0.
- * It first contains predefined attributes, as listed
- * in ::hwloc_memattr_id_e (from \c 0 to \c HWLOC_MEMATTR_ID_MAX-1).
- * Then custom attributes may be dynamically registered with
- * hwloc_memattr_register(). They will get the following IDs
- * (\c HWLOC_MEMATTR_ID_MAX for the first one, etc.).
- *
- * To iterate over all valid attributes
- * (either predefined or dynamically registered custom ones),
- * one may iterate over IDs starting from \c 0 until hwloc_memattr_get_name()
- * or hwloc_memattr_get_flags() returns an error.
- *
- * The values for an existing attribute or for custom dynamically registered ones
- * may be set or modified with hwloc_memattr_set_value().
- *
- * @{
- */
-
-/** \brief Return the name of a memory attribute.
- *
- * The output pointer \p name cannot be \c NULL.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c EINVAL if the attribute does not exist.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_get_name(hwloc_topology_t topology,
- hwloc_memattr_id_t attribute,
- const char **name);
-
-/** \brief Return the flags of the given attribute.
- *
- * Flags are a OR'ed set of ::hwloc_memattr_flag_e.
- *
- * The output pointer \p flags cannot be \c NULL.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c EINVAL if the attribute does not exist.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_get_flags(hwloc_topology_t topology,
- hwloc_memattr_id_t attribute,
- unsigned long *flags);
-
-/** \brief Memory attribute flags.
- * Given to hwloc_memattr_register() and returned by hwloc_memattr_get_flags().
- */
-enum hwloc_memattr_flag_e {
- /** \brief The best nodes for this memory attribute are those with the higher values.
- * For instance Bandwidth.
- */
- HWLOC_MEMATTR_FLAG_HIGHER_FIRST = (1UL<<0),
- /** \brief The best nodes for this memory attribute are those with the lower values.
- * For instance Latency.
- */
- HWLOC_MEMATTR_FLAG_LOWER_FIRST = (1UL<<1),
- /** \brief The value returned for this memory attribute depends on the given initiator.
- * For instance Bandwidth and Latency, but not Capacity.
- */
- HWLOC_MEMATTR_FLAG_NEED_INITIATOR = (1UL<<2)
-};
-
-/** \brief Register a new memory attribute.
- *
- * Add a new custom memory attribute.
- * Flags are a OR'ed set of ::hwloc_memattr_flag_e. It must contain one of
- * ::HWLOC_MEMATTR_FLAG_HIGHER_FIRST or ::HWLOC_MEMATTR_FLAG_LOWER_FIRST but not both.
- *
- * The new attribute \p id is immediately after the last existing attribute ID
- * (which is either the ID of the last registered attribute if any,
- * or the ID of the last predefined attribute in ::hwloc_memattr_id_e).
- *
- * \return 0 on success.
- * \return -1 with errno set to \c EINVAL if an invalid set of flags is given.
- * \return -1 with errno set to \c EBUSY if another attribute already uses this name.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_register(hwloc_topology_t topology,
- const char *name,
- unsigned long flags,
- hwloc_memattr_id_t *id);
-
-/** \brief Set an attribute value for a specific target NUMA node.
- *
- * If the attribute does not relate to a specific initiator
- * (it does not have the flag ::HWLOC_MEMATTR_FLAG_NEED_INITIATOR),
- * location \p initiator is ignored and may be \c NULL.
- *
- * The initiator will be copied into the topology,
- * the caller should free anything allocated to store the initiator,
- * for instance the cpuset.
- *
- * \p target_node cannot be \c NULL.
- *
- * \p attribute cannot be ::HWLOC_MEMATTR_FLAG_ID_CAPACITY or
- * ::HWLOC_MEMATTR_FLAG_ID_LOCALITY.
- *
- * \p flags must be \c 0 for now.
- *
- * \note The initiator \p initiator should be of type ::HWLOC_LOCATION_TYPE_CPUSET
- * when referring to accesses performed by CPU cores.
- * ::HWLOC_LOCATION_TYPE_OBJECT is currently unused internally by hwloc,
- * but users may for instance use it to provide custom information about
- * host memory accesses performed by GPUs.
- *
- * \return 0 on success or -1 on error.
- */
-HWLOC_DECLSPEC int
-hwloc_memattr_set_value(hwloc_topology_t topology,
- hwloc_memattr_id_t attribute,
- hwloc_obj_t target_node,
- struct hwloc_location *initiator,
- unsigned long flags,
- hwloc_uint64_t value);
-
-/** @} */
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_MEMATTR_H */
### src/3rdparty/hwloc/include/hwloc/nvml.h
@@ -1,184 +0,0 @@
-/*
- * Copyright © 2012-2023 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and the NVIDIA Management Library.
- *
- * Applications that use both hwloc and the NVIDIA Management Library may want to
- * include this file so as to get topology information for NVML devices.
- */
-
-#ifndef HWLOC_NVML_H
-#define HWLOC_NVML_H
-
-#include "hwloc.h"
-#include "hwloc/autogen/config.h"
-#include "hwloc/helper.h"
-#ifdef HWLOC_LINUX_SYS
-#include "hwloc/linux.h"
-#endif
-
-#include <nvml.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_nvml Interoperability with the NVIDIA Management Library
- *
- * This interface offers ways to retrieve topology information about
- * devices managed by the NVIDIA Management Library (NVML).
- *
- * @{
- */
-
-/** \brief Get the CPU set of processors that are physically
- * close to NVML device \p device.
- *
- * Store in \p set the CPU-set describing the locality of the NVML device \p device.
- *
- * Topology \p topology and device \p device must match the local machine.
- * I/O devices detection and the NVML component are not needed in the topology.
- *
- * The function only returns the locality of the device.
- * If more information about the device is needed, OS objects should
- * be used instead, see hwloc_nvml_get_device_osdev()
- * and hwloc_nvml_get_device_osdev_by_index().
- *
- * This function is currently only implemented in a meaningful way for
- * Linux; other systems will simply get a full cpuset.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_nvml_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
- nvmlDevice_t device, hwloc_cpuset_t set)
-{
-#ifdef HWLOC_LINUX_SYS
- /* If we're on Linux, use the sysfs mechanism to get the local cpus */
-#define HWLOC_NVML_DEVICE_SYSFS_PATH_MAX 128
- char path[HWLOC_NVML_DEVICE_SYSFS_PATH_MAX];
- nvmlReturn_t nvres;
- nvmlPciInfo_t pci;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return -1;
- }
-
- nvres = nvmlDeviceGetPciInfo(device, &pci);
- if (NVML_SUCCESS != nvres) {
- errno = EINVAL;
- return -1;
- }
-
- sprintf(path, "/sys/bus/pci/devices/%04x:%02x:%02x.0/local_cpus", pci.domain, pci.bus, pci.device);
- if (hwloc_linux_read_path_as_cpumask(path, set) < 0
- || hwloc_bitmap_iszero(set))
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#else
- /* Non-Linux systems simply get a full cpuset */
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#endif
- return 0;
-}
-
-/** \brief Get the hwloc OS device object corresponding to the
- * NVML device whose index is \p idx.
- *
- * \return The hwloc OS device object describing the NVML device whose index is \p idx.
- * \return \c NULL if none could be found.
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection and the NVML component must be enabled in the topology.
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_nvml_get_device_osdev_by_index(hwloc_topology_t topology, unsigned idx)
-{
- hwloc_obj_t osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- if (HWLOC_OBJ_OSDEV_GPU == osdev->attr->osdev.type
- && osdev->name
- && !strncmp("nvml", osdev->name, 4)
- && atoi(osdev->name + 4) == (int) idx)
- return osdev;
- }
- return NULL;
-}
-
-/** \brief Get the hwloc OS device object corresponding to NVML device \p device.
- *
- * \return The hwloc OS device object that describes the given NVML device \p device.
- * \return \c NULL if none could be found.
- *
- * Topology \p topology and device \p device must match the local machine.
- * I/O devices detection and the NVML component must be enabled in the topology.
- * If not, the locality of the object may still be found using
- * hwloc_nvml_get_device_cpuset().
- *
- * \note The corresponding hwloc PCI device may be found by looking
- * at the result parent pointer (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_nvml_get_device_osdev(hwloc_topology_t topology, nvmlDevice_t device)
-{
- hwloc_obj_t osdev;
- nvmlReturn_t nvres;
- nvmlPciInfo_t pci;
- char uuid[64];
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return NULL;
- }
-
- nvres = nvmlDeviceGetPciInfo(device, &pci);
- if (NVML_SUCCESS != nvres)
- return NULL;
-
- nvres = nvmlDeviceGetUUID(device, uuid, sizeof(uuid));
- if (NVML_SUCCESS != nvres)
- uuid[0] = '\0';
-
- osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- hwloc_obj_t pcidev = osdev->parent;
- const char *info;
-
- if (strncmp(osdev->name, "nvml", 4))
- continue;
-
- if (pcidev
- && pcidev->type == HWLOC_OBJ_PCI_DEVICE
- && pcidev->attr->pcidev.domain == pci.domain
- && pcidev->attr->pcidev.bus == pci.bus
- && pcidev->attr->pcidev.dev == pci.device
- && pcidev->attr->pcidev.func == 0)
- return osdev;
-
- info = hwloc_obj_get_info_by_name(osdev, "NVIDIAUUID");
- if (info && !strcmp(info, uuid))
- return osdev;
- }
-
- return NULL;
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_NVML_H */
### src/3rdparty/hwloc/include/hwloc/opencl.h
@@ -1,277 +0,0 @@
-/*
- * Copyright © 2012-2023 Inria. All rights reserved.
- * Copyright © 2013, 2018 Université Bordeaux. All right reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and the OpenCL interface.
- *
- * Applications that use both hwloc and OpenCL may want to
- * include this file so as to get topology information for OpenCL devices.
- */
-
-#ifndef HWLOC_OPENCL_H
-#define HWLOC_OPENCL_H
-
-#include "hwloc.h"
-#include "hwloc/autogen/config.h"
-#include "hwloc/helper.h"
-#ifdef HWLOC_LINUX_SYS
-#include "hwloc/linux.h"
-#endif
-
-#ifdef __APPLE__
-#include <OpenCL/cl.h>
-#else
-#include <CL/cl.h>
-#endif
-
-#include <stdio.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* OpenCL extensions aren't always shipped with default headers, and
- * they don't always reflect what the installed implementations support.
- * Try everything and let the implementation return errors when non supported.
- */
-/* Copyright (c) 2008-2018 The Khronos Group Inc. */
-
-/* needs "cl_khr_pci_bus_info" device extension, but not strictly required for clGetDeviceInfo() */
-typedef struct {
- cl_uint pci_domain;
- cl_uint pci_bus;
- cl_uint pci_device;
- cl_uint pci_function;
-} hwloc_cl_device_pci_bus_info_khr;
-#define HWLOC_CL_DEVICE_PCI_BUS_INFO_KHR 0x410F
-
-/* needs "cl_amd_device_attribute_query" device extension, but not strictly required for clGetDeviceInfo() */
-#define HWLOC_CL_DEVICE_TOPOLOGY_AMD 0x4037
-typedef union {
- struct { cl_uint type; cl_uint data[5]; } raw;
- struct { cl_uint type; cl_char unused[17]; cl_char bus; cl_char device; cl_char function; } pcie;
-} hwloc_cl_device_topology_amd;
-#define HWLOC_CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD 1
-
-/* needs "cl_nv_device_attribute_query" device extension, but not strictly required for clGetDeviceInfo() */
-#define HWLOC_CL_DEVICE_PCI_BUS_ID_NV 0x4008
-#define HWLOC_CL_DEVICE_PCI_SLOT_ID_NV 0x4009
-#define HWLOC_CL_DEVICE_PCI_DOMAIN_ID_NV 0x400A
-
-
-/** \defgroup hwlocality_opencl Interoperability with OpenCL
- *
- * This interface offers ways to retrieve topology information about
- * OpenCL devices.
- *
- * Only AMD and NVIDIA OpenCL implementations currently offer useful locality
- * information about their devices.
- *
- * @{
- */
-
-/** \brief Return the domain, bus and device IDs of the OpenCL device \p device.
- *
- * Device \p device must match the local machine.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_opencl_get_device_pci_busid(cl_device_id device,
- unsigned *domain, unsigned *bus, unsigned *dev, unsigned *func)
-{
- hwloc_cl_device_topology_amd amdtopo;
- hwloc_cl_device_pci_bus_info_khr khrbusinfo;
- cl_uint nvbus, nvslot, nvdomain;
- cl_int clret;
-
- clret = clGetDeviceInfo(device, HWLOC_CL_DEVICE_PCI_BUS_INFO_KHR, sizeof(khrbusinfo), &khrbusinfo, NULL);
- if (CL_SUCCESS == clret) {
- *domain = (unsigned) khrbusinfo.pci_domain;
- *bus = (unsigned) khrbusinfo.pci_bus;
- *dev = (unsigned) khrbusinfo.pci_device;
- *func = (unsigned) khrbusinfo.pci_function;
- return 0;
- }
-
- clret = clGetDeviceInfo(device, HWLOC_CL_DEVICE_TOPOLOGY_AMD, sizeof(amdtopo), &amdtopo, NULL);
- if (CL_SUCCESS == clret
- && HWLOC_CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD == amdtopo.raw.type) {
- *domain = 0; /* can't do anything better */
- /* cl_device_topology_amd stores bus ID in cl_char, dont convert those signed char directly to unsigned int */
- *bus = (unsigned) (unsigned char) amdtopo.pcie.bus;
- *dev = (unsigned) (unsigned char) amdtopo.pcie.device;
- *func = (unsigned) (unsigned char) amdtopo.pcie.function;
- return 0;
- }
-
- clret = clGetDeviceInfo(device, HWLOC_CL_DEVICE_PCI_BUS_ID_NV, sizeof(nvbus), &nvbus, NULL);
- if (CL_SUCCESS == clret) {
- clret = clGetDeviceInfo(device, HWLOC_CL_DEVICE_PCI_SLOT_ID_NV, sizeof(nvslot), &nvslot, NULL);
- if (CL_SUCCESS == clret) {
- clret = clGetDeviceInfo(device, HWLOC_CL_DEVICE_PCI_DOMAIN_ID_NV, sizeof(nvdomain), &nvdomain, NULL);
- if (CL_SUCCESS == clret) { /* available since CUDA 10.2 */
- *domain = nvdomain;
- } else {
- *domain = 0;
- }
- *bus = nvbus & 0xff;
- /* non-documented but used in many other projects */
- *dev = nvslot >> 3;
- *func = nvslot & 0x7;
- return 0;
- }
- }
-
- return -1;
-}
-
-/** \brief Get the CPU set of processors that are physically
- * close to OpenCL device \p device.
- *
- * Store in \p set the CPU-set describing the locality of the OpenCL device \p device.
- *
- * Topology \p topology and device \p device must match the local machine.
- * I/O devices detection and the OpenCL component are not needed in the topology.
- *
- * The function only returns the locality of the device.
- * If more information about the device is needed, OS objects should
- * be used instead, see hwloc_opencl_get_device_osdev()
- * and hwloc_opencl_get_device_osdev_by_index().
- *
- * This function is currently only implemented in a meaningful way for
- * Linux with the AMD or NVIDIA OpenCL implementation; other systems will simply
- * get a full cpuset.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if the device could not be found.
- */
-static __hwloc_inline int
-hwloc_opencl_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
- cl_device_id device __hwloc_attribute_unused,
- hwloc_cpuset_t set)
-{
-#if (defined HWLOC_LINUX_SYS)
- /* If we're on Linux, try AMD/NVIDIA extensions + the sysfs mechanism to get the local cpus */
-#define HWLOC_OPENCL_DEVICE_SYSFS_PATH_MAX 128
- char path[HWLOC_OPENCL_DEVICE_SYSFS_PATH_MAX];
- unsigned pcidomain, pcibus, pcidev, pcifunc;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return -1;
- }
-
- if (hwloc_opencl_get_device_pci_busid(device, &pcidomain, &pcibus, &pcidev, &pcifunc) < 0) {
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
- return 0;
- }
-
- sprintf(path, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/local_cpus", pcidomain, pcibus, pcidev, pcifunc);
- if (hwloc_linux_read_path_as_cpumask(path, set) < 0
- || hwloc_bitmap_iszero(set))
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#else
- /* Non-Linux systems simply get a full cpuset */
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#endif
- return 0;
-}
-
-/** \brief Get the hwloc OS device object corresponding to the
- * OpenCL device for the given indexes.
- *
- * \return The hwloc OS device object describing the OpenCL device
- * whose platform index is \p platform_index,
- * and whose device index within this platform if \p device_index.
- * \return \c NULL if there is none.
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection and the OpenCL component must be enabled in the topology.
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_opencl_get_device_osdev_by_index(hwloc_topology_t topology,
- unsigned platform_index, unsigned device_index)
-{
- unsigned x = (unsigned) -1, y = (unsigned) -1;
- hwloc_obj_t osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- if (HWLOC_OBJ_OSDEV_COPROC == osdev->attr->osdev.type
- && osdev->name
- && sscanf(osdev->name, "opencl%ud%u", &x, &y) == 2
- && platform_index == x && device_index == y)
- return osdev;
- }
- return NULL;
-}
-
-/** \brief Get the hwloc OS device object corresponding to OpenCL device \p deviceX.
- *
- * \return The hwloc OS device object corresponding to the given OpenCL device \p device.
- * \return \c NULL if none could be found, for instance
- * if required OpenCL attributes are not available.
- *
- * This function currently only works on AMD and NVIDIA OpenCL devices that support
- * relevant OpenCL extensions. hwloc_opencl_get_device_osdev_by_index()
- * should be preferred whenever possible, i.e. when platform and device index
- * are known.
- *
- * Topology \p topology and device \p device must match the local machine.
- * I/O devices detection and the OpenCL component must be enabled in the topology.
- * If not, the locality of the object may still be found using
- * hwloc_opencl_get_device_cpuset().
- *
- * \note This function cannot work if PCI devices are filtered out.
- *
- * \note The corresponding hwloc PCI device may be found by looking
- * at the result parent pointer (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_opencl_get_device_osdev(hwloc_topology_t topology __hwloc_attribute_unused,
- cl_device_id device __hwloc_attribute_unused)
-{
- hwloc_obj_t osdev;
- unsigned pcidomain, pcibus, pcidevice, pcifunc;
-
- if (hwloc_opencl_get_device_pci_busid(device, &pcidomain, &pcibus, &pcidevice, &pcifunc) < 0) {
- errno = EINVAL;
- return NULL;
- }
-
- osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- hwloc_obj_t pcidev = osdev->parent;
- if (strncmp(osdev->name, "opencl", 6))
- continue;
- if (pcidev
- && pcidev->type == HWLOC_OBJ_PCI_DEVICE
- && pcidev->attr->pcidev.domain == pcidomain
- && pcidev->attr->pcidev.bus == pcibus
- && pcidev->attr->pcidev.dev == pcidevice
- && pcidev->attr->pcidev.func == pcifunc)
- return osdev;
- /* if PCI are filtered out, we need a info attr to match on */
- }
-
- return NULL;
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_OPENCL_H */
### src/3rdparty/hwloc/include/hwloc/openfabrics-verbs.h
@@ -1,155 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2023 Inria. All rights reserved.
- * Copyright © 2009-2010 Université Bordeaux
- * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and OpenFabrics
- * verbs.
- *
- * Applications that use both hwloc and OpenFabrics verbs may want to
- * include this file so as to get topology information for OpenFabrics
- * hardware (InfiniBand, etc).
- *
- */
-
-#ifndef HWLOC_OPENFABRICS_VERBS_H
-#define HWLOC_OPENFABRICS_VERBS_H
-
-#include "hwloc.h"
-#include "hwloc/autogen/config.h"
-#ifdef HWLOC_LINUX_SYS
-#include "hwloc/linux.h"
-#endif
-
-#include <infiniband/verbs.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_openfabrics Interoperability with OpenFabrics
- *
- * This interface offers ways to retrieve topology information about
- * OpenFabrics devices (InfiniBand, Omni-Path, usNIC, etc).
- *
- * @{
- */
-
-/** \brief Get the CPU set of processors that are physically
- * close to device \p ibdev.
- *
- * Store in \p set the CPU-set describing the locality of the OpenFabrics
- * device \p ibdev (InfiniBand, etc).
- *
- * Topology \p topology and device \p ibdev must match the local machine.
- * I/O devices detection is not needed in the topology.
- *
- * The function only returns the locality of the device.
- * If more information about the device is needed, OS objects should
- * be used instead, see hwloc_ibv_get_device_osdev()
- * and hwloc_ibv_get_device_osdev_by_name().
- *
- * This function is currently only implemented in a meaningful way for
- * Linux; other systems will simply get a full cpuset.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_ibv_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
- struct ibv_device *ibdev, hwloc_cpuset_t set)
-{
-#ifdef HWLOC_LINUX_SYS
- /* If we're on Linux, use the verbs-provided sysfs mechanism to
- get the local cpus */
-#define HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX 128
- char path[HWLOC_OPENFABRICS_VERBS_SYSFS_PATH_MAX];
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return -1;
- }
-
- sprintf(path, "/sys/class/infiniband/%s/device/local_cpus",
- ibv_get_device_name(ibdev));
- if (hwloc_linux_read_path_as_cpumask(path, set) < 0
- || hwloc_bitmap_iszero(set))
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#else
- /* Non-Linux systems simply get a full cpuset */
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#endif
- return 0;
-}
-
-/** \brief Get the hwloc OS device object corresponding to the OpenFabrics
- * device named \p ibname.
- *
- * \return The hwloc OS device object describing the OpenFabrics device
- * (InfiniBand, Omni-Path, usNIC, etc) whose name is \p ibname
- * (mlx5_0, hfi1_0, usnic_0, qib0, etc).
- * \return \c NULL if none could be found.
- *
- * The name \p ibname is usually obtained from ibv_get_device_name().
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection must be enabled in the topology.
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_ibv_get_device_osdev_by_name(hwloc_topology_t topology,
- const char *ibname)
-{
- hwloc_obj_t osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- if (HWLOC_OBJ_OSDEV_OPENFABRICS == osdev->attr->osdev.type
- && osdev->name && !strcmp(ibname, osdev->name))
- return osdev;
- }
- return NULL;
-}
-
-/** \brief Get the hwloc OS device object corresponding to the OpenFabrics
- * device \p ibdev.
- *
- * \return The hwloc OS device object describing the OpenFabrics
- * device \p ibdev (InfiniBand, etc).
- * \return \c NULL if none could be found.
- *
- * Topology \p topology and device \p ibdev must match the local machine.
- * I/O devices detection must be enabled in the topology.
- * If not, the locality of the object may still be found using
- * hwloc_ibv_get_device_cpuset().
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object.
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_ibv_get_device_osdev(hwloc_topology_t topology,
- struct ibv_device *ibdev)
-{
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return NULL;
- }
- return hwloc_ibv_get_device_osdev_by_name(topology, ibv_get_device_name(ibdev));
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_OPENFABRICS_VERBS_H */
### src/3rdparty/hwloc/include/hwloc/plugins.h
@@ -1,697 +0,0 @@
-/*
- * Copyright © 2013-2024 Inria. All rights reserved.
- * Copyright © 2016 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-#ifndef HWLOC_PLUGINS_H
-#define HWLOC_PLUGINS_H
-
-/** \file
- * \brief Public interface for building hwloc plugins.
- */
-
-struct hwloc_backend;
-
-#include "hwloc.h"
-
-#ifdef HWLOC_INSIDE_PLUGIN
-/* needed for hwloc_plugin_check_namespace() */
-#ifdef HWLOC_HAVE_LTDL
-#include <ltdl.h>
-#else
-#include <dlfcn.h>
-#endif
-#endif
-
-
-
-/** \defgroup hwlocality_disc_components Components and Plugins: Discovery components and backends
- *
- * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified.
- *
- * @{
- */
-
-/** \brief Discovery component structure
- *
- * This is the major kind of components, taking care of the discovery.
- * They are registered by generic components, either statically-built or as plugins.
- */
-struct hwloc_disc_component {
- /** \brief Name.
- * If this component is built as a plugin, this name does not have to match the plugin filename.
- */
- const char *name;
-
- /** \brief Discovery phases performed by this component.
- * OR'ed set of ::hwloc_disc_phase_t
- */
- unsigned phases;
-
- /** \brief Component phases to exclude, as an OR'ed set of ::hwloc_disc_phase_t.
- *
- * For a GLOBAL component, this usually includes all other phases (\c ~UL).
- *
- * Other components only exclude types that may bring conflicting
- * topology information. MISC components should likely not be excluded
- * since they usually bring non-primary additional information.
- */
- unsigned excluded_phases;
-
- /** \brief Instantiate callback to create a backend from the component.
- * Parameters data1, data2, data3 are NULL except for components
- * that have special enabling routines such as hwloc_topology_set_xml(). */
- struct hwloc_backend * (*instantiate)(struct hwloc_topology *topology, struct hwloc_disc_component *component, unsigned excluded_phases, const void *data1, const void *data2, const void *data3);
-
- /** \brief Component priority.
- * Used to sort topology->components, higher priority first.
- * Also used to decide between two components with the same name.
- *
- * Usual values are
- * 50 for native OS (or platform) components,
- * 45 for x86,
- * 40 for no-OS fallback,
- * 30 for global components (xml, synthetic),
- * 20 for pci,
- * 10 for other misc components (opencl etc.).
- */
- unsigned priority;
-
- /** \brief Enabled by default.
- * If unset, if will be disabled unless explicitly requested.
- */
- unsigned enabled_by_default;
-
- /** \private Used internally to list components by priority on topology->components
- * (the component structure is usually read-only,
- * the core copies it before using this field for queueing)
- */
- struct hwloc_disc_component * next;
-};
-
-/** \brief Discovery phase */
-typedef enum hwloc_disc_phase_e {
- /** \brief xml or synthetic, platform-specific components such as bgq.
- * Discovers everything including CPU, memory, I/O and everything else.
- * A component with a Global phase usually excludes all other phases.
- * \hideinitializer */
- HWLOC_DISC_PHASE_GLOBAL = (1U<<0),
-
- /** \brief CPU discovery.
- * \hideinitializer */
- HWLOC_DISC_PHASE_CPU = (1U<<1),
-
- /** \brief Attach memory to existing CPU objects.
- * \hideinitializer */
- HWLOC_DISC_PHASE_MEMORY = (1U<<2),
-
- /** \brief Attach PCI devices and bridges to existing CPU objects.
- * \hideinitializer */
- HWLOC_DISC_PHASE_PCI = (1U<<3),
-
- /** \brief I/O discovery that requires PCI devices (OS devices such as OpenCL, CUDA, etc.).
- * \hideinitializer */
- HWLOC_DISC_PHASE_IO = (1U<<4),
-
- /** \brief Misc objects that gets added below anything else.
- * \hideinitializer */
- HWLOC_DISC_PHASE_MISC = (1U<<5),
-
- /** \brief Annotating existing objects, adding distances, etc.
- * \hideinitializer */
- HWLOC_DISC_PHASE_ANNOTATE = (1U<<6),
-
- /** \brief Final tweaks to a ready-to-use topology.
- * This phase runs once the topology is loaded, before it is returned to the topology.
- * Hence it may only use the main hwloc API for modifying the topology,
- * for instance by restricting it, adding info attributes, etc.
- * \hideinitializer */
- HWLOC_DISC_PHASE_TWEAK = (1U<<7)
-} hwloc_disc_phase_t;
-
-/** \brief Discovery status flags */
-enum hwloc_disc_status_flag_e {
- /** \brief The sets of allowed resources were already retrieved \hideinitializer */
- HWLOC_DISC_STATUS_FLAG_GOT_ALLOWED_RESOURCES = (1UL<<1)
-};
-
-/** \brief Discovery status structure
- *
- * Used by the core and backends to inform about what has been/is being done
- * during the discovery process.
- */
-struct hwloc_disc_status {
- /** \brief The current discovery phase that is performed.
- * Must match one of the phases in the component phases field.
- */
- hwloc_disc_phase_t phase;
-
- /** \brief Dynamically excluded phases.
- * If a component decides during discovery that some phases are no longer needed.
- */
- unsigned excluded_phases;
-
- /** \brief OR'ed set of ::hwloc_disc_status_flag_e */
- unsigned long flags;
-};
-
-/** \brief Discovery backend structure
- *
- * A backend is the instantiation of a discovery component.
- * When a component gets enabled for a topology,
- * its instantiate() callback creates a backend.
- *
- * hwloc_backend_alloc() initializes all fields to default values
- * that the component may change (except "component" and "next")
- * before enabling the backend with hwloc_backend_enable().
- *
- * Most backends assume that the topology is_thissystem flag is
- * set because they talk to the underlying operating system.
- * However they may still be used in topologies without the
- * is_thissystem flag for debugging reasons.
- * In practice, they are usually auto-disabled in such cases
- * (excluded by xml or synthetic backends, or by environment
- * variables when changing the Linux fsroot or the x86 cpuid path).
- */
-struct hwloc_backend {
- /** \private Reserved for the core, set by hwloc_backend_alloc() */
- struct hwloc_disc_component * component;
- /** \private Reserved for the core, set by hwloc_backend_enable() */
- struct hwloc_topology * topology;
- /** \private Reserved for the core. Set to 1 if forced through envvar, 0 otherwise. */
- int envvar_forced;
- /** \private Reserved for the core. Used internally to list backends topology->backends. */
- struct hwloc_backend * next;
-
- /** \brief Discovery phases performed by this component, possibly without some of them if excluded by other components.
- * OR'ed set of ::hwloc_disc_phase_t
- */
- unsigned phases;
-
- /** \brief Backend flags, currently always 0. */
- unsigned long flags;
-
- /** \brief Backend-specific 'is_thissystem' property.
- * Set to 0 if the backend disables the thissystem flag for this topology
- * (e.g. loading from xml or synthetic string,
- * or using a different fsroot on Linux, or a x86 CPUID dump).
- * Set to -1 if the backend doesn't care (default).
- */
- int is_thissystem;
-
- /** \brief Backend private data, or NULL if none. */
- void * private_data;
- /** \brief Callback for freeing the private_data.
- * May be NULL.
- */
- void (*disable)(struct hwloc_backend *backend);
-
- /** \brief Main discovery callback.
- * returns -1 on error, either because it couldn't add its objects ot the existing topology,
- * or because of an actual discovery/gathering failure.
- * May be NULL.
- */
- int (*discover)(struct hwloc_backend *backend, struct hwloc_disc_status *status);
-
- /** \brief Callback to retrieve the locality of a PCI object.
- * Called by the PCI core when attaching PCI hierarchy to CPU objects.
- * May be NULL.
- */
- int (*get_pci_busid_cpuset)(struct hwloc_backend *backend, struct hwloc_pcidev_attr_s *busid, hwloc_bitmap_t cpuset);
-};
-
-/** \brief Allocate a backend structure, set good default values, initialize backend->component and topology, etc.
- * The caller will then modify whatever needed, and call hwloc_backend_enable().
- */
-HWLOC_DECLSPEC struct hwloc_backend * hwloc_backend_alloc(struct hwloc_topology *topology, struct hwloc_disc_component *component);
-
-/** \brief Enable a previously allocated and setup backend. */
-HWLOC_DECLSPEC int hwloc_backend_enable(struct hwloc_backend *backend);
-
-/** @} */
-
-
-
-
-/** \defgroup hwlocality_generic_components Components and Plugins: Generic components
- *
- * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified.
- *
- * @{
- */
-
-/** \brief Generic component type */
-typedef enum hwloc_component_type_e {
- /** \brief The data field must point to a struct hwloc_disc_component. */
- HWLOC_COMPONENT_TYPE_DISC,
-
- /** \brief The data field must point to a struct hwloc_xml_component. */
- HWLOC_COMPONENT_TYPE_XML
-} hwloc_component_type_t;
-
-/** \brief Generic component structure
- *
- * Generic components structure, either statically listed by configure in static-components.h
- * or dynamically loaded as a plugin.
- */
-struct hwloc_component {
- /** \brief Component ABI version, set to ::HWLOC_COMPONENT_ABI */
- unsigned abi;
-
- /** \brief Process-wide component initialization callback.
- *
- * This optional callback is called when the component is registered
- * to the hwloc core (after loading the plugin).
- *
- * When the component is built as a plugin, this callback
- * should call hwloc_check_plugin_namespace()
- * and return an negative error code on error.
- *
- * \p flags is always 0 for now.
- *
- * \return 0 on success, or a negative code on error.
- *
- * \note If the component uses ltdl for loading its own plugins,
- * it should load/unload them only in init() and finalize(),
- * to avoid race conditions with hwloc's use of ltdl.
- */
- int (*init)(unsigned long flags);
-
- /** \brief Process-wide component termination callback.
- *
- * This optional callback is called after unregistering the component
- * from the hwloc core (before unloading the plugin).
- *
- * \p flags is always 0 for now.
- *
- * \note If the component uses ltdl for loading its own plugins,
- * it should load/unload them only in init() and finalize(),
- * to avoid race conditions with hwloc's use of ltdl.
- */
- void (*finalize)(unsigned long flags);
-
- /** \brief Component type */
- hwloc_component_type_t type;
-
- /** \brief Component flags, unused for now */
- unsigned long flags;
-
- /** \brief Component data, pointing to a struct hwloc_disc_component or struct hwloc_xml_component. */
- void * data;
-};
-
-/** \brief Make sure that plugins can lookup core symbols.
- *
- * This is a sanity check to avoid lazy-lookup failures when libhwloc
- * is loaded within a plugin, and later tries to load its own plugins.
- * This may fail (and abort the program) if libhwloc symbols are in a
- * private namespace.
- *
- * \return 0 on success.
- * \return -1 if the plugin cannot be successfully loaded. The caller
- * plugin init() callback should return a negative error code as well.
- *
- * Plugins should call this function in their init() callback to avoid
- * later crashes if lazy symbol resolution is used by the upper layer that
- * loaded hwloc (e.g. OpenCL implementations using dlopen with RTLD_LAZY).
- *
- * \note The build system must define HWLOC_INSIDE_PLUGIN if and only if
- * building the caller as a plugin.
- *
- * \note This function should remain inline so plugins can call it even
- * when they cannot find libhwloc symbols.
- */
-static __hwloc_inline int
-hwloc_plugin_check_namespace(const char *pluginname __hwloc_attribute_unused, const char *symbol __hwloc_attribute_unused)
-{
-#ifdef HWLOC_INSIDE_PLUGIN
- void *sym;
-#ifdef HWLOC_HAVE_LTDL
- lt_dlhandle handle = lt_dlopen(NULL);
-#else
- void *handle = dlopen(NULL, RTLD_NOW|RTLD_LOCAL);
-#endif
- if (!handle)
- /* cannot check, assume things will work */
- return 0;
-#ifdef HWLOC_HAVE_LTDL
- sym = lt_dlsym(handle, symbol);
- lt_dlclose(handle);
-#else
- sym = dlsym(handle, symbol);
- dlclose(handle);
-#endif
- if (!sym) {
- static int verboseenv_checked = 0;
- static int verboseenv_value = 0;
- if (!verboseenv_checked) {
- const char *verboseenv = getenv("HWLOC_PLUGINS_VERBOSE");
- verboseenv_value = verboseenv ? atoi(verboseenv) : 0;
- verboseenv_checked = 1;
- }
- if (verboseenv_value)
- fprintf(stderr, "Plugin `%s' disabling itself because it cannot find the `%s' core symbol.\n",
- pluginname, symbol);
- return -1;
- }
-#endif /* HWLOC_INSIDE_PLUGIN */
- return 0;
-}
-
-/** @} */
-
-
-
-
-/** \defgroup hwlocality_components_core_funcs Components and Plugins: Core functions to be used by components
- *
- * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified.
- *
- * @{
- */
-
-/** \brief Check whether error messages are hidden.
- *
- * Callers should print critical error messages
- * (e.g. invalid hw topo info, invalid config)
- * only if this function returns strictly less than 2.
- *
- * Callers should print non-critical error messages
- * (e.g. failure to initialize CUDA)
- * if this function returns 0.
- *
- * This function return 1 by default (show critical only),
- * 0 in lstopo (show all),
- * or anything set in HWLOC_HIDE_ERRORS in the environment.
- *
- * Use macros HWLOC_SHOW_CRITICAL_ERRORS() and HWLOC_SHOW_ALL_ERRORS()
- * for clarity.
- */
-HWLOC_DECLSPEC int hwloc_hide_errors(void);
-
-#define HWLOC_SHOW_CRITICAL_ERRORS() (hwloc_hide_errors() < 2)
-#define HWLOC_SHOW_ALL_ERRORS() (hwloc_hide_errors() == 0)
-
-/** \brief Add an object to the topology.
- *
- * Insert new object \p obj in the topology starting under existing object \p root
- * (if \c NULL, the topology root object is used).
- *
- * It is sorted along the tree of other objects according to the inclusion of
- * cpusets, to eventually be added as a child of the smallest object including
- * this object.
- *
- * If the cpuset is empty, the type of the object (and maybe some attributes)
- * must be enough to find where to insert the object. This is especially true
- * for NUMA nodes with memory and no CPUs.
- *
- * The given object should not have children.
- *
- * This shall only be called before levels are built.
- *
- * The caller should check whether the object type is filtered-out before calling this function.
- *
- * The topology cpuset/nodesets will be enlarged to include the object sets.
- *
- * \p reason is a unique string identifying where and why this insertion call was performed
- * (it will be displayed in case of internal insertion error).
- *
- * Returns the object on success.
- * Returns NULL and frees obj on error.
- * Returns another object and frees obj if it was merged with an identical pre-existing object.
- */
-HWLOC_DECLSPEC hwloc_obj_t
-hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t root,
- hwloc_obj_t obj, const char *reason);
-
-/** \brief Insert an object somewhere in the topology.
- *
- * It is added as the last child of the given parent.
- * The cpuset is completely ignored, so strange objects such as I/O devices should
- * preferably be inserted with this.
- *
- * When used for "normal" children with cpusets (when importing from XML
- * when duplicating a topology), the caller should make sure that:
- * - children are inserted in order,
- * - children cpusets do not intersect.
- *
- * The given object may have normal, I/O or Misc children, as long as they are in order as well.
- * These children must have valid parent and next_sibling pointers.
- *
- * The caller should check whether the object type is filtered-out before calling this function.
- */
-HWLOC_DECLSPEC void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj);
-
-/** \brief Allocate and initialize an object of the given type and physical index.
- *
- * If \p os_index is unknown or irrelevant, use \c HWLOC_UNKNOWN_INDEX.
- */
-HWLOC_DECLSPEC hwloc_obj_t hwloc_alloc_setup_object(hwloc_topology_t topology, hwloc_obj_type_t type, unsigned os_index);
-
-/** \brief Setup object cpusets/nodesets by OR'ing its children.
- *
- * Used when adding an object late in the topology.
- * Will update the new object by OR'ing all its new children sets.
- *
- * Used when PCI backend adds a hostbridge parent, when distances
- * add a new Group, etc.
- */
-HWLOC_DECLSPEC int hwloc_obj_add_children_sets(hwloc_obj_t obj);
-
-/** \brief Request a reconnection of children and levels in the topology.
- *
- * May be used by backends during discovery if they need arrays or lists
- * of object within levels or children to be fully connected.
- *
- * \p flags is currently unused, must 0.
- */
-HWLOC_DECLSPEC int hwloc_topology_reconnect(hwloc_topology_t topology, unsigned long flags __hwloc_attribute_unused);
-
-/** @} */
-
-
-
-
-/** \defgroup hwlocality_components_filtering Components and Plugins: Filtering objects
- *
- * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified.
- *
- * @{
- */
-
-/** \brief Check whether the given PCI device classid is important.
- *
- * \return 1 if important, 0 otherwise.
- */
-static __hwloc_inline int
-hwloc_filter_check_pcidev_subtype_important(unsigned classid)
-{
- unsigned baseclass = classid >> 8;
- return (baseclass == 0x03 /* PCI_BASE_CLASS_DISPLAY */
- || baseclass == 0x02 /* PCI_BASE_CLASS_NETWORK */
- || baseclass == 0x01 /* PCI_BASE_CLASS_STORAGE */
- || baseclass == 0x00 /* Unclassified, for Atos/Bull BXI */
- || baseclass == 0x0b /* PCI_BASE_CLASS_PROCESSOR */
- || classid == 0x0c04 /* PCI_CLASS_SERIAL_FIBER */
- || classid == 0x0c06 /* PCI_CLASS_SERIAL_INFINIBAND */
- || classid == 0x0502 /* PCI_CLASS_MEMORY_CXL */
- || baseclass == 0x06 /* PCI_BASE_CLASS_BRIDGE with non-PCI downstream. the core will drop the useless ones later */
- || baseclass == 0x12 /* Processing Accelerators */);
-}
-
-/** \brief Check whether the given OS device subtype is important.
- *
- * \return 1 if important, 0 otherwise.
- */
-static __hwloc_inline int
-hwloc_filter_check_osdev_subtype_important(hwloc_obj_osdev_type_t subtype)
-{
- return (subtype != HWLOC_OBJ_OSDEV_DMA);
-}
-
-/** \brief Check whether a non-I/O object type should be filtered-out.
- *
- * Cannot be used for I/O objects.
- *
- * \return 1 if the object type should be kept, 0 otherwise.
- */
-static __hwloc_inline int
-hwloc_filter_check_keep_object_type(hwloc_topology_t topology, hwloc_obj_type_t type)
-{
- enum hwloc_type_filter_e filter = HWLOC_TYPE_FILTER_KEEP_NONE;
- hwloc_topology_get_type_filter(topology, type, &filter);
- assert(filter != HWLOC_TYPE_FILTER_KEEP_IMPORTANT); /* IMPORTANT only used for I/O */
- return filter == HWLOC_TYPE_FILTER_KEEP_NONE ? 0 : 1;
-}
-
-/** \brief Check whether the given object should be filtered-out.
- *
- * \return 1 if the object type should be kept, 0 otherwise.
- */
-static __hwloc_inline int
-hwloc_filter_check_keep_object(hwloc_topology_t topology, hwloc_obj_t obj)
-{
- hwloc_obj_type_t type = obj->type;
- enum hwloc_type_filter_e filter = HWLOC_TYPE_FILTER_KEEP_NONE;
- hwloc_topology_get_type_filter(topology, type, &filter);
- if (filter == HWLOC_TYPE_FILTER_KEEP_NONE)
- return 0;
- if (filter == HWLOC_TYPE_FILTER_KEEP_IMPORTANT) {
- if (type == HWLOC_OBJ_PCI_DEVICE)
- return hwloc_filter_check_pcidev_subtype_important(obj->attr->pcidev.class_id);
- if (type == HWLOC_OBJ_OS_DEVICE)
- return hwloc_filter_check_osdev_subtype_important(obj->attr->osdev.type);
- }
- return 1;
-}
-
-/** @} */
-
-
-
-
-/** \defgroup hwlocality_components_pcidisc Components and Plugins: helpers for PCI discovery
- *
- * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified.
- *
- * @{
- */
-
-/** \brief Return the offset of the given capability in the PCI config space buffer
- *
- * This function requires a 256-bytes config space. Unknown/unavailable bytes should be set to 0xff.
- */
-HWLOC_DECLSPEC unsigned hwloc_pcidisc_find_cap(const unsigned char *config, unsigned cap);
-
-/** \brief Fill linkspeed by reading the PCI config space where PCI_CAP_ID_EXP is at position offset.
- *
- * Needs 20 bytes of EXP capability block starting at offset in the config space
- * for registers up to link status.
- */
-HWLOC_DECLSPEC int hwloc_pcidisc_find_linkspeed(const unsigned char *config, unsigned offset, float *linkspeed);
-
-/** \brief Return the hwloc object type (PCI device or Bridge) for the given class and configuration space.
- *
- * This function requires 16 bytes of common configuration header at the beginning of config.
- */
-HWLOC_DECLSPEC hwloc_obj_type_t hwloc_pcidisc_check_bridge_type(unsigned device_class, const unsigned char *config);
-
-/** \brief Fills the attributes of the given PCI bridge using the given PCI config space.
- *
- * This function requires 32 bytes of common configuration header at the beginning of config.
- *
- * Returns -1 and destroys /p obj if bridge fields are invalid.
- */
-HWLOC_DECLSPEC int hwloc_pcidisc_find_bridge_buses(unsigned domain, unsigned bus, unsigned dev, unsigned func,
- unsigned *secondary_busp, unsigned *subordinate_busp,
- const unsigned char *config);
-
-/** \brief Insert a PCI object in the given PCI tree by looking at PCI bus IDs.
- *
- * If \p treep points to \c NULL, the new object is inserted there.
- */
-HWLOC_DECLSPEC void hwloc_pcidisc_tree_insert_by_busid(struct hwloc_obj **treep, struct hwloc_obj *obj);
-
-/** \brief Add some hostbridges on top of the given tree of PCI objects and attach them to the topology.
- *
- * Other backends may lookup PCI objects or localities (for instance to attach OS devices)
- * by using hwloc_pcidisc_find_by_busid() or hwloc_pcidisc_find_busid_parent().
- */
-HWLOC_DECLSPEC int hwloc_pcidisc_tree_attach(struct hwloc_topology *topology, struct hwloc_obj *tree);
-
-/** @} */
-
-
-
-
-/** \defgroup hwlocality_components_pcifind Components and Plugins: finding PCI objects during other discoveries
- *
- * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified.
- *
- * @{
- */
-
-/** \brief Find the object or a parent of a PCI bus ID.
- *
- * When attaching a new object (typically an OS device) whose locality
- * is specified by PCI bus ID, this function returns the PCI object
- * to use as a parent for attaching.
- *
- * If the exact PCI device with this bus ID exists, it is returned.
- * Otherwise (for instance if it was filtered out), the function returns
- * another object with similar locality (for instance a parent bridge,
- * or the local CPU Package).
- */
-HWLOC_DECLSPEC struct hwloc_obj * hwloc_pci_find_parent_by_busid(struct hwloc_topology *topology, unsigned domain, unsigned bus, unsigned dev, unsigned func);
-
-/** \brief Find the PCI device or bridge matching a PCI bus ID exactly.
- *
- * This is useful for adding specific information about some objects
- * based on their PCI id. When it comes to attaching objects based on
- * PCI locality, hwloc_pci_find_parent_by_busid() should be preferred.
- */
-HWLOC_DECLSPEC struct hwloc_obj * hwloc_pci_find_by_busid(struct hwloc_topology *topology, unsigned domain, unsigned bus, unsigned dev, unsigned func);
-
-
-/** @} */
-
-
-
-
-/** \defgroup hwlocality_components_distances Components and Plugins: distances
- *
- * \note These structures and functions may change when ::HWLOC_COMPONENT_ABI is modified.
- *
- * @{
- */
-
-/** \brief Handle to a new distances structure during its addition to the topology. */
-typedef void * hwloc_backend_distances_add_handle_t;
-
-/** \brief Create a new empty distances structure.
- *
- * This is identical to hwloc_distances_add_create()
- * but this variant is designed for backend inserting
- * distances during topology discovery.
- */
-HWLOC_DECLSPEC hwloc_backend_distances_add_handle_t
-hwloc_backend_distances_add_create(hwloc_topology_t topology,
- const char *name, unsigned long kind,
- unsigned long flags);
-
-/** \brief Specify the objects and values in a new empty distances structure.
- *
- * This is similar to hwloc_distances_add_values()
- * but this variant is designed for backend inserting
- * distances during topology discovery.
- *
- * The only semantical difference is that \p objs and \p values
- * are not duplicated, but directly attached to the topology.
- * On success, these arrays are given to the core and should not
- * ever be freed by the caller anymore.
- */
-HWLOC_DECLSPEC int
-hwloc_backend_distances_add_values(hwloc_topology_t topology,
- hwloc_backend_distances_add_handle_t handle,
- unsigned nbobjs, hwloc_obj_t *objs,
- hwloc_uint64_t *values,
- unsigned long flags);
-
-/** \brief Commit a new distances structure.
- *
- * This is similar to hwloc_distances_add_commit()
- * but this variant is designed for backend inserting
- * distances during topology discovery.
- */
-HWLOC_DECLSPEC int
-hwloc_backend_distances_add_commit(hwloc_topology_t topology,
- hwloc_backend_distances_add_handle_t handle,
- unsigned long flags);
-
-/** @} */
-
-
-
-
-#endif /* HWLOC_PLUGINS_H */
### src/3rdparty/hwloc/include/hwloc/rename.h
@@ -1,922 +0,0 @@
-/*
- * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
- * Copyright © 2010-2025 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-#ifndef HWLOC_RENAME_H
-#define HWLOC_RENAME_H
-
-#include "hwloc/autogen/config.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Only enact these defines if we're actually renaming the symbols
- (i.e., avoid trying to have no-op defines if we're *not*
- renaming). */
-
-#if HWLOC_SYM_TRANSFORM
-
-/* Use a preprocessor two-step in order to get the prefixing right.
- Make 2 macros: HWLOC_NAME and HWLOC_NAME_CAPS for renaming
- things. */
-
-#define HWLOC_MUNGE_NAME(a, b) HWLOC_MUNGE_NAME2(a, b)
-#define HWLOC_MUNGE_NAME2(a, b) a ## b
-#define HWLOC_NAME(name) HWLOC_MUNGE_NAME(HWLOC_SYM_PREFIX, hwloc_ ## name)
-/* FIXME: should be "HWLOC_ ## name" below, unchanged because it doesn't matter much and could break some embedders hacks */
-#define HWLOC_NAME_CAPS(name) HWLOC_MUNGE_NAME(HWLOC_SYM_PREFIX_CAPS, hwloc_ ## name)
-
-/* Now define all the "real" names to be the prefixed names. This
- allows us to use the real names throughout the code base (i.e.,
- "hwloc_<foo>"); the preprocessor will adjust to have the prefixed
- name under the covers. */
-
-/* Names from hwloc.h */
-
-#define hwloc_get_api_version HWLOC_NAME(get_api_version)
-
-#define hwloc_topology HWLOC_NAME(topology)
-#define hwloc_topology_t HWLOC_NAME(topology_t)
-
-#define hwloc_cpuset_t HWLOC_NAME(cpuset_t)
-#define hwloc_const_cpuset_t HWLOC_NAME(const_cpuset_t)
-#define hwloc_nodeset_t HWLOC_NAME(nodeset_t)
-#define hwloc_const_nodeset_t HWLOC_NAME(const_nodeset_t)
-
-#define HWLOC_OBJ_MACHINE HWLOC_NAME_CAPS(OBJ_MACHINE)
-#define HWLOC_OBJ_NUMANODE HWLOC_NAME_CAPS(OBJ_NUMANODE)
-#define HWLOC_OBJ_MEMCACHE HWLOC_NAME_CAPS(OBJ_MEMCACHE)
-#define HWLOC_OBJ_PACKAGE HWLOC_NAME_CAPS(OBJ_PACKAGE)
-#define HWLOC_OBJ_DIE HWLOC_NAME_CAPS(OBJ_DIE)
-#define HWLOC_OBJ_CORE HWLOC_NAME_CAPS(OBJ_CORE)
-#define HWLOC_OBJ_PU HWLOC_NAME_CAPS(OBJ_PU)
-#define HWLOC_OBJ_L1CACHE HWLOC_NAME_CAPS(OBJ_L1CACHE)
-#define HWLOC_OBJ_L2CACHE HWLOC_NAME_CAPS(OBJ_L2CACHE)
-#define HWLOC_OBJ_L3CACHE HWLOC_NAME_CAPS(OBJ_L3CACHE)
-#define HWLOC_OBJ_L4CACHE HWLOC_NAME_CAPS(OBJ_L4CACHE)
-#define HWLOC_OBJ_L5CACHE HWLOC_NAME_CAPS(OBJ_L5CACHE)
-#define HWLOC_OBJ_L1ICACHE HWLOC_NAME_CAPS(OBJ_L1ICACHE)
-#define HWLOC_OBJ_L2ICACHE HWLOC_NAME_CAPS(OBJ_L2ICACHE)
-#define HWLOC_OBJ_L3ICACHE HWLOC_NAME_CAPS(OBJ_L3ICACHE)
-#define HWLOC_OBJ_MISC HWLOC_NAME_CAPS(OBJ_MISC)
-#define HWLOC_OBJ_GROUP HWLOC_NAME_CAPS(OBJ_GROUP)
-#define HWLOC_OBJ_BRIDGE HWLOC_NAME_CAPS(OBJ_BRIDGE)
-#define HWLOC_OBJ_PCI_DEVICE HWLOC_NAME_CAPS(OBJ_PCI_DEVICE)
-#define HWLOC_OBJ_OS_DEVICE HWLOC_NAME_CAPS(OBJ_OS_DEVICE)
-#define HWLOC_OBJ_TYPE_MAX HWLOC_NAME_CAPS(OBJ_TYPE_MAX)
-#define hwloc_obj_type_t HWLOC_NAME(obj_type_t)
-
-#define hwloc_obj_cache_type_e HWLOC_NAME(obj_cache_type_e)
-#define hwloc_obj_cache_type_t HWLOC_NAME(obj_cache_type_t)
-#define HWLOC_OBJ_CACHE_UNIFIED HWLOC_NAME_CAPS(OBJ_CACHE_UNIFIED)
-#define HWLOC_OBJ_CACHE_DATA HWLOC_NAME_CAPS(OBJ_CACHE_DATA)
-#define HWLOC_OBJ_CACHE_INSTRUCTION HWLOC_NAME_CAPS(OBJ_CACHE_INSTRUCTION)
-
-#define hwloc_obj_bridge_type_e HWLOC_NAME(obj_bridge_type_e)
-#define hwloc_obj_bridge_type_t HWLOC_NAME(obj_bridge_type_t)
-#define HWLOC_OBJ_BRIDGE_HOST HWLOC_NAME_CAPS(OBJ_BRIDGE_HOST)
-#define HWLOC_OBJ_BRIDGE_PCI HWLOC_NAME_CAPS(OBJ_BRIDGE_PCI)
-
-#define hwloc_obj_osdev_type_e HWLOC_NAME(obj_osdev_type_e)
-#define hwloc_obj_osdev_type_t HWLOC_NAME(obj_osdev_type_t)
-#define HWLOC_OBJ_OSDEV_BLOCK HWLOC_NAME_CAPS(OBJ_OSDEV_BLOCK)
-#define HWLOC_OBJ_OSDEV_GPU HWLOC_NAME_CAPS(OBJ_OSDEV_GPU)
-#define HWLOC_OBJ_OSDEV_NETWORK HWLOC_NAME_CAPS(OBJ_OSDEV_NETWORK)
-#define HWLOC_OBJ_OSDEV_OPENFABRICS HWLOC_NAME_CAPS(OBJ_OSDEV_OPENFABRICS)
-#define HWLOC_OBJ_OSDEV_DMA HWLOC_NAME_CAPS(OBJ_OSDEV_DMA)
-#define HWLOC_OBJ_OSDEV_COPROC HWLOC_NAME_CAPS(OBJ_OSDEV_COPROC)
-
-#define hwloc_compare_types HWLOC_NAME(compare_types)
-
-#define hwloc_obj HWLOC_NAME(obj)
-#define hwloc_obj_t HWLOC_NAME(obj_t)
-
-#define hwloc_info_s HWLOC_NAME(info_s)
-
-#define hwloc_obj_attr_u HWLOC_NAME(obj_attr_u)
-#define hwloc_numanode_attr_s HWLOC_NAME(numanode_attr_s)
-#define hwloc_memory_page_type_s HWLOC_NAME(memory_page_type_s)
-#define hwloc_cache_attr_s HWLOC_NAME(cache_attr_s)
-#define hwloc_group_attr_s HWLOC_NAME(group_attr_s)
-#define hwloc_pcidev_attr_s HWLOC_NAME(pcidev_attr_s)
-#define hwloc_bridge_attr_s HWLOC_NAME(bridge_attr_s)
-#define hwloc_osdev_attr_s HWLOC_NAME(osdev_attr_s)
-
-#define hwloc_topology_init HWLOC_NAME(topology_init)
-#define hwloc_topology_load HWLOC_NAME(topology_load)
-#define hwloc_topology_destroy HWLOC_NAME(topology_destroy)
-#define hwloc_topology_dup HWLOC_NAME(topology_dup)
-#define hwloc_topology_abi_check HWLOC_NAME(topology_abi_check)
-#define hwloc_topology_check HWLOC_NAME(topology_check)
-
-#define hwloc_topology_flags_e HWLOC_NAME(topology_flags_e)
-
-#define HWLOC_TOPOLOGY_FLAG_INCLUDE_DISALLOWED HWLOC_NAME_CAPS(TOPOLOGY_FLAG_WITH_DISALLOWED)
-#define HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM HWLOC_NAME_CAPS(TOPOLOGY_FLAG_IS_THISSYSTEM)
-#define HWLOC_TOPOLOGY_FLAG_THISSYSTEM_ALLOWED_RESOURCES HWLOC_NAME_CAPS(TOPOLOGY_FLAG_THISSYSTEM_ALLOWED_RESOURCES)
-#define HWLOC_TOPOLOGY_FLAG_IMPORT_SUPPORT HWLOC_NAME_CAPS(TOPOLOGY_FLAG_IMPORT_SUPPORT)
-#define HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING HWLOC_NAME_CAPS(TOPOLOGY_FLAG_RESTRICT_TO_CPUBINDING)
-#define HWLOC_TOPOLOGY_FLAG_RESTRICT_TO_MEMBINDING HWLOC_NAME_CAPS(TOPOLOGY_FLAG_RESTRICT_TO_MEMBINDING)
-#define HWLOC_TOPOLOGY_FLAG_DONT_CHANGE_BINDING HWLOC_NAME_CAPS(TOPOLOGY_FLAG_DONT_CHANGE_BINDING)
-#define HWLOC_TOPOLOGY_FLAG_NO_DISTANCES HWLOC_NAME_CAPS(TOPOLOGY_FLAG_NO_DISTANCES)
-#define HWLOC_TOPOLOGY_FLAG_NO_MEMATTRS HWLOC_NAME_CAPS(TOPOLOGY_FLAG_NO_MEMATTRS)
-#define HWLOC_TOPOLOGY_FLAG_NO_CPUKINDS HWLOC_NAME_CAPS(TOPOLOGY_FLAG_NO_CPUKINDS)
-
-#define hwloc_topology_set_pid HWLOC_NAME(topology_set_pid)
-#define hwloc_topology_set_synthetic HWLOC_NAME(topology_set_synthetic)
-#define hwloc_topology_set_xml HWLOC_NAME(topology_set_xml)
-#define hwloc_topology_set_xmlbuffer HWLOC_NAME(topology_set_xmlbuffer)
-#define hwloc_topology_components_flag_e HWLOC_NAME(hwloc_topology_components_flag_e)
-#define HWLOC_TOPOLOGY_COMPONENTS_FLAG_BLACKLIST HWLOC_NAME_CAPS(TOPOLOGY_COMPONENTS_FLAG_BLACKLIST)
-#define hwloc_topology_set_components HWLOC_NAME(topology_set_components)
-
-#define hwloc_topology_set_flags HWLOC_NAME(topology_set_flags)
-#define hwloc_topology_is_thissystem HWLOC_NAME(topology_is_thissystem)
-#define hwloc_topology_get_flags HWLOC_NAME(topology_get_flags)
-#define hwloc_topology_discovery_support HWLOC_NAME(topology_discovery_support)
-#define hwloc_topology_cpubind_support HWLOC_NAME(topology_cpubind_support)
-#define hwloc_topology_membind_support HWLOC_NAME(topology_membind_support)
-#define hwloc_topology_misc_support HWLOC_NAME(topology_misc_support)
-#define hwloc_topology_support HWLOC_NAME(topology_support)
-#define hwloc_topology_get_support HWLOC_NAME(topology_get_support)
-
-#define hwloc_type_filter_e HWLOC_NAME(type_filter_e)
-#define HWLOC_TYPE_FILTER_KEEP_ALL HWLOC_NAME_CAPS(TYPE_FILTER_KEEP_ALL)
-#define HWLOC_TYPE_FILTER_KEEP_NONE HWLOC_NAME_CAPS(TYPE_FILTER_KEEP_NONE)
-#define HWLOC_TYPE_FILTER_KEEP_STRUCTURE HWLOC_NAME_CAPS(TYPE_FILTER_KEEP_STRUCTURE)
-#define HWLOC_TYPE_FILTER_KEEP_IMPORTANT HWLOC_NAME_CAPS(TYPE_FILTER_KEEP_IMPORTANT)
-#define hwloc_topology_set_type_filter HWLOC_NAME(topology_set_type_filter)
-#define hwloc_topology_get_type_filter HWLOC_NAME(topology_get_type_filter)
-#define hwloc_topology_set_all_types_filter HWLOC_NAME(topology_set_all_types_filter)
-#define hwloc_topology_set_cache_types_filter HWLOC_NAME(topology_set_cache_types_filter)
-#define hwloc_topology_set_icache_types_filter HWLOC_NAME(topology_set_icache_types_filter)
-#define hwloc_topology_set_io_types_filter HWLOC_NAME(topology_set_io_types_filter)
-
-#define hwloc_topology_set_userdata HWLOC_NAME(topology_set_userdata)
-#define hwloc_topology_get_userdata HWLOC_NAME(topology_get_userdata)
-
-#define hwloc_restrict_flags_e HWLOC_NAME(restrict_flags_e)
-#define HWLOC_RESTRICT_FLAG_REMOVE_CPULESS HWLOC_NAME_CAPS(RESTRICT_FLAG_REMOVE_CPULESS)
-#define HWLOC_RESTRICT_FLAG_BYNODESET HWLOC_NAME_CAPS(RESTRICT_FLAG_BYNODESET)
-#define HWLOC_RESTRICT_FLAG_REMOVE_MEMLESS HWLOC_NAME_CAPS(RESTRICT_FLAG_REMOVE_MEMLESS)
-#define HWLOC_RESTRICT_FLAG_ADAPT_MISC HWLOC_NAME_CAPS(RESTRICT_FLAG_ADAPT_MISC)
-#define HWLOC_RESTRICT_FLAG_ADAPT_IO HWLOC_NAME_CAPS(RESTRICT_FLAG_ADAPT_IO)
-#define hwloc_topology_restrict HWLOC_NAME(topology_restrict)
-
-#define hwloc_allow_flags_e HWLOC_NAME(allow_flags_e)
-#define HWLOC_ALLOW_FLAG_ALL HWLOC_NAME_CAPS(ALLOW_FLAG_ALL)
-#define HWLOC_ALLOW_FLAG_LOCAL_RESTRICTIONS HWLOC_NAME_CAPS(ALLOW_FLAG_LOCAL_RESTRICTIONS)
-#define HWLOC_ALLOW_FLAG_CUSTOM HWLOC_NAME_CAPS(ALLOW_FLAG_CUSTOM)
-#define hwloc_topology_allow HWLOC_NAME(topology_allow)
-
-#define hwloc_topology_insert_misc_object HWLOC_NAME(topology_insert_misc_object)
-#define hwloc_topology_alloc_group_object HWLOC_NAME(topology_alloc_group_object)
-#define hwloc_topology_free_group_object HWLOC_NAME(topology_free_group_object)
-#define hwloc_topology_insert_group_object HWLOC_NAME(topology_insert_group_object)
-#define hwloc_obj_add_other_obj_sets HWLOC_NAME(obj_add_other_obj_sets)
-#define hwloc_topology_refresh HWLOC_NAME(topology_refresh)
-
-#define hwloc_topology_get_depth HWLOC_NAME(topology_get_depth)
-#define hwloc_get_type_depth HWLOC_NAME(get_type_depth)
-#define hwloc_get_memory_parents_depth HWLOC_NAME(get_memory_parents_depth)
-
-#define hwloc_get_type_depth_e HWLOC_NAME(get_type_depth_e)
-#define HWLOC_TYPE_DEPTH_UNKNOWN HWLOC_NAME_CAPS(TYPE_DEPTH_UNKNOWN)
-#define HWLOC_TYPE_DEPTH_MULTIPLE HWLOC_NAME_CAPS(TYPE_DEPTH_MULTIPLE)
-#define HWLOC_TYPE_DEPTH_BRIDGE HWLOC_NAME_CAPS(TYPE_DEPTH_BRIDGE)
-#define HWLOC_TYPE_DEPTH_PCI_DEVICE HWLOC_NAME_CAPS(TYPE_DEPTH_PCI_DEVICE)
-#define HWLOC_TYPE_DEPTH_OS_DEVICE HWLOC_NAME_CAPS(TYPE_DEPTH_OS_DEVICE)
-#define HWLOC_TYPE_DEPTH_MISC HWLOC_NAME_CAPS(TYPE_DEPTH_MISC)
-#define HWLOC_TYPE_DEPTH_NUMANODE HWLOC_NAME_CAPS(TYPE_DEPTH_NUMANODE)
-#define HWLOC_TYPE_DEPTH_MEMCACHE HWLOC_NAME_CAPS(TYPE_DEPTH_MEMCACHE)
-
-#define hwloc_get_depth_type HWLOC_NAME(get_depth_type)
-#define hwloc_get_nbobjs_by_depth HWLOC_NAME(get_nbobjs_by_depth)
-#define hwloc_get_nbobjs_by_type HWLOC_NAME(get_nbobjs_by_type)
-
-#define hwloc_get_obj_by_depth HWLOC_NAME(get_obj_by_depth )
-#define hwloc_get_obj_by_type HWLOC_NAME(get_obj_by_type )
-
-#define hwloc_obj_type_string HWLOC_NAME(obj_type_string )
-#define hwloc_obj_type_snprintf HWLOC_NAME(obj_type_snprintf )
-#define hwloc_obj_attr_snprintf HWLOC_NAME(obj_attr_snprintf )
-#define hwloc_type_sscanf HWLOC_NAME(type_sscanf)
-#define hwloc_type_sscanf_as_depth HWLOC_NAME(type_sscanf_as_depth)
-
-#define hwloc_obj_get_info_by_name HWLOC_NAME(obj_get_info_by_name)
-#define hwloc_obj_add_info HWLOC_NAME(obj_add_info)
-#define hwloc_obj_set_subtype HWLOC_NAME(obj_set_subtype)
-
-#define HWLOC_CPUBIND_PROCESS HWLOC_NAME_CAPS(CPUBIND_PROCESS)
-#define HWLOC_CPUBIND_THREAD HWLOC_NAME_CAPS(CPUBIND_THREAD)
-#define HWLOC_CPUBIND_STRICT HWLOC_NAME_CAPS(CPUBIND_STRICT)
-#define HWLOC_CPUBIND_NOMEMBIND HWLOC_NAME_CAPS(CPUBIND_NOMEMBIND)
-
-#define hwloc_cpubind_flags_t HWLOC_NAME(cpubind_flags_t)
-
-#define hwloc_set_cpubind HWLOC_NAME(set_cpubind)
-#define hwloc_get_cpubind HWLOC_NAME(get_cpubind)
-#define hwloc_set_proc_cpubind HWLOC_NAME(set_proc_cpubind)
-#define hwloc_get_proc_cpubind HWLOC_NAME(get_proc_cpubind)
-#define hwloc_set_thread_cpubind HWLOC_NAME(set_thread_cpubind)
-#define hwloc_get_thread_cpubind HWLOC_NAME(get_thread_cpubind)
-
-#define hwloc_get_last_cpu_location HWLOC_NAME(get_last_cpu_location)
-#define hwloc_get_proc_last_cpu_location HWLOC_NAME(get_proc_last_cpu_location)
-
-#define HWLOC_MEMBIND_DEFAULT HWLOC_NAME_CAPS(MEMBIND_DEFAULT)
-#define HWLOC_MEMBIND_FIRSTTOUCH HWLOC_NAME_CAPS(MEMBIND_FIRSTTOUCH)
-#define HWLOC_MEMBIND_BIND HWLOC_NAME_CAPS(MEMBIND_BIND)
-#define HWLOC_MEMBIND_INTERLEAVE HWLOC_NAME_CAPS(MEMBIND_INTERLEAVE)
-#define HWLOC_MEMBIND_WEIGHTED_INTERLEAVE HWLOC_NAME_CAPS(MEMBIND_WEIGHTED_INTERLEAVE)
-#define HWLOC_MEMBIND_NEXTTOUCH HWLOC_NAME_CAPS(MEMBIND_NEXTTOUCH)
-#define HWLOC_MEMBIND_MIXED HWLOC_NAME_CAPS(MEMBIND_MIXED)
-
-#define hwloc_membind_policy_t HWLOC_NAME(membind_policy_t)
-
-#define HWLOC_MEMBIND_PROCESS HWLOC_NAME_CAPS(MEMBIND_PROCESS)
-#define HWLOC_MEMBIND_THREAD HWLOC_NAME_CAPS(MEMBIND_THREAD)
-#define HWLOC_MEMBIND_STRICT HWLOC_NAME_CAPS(MEMBIND_STRICT)
-#define HWLOC_MEMBIND_MIGRATE HWLOC_NAME_CAPS(MEMBIND_MIGRATE)
-#define HWLOC_MEMBIND_NOCPUBIND HWLOC_NAME_CAPS(MEMBIND_NOCPUBIND)
-#define HWLOC_MEMBIND_BYNODESET HWLOC_NAME_CAPS(MEMBIND_BYNODESET)
-
-#define hwloc_membind_flags_t HWLOC_NAME(membind_flags_t)
-
-#define hwloc_set_membind HWLOC_NAME(set_membind)
-#define hwloc_get_membind HWLOC_NAME(get_membind)
-#define hwloc_set_proc_membind HWLOC_NAME(set_proc_membind)
-#define hwloc_get_proc_membind HWLOC_NAME(get_proc_membind)
-#define hwloc_set_area_membind HWLOC_NAME(set_area_membind)
-#define hwloc_get_area_membind HWLOC_NAME(get_area_membind)
-#define hwloc_get_area_memlocation HWLOC_NAME(get_area_memlocation)
-#define hwloc_alloc_membind HWLOC_NAME(alloc_membind)
-#define hwloc_alloc HWLOC_NAME(alloc)
-#define hwloc_free HWLOC_NAME(free)
-
-#define hwloc_get_non_io_ancestor_obj HWLOC_NAME(get_non_io_ancestor_obj)
-#define hwloc_get_next_pcidev HWLOC_NAME(get_next_pcidev)
-#define hwloc_get_pcidev_by_busid HWLOC_NAME(get_pcidev_by_busid)
-#define hwloc_get_pcidev_by_busidstring HWLOC_NAME(get_pcidev_by_busidstring)
-#define hwloc_get_next_osdev HWLOC_NAME(get_next_osdev)
-#define hwloc_get_next_bridge HWLOC_NAME(get_next_bridge)
-#define hwloc_bridge_covers_pcibus HWLOC_NAME(bridge_covers_pcibus)
-
-/* hwloc/bitmap.h */
-
-#define hwloc_bitmap_s HWLOC_NAME(bitmap_s)
-#define hwloc_bitmap_t HWLOC_NAME(bitmap_t)
-#define hwloc_const_bitmap_t HWLOC_NAME(const_bitmap_t)
-
-#define hwloc_bitmap_alloc HWLOC_NAME(bitmap_alloc)
-#define hwloc_bitmap_alloc_full HWLOC_NAME(bitmap_alloc_full)
-#define hwloc_bitmap_free HWLOC_NAME(bitmap_free)
-#define hwloc_bitmap_dup HWLOC_NAME(bitmap_dup)
-#define hwloc_bitmap_copy HWLOC_NAME(bitmap_copy)
-#define hwloc_bitmap_snprintf HWLOC_NAME(bitmap_snprintf)
-#define hwloc_bitmap_asprintf HWLOC_NAME(bitmap_asprintf)
-#define hwloc_bitmap_sscanf HWLOC_NAME(bitmap_sscanf)
-#define hwloc_bitmap_list_snprintf HWLOC_NAME(bitmap_list_snprintf)
-#define hwloc_bitmap_list_asprintf HWLOC_NAME(bitmap_list_asprintf)
-#define hwloc_bitmap_list_sscanf HWLOC_NAME(bitmap_list_sscanf)
-#define hwloc_bitmap_taskset_snprintf HWLOC_NAME(bitmap_taskset_snprintf)
-#define hwloc_bitmap_taskset_asprintf HWLOC_NAME(bitmap_taskset_asprintf)
-#define hwloc_bitmap_taskset_sscanf HWLOC_NAME(bitmap_taskset_sscanf)
-#define hwloc_bitmap_zero HWLOC_NAME(bitmap_zero)
-#define hwloc_bitmap_fill HWLOC_NAME(bitmap_fill)
-#define hwloc_bitmap_from_ulong HWLOC_NAME(bitmap_from_ulong)
-#define hwloc_bitmap_from_ulongs HWLOC_NAME(bitmap_from_ulongs)
-#define hwloc_bitmap_from_ith_ulong HWLOC_NAME(bitmap_from_ith_ulong)
-#define hwloc_bitmap_to_ulong HWLOC_NAME(bitmap_to_ulong)
-#define hwloc_bitmap_to_ith_ulong HWLOC_NAME(bitmap_to_ith_ulong)
-#define hwloc_bitmap_to_ulongs HWLOC_NAME(bitmap_to_ulongs)
-#define hwloc_bitmap_nr_ulongs HWLOC_NAME(bitmap_nr_ulongs)
-#define hwloc_bitmap_only HWLOC_NAME(bitmap_only)
-#define hwloc_bitmap_allbut HWLOC_NAME(bitmap_allbut)
-#define hwloc_bitmap_set HWLOC_NAME(bitmap_set)
-#define hwloc_bitmap_set_range HWLOC_NAME(bitmap_set_range)
-#define hwloc_bitmap_set_ith_ulong HWLOC_NAME(bitmap_set_ith_ulong)
-#define hwloc_bitmap_clr HWLOC_NAME(bitmap_clr)
-#define hwloc_bitmap_clr_range HWLOC_NAME(bitmap_clr_range)
-#define hwloc_bitmap_isset HWLOC_NAME(bitmap_isset)
-#define hwloc_bitmap_iszero HWLOC_NAME(bitmap_iszero)
-#define hwloc_bitmap_isfull HWLOC_NAME(bitmap_isfull)
-#define hwloc_bitmap_isequal HWLOC_NAME(bitmap_isequal)
-#define hwloc_bitmap_intersects HWLOC_NAME(bitmap_intersects)
-#define hwloc_bitmap_isincluded HWLOC_NAME(bitmap_isincluded)
-#define hwloc_bitmap_or HWLOC_NAME(bitmap_or)
-#define hwloc_bitmap_and HWLOC_NAME(bitmap_and)
-#define hwloc_bitmap_andnot HWLOC_NAME(bitmap_andnot)
-#define hwloc_bitmap_xor HWLOC_NAME(bitmap_xor)
-#define hwloc_bitmap_not HWLOC_NAME(bitmap_not)
-#define hwloc_bitmap_first HWLOC_NAME(bitmap_first)
-#define hwloc_bitmap_last HWLOC_NAME(bitmap_last)
-#define hwloc_bitmap_next HWLOC_NAME(bitmap_next)
-#define hwloc_bitmap_first_unset HWLOC_NAME(bitmap_first_unset)
-#define hwloc_bitmap_last_unset HWLOC_NAME(bitmap_last_unset)
-#define hwloc_bitmap_next_unset HWLOC_NAME(bitmap_next_unset)
-#define hwloc_bitmap_singlify HWLOC_NAME(bitmap_singlify)
-#define hwloc_bitmap_compare_first HWLOC_NAME(bitmap_compare_first)
-#define hwloc_bitmap_compare HWLOC_NAME(bitmap_compare)
-#define hwloc_bitmap_weight HWLOC_NAME(bitmap_weight)
-
-/* hwloc/helper.h */
-
-#define hwloc_get_type_or_below_depth HWLOC_NAME(get_type_or_below_depth)
-#define hwloc_get_type_or_above_depth HWLOC_NAME(get_type_or_above_depth)
-#define hwloc_get_root_obj HWLOC_NAME(get_root_obj)
-#define hwloc_get_ancestor_obj_by_depth HWLOC_NAME(get_ancestor_obj_by_depth)
-#define hwloc_get_ancestor_obj_by_type HWLOC_NAME(get_ancestor_obj_by_type)
-#define hwloc_get_next_obj_by_depth HWLOC_NAME(get_next_obj_by_depth)
-#define hwloc_get_next_obj_by_type HWLOC_NAME(get_next_obj_by_type)
-#define hwloc_bitmap_singlify_per_core HWLOC_NAME(bitmap_singlify_by_core)
-#define hwloc_get_pu_obj_by_os_index HWLOC_NAME(get_pu_obj_by_os_index)
-#define hwloc_get_numanode_obj_by_os_index HWLOC_NAME(get_numanode_obj_by_os_index)
-#define hwloc_get_next_child HWLOC_NAME(get_next_child)
-#define hwloc_get_common_ancestor_obj HWLOC_NAME(get_common_ancestor_obj)
-#define hwloc_obj_is_in_subtree HWLOC_NAME(obj_is_in_subtree)
-#define hwloc_get_first_largest_obj_inside_cpuset HWLOC_NAME(get_first_largest_obj_inside_cpuset)
-#define hwloc_get_largest_objs_inside_cpuset HWLOC_NAME(get_largest_objs_inside_cpuset)
-#define hwloc_get_next_obj_inside_cpuset_by_depth HWLOC_NAME(get_next_obj_inside_cpuset_by_depth)
-#define hwloc_get_next_obj_inside_cpuset_by_type HWLOC_NAME(get_next_obj_inside_cpuset_by_type)
-#define hwloc_get_obj_inside_cpuset_by_depth HWLOC_NAME(get_obj_inside_cpuset_by_depth)
-#define hwloc_get_obj_inside_cpuset_by_type HWLOC_NAME(get_obj_inside_cpuset_by_type)
-#define hwloc_get_nbobjs_inside_cpuset_by_depth HWLOC_NAME(get_nbobjs_inside_cpuset_by_depth)
-#define hwloc_get_nbobjs_inside_cpuset_by_type HWLOC_NAME(get_nbobjs_inside_cpuset_by_type)
-#define hwloc_get_obj_index_inside_cpuset HWLOC_NAME(get_obj_index_inside_cpuset)
-#define hwloc_get_child_covering_cpuset HWLOC_NAME(get_child_covering_cpuset)
-#define hwloc_get_obj_covering_cpuset HWLOC_NAME(get_obj_covering_cpuset)
-#define hwloc_get_next_obj_covering_cpuset_by_depth HWLOC_NAME(get_next_obj_covering_cpuset_by_depth)
-#define hwloc_get_next_obj_covering_cpuset_by_type HWLOC_NAME(get_next_obj_covering_cpuset_by_type)
-#define hwloc_obj_type_is_normal HWLOC_NAME(obj_type_is_normal)
-#define hwloc_obj_type_is_memory HWLOC_NAME(obj_type_is_memory)
-#define hwloc_obj_type_is_io HWLOC_NAME(obj_type_is_io)
-#define hwloc_obj_type_is_cache HWLOC_NAME(obj_type_is_cache)
-#define hwloc_obj_type_is_dcache HWLOC_NAME(obj_type_is_dcache)
-#define hwloc_obj_type_is_icache HWLOC_NAME(obj_type_is_icache)
-#define hwloc_get_cache_type_depth HWLOC_NAME(get_cache_type_depth)
-#define hwloc_get_cache_covering_cpuset HWLOC_NAME(get_cache_covering_cpuset)
-#define hwloc_get_shared_cache_covering_obj HWLOC_NAME(get_shared_cache_covering_obj)
-#define hwloc_get_closest_objs HWLOC_NAME(get_closest_objs)
-#define hwloc_get_obj_below_by_type HWLOC_NAME(get_obj_below_by_type)
-#define hwloc_get_obj_below_array_by_type HWLOC_NAME(get_obj_below_array_by_type)
-#define hwloc_get_obj_with_same_locality HWLOC_NAME(get_obj_with_same_locality)
-#define hwloc_distrib_flags_e HWLOC_NAME(distrib_flags_e)
-#define HWLOC_DISTRIB_FLAG_REVERSE HWLOC_NAME_CAPS(DISTRIB_FLAG_REVERSE)
-#define hwloc_distrib HWLOC_NAME(distrib)
-#define hwloc_alloc_membind_policy HWLOC_NAME(alloc_membind_policy)
-#define hwloc_alloc_membind_policy_nodeset HWLOC_NAME(alloc_membind_policy_nodeset)
-#define hwloc_topology_get_complete_cpuset HWLOC_NAME(topology_get_complete_cpuset)
-#define hwloc_topology_get_topology_cpuset HWLOC_NAME(topology_get_topology_cpuset)
-#define hwloc_topology_get_allowed_cpuset HWLOC_NAME(topology_get_allowed_cpuset)
-#define hwloc_topology_get_complete_nodeset HWLOC_NAME(topology_get_complete_nodeset)
-#define hwloc_topology_get_topology_nodeset HWLOC_NAME(topology_get_topology_nodeset)
-#define hwloc_topology_get_allowed_nodeset HWLOC_NAME(topology_get_allowed_nodeset)
-#define hwloc_cpuset_to_nodeset HWLOC_NAME(cpuset_to_nodeset)
-#define hwloc_cpuset_from_nodeset HWLOC_NAME(cpuset_from_nodeset)
-
-/* memattrs.h */
-
-#define hwloc_memattr_id_e HWLOC_NAME(memattr_id_e)
-#define HWLOC_MEMATTR_ID_CAPACITY HWLOC_NAME_CAPS(MEMATTR_ID_CAPACITY)
-#define HWLOC_MEMATTR_ID_LOCALITY HWLOC_NAME_CAPS(MEMATTR_ID_LOCALITY)
-#define HWLOC_MEMATTR_ID_BANDWIDTH HWLOC_NAME_CAPS(MEMATTR_ID_BANDWIDTH)
-#define HWLOC_MEMATTR_ID_LATENCY HWLOC_NAME_CAPS(MEMATTR_ID_LATENCY)
-#define HWLOC_MEMATTR_ID_READ_BANDWIDTH HWLOC_NAME_CAPS(MEMATTR_ID_READ_BANDWIDTH)
-#define HWLOC_MEMATTR_ID_WRITE_BANDWIDTH HWLOC_NAME_CAPS(MEMATTR_ID_WRITE_BANDWIDTH)
-#define HWLOC_MEMATTR_ID_READ_LATENCY HWLOC_NAME_CAPS(MEMATTR_ID_READ_LATENCY)
-#define HWLOC_MEMATTR_ID_WRITE_LATENCY HWLOC_NAME_CAPS(MEMATTR_ID_WRITE_LATENCY)
-#define HWLOC_MEMATTR_ID_MAX HWLOC_NAME_CAPS(MEMATTR_ID_MAX)
-
-#define hwloc_memattr_id_t HWLOC_NAME(memattr_id_t)
-#define hwloc_memattr_get_by_name HWLOC_NAME(memattr_get_by_name)
-
-#define hwloc_location HWLOC_NAME(location)
-#define hwloc_location_type_e HWLOC_NAME(location_type_e)
-#define HWLOC_LOCATION_TYPE_OBJECT HWLOC_NAME_CAPS(LOCATION_TYPE_OBJECT)
-#define HWLOC_LOCATION_TYPE_CPUSET HWLOC_NAME_CAPS(LOCATION_TYPE_CPUSET)
-#define hwloc_location_u HWLOC_NAME(location_u)
-
-#define hwloc_memattr_get_value HWLOC_NAME(memattr_get_value)
-#define hwloc_memattr_get_best_target HWLOC_NAME(memattr_get_best_target)
-#define hwloc_memattr_get_best_initiator HWLOC_NAME(memattr_get_best_initiator)
-
-#define hwloc_local_numanode_flag_e HWLOC_NAME(local_numanode_flag_e)
-#define HWLOC_LOCAL_NUMANODE_FLAG_LARGER_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_LARGER_LOCALITY)
-#define HWLOC_LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_SMALLER_LOCALITY)
-#define HWLOC_LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_INTERSECT_LOCALITY)
-#define HWLOC_LOCAL_NUMANODE_FLAG_ALL HWLOC_NAME_CAPS(LOCAL_NUMANODE_FLAG_ALL)
-#define hwloc_get_local_numanode_objs HWLOC_NAME(get_local_numanode_objs)
-#define hwloc_topology_get_default_nodeset HWLOC_NAME(topology_get_default_nodeset)
-
-#define hwloc_memattr_get_name HWLOC_NAME(memattr_get_name)
-#define hwloc_memattr_get_flags HWLOC_NAME(memattr_get_flags)
-#define hwloc_memattr_flag_e HWLOC_NAME(memattr_flag_e)
-#define HWLOC_MEMATTR_FLAG_HIGHER_FIRST HWLOC_NAME_CAPS(MEMATTR_FLAG_HIGHER_FIRST)
-#define HWLOC_MEMATTR_FLAG_LOWER_FIRST HWLOC_NAME_CAPS(MEMATTR_FLAG_LOWER_FIRST)
-#define HWLOC_MEMATTR_FLAG_NEED_INITIATOR HWLOC_NAME_CAPS(MEMATTR_FLAG_NEED_INITIATOR)
-#define hwloc_memattr_register HWLOC_NAME(memattr_register)
-#define hwloc_memattr_set_value HWLOC_NAME(memattr_set_value)
-#define hwloc_memattr_get_targets HWLOC_NAME(memattr_get_targets)
-#define hwloc_memattr_get_initiators HWLOC_NAME(memattr_get_initiators)
-
-/* cpukinds.h */
-
-#define hwloc_cpukinds_get_nr HWLOC_NAME(cpukinds_get_nr)
-#define hwloc_cpukinds_get_by_cpuset HWLOC_NAME(cpukinds_get_by_cpuset)
-#define hwloc_cpukinds_get_info HWLOC_NAME(cpukinds_get_info)
-#define hwloc_cpukinds_register HWLOC_NAME(cpukinds_register)
-
-/* export.h */
-
-#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 HWLOC_NAME(topology_export_xml)
-#define hwloc_topology_export_xmlbuffer HWLOC_NAME(topology_export_xmlbuffer)
-#define hwloc_free_xmlbuffer HWLOC_NAME(free_xmlbuffer)
-#define hwloc_topology_set_userdata_export_callback HWLOC_NAME(topology_set_userdata_export_callback)
-#define hwloc_export_obj_userdata HWLOC_NAME(export_obj_userdata)
-#define hwloc_export_obj_userdata_base64 HWLOC_NAME(export_obj_userdata_base64)
-#define hwloc_topology_set_userdata_import_callback HWLOC_NAME(topology_set_userdata_import_callback)
-
-#define hwloc_topology_export_synthetic_flags_e HWLOC_NAME(topology_export_synthetic_flags_e)
-#define HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_NO_EXTENDED_TYPES HWLOC_NAME_CAPS(TOPOLOGY_EXPORT_SYNTHETIC_FLAG_NO_EXTENDED_TYPES)
-#define HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_NO_ATTRS HWLOC_NAME_CAPS(TOPOLOGY_EXPORT_SYNTHETIC_FLAG_NO_ATTRS)
-#define HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_V1 HWLOC_NAME_CAPS(TOPOLOGY_EXPORT_SYNTHETIC_FLAG_V1)
-#define HWLOC_TOPOLOGY_EXPORT_SYNTHETIC_FLAG_IGNORE_MEMORY HWLOC_NAME_CAPS(TOPOLOGY_EXPORT_SYNTHETIC_FLAG_IGNORE_MEMORY)
-#define hwloc_topology_export_synthetic HWLOC_NAME(topology_export_synthetic)
-
-/* distances.h */
-
-#define hwloc_distances_s HWLOC_NAME(distances_s)
-
-#define hwloc_distances_kind_e HWLOC_NAME(distances_kind_e)
-#define HWLOC_DISTANCES_KIND_FROM_OS HWLOC_NAME_CAPS(DISTANCES_KIND_FROM_OS)
-#define HWLOC_DISTANCES_KIND_FROM_USER HWLOC_NAME_CAPS(DISTANCES_KIND_FROM_USER)
-#define HWLOC_DISTANCES_KIND_MEANS_LATENCY HWLOC_NAME_CAPS(DISTANCES_KIND_MEANS_LATENCY)
-#define HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH HWLOC_NAME_CAPS(DISTANCES_KIND_MEANS_BANDWIDTH)
-#define HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES HWLOC_NAME_CAPS(DISTANCES_KIND_HETEROGENEOUS_TYPES)
-
-#define hwloc_distances_get HWLOC_NAME(distances_get)
-#define hwloc_distances_get_by_depth HWLOC_NAME(distances_get_by_depth)
-#define hwloc_distances_get_by_type HWLOC_NAME(distances_get_by_type)
-#define hwloc_distances_get_by_name HWLOC_NAME(distances_get_by_name)
-#define hwloc_distances_get_name HWLOC_NAME(distances_get_name)
-#define hwloc_distances_release HWLOC_NAME(distances_release)
-#define hwloc_distances_obj_index HWLOC_NAME(distances_obj_index)
-#define hwloc_distances_obj_pair_values HWLOC_NAME(distances_pair_values)
-
-#define hwloc_distances_transform_e HWLOC_NAME(distances_transform_e)
-#define HWLOC_DISTANCES_TRANSFORM_REMOVE_NULL HWLOC_NAME_CAPS(DISTANCES_TRANSFORM_REMOVE_NULL)
-#define HWLOC_DISTANCES_TRANSFORM_LINKS HWLOC_NAME_CAPS(DISTANCES_TRANSFORM_LINKS)
-#define HWLOC_DISTANCES_TRANSFORM_MERGE_SWITCH_PORTS HWLOC_NAME_CAPS(DISTANCES_TRANSFORM_MERGE_SWITCH_PORTS)
-#define HWLOC_DISTANCES_TRANSFORM_TRANSITIVE_CLOSURE HWLOC_NAME_CAPS(DISTANCES_TRANSFORM_TRANSITIVE_CLOSURE)
-#define hwloc_distances_transform HWLOC_NAME(distances_transform)
-
-#define hwloc_distances_add_flag_e HWLOC_NAME(distances_add_flag_e)
-#define HWLOC_DISTANCES_ADD_FLAG_GROUP HWLOC_NAME_CAPS(DISTANCES_ADD_FLAG_GROUP)
-#define HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE HWLOC_NAME_CAPS(DISTANCES_ADD_FLAG_GROUP_INACCURATE)
-
-#define hwloc_distances_add_handle_t HWLOC_NAME(distances_add_handle_t)
-#define hwloc_distances_add_create HWLOC_NAME(distances_add_create)
-#define hwloc_distances_add_values HWLOC_NAME(distances_add_values)
-#define hwloc_distances_add_commit HWLOC_NAME(distances_add_commit)
-
-#define hwloc_distances_remove HWLOC_NAME(distances_remove)
-#define hwloc_distances_remove_by_depth HWLOC_NAME(distances_remove_by_depth)
-#define hwloc_distances_remove_by_type HWLOC_NAME(distances_remove_by_type)
-#define hwloc_distances_release_remove HWLOC_NAME(distances_release_remove)
-
-/* diff.h */
-
-#define hwloc_topology_diff_obj_attr_type_e HWLOC_NAME(topology_diff_obj_attr_type_e)
-#define hwloc_topology_diff_obj_attr_type_t HWLOC_NAME(topology_diff_obj_attr_type_t)
-#define HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_SIZE HWLOC_NAME_CAPS(TOPOLOGY_DIFF_OBJ_ATTR_SIZE)
-#define HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_NAME HWLOC_NAME_CAPS(TOPOLOGY_DIFF_OBJ_ATTR_NAME)
-#define HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO HWLOC_NAME_CAPS(TOPOLOGY_DIFF_OBJ_ATTR_INFO)
-#define hwloc_topology_diff_obj_attr_u HWLOC_NAME(topology_diff_obj_attr_u)
-#define hwloc_topology_diff_obj_attr_generic_s HWLOC_NAME(topology_diff_obj_attr_generic_s)
-#define hwloc_topology_diff_obj_attr_uint64_s HWLOC_NAME(topology_diff_obj_attr_uint64_s)
-#define hwloc_topology_diff_obj_attr_string_s HWLOC_NAME(topology_diff_obj_attr_string_s)
-#define hwloc_topology_diff_type_e HWLOC_NAME(topology_diff_type_e)
-#define hwloc_topology_diff_type_t HWLOC_NAME(topology_diff_type_t)
-#define HWLOC_TOPOLOGY_DIFF_OBJ_ATTR HWLOC_NAME_CAPS(TOPOLOGY_DIFF_OBJ_ATTR)
-#define HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX HWLOC_NAME_CAPS(TOPOLOGY_DIFF_TOO_COMPLEX)
-#define hwloc_topology_diff_u HWLOC_NAME(topology_diff_u)
-#define hwloc_topology_diff_t HWLOC_NAME(topology_diff_t)
-#define hwloc_topology_diff_generic_s HWLOC_NAME(topology_diff_generic_s)
-#define hwloc_topology_diff_obj_attr_s HWLOC_NAME(topology_diff_obj_attr_s)
-#define hwloc_topology_diff_too_complex_s HWLOC_NAME(topology_diff_too_complex_s)
-#define hwloc_topology_diff_build HWLOC_NAME(topology_diff_build)
-#define hwloc_topology_diff_apply_flags_e HWLOC_NAME(topology_diff_apply_flags_e)
-#define HWLOC_TOPOLOGY_DIFF_APPLY_REVERSE HWLOC_NAME_CAPS(TOPOLOGY_DIFF_APPLY_REVERSE)
-#define hwloc_topology_diff_apply HWLOC_NAME(topology_diff_apply)
-#define hwloc_topology_diff_destroy HWLOC_NAME(topology_diff_destroy)
-#define hwloc_topology_diff_load_xml HWLOC_NAME(topology_diff_load_xml)
-#define hwloc_topology_diff_export_xml HWLOC_NAME(topology_diff_export_xml)
-#define hwloc_topology_diff_load_xmlbuffer HWLOC_NAME(topology_diff_load_xmlbuffer)
-#define hwloc_topology_diff_export_xmlbuffer HWLOC_NAME(topology_diff_export_xmlbuffer)
-
-/* shmem.h */
-
-#define hwloc_shmem_topology_get_length HWLOC_NAME(shmem_topology_get_length)
-#define hwloc_shmem_topology_write HWLOC_NAME(shmem_topology_write)
-#define hwloc_shmem_topology_adopt HWLOC_NAME(shmem_topology_adopt)
-
-/* glibc-sched.h */
-
-#define hwloc_cpuset_to_glibc_sched_affinity HWLOC_NAME(cpuset_to_glibc_sched_affinity)
-#define hwloc_cpuset_from_glibc_sched_affinity HWLOC_NAME(cpuset_from_glibc_sched_affinity)
-
-/* linux-libnuma.h */
-
-#define hwloc_cpuset_to_linux_libnuma_ulongs HWLOC_NAME(cpuset_to_linux_libnuma_ulongs)
-#define hwloc_nodeset_to_linux_libnuma_ulongs HWLOC_NAME(nodeset_to_linux_libnuma_ulongs)
-#define hwloc_cpuset_from_linux_libnuma_ulongs HWLOC_NAME(cpuset_from_linux_libnuma_ulongs)
-#define hwloc_nodeset_from_linux_libnuma_ulongs HWLOC_NAME(nodeset_from_linux_libnuma_ulongs)
-#define hwloc_cpuset_to_linux_libnuma_bitmask HWLOC_NAME(cpuset_to_linux_libnuma_bitmask)
-#define hwloc_nodeset_to_linux_libnuma_bitmask HWLOC_NAME(nodeset_to_linux_libnuma_bitmask)
-#define hwloc_cpuset_from_linux_libnuma_bitmask HWLOC_NAME(cpuset_from_linux_libnuma_bitmask)
-#define hwloc_nodeset_from_linux_libnuma_bitmask HWLOC_NAME(nodeset_from_linux_libnuma_bitmask)
-
-/* linux.h */
-
-#define hwloc_linux_set_tid_cpubind HWLOC_NAME(linux_set_tid_cpubind)
-#define hwloc_linux_get_tid_cpubind HWLOC_NAME(linux_get_tid_cpubind)
-#define hwloc_linux_get_tid_last_cpu_location HWLOC_NAME(linux_get_tid_last_cpu_location)
-#define hwloc_linux_read_path_as_cpumask HWLOC_NAME(linux_read_file_cpumask)
-
-/* windows.h */
-
-#define hwloc_windows_get_nr_processor_groups HWLOC_NAME(windows_get_nr_processor_groups)
-#define hwloc_windows_get_processor_group_cpuset HWLOC_NAME(windows_get_processor_group_cpuset)
-
-/* openfabrics-verbs.h */
-
-#define hwloc_ibv_get_device_cpuset HWLOC_NAME(ibv_get_device_cpuset)
-#define hwloc_ibv_get_device_osdev HWLOC_NAME(ibv_get_device_osdev)
-#define hwloc_ibv_get_device_osdev_by_name HWLOC_NAME(ibv_get_device_osdev_by_name)
-
-/* opencl.h */
-
-#define hwloc_cl_device_pci_bus_info_khr HWLOC_NAME(cl_device_pci_bus_info_khr)
-#define hwloc_cl_device_topology_amd HWLOC_NAME(cl_device_topology_amd)
-#define hwloc_opencl_get_device_pci_busid HWLOC_NAME(opencl_get_device_pci_ids)
-#define hwloc_opencl_get_device_cpuset HWLOC_NAME(opencl_get_device_cpuset)
-#define hwloc_opencl_get_device_osdev HWLOC_NAME(opencl_get_device_osdev)
-#define hwloc_opencl_get_device_osdev_by_index HWLOC_NAME(opencl_get_device_osdev_by_index)
-
-/* cuda.h */
-
-#define hwloc_cuda_get_device_pci_ids HWLOC_NAME(cuda_get_device_pci_ids)
-#define hwloc_cuda_get_device_cpuset HWLOC_NAME(cuda_get_device_cpuset)
-#define hwloc_cuda_get_device_pcidev HWLOC_NAME(cuda_get_device_pcidev)
-#define hwloc_cuda_get_device_osdev HWLOC_NAME(cuda_get_device_osdev)
-#define hwloc_cuda_get_device_osdev_by_index HWLOC_NAME(cuda_get_device_osdev_by_index)
-
-/* cudart.h */
-
-#define hwloc_cudart_get_device_pci_ids HWLOC_NAME(cudart_get_device_pci_ids)
-#define hwloc_cudart_get_device_cpuset HWLOC_NAME(cudart_get_device_cpuset)
-#define hwloc_cudart_get_device_pcidev HWLOC_NAME(cudart_get_device_pcidev)
-#define hwloc_cudart_get_device_osdev_by_index HWLOC_NAME(cudart_get_device_osdev_by_index)
-
-/* nvml.h */
-
-#define hwloc_nvml_get_device_cpuset HWLOC_NAME(nvml_get_device_cpuset)
-#define hwloc_nvml_get_device_osdev HWLOC_NAME(nvml_get_device_osdev)
-#define hwloc_nvml_get_device_osdev_by_index HWLOC_NAME(nvml_get_device_osdev_by_index)
-
-/* rsmi.h */
-
-#define hwloc_rsmi_get_device_cpuset HWLOC_NAME(rsmi_get_device_cpuset)
-#define hwloc_rsmi_get_device_osdev HWLOC_NAME(rsmi_get_device_osdev)
-#define hwloc_rsmi_get_device_osdev_by_index HWLOC_NAME(rsmi_get_device_osdev_by_index)
-
-/* levelzero.h */
-
-#define hwloc_levelzero_get_device_cpuset HWLOC_NAME(levelzero_get_device_cpuset)
-#define hwloc_levelzero_get_sysman_device_cpuset HWLOC_NAME(levelzero_get_sysman_device_cpuset)
-#define hwloc_levelzero_get_device_osdev HWLOC_NAME(levelzero_get_device_osdev)
-#define hwloc_levelzero_get_sysman_device_osdev HWLOC_NAME(levelzero_get_sysman_device_osdev)
-
-/* gl.h */
-
-#define hwloc_gl_get_display_osdev_by_port_device HWLOC_NAME(gl_get_display_osdev_by_port_device)
-#define hwloc_gl_get_display_osdev_by_name HWLOC_NAME(gl_get_display_osdev_by_name)
-#define hwloc_gl_get_display_by_osdev HWLOC_NAME(gl_get_display_by_osdev)
-
-/* hwloc/plugins.h */
-
-#define hwloc_disc_phase_e HWLOC_NAME(disc_phase_e)
-#define HWLOC_DISC_PHASE_GLOBAL HWLOC_NAME_CAPS(DISC_PHASE_GLOBAL)
-#define HWLOC_DISC_PHASE_CPU HWLOC_NAME_CAPS(DISC_PHASE_CPU)
-#define HWLOC_DISC_PHASE_MEMORY HWLOC_NAME_CAPS(DISC_PHASE_MEMORY)
-#define HWLOC_DISC_PHASE_PCI HWLOC_NAME_CAPS(DISC_PHASE_PCI)
-#define HWLOC_DISC_PHASE_IO HWLOC_NAME_CAPS(DISC_PHASE_IO)
-#define HWLOC_DISC_PHASE_MISC HWLOC_NAME_CAPS(DISC_PHASE_MISC)
-#define HWLOC_DISC_PHASE_ANNOTATE HWLOC_NAME_CAPS(DISC_PHASE_ANNOTATE)
-#define HWLOC_DISC_PHASE_TWEAK HWLOC_NAME_CAPS(DISC_PHASE_TWEAK)
-#define hwloc_disc_phase_t HWLOC_NAME(disc_phase_t)
-#define hwloc_disc_component HWLOC_NAME(disc_component)
-
-#define hwloc_disc_status_flag_e HWLOC_NAME(disc_status_flag_e)
-#define HWLOC_DISC_STATUS_FLAG_GOT_ALLOWED_RESOURCES HWLOC_NAME_CAPS(DISC_STATUS_FLAG_GOT_ALLOWED_RESOURCES)
-#define hwloc_disc_status HWLOC_NAME(disc_status)
-
-#define hwloc_backend HWLOC_NAME(backend)
-
-#define hwloc_backend_alloc HWLOC_NAME(backend_alloc)
-#define hwloc_backend_enable HWLOC_NAME(backend_enable)
-
-#define hwloc_component_type_e HWLOC_NAME(component_type_e)
-#define HWLOC_COMPONENT_TYPE_DISC HWLOC_NAME_CAPS(COMPONENT_TYPE_DISC)
-#define HWLOC_COMPONENT_TYPE_XML HWLOC_NAME_CAPS(COMPONENT_TYPE_XML)
-#define hwloc_component_type_t HWLOC_NAME(component_type_t)
-#define hwloc_component HWLOC_NAME(component)
-
-#define hwloc_plugin_check_namespace HWLOC_NAME(plugin_check_namespace)
-
-#define hwloc_hide_errors HWLOC_NAME(hide_errors)
-#define hwloc__insert_object_by_cpuset HWLOC_NAME(_insert_object_by_cpuset)
-#define hwloc_insert_object_by_parent HWLOC_NAME(insert_object_by_parent)
-#define hwloc_alloc_setup_object HWLOC_NAME(alloc_setup_object)
-#define hwloc_obj_add_children_sets HWLOC_NAME(add_children_sets)
-#define hwloc_topology_reconnect HWLOC_NAME(topology_reconnect)
-
-#define hwloc_filter_check_pcidev_subtype_important HWLOC_NAME(filter_check_pcidev_subtype_important)
-#define hwloc_filter_check_osdev_subtype_important HWLOC_NAME(filter_check_osdev_subtype_important)
-#define hwloc_filter_check_keep_object_type HWLOC_NAME(filter_check_keep_object_type)
-#define hwloc_filter_check_keep_object HWLOC_NAME(filter_check_keep_object)
-
-#define hwloc_pcidisc_find_cap HWLOC_NAME(pcidisc_find_cap)
-#define hwloc_pcidisc_find_linkspeed HWLOC_NAME(pcidisc_find_linkspeed)
-#define hwloc_pcidisc_check_bridge_type HWLOC_NAME(pcidisc_check_bridge_type)
-#define hwloc_pcidisc_find_bridge_buses HWLOC_NAME(pcidisc_find_bridge_buses)
-#define hwloc_pcidisc_tree_insert_by_busid HWLOC_NAME(pcidisc_tree_insert_by_busid)
-#define hwloc_pcidisc_tree_attach HWLOC_NAME(pcidisc_tree_attach)
-
-#define hwloc_pci_find_by_busid HWLOC_NAME(pcidisc_find_by_busid)
-#define hwloc_pci_find_parent_by_busid HWLOC_NAME(pcidisc_find_busid_parent)
-
-#define hwloc_backend_distances_add_handle_t HWLOC_NAME(backend_distances_add_handle_t)
-#define hwloc_backend_distances_add_create HWLOC_NAME(backend_distances_add_create)
-#define hwloc_backend_distances_add_values HWLOC_NAME(backend_distances_add_values)
-#define hwloc_backend_distances_add_commit HWLOC_NAME(backend_distances_add_commit)
-
-/* hwloc/deprecated.h */
-
-#define hwloc_distances_add HWLOC_NAME(distances_add)
-
-#define hwloc_topology_insert_misc_object_by_parent HWLOC_NAME(topology_insert_misc_object_by_parent)
-#define hwloc_obj_cpuset_snprintf HWLOC_NAME(obj_cpuset_snprintf)
-#define hwloc_obj_type_sscanf HWLOC_NAME(obj_type_sscanf)
-
-#define hwloc_set_membind_nodeset HWLOC_NAME(set_membind_nodeset)
-#define hwloc_get_membind_nodeset HWLOC_NAME(get_membind_nodeset)
-#define hwloc_set_proc_membind_nodeset HWLOC_NAME(set_proc_membind_nodeset)
-#define hwloc_get_proc_membind_nodeset HWLOC_NAME(get_proc_membind_nodeset)
-#define hwloc_set_area_membind_nodeset HWLOC_NAME(set_area_membind_nodeset)
-#define hwloc_get_area_membind_nodeset HWLOC_NAME(get_area_membind_nodeset)
-#define hwloc_alloc_membind_nodeset HWLOC_NAME(alloc_membind_nodeset)
-
-#define hwloc_cpuset_to_nodeset_strict HWLOC_NAME(cpuset_to_nodeset_strict)
-#define hwloc_cpuset_from_nodeset_strict HWLOC_NAME(cpuset_from_nodeset_strict)
-
-/* private/debug.h */
-
-#define hwloc_debug_enabled HWLOC_NAME(debug_enabled)
-#define hwloc_debug HWLOC_NAME(debug)
-
-/* private/misc.h */
-
-#ifndef HWLOC_HAVE_CORRECT_SNPRINTF
-#define hwloc_snprintf HWLOC_NAME(snprintf)
-#endif
-#define hwloc_ffsl_manual HWLOC_NAME(ffsl_manual)
-#define hwloc_ffs32 HWLOC_NAME(ffs32)
-#define hwloc_ffsl_from_ffs32 HWLOC_NAME(ffsl_from_ffs32)
-#define hwloc_flsl_manual HWLOC_NAME(flsl_manual)
-#define hwloc_fls32 HWLOC_NAME(fls32)
-#define hwloc_flsl_from_fls32 HWLOC_NAME(flsl_from_fls32)
-#define hwloc_weight_long HWLOC_NAME(weight_long)
-#define hwloc_strncasecmp HWLOC_NAME(strncasecmp)
-
-#define hwloc_bitmap_compare_inclusion HWLOC_NAME(bitmap_compare_inclusion)
-
-#define hwloc_pci_class_string HWLOC_NAME(pci_class_string)
-#define hwloc_linux_pci_link_speed_from_string HWLOC_NAME(linux_pci_link_speed_from_string)
-
-#define hwloc_cache_type_by_depth_type HWLOC_NAME(cache_type_by_depth_type)
-#define hwloc__obj_type_is_normal HWLOC_NAME(_obj_type_is_normal)
-#define hwloc__obj_type_is_memory HWLOC_NAME(_obj_type_is_memory)
-#define hwloc__obj_type_is_io HWLOC_NAME(_obj_type_is_io)
-#define hwloc__obj_type_is_special HWLOC_NAME(_obj_type_is_special)
-
-#define hwloc__obj_type_is_cache HWLOC_NAME(_obj_type_is_cache)
-#define hwloc__obj_type_is_dcache HWLOC_NAME(_obj_type_is_dcache)
-#define hwloc__obj_type_is_icache HWLOC_NAME(_obj_type_is_icache)
-
-#define hwloc__pci_link_speed HWLOC_NAME(_pci_link_speed)
-
-/* private/cpuid-x86.h */
-
-#define hwloc_have_x86_cpuid HWLOC_NAME(have_x86_cpuid)
-#define hwloc_x86_cpuid HWLOC_NAME(x86_cpuid)
-
-/* private/xml.h */
-
-#define hwloc__xml_verbose HWLOC_NAME(_xml_verbose)
-
-#define hwloc__xml_import_state_s HWLOC_NAME(_xml_import_state_s)
-#define hwloc__xml_import_state_t HWLOC_NAME(_xml_import_state_t)
-#define hwloc__xml_import_diff HWLOC_NAME(_xml_import_diff)
-#define hwloc_xml_backend_data_s HWLOC_NAME(xml_backend_data_s)
-#define hwloc__xml_export_state_s HWLOC_NAME(_xml_export_state_s)
-#define hwloc__xml_export_state_t HWLOC_NAME(_xml_export_state_t)
-#define hwloc__xml_export_data_s HWLOC_NAME(_xml_export_data_s)
-#define hwloc__xml_export_topology HWLOC_NAME(_xml_export_topology)
-#define hwloc__xml_export_diff HWLOC_NAME(_xml_export_diff)
-
-#define hwloc_xml_callbacks HWLOC_NAME(xml_callbacks)
-#define hwloc_xml_component HWLOC_NAME(xml_component)
-#define hwloc_xml_callbacks_register HWLOC_NAME(xml_callbacks_register)
-#define hwloc_xml_callbacks_reset HWLOC_NAME(xml_callbacks_reset)
-
-#define hwloc__xml_imported_v1distances_s HWLOC_NAME(_xml_imported_v1distances_s)
-
-/* private/components.h */
-
-#define hwloc_disc_component_force_enable HWLOC_NAME(disc_component_force_enable)
-#define hwloc_disc_components_enable_others HWLOC_NAME(disc_components_instantiate_others)
-
-#define hwloc_backends_is_thissystem HWLOC_NAME(backends_is_thissystem)
-#define hwloc_backends_find_callbacks HWLOC_NAME(backends_find_callbacks)
-
-#define hwloc_topology_components_init HWLOC_NAME(topology_components_init)
-#define hwloc_backends_disable_all HWLOC_NAME(backends_disable_all)
-#define hwloc_topology_components_fini HWLOC_NAME(topology_components_fini)
-
-#define hwloc_components_init HWLOC_NAME(components_init)
-#define hwloc_components_fini HWLOC_NAME(components_fini)
-
-/* private/internal-private.h */
-
-#define hwloc_xml_component HWLOC_NAME(xml_component)
-#define hwloc_synthetic_component HWLOC_NAME(synthetic_component)
-
-#define hwloc_aix_component HWLOC_NAME(aix_component)
-#define hwloc_bgq_component HWLOC_NAME(bgq_component)
-#define hwloc_darwin_component HWLOC_NAME(darwin_component)
-#define hwloc_freebsd_component HWLOC_NAME(freebsd_component)
-#define hwloc_hpux_component HWLOC_NAME(hpux_component)
-#define hwloc_linux_component HWLOC_NAME(linux_component)
-#define hwloc_netbsd_component HWLOC_NAME(netbsd_component)
-#define hwloc_noos_component HWLOC_NAME(noos_component)
-#define hwloc_solaris_component HWLOC_NAME(solaris_component)
-#define hwloc_windows_component HWLOC_NAME(windows_component)
-#define hwloc_x86_component HWLOC_NAME(x86_component)
-
-#define hwloc_cuda_component HWLOC_NAME(cuda_component)
-#define hwloc_gl_component HWLOC_NAME(gl_component)
-#define hwloc_levelzero_component HWLOC_NAME(levelzero_component)
-#define hwloc_nvml_component HWLOC_NAME(nvml_component)
-#define hwloc_rsmi_component HWLOC_NAME(rsmi_component)
-#define hwloc_opencl_component HWLOC_NAME(opencl_component)
-#define hwloc_pci_component HWLOC_NAME(pci_component)
-
-#define hwloc_xml_libxml_component HWLOC_NAME(xml_libxml_component)
-#define hwloc_xml_nolibxml_component HWLOC_NAME(xml_nolibxml_component)
-
-/* private/private.h */
-
-#define hwloc_internal_location_s HWLOC_NAME(internal_location_s)
-
-#define hwloc_special_level_s HWLOC_NAME(special_level_s)
-
-#define hwloc_pci_forced_locality_s HWLOC_NAME(pci_forced_locality_s)
-#define hwloc_pci_locality_s HWLOC_NAME(pci_locality_s)
-
-#define hwloc_topology_forced_component_s HWLOC_NAME(topology_forced_component)
-
-#define hwloc_alloc_root_sets HWLOC_NAME(alloc_root_sets)
-#define hwloc_setup_pu_level HWLOC_NAME(setup_pu_level)
-#define hwloc_get_sysctlbyname HWLOC_NAME(get_sysctlbyname)
-#define hwloc_get_sysctl HWLOC_NAME(get_sysctl)
-#define hwloc_fallback_nbprocessors HWLOC_NAME(fallback_nbprocessors)
-#define hwloc_fallback_memsize HWLOC_NAME(fallback_memsize)
-
-#define hwloc__object_cpusets_compare_first HWLOC_NAME(_object_cpusets_compare_first)
-#define hwloc__reorder_children HWLOC_NAME(_reorder_children)
-
-#define hwloc_topology_setup_defaults HWLOC_NAME(topology_setup_defaults)
-#define hwloc_topology_clear HWLOC_NAME(topology_clear)
-
-#define hwloc__reconnect HWLOC_NAME(_reconnect)
-
-#define hwloc__attach_memory_object HWLOC_NAME(insert_memory_object)
-
-#define hwloc_get_obj_by_type_and_gp_index HWLOC_NAME(get_obj_by_type_and_gp_index)
-
-#define hwloc_pci_discovery_init HWLOC_NAME(pci_discovery_init)
-#define hwloc_pci_discovery_prepare HWLOC_NAME(pci_discovery_prepare)
-#define hwloc_pci_discovery_exit HWLOC_NAME(pci_discovery_exit)
-#define hwloc_find_insert_io_parent_by_complete_cpuset HWLOC_NAME(hwloc_find_insert_io_parent_by_complete_cpuset)
-
-#define hwloc__add_info HWLOC_NAME(_add_info)
-#define hwloc__add_info_nodup HWLOC_NAME(_add_info_nodup)
-#define hwloc__move_infos HWLOC_NAME(_move_infos)
-#define hwloc__free_infos HWLOC_NAME(_free_infos)
-#define hwloc__tma_dup_infos HWLOC_NAME(_tma_dup_infos)
-
-#define hwloc_binding_hooks HWLOC_NAME(binding_hooks)
-#define hwloc_set_native_binding_hooks HWLOC_NAME(set_native_binding_hooks)
-#define hwloc_set_binding_hooks HWLOC_NAME(set_binding_hooks)
-
-#define hwloc_set_linuxfs_hooks HWLOC_NAME(set_linuxfs_hooks)
-#define hwloc_set_bgq_hooks HWLOC_NAME(set_bgq_hooks)
-#define hwloc_set_solaris_hooks HWLOC_NAME(set_solaris_hooks)
-#define hwloc_set_aix_hooks HWLOC_NAME(set_aix_hooks)
-#define hwloc_set_windows_hooks HWLOC_NAME(set_windows_hooks)
-#define hwloc_set_darwin_hooks HWLOC_NAME(set_darwin_hooks)
-#define hwloc_set_freebsd_hooks HWLOC_NAME(set_freebsd_hooks)
-#define hwloc_set_netbsd_hooks HWLOC_NAME(set_netbsd_hooks)
-#define hwloc_set_hpux_hooks HWLOC_NAME(set_hpux_hooks)
-
-#define hwloc_look_hardwired_fujitsu_k HWLOC_NAME(look_hardwired_fujitsu_k)
-#define hwloc_look_hardwired_fujitsu_fx10 HWLOC_NAME(look_hardwired_fujitsu_fx10)
-#define hwloc_look_hardwired_fujitsu_fx100 HWLOC_NAME(look_hardwired_fujitsu_fx100)
-
-#define hwloc_add_uname_info HWLOC_NAME(add_uname_info)
-#define hwloc_free_unlinked_object HWLOC_NAME(free_unlinked_object)
-#define hwloc_free_object_and_children HWLOC_NAME(free_object_and_children)
-#define hwloc_free_object_siblings_and_children HWLOC_NAME(free_object_siblings_and_children)
-
-#define hwloc_alloc_heap HWLOC_NAME(alloc_heap)
-#define hwloc_alloc_mmap HWLOC_NAME(alloc_mmap)
-#define hwloc_free_heap HWLOC_NAME(free_heap)
-#define hwloc_free_mmap HWLOC_NAME(free_mmap)
-#define hwloc_alloc_or_fail HWLOC_NAME(alloc_or_fail)
-
-#define hwloc_internal_distances_s HWLOC_NAME(internal_distances_s)
-#define hwloc_internal_distances_init HWLOC_NAME(internal_distances_init)
-#define hwloc_internal_distances_prepare HWLOC_NAME(internal_distances_prepare)
-#define hwloc_internal_distances_dup HWLOC_NAME(internal_distances_dup)
-#define hwloc_internal_distances_refresh HWLOC_NAME(internal_distances_refresh)
-#define hwloc_internal_distances_destroy HWLOC_NAME(internal_distances_destroy)
-#define hwloc_internal_distances_add HWLOC_NAME(internal_distances_add)
-#define hwloc_internal_distances_add_by_index HWLOC_NAME(internal_distances_add_by_index)
-#define hwloc_internal_distances_invalidate_cached_objs HWLOC_NAME(hwloc_internal_distances_invalidate_cached_objs)
-
-#define hwloc_internal_memattr_s HWLOC_NAME(internal_memattr_s)
-#define hwloc_internal_memattr_target_s HWLOC_NAME(internal_memattr_target_s)
-#define hwloc_internal_memattr_initiator_s HWLOC_NAME(internal_memattr_initiator_s)
-#define hwloc_internal_memattrs_init HWLOC_NAME(internal_memattrs_init)
-#define hwloc_internal_memattrs_prepare HWLOC_NAME(internal_memattrs_prepare)
-#define hwloc_internal_memattrs_dup HWLOC_NAME(internal_memattrs_dup)
-#define hwloc_internal_memattrs_destroy HWLOC_NAME(internal_memattrs_destroy)
-#define hwloc_internal_memattrs_need_refresh HWLOC_NAME(internal_memattrs_need_refresh)
-#define hwloc_internal_memattrs_refresh HWLOC_NAME(internal_memattrs_refresh)
-#define hwloc_internal_memattrs_guess_memory_tiers HWLOC_NAME(internal_memattrs_guess_memory_tiers)
-
-#define hwloc_internal_cpukind_s HWLOC_NAME(internal_cpukind_s)
-#define hwloc_internal_cpukinds_init HWLOC_NAME(internal_cpukinds_init)
-#define hwloc_internal_cpukinds_destroy HWLOC_NAME(internal_cpukinds_destroy)
-#define hwloc_internal_cpukinds_dup HWLOC_NAME(internal_cpukinds_dup)
-#define hwloc_internal_cpukinds_register HWLOC_NAME(internal_cpukinds_register)
-#define hwloc_internal_cpukinds_rank HWLOC_NAME(internal_cpukinds_rank)
-#define hwloc_internal_cpukinds_restrict HWLOC_NAME(internal_cpukinds_restrict)
-
-#define hwloc_encode_to_base64 HWLOC_NAME(encode_to_base64)
-#define hwloc_decode_from_base64 HWLOC_NAME(decode_from_base64)
-
-#define hwloc_progname HWLOC_NAME(progname)
-
-#define hwloc__topology_disadopt HWLOC_NAME(_topology_disadopt)
-#define hwloc__topology_dup HWLOC_NAME(_topology_dup)
-
-#define hwloc_tma HWLOC_NAME(tma)
-#define hwloc_tma_malloc HWLOC_NAME(tma_malloc)
-#define hwloc_tma_calloc HWLOC_NAME(tma_calloc)
-#define hwloc_tma_strdup HWLOC_NAME(tma_strdup)
-#define hwloc_bitmap_tma_dup HWLOC_NAME(bitmap_tma_dup)
-
-/* private/solaris-chiptype.h */
-
-#define hwloc_solaris_chip_info_s HWLOC_NAME(solaris_chip_info_s)
-#define hwloc_solaris_get_chip_info HWLOC_NAME(solaris_get_chip_info)
-
-#endif /* HWLOC_SYM_TRANSFORM */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_RENAME_H */
### src/3rdparty/hwloc/include/hwloc/rsmi.h
@@ -1,206 +0,0 @@
-/*
- * Copyright © 2012-2023 Inria. All rights reserved.
- * Copyright (c) 2020, Advanced Micro Devices, Inc. All rights reserved.
- * Written by Advanced Micro Devices,
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and the ROCm SMI Management Library.
- *
- * Applications that use both hwloc and the ROCm SMI Management Library may want to
- * include this file so as to get topology information for AMD GPU devices.
- */
-
-#ifndef HWLOC_RSMI_H
-#define HWLOC_RSMI_H
-
-#include "hwloc.h"
-#include "hwloc/autogen/config.h"
-#include "hwloc/helper.h"
-#ifdef HWLOC_LINUX_SYS
-#include "hwloc/linux.h"
-#endif
-
-#include <rocm_smi/rocm_smi.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_rsmi Interoperability with the ROCm SMI Management Library
- *
- * This interface offers ways to retrieve topology information about
- * devices managed by the ROCm SMI Management Library.
- *
- * @{
- */
-
-/** \brief Get the CPU set of logical processors that are physically
- * close to AMD GPU device whose index is \p dv_ind.
- *
- * Store in \p set the CPU-set describing the locality of the AMD GPU device
- * whose index is \p dv_ind.
- *
- * Topology \p topology and device \p dv_ind must match the local machine.
- * I/O devices detection and the ROCm SMI component are not needed in the
- * topology.
- *
- * The function only returns the locality of the device.
- * If more information about the device is needed, OS objects should
- * be used instead, see hwloc_rsmi_get_device_osdev()
- * and hwloc_rsmi_get_device_osdev_by_index().
- *
- * This function is currently only implemented in a meaningful way for
- * Linux; other systems will simply get a full cpuset.
- *
- * \return 0 on success.
- * \return -1 on error, for instance if device information could not be found.
- */
-static __hwloc_inline int
-hwloc_rsmi_get_device_cpuset(hwloc_topology_t topology __hwloc_attribute_unused,
- uint32_t dv_ind, hwloc_cpuset_t set)
-{
-#ifdef HWLOC_LINUX_SYS
- /* If we're on Linux, use the sysfs mechanism to get the local cpus */
-#define HWLOC_RSMI_DEVICE_SYSFS_PATH_MAX 128
- char path[HWLOC_RSMI_DEVICE_SYSFS_PATH_MAX];
- rsmi_status_t ret;
- uint64_t bdfid = 0;
- unsigned domain, device, bus;
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return -1;
- }
-
- ret = rsmi_dev_pci_id_get(dv_ind, &bdfid);
- if (RSMI_STATUS_SUCCESS != ret) {
- errno = EINVAL;
- return -1;
- }
- domain = (bdfid>>32) & 0xffffffff;
- bus = ((bdfid & 0xffff)>>8) & 0xff;
- device = ((bdfid & 0xff)>>3) & 0x1f;
-
- sprintf(path, "/sys/bus/pci/devices/%04x:%02x:%02x.0/local_cpus", domain, bus, device);
- if (hwloc_linux_read_path_as_cpumask(path, set) < 0
- || hwloc_bitmap_iszero(set))
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#else
- /* Non-Linux systems simply get a full cpuset */
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-#endif
- return 0;
-}
-
-/** \brief Get the hwloc OS device object corresponding to the
- * AMD GPU device whose index is \p dv_ind.
- *
- * \return The hwloc OS device object describing the AMD GPU device whose
- * index is \p dv_ind.
- * \return \c NULL if none could be found.
- *
- * The topology \p topology does not necessarily have to match the current
- * machine. For instance the topology may be an XML import of a remote host.
- * I/O devices detection and the ROCm SMI component must be enabled in the
- * topology.
- *
- * \note The corresponding PCI device object can be obtained by looking
- * at the OS device parent object (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_rsmi_get_device_osdev_by_index(hwloc_topology_t topology, uint32_t dv_ind)
-{
- hwloc_obj_t osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- if (HWLOC_OBJ_OSDEV_GPU == osdev->attr->osdev.type
- && osdev->name
- && !strncmp("rsmi", osdev->name, 4)
- && atoi(osdev->name + 4) == (int) dv_ind)
- return osdev;
- }
- return NULL;
-}
-
-/** \brief Get the hwloc OS device object corresponding to AMD GPU device,
- * whose index is \p dv_ind.
- *
- * \return The hwloc OS device object that describes the given
- * AMD GPU, whose index is \p dv_ind.
- * \return \c NULL if none could be found.
- *
- * Topology \p topology and device \p dv_ind must match the local machine.
- * I/O devices detection and the ROCm SMI component must be enabled in the
- * topology. If not, the locality of the object may still be found using
- * hwloc_rsmi_get_device_cpuset().
- *
- * \note The corresponding hwloc PCI device may be found by looking
- * at the result parent pointer (unless PCI devices are filtered out).
- */
-static __hwloc_inline hwloc_obj_t
-hwloc_rsmi_get_device_osdev(hwloc_topology_t topology, uint32_t dv_ind)
-{
- hwloc_obj_t osdev;
- rsmi_status_t ret;
- uint64_t bdfid = 0;
- unsigned domain, device, bus, func;
- uint64_t id;
- char uuid[64];
-
- if (!hwloc_topology_is_thissystem(topology)) {
- errno = EINVAL;
- return NULL;
- }
-
- ret = rsmi_dev_pci_id_get(dv_ind, &bdfid);
- if (RSMI_STATUS_SUCCESS != ret) {
- errno = EINVAL;
- return NULL;
- }
- domain = (bdfid>>32) & 0xffffffff;
- bus = ((bdfid & 0xffff)>>8) & 0xff;
- device = ((bdfid & 0xff)>>3) & 0x1f;
- func = bdfid & 0x7;
-
- ret = rsmi_dev_unique_id_get(dv_ind, &id);
- if (RSMI_STATUS_SUCCESS != ret)
- uuid[0] = '\0';
- else
- sprintf(uuid, "%lx", id);
-
- osdev = NULL;
- while ((osdev = hwloc_get_next_osdev(topology, osdev)) != NULL) {
- hwloc_obj_t pcidev = osdev->parent;
- const char *info;
-
- if (strncmp(osdev->name, "rsmi", 4))
- continue;
-
- if (pcidev
- && pcidev->type == HWLOC_OBJ_PCI_DEVICE
- && pcidev->attr->pcidev.domain == domain
- && pcidev->attr->pcidev.bus == bus
- && pcidev->attr->pcidev.dev == device
- && pcidev->attr->pcidev.func == func)
- return osdev;
-
- info = hwloc_obj_get_info_by_name(osdev, "AMDUUID");
- if (info && !strcmp(info, uuid))
- return osdev;
- }
-
- return NULL;
-}
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_RSMI_H */
### src/3rdparty/hwloc/include/hwloc/shmem.h
@@ -1,142 +0,0 @@
-/*
- * Copyright © 2013-2023 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Sharing topologies between processes
- */
-
-#ifndef HWLOC_SHMEM_H
-#define HWLOC_SHMEM_H
-
-#include "hwloc.h"
-
-#ifdef __cplusplus
-extern "C" {
-#elif 0
-}
-#endif
-
-
-/** \defgroup hwlocality_shmem Sharing topologies between processes
- *
- * These functions are used to share a topology between processes by
- * duplicating it into a file-backed shared-memory buffer.
- *
- * The master process must first get the required shared-memory size
- * for storing this topology with hwloc_shmem_topology_get_length().
- *
- * Then it must find a virtual memory area of that size that is available
- * in all processes (identical virtual addresses in all processes).
- * On Linux, this can be done by comparing holes found in /proc/\<pid\>/maps
- * for each process.
- *
- * Once found, it must open a destination file for storing the buffer,
- * and pass it to hwloc_shmem_topology_write() together with
- * virtual memory address and length obtained above.
- *
- * Other processes may then adopt this shared topology by opening the
- * same file and passing it to hwloc_shmem_topology_adopt() with the
- * exact same virtual memory address and length.
- *
- * @{
- */
-
-/** \brief Get the required shared memory length for storing a topology.
- *
- * This length (in bytes) must be used in hwloc_shmem_topology_write()
- * and hwloc_shmem_topology_adopt() later.
- *
- * \return the length, or -1 on error, for instance if flags are invalid.
- *
- * \note Flags \p flags are currently unused, must be 0.
- */
-HWLOC_DECLSPEC int hwloc_shmem_topology_get_length(hwloc_topology_t topology,
- size_t *lengthp,
- unsigned long flags);
-
-/** \brief Duplicate a topology to a shared memory file.
- *
- * Temporarily map a file in virtual memory and duplicate the
- * topology \p topology by allocating duplicates in there.
- *
- * The segment of the file pointed by descriptor \p fd,
- * starting at offset \p fileoffset, and of length \p length (in bytes),
- * will be temporarily mapped at virtual address \p mmap_address
- * during the duplication.
- *
- * The mapping length \p length must have been previously obtained with
- * hwloc_shmem_topology_get_length()
- * and the topology must not have been modified in the meantime.
- *
- * \note Flags \p flags are currently unused, must be 0.
- *
- * \note The object userdata pointer is duplicated but the pointed buffer
- * is not. However the caller may also allocate it manually in shared memory
- * to share it as well.
- *
- * \return 0 on success.
- * \return -1 with errno set to \c EBUSY if the virtual memory mapping defined
- * by \p mmap_address and \p length isn't available in the process.
- * \return -1 with errno set to \c EINVAL if \p fileoffset, \p mmap_address
- * or \p length aren't page-aligned.
- */
-HWLOC_DECLSPEC int hwloc_shmem_topology_write(hwloc_topology_t topology,
- int fd, hwloc_uint64_t fileoffset,
- void *mmap_address, size_t length,
- unsigned long flags);
-
-/** \brief Adopt a shared memory topology stored in a file.
- *
- * Map a file in virtual memory and adopt the topology that was previously
- * stored there with hwloc_shmem_topology_write().
- *
- * The returned adopted topology in \p topologyp can be used just like any
- * topology. And it must be destroyed with hwloc_topology_destroy() as usual.
- *
- * However the topology is read-only.
- * For instance, it cannot be modified with hwloc_topology_restrict()
- * and object userdata pointers cannot be changed.
- *
- * The segment of the file pointed by descriptor \p fd,
- * starting at offset \p fileoffset, and of length \p length (in bytes),
- * will be mapped at virtual address \p mmap_address.
- *
- * The file pointed by descriptor \p fd, the offset \p fileoffset,
- * the requested mapping virtual address \p mmap_address and the length \p length
- * must be identical to what was given to hwloc_shmem_topology_write() earlier.
- *
- * \note Flags \p flags are currently unused, must be 0.
- *
- * \note The object userdata pointer should not be used unless the process
- * that created the shared topology also placed userdata-pointed buffers
- * in shared memory.
- *
- * \note This function takes care of calling hwloc_topology_abi_check().
- *
- * \return 0 on success.
- *
- * \return -1 with errno set to \c EBUSY if the virtual memory mapping defined
- * by \p mmap_address and \p length isn't available in the process.
- *
- * \return -1 with errno set to \c EINVAL if \p fileoffset, \p mmap_address
- * or \p length aren't page-aligned, or do not match what was given to
- * hwloc_shmem_topology_write() earlier.
- *
- * \return -1 with errno set to \c EINVAL if the layout of the topology structure
- * is different between the writer process and the adopter process.
- */
-HWLOC_DECLSPEC int hwloc_shmem_topology_adopt(hwloc_topology_t *topologyp,
- int fd, hwloc_uint64_t fileoffset,
- void *mmap_address, size_t length,
- unsigned long flags);
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_SHMEM_H */
### src/3rdparty/hwloc/include/hwloc/windows.h
@@ -1,76 +0,0 @@
-/*
- * Copyright © 2021 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/** \file
- * \brief Macros to help interaction between hwloc and Windows.
- *
- * Applications that use hwloc on Windows may want to include this file
- * for Windows specific hwloc features.
- */
-
-#ifndef HWLOC_WINDOWS_H
-#define HWLOC_WINDOWS_H
-
-#include "hwloc.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup hwlocality_windows Windows-specific helpers
- *
- * These functions query Windows processor groups.
- * These groups partition the operating system into virtual sets
- * of up to 64 neighbor PUs.
- * Threads and processes may only be bound inside a single group.
- * Although Windows processor groups may be exposed in the hwloc
- * hierarchy as hwloc Groups, they are also often merged into
- * existing hwloc objects such as NUMA nodes or Packages.
- * This API provides explicit information about Windows processor
- * groups so that applications know whether binding to a large
- * set of PUs may fail because it spans over multiple Windows
- * processor groups.
- *
- * @{
- */
-
-
-/** \brief Get the number of Windows processor groups
- *
- * \p flags must be 0 for now.
- *
- * \return at least \c 1 on success.
- * \return -1 on error, for instance if the topology does not match
- * the current system (e.g. loaded from another machine through XML).
- */
-HWLOC_DECLSPEC int hwloc_windows_get_nr_processor_groups(hwloc_topology_t topology, unsigned long flags);
-
-/** \brief Get the CPU-set of a Windows processor group.
- *
- * Get the set of PU included in the processor group specified
- * by \p pg_index.
- * \p pg_index must be between \c 0 and the value returned
- * by hwloc_windows_get_nr_processor_groups() minus 1.
- *
- * \p flags must be 0 for now.
- *
- * \return \c 0 on success.
- * \return \c -1 on error, for instance if \p pg_index is invalid,
- * or if the topology does not match the current system (e.g. loaded
- * from another machine through XML).
- */
-HWLOC_DECLSPEC int hwloc_windows_get_processor_group_cpuset(hwloc_topology_t topology, unsigned pg_index, hwloc_cpuset_t cpuset, unsigned long flags);
-
-/** @} */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-
-#endif /* HWLOC_WINDOWS_H */
### src/3rdparty/hwloc/include/private/autogen/config.h
@@ -1,672 +0,0 @@
-/*
- * Copyright © 2009, 2011, 2012 CNRS. All rights reserved.
- * Copyright © 2009-2021 Inria. All rights reserved.
- * Copyright © 2009, 2011, 2012, 2015 Université Bordeaux. All rights reserved.
- * Copyright © 2009-2020 Cisco Systems, Inc. All rights reserved.
- * $COPYRIGHT$
- *
- * Additional copyrights may follow
- *
- * $HEADER$
- */
-
-#ifndef HWLOC_CONFIGURE_H
-#define HWLOC_CONFIGURE_H
-
-#define DECLSPEC_EXPORTS
-
-#define HWLOC_HAVE_MSVC_CPUIDEX 1
-
-/* Define to 1 if the system has the type `CACHE_DESCRIPTOR'. */
-#define HAVE_CACHE_DESCRIPTOR 0
-
-/* Define to 1 if the system has the type `CACHE_RELATIONSHIP'. */
-#define HAVE_CACHE_RELATIONSHIP 0
-
-/* Define to 1 if you have the `clz' function. */
-/* #undef HAVE_CLZ */
-
-/* Define to 1 if you have the `clzl' function. */
-/* #undef HAVE_CLZL */
-
-/* Define to 1 if you have the <CL/cl_ext.h> header file. */
-/* #undef HAVE_CL_CL_EXT_H */
-
-/* Define to 1 if you have the `cpuset_setaffinity' function. */
-/* #undef HAVE_CPUSET_SETAFFINITY */
-
-/* Define to 1 if you have the `cpuset_setid' function. */
-/* #undef HAVE_CPUSET_SETID */
-
-/* Define to 1 if we have -lcuda */
-/* #undef HAVE_CUDA */
-
-/* Define to 1 if you have the <cuda.h> header file. */
-/* #undef HAVE_CUDA_H */
-
-/* Define to 1 if you have the <cuda_runtime_api.h> header file. */
-/* #undef HAVE_CUDA_RUNTIME_API_H */
-
-/* Define to 1 if you have the declaration of `CL_DEVICE_TOPOLOGY_AMD', and to
- 0 if you don't. */
-/* #undef HAVE_DECL_CL_DEVICE_TOPOLOGY_AMD */
-
-/* Define to 1 if you have the declaration of `CTL_HW', and to 0 if you don't.
- */
-/* #undef HAVE_DECL_CTL_HW */
-
-/* Define to 1 if you have the declaration of `fabsf', and to 0 if you don't.
- */
-#define HAVE_DECL_FABSF 1
-
-/* Define to 1 if you have the declaration of `modff', and to 0 if you don't.
- */
-#define HAVE_DECL_MODFF 1
-
-/* Define to 1 if you have the declaration of `HW_NCPU', and to 0 if you
- don't. */
-/* #undef HAVE_DECL_HW_NCPU */
-
-/* Define to 1 if you have the declaration of
- `nvmlDeviceGetMaxPcieLinkGeneration', and to 0 if you don't. */
-/* #undef HAVE_DECL_NVMLDEVICEGETMAXPCIELINKGENERATION */
-
-/* Define to 1 if you have the declaration of `pthread_getaffinity_np', and to
- 0 if you don't. */
-#define HAVE_DECL_PTHREAD_GETAFFINITY_NP 0
-
-/* Define to 1 if you have the declaration of `pthread_setaffinity_np', and to
- 0 if you don't. */
-#define HAVE_DECL_PTHREAD_SETAFFINITY_NP 0
-
-/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
- don't. */
-#define HAVE_DECL_STRTOULL 0
-
-/* Define to 1 if you have the declaration of `strcasecmp', and to 0 if you
- don't. */
-/* #undef HWLOC_HAVE_DECL_STRCASECMP */
-
-/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
- don't. */
-#define HAVE_DECL_SNPRINTF 0
-
-/* Define to 1 if you have the declaration of `_strdup', and to 0 if you
- don't. */
-#define HAVE_DECL__STRDUP 1
-
-/* Define to 1 if you have the declaration of `_putenv', and to 0 if you
- don't. */
-#define HAVE_DECL__PUTENV 1
-
-/* Define to 1 if you have the declaration of `_SC_LARGE_PAGESIZE', and to 0
- if you don't. */
-#define HAVE_DECL__SC_LARGE_PAGESIZE 0
-
-/* Define to 1 if you have the declaration of `_SC_NPROCESSORS_CONF', and to 0
- if you don't. */
-#define HAVE_DECL__SC_NPROCESSORS_CONF 0
-
-/* Define to 1 if you have the declaration of `_SC_NPROCESSORS_ONLN', and to 0
- if you don't. */
-#define HAVE_DECL__SC_NPROCESSORS_ONLN 0
-
-/* Define to 1 if you have the declaration of `_SC_NPROC_CONF', and to 0 if
- you don't. */
-#define HAVE_DECL__SC_NPROC_CONF 0
-
-/* Define to 1 if you have the declaration of `_SC_NPROC_ONLN', and to 0 if
- you don't. */
-#define HAVE_DECL__SC_NPROC_ONLN 0
-
-/* Define to 1 if you have the declaration of `_SC_PAGESIZE', and to 0 if you
- don't. */
-#define HAVE_DECL__SC_PAGESIZE 0
-
-/* Define to 1 if you have the declaration of `_SC_PAGE_SIZE', and to 0 if you
- don't. */
-#define HAVE_DECL__SC_PAGE_SIZE 0
-
-/* Define to 1 if you have the <dirent.h> header file. */
-/* #define HAVE_DIRENT_H 1 */
-#undef HAVE_DIRENT_H
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-/* #undef HAVE_DLFCN_H */
-
-/* Define to 1 if you have the `ffs' function. */
-/* #undef HAVE_FFS */
-
-/* Define to 1 if you have the `ffsl' function. */
-/* #undef HAVE_FFSL */
-
-/* Define to 1 if you have the `fls' function. */
-/* #undef HAVE_FLS */
-
-/* Define to 1 if you have the `flsl' function. */
-/* #undef HAVE_FLSL */
-
-/* Define to 1 if you have the `getpagesize' function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define to 1 if the system has the type `GROUP_AFFINITY'. */
-#define HAVE_GROUP_AFFINITY 1
-
-/* Define to 1 if the system has the type `GROUP_RELATIONSHIP'. */
-#define HAVE_GROUP_RELATIONSHIP 1
-
-/* Define to 1 if you have the `host_info' function. */
-/* #undef HAVE_HOST_INFO */
-
-/* Define to 1 if you have the <infiniband/verbs.h> header file. */
-/* #undef HAVE_INFINIBAND_VERBS_H */
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if the system has the type `KAFFINITY'. */
-#define HAVE_KAFFINITY 1
-
-/* Define to 1 if you have the <kstat.h> header file. */
-/* #undef HAVE_KSTAT_H */
-
-/* Define to 1 if you have the <langinfo.h> header file. */
-/* #undef HAVE_LANGINFO_H */
-
-/* Define to 1 if we have -lgdi32 */
-#define HAVE_LIBGDI32 1
-
-/* Define to 1 if we have -libverbs */
-/* #undef HAVE_LIBIBVERBS */
-
-/* Define to 1 if we have -lkstat */
-/* #undef HAVE_LIBKSTAT */
-
-/* Define to 1 if we have -llgrp */
-/* #undef HAVE_LIBLGRP */
-
-/* Define to 1 if you have the <locale.h> header file. */
-#define HAVE_LOCALE_H 1
-
-/* Define to 1 if the system has the type `LOGICAL_PROCESSOR_RELATIONSHIP'. */
-#define HAVE_LOGICAL_PROCESSOR_RELATIONSHIP 1
-
-/* Define to 1 if you have the <mach/mach_host.h> header file. */
-/* #undef HAVE_MACH_MACH_HOST_H */
-
-/* Define to 1 if you have the <mach/mach_init.h> header file. */
-/* #undef HAVE_MACH_MACH_INIT_H */
-
-/* Define to 1 if you have the <malloc.h> header file. */
-#define HAVE_MALLOC_H 1
-
-/* Define to 1 if you have the `memalign' function. */
-/* #undef HAVE_MEMALIGN */
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `nl_langinfo' function. */
-/* #undef HAVE_NL_LANGINFO */
-
-/* Define to 1 if you have the <numaif.h> header file. */
-/* #undef HAVE_NUMAIF_H */
-
-/* Define to 1 if the system has the type `NUMA_NODE_RELATIONSHIP'. */
-#define HAVE_NUMA_NODE_RELATIONSHIP 1
-
-/* Define to 1 if you have the <NVCtrl/NVCtrl.h> header file. */
-/* #undef HAVE_NVCTRL_NVCTRL_H */
-
-/* Define to 1 if you have the <nvml.h> header file. */
-/* #undef HAVE_NVML_H */
-
-/* Define to 1 if you have the `openat' function. */
-/* #undef HAVE_OPENAT */
-
-/* Define to 1 if you have the <picl.h> header file. */
-/* #undef HAVE_PICL_H */
-
-/* Define to 1 if you have the `posix_memalign' function. */
-/* #undef HAVE_POSIX_MEMALIGN */
-
-/* Define to 1 if the system has the type `PROCESSOR_CACHE_TYPE'. */
-#define HAVE_PROCESSOR_CACHE_TYPE 1
-
-/* Define to 1 if the system has the type `PROCESSOR_GROUP_INFO'. */
-#define HAVE_PROCESSOR_GROUP_INFO 1
-
-/* Define to 1 if the system has the type `PROCESSOR_RELATIONSHIP'. */
-#define HAVE_PROCESSOR_RELATIONSHIP 1
-
-/* Define to 1 if the system has the type `PSAPI_WORKING_SET_EX_BLOCK'. */
-/* #undef HAVE_PSAPI_WORKING_SET_EX_BLOCK */
-
-/* Define to 1 if the system has the type `PSAPI_WORKING_SET_EX_INFORMATION'.
- */
-/* #undef HAVE_PSAPI_WORKING_SET_EX_INFORMATION */
-
-/* Define to 1 if the system has the type `PROCESSOR_NUMBER'. */
-#define HAVE_PROCESSOR_NUMBER 1
-
-/* Define to 1 if you have the <pthread_np.h> header file. */
-/* #undef HAVE_PTHREAD_NP_H */
-
-/* Define to 1 if the system has the type `pthread_t'. */
-/* #undef HAVE_PTHREAD_T */
-#undef HAVE_PTHREAD_T
-
-/* Define to 1 if you have the `putwc' function. */
-#define HAVE_PUTWC 1
-
-/* Define to 1 if the system has the type `RelationProcessorPackage'. */
-/* #undef HAVE_RELATIONPROCESSORPACKAGE */
-
-/* Define to 1 if you have the `setlocale' function. */
-#define HAVE_SETLOCALE 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strftime' function. */
-#define HAVE_STRFTIME 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-/* #define HAVE_STRINGS_H 1*/
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strncasecmp' function. */
-#define HAVE_STRNCASECMP 1
-
-/* Define to '1' if sysctl is present and usable */
-/* #undef HAVE_SYSCTL */
-
-/* Define to '1' if sysctlbyname is present and usable */
-/* #undef HAVE_SYSCTLBYNAME */
-
-/* Define to 1 if the system has the type
- `SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX'. */
-#define HAVE_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX 1
-
-/* Define to 1 if you have the <sys/cpuset.h> header file. */
-/* #undef HAVE_SYS_CPUSET_H */
-
-/* Define to 1 if you have the <sys/lgrp_user.h> header file. */
-/* #undef HAVE_SYS_LGRP_USER_H */
-
-/* Define to 1 if you have the <sys/mman.h> header file. */
-/* #undef HAVE_SYS_MMAN_H */
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-/* #define HAVE_SYS_PARAM_H 1 */
-#undef HAVE_SYS_PARAM_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/sysctl.h> header file. */
-/* #undef HAVE_SYS_SYSCTL_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <sys/utsname.h> header file. */
-/* #undef HAVE_SYS_UTSNAME_H */
-
-/* Define to 1 if you have the `uname' function. */
-/* #undef HAVE_UNAME */
-
-/* Define to 1 if you have the <unistd.h> header file. */
-/* #define HAVE_UNISTD_H 1 */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the `uselocale' function. */
-/* #undef HAVE_USELOCALE */
-
-/* Define to 1 if the system has the type `wchar_t'. */
-#define HAVE_WCHAR_T 1
-
-/* Define to 1 if you have the <X11/keysym.h> header file. */
-/* #undef HAVE_X11_KEYSYM_H */
-
-/* Define to 1 if you have the <X11/Xlib.h> header file. */
-/* #undef HAVE_X11_XLIB_H */
-
-/* Define to 1 if you have the <X11/Xutil.h> header file. */
-/* #undef HAVE_X11_XUTIL_H */
-
-/* Define to 1 if you have the <xlocale.h> header file. */
-/* #undef HAVE_XLOCALE_H */
-
-/* Define to 1 on AIX */
-/* #undef HWLOC_AIX_SYS */
-
-/* Define to 1 on BlueGene/Q */
-/* #undef HWLOC_BGQ_SYS */
-
-/* Whether C compiler supports symbol visibility or not */
-#define HWLOC_C_HAVE_VISIBILITY 0
-
-/* Define to 1 on Darwin */
-/* #undef HWLOC_DARWIN_SYS */
-
-/* Whether we are in debugging mode or not */
-/* #undef HWLOC_DEBUG */
-
-/* Define to 1 on *FREEBSD */
-/* #undef HWLOC_FREEBSD_SYS */
-
-/* Whether your compiler has __attribute__ or not */
-/* #define HWLOC_HAVE_ATTRIBUTE 1 */
-#undef HWLOC_HAVE_ATTRIBUTE
-
-/* Whether your compiler has __attribute__ aligned or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_ALIGNED 1 */
-
-/* Whether your compiler has __attribute__ always_inline or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_ALWAYS_INLINE 1 */
-
-/* Whether your compiler has __attribute__ cold or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_COLD 1 */
-
-/* Whether your compiler has __attribute__ const or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_CONST 1 */
-
-/* Whether your compiler has __attribute__ deprecated or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_DEPRECATED 1 */
-
-/* Whether your compiler has __attribute__ format or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_FORMAT 1 */
-
-/* Whether your compiler has __attribute__ hot or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_HOT 1 */
-
-/* Whether your compiler has __attribute__ malloc or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_MALLOC 1 */
-
-/* Whether your compiler has __attribute__ may_alias or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_MAY_ALIAS 1 */
-
-/* Whether your compiler has __attribute__ nonnull or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_NONNULL 1 */
-
-/* Whether your compiler has __attribute__ noreturn or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_NORETURN 1 */
-
-/* Whether your compiler has __attribute__ no_instrument_function or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_NO_INSTRUMENT_FUNCTION 1 */
-
-/* Whether your compiler has __attribute__ packed or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_PACKED 1 */
-
-/* Whether your compiler has __attribute__ pure or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_PURE 1 */
-
-/* Whether your compiler has __attribute__ sentinel or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_SENTINEL 1 */
-
-/* Whether your compiler has __attribute__ unused or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_UNUSED 1 */
-
-/* Whether your compiler has __attribute__ warn unused result or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_WARN_UNUSED_RESULT 1 */
-
-/* Whether your compiler has __attribute__ weak alias or not */
-/* #define HWLOC_HAVE_ATTRIBUTE_WEAK_ALIAS 1 */
-
-/* Define to 1 if your `ffs' function is known to be broken. */
-/* #undef HWLOC_HAVE_BROKEN_FFS */
-
-/* Define to 1 if you have the `cairo' library. */
-/* #undef HWLOC_HAVE_CAIRO */
-
-/* Define to 1 if you have the `clz' function. */
-/* #undef HWLOC_HAVE_CLZ */
-
-/* Define to 1 if you have the `clzl' function. */
-/* #undef HWLOC_HAVE_CLZL */
-
-/* Define to 1 if you have cpuid */
-/* #undef HWLOC_HAVE_CPUID */
-
-/* Define to 1 if the CPU_SET macro works */
-/* #undef HWLOC_HAVE_CPU_SET */
-
-/* Define to 1 if the CPU_SET_S macro works */
-/* #undef HWLOC_HAVE_CPU_SET_S */
-
-/* Define to 1 if you have the `cudart' SDK. */
-/* #undef HWLOC_HAVE_CUDART */
-
-/* Define to 1 if function `clz' is declared by system headers */
-/* #undef HWLOC_HAVE_DECL_CLZ */
-
-/* Define to 1 if function `clzl' is declared by system headers */
-/* #undef HWLOC_HAVE_DECL_CLZL */
-
-/* Define to 1 if function `ffs' is declared by system headers */
-/* #undef HWLOC_HAVE_DECL_FFS */
-
-/* Define to 1 if function `ffsl' is declared by system headers */
-/* #undef HWLOC_HAVE_DECL_FFSL */
-
-/* Define to 1 if function `fls' is declared by system headers */
-/* #undef HWLOC_HAVE_DECL_FLS */
-
-/* Define to 1 if function `flsl' is declared by system headers */
-/* #undef HWLOC_HAVE_DECL_FLSL */
-
-/* Define to 1 if you have the `ffs' function. */
-/* #undef HWLOC_HAVE_FFS */
-
-/* Define to 1 if you have the `ffsl' function. */
-/* #undef HWLOC_HAVE_FFSL */
-
-/* Define to 1 if you have the `fls' function. */
-/* #undef HWLOC_HAVE_FLS */
-
-/* Define to 1 if you have the `flsl' function. */
-/* #undef HWLOC_HAVE_FLSL */
-
-/* Define to 1 if you have the GL module components. */
-/* #undef HWLOC_HAVE_GL */
-
-/* Define to 1 if you have a library providing the termcap interface */
-/* #undef HWLOC_HAVE_LIBTERMCAP */
-
-/* Define to 1 if you have the `libxml2' library. */
-/* #undef HWLOC_HAVE_LIBXML2 */
-
-/* Define to 1 if building the Linux PCI component */
-/* #undef HWLOC_HAVE_LINUXPCI */
-
-/* Define to 1 if you have the `NVML' library. */
-/* #undef HWLOC_HAVE_NVML */
-
-/* Define to 1 if glibc provides the old prototype (without length) of
- sched_setaffinity() */
-/* #undef HWLOC_HAVE_OLD_SCHED_SETAFFINITY */
-
-/* Define to 1 if you have the `OpenCL' library. */
-/* #undef HWLOC_HAVE_OPENCL */
-
-/* Define to 1 if the hwloc library should support dynamically-loaded plugins
- */
-/* #undef HWLOC_HAVE_PLUGINS */
-
-/* `Define to 1 if you have pthread_getthrds_np' */
-/* #undef HWLOC_HAVE_PTHREAD_GETTHRDS_NP */
-
-/* Define to 1 if pthread mutexes are available */
-/* #undef HWLOC_HAVE_PTHREAD_MUTEX */
-
-/* Define to 1 if glibc provides a prototype of sched_setaffinity() */
-#define HWLOC_HAVE_SCHED_SETAFFINITY 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HWLOC_HAVE_STDINT_H 1
-
-/* Define to 1 if you have the `windows.h' header. */
-#define HWLOC_HAVE_WINDOWS_H 1
-
-/* Define to 1 if X11 headers including Xutil.h and keysym.h are available. */
-/* #undef HWLOC_HAVE_X11_KEYSYM */
-
-/* Define to 1 if function `syscall' is available */
-/* #undef HWLOC_HAVE_SYSCALL */
-
-/* Define to 1 on HP-UX */
-/* #undef HWLOC_HPUX_SYS */
-
-/* Define to 1 on Linux */
-/* #undef HWLOC_LINUX_SYS */
-
-/* Define to 1 on *NETBSD */
-/* #undef HWLOC_NETBSD_SYS */
-
-/* The size of `unsigned int', as computed by sizeof */
-#define HWLOC_SIZEOF_UNSIGNED_INT 4
-
-/* The size of `unsigned long', as computed by sizeof */
-#define HWLOC_SIZEOF_UNSIGNED_LONG 4
-
-/* Define to 1 on Solaris */
-/* #undef HWLOC_SOLARIS_SYS */
-
-/* The hwloc symbol prefix */
-#define HWLOC_SYM_PREFIX hwloc_
-
-/* The hwloc symbol prefix in all caps */
-#define HWLOC_SYM_PREFIX_CAPS HWLOC_
-
-/* Whether we need to re-define all the hwloc public symbols or not */
-#define HWLOC_SYM_TRANSFORM 0
-
-/* Define to 1 on unsupported systems */
-/* #undef HWLOC_UNSUPPORTED_SYS */
-
-/* Define to 1 if ncurses works, preferred over curses */
-/* #undef HWLOC_USE_NCURSES */
-
-/* Define to 1 on WINDOWS */
-#define HWLOC_WIN_SYS 1
-
-/* Define to 1 on x86_32 */
-/* #undef HWLOC_X86_32_ARCH */
-
-/* Define to 1 on x86_64 */
-#define HWLOC_X86_64_ARCH 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#define LT_OBJDIR ".libs/"
-
-/* Name of package */
-#define PACKAGE "hwloc"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "https://www.open-mpi.org/projects/hwloc/"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "hwloc"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "hwloc"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "hwloc"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION HWLOC_VERSION
-
-/* The size of `unsigned int', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_INT 4
-
-/* The size of `unsigned long', as computed by sizeof. */
-#define SIZEOF_UNSIGNED_LONG 4
-
-/* The size of `void *', as computed by sizeof. */
-#define SIZEOF_VOID_P 8
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Enable extensions on HP-UX. */
-#ifndef _HPUX_SOURCE
-# define _HPUX_SOURCE 1
-#endif
-
-
-/* Enable extensions on AIX 3, Interix. */
-/*
-#ifndef _ALL_SOURCE
-# define _ALL_SOURCE 1
-#endif
-*/
-
-/* Enable GNU extensions on systems that have them. */
-/*
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-*/
-/* Enable threading extensions on Solaris. */
-/*
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# define _POSIX_PTHREAD_SEMANTICS 1
-#endif
-*/
-/* Enable extensions on HP NonStop. */
-/*
-#ifndef _TANDEM_SOURCE
-# define _TANDEM_SOURCE 1
-#endif
-*/
-/* Enable general extensions on Solaris. */
-/*
-#ifndef __EXTENSIONS__
-# define __EXTENSIONS__ 1
-#endif
-*/
-
-
-/* Version number of package */
-#define VERSION HWLOC_VERSION
-
-/* Define to 1 if the X Window System is missing or not being used. */
-#define X_DISPLAY_MISSING 1
-
-/* Define to 1 if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to 2 if the system does not provide POSIX.1 features except with
- this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define to 1 if you need to in order for `stat' and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define this to the process ID type */
-#define hwloc_pid_t HANDLE
-
-/* Define this to either strncasecmp or strncmp */
-#define hwloc_strncasecmp strncasecmp
-
-/* Define this to the thread ID type */
-#define hwloc_thread_t HANDLE
-
-/* Define to 1 if you have the declaration of `GetModuleFileName', and to 0 if
- you don't. */
-#define HAVE_DECL_GETMODULEFILENAME 1
-
-
-#endif /* HWLOC_CONFIGURE_H */
### src/3rdparty/hwloc/include/private/components.h
@@ -1,45 +0,0 @@
-/*
- * Copyright © 2012-2019 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-
-#ifdef HWLOC_INSIDE_PLUGIN
-/*
- * these declarations are internal only, they are not available to plugins
- * (many functions below are internal static symbols).
- */
-#error This file should not be used in plugins
-#endif
-
-
-#ifndef PRIVATE_COMPONENTS_H
-#define PRIVATE_COMPONENTS_H 1
-
-#include "hwloc/plugins.h"
-
-struct hwloc_topology;
-
-extern int hwloc_disc_component_force_enable(struct hwloc_topology *topology,
- int envvar_forced, /* 1 if forced through envvar, 0 if forced through API */
- const char *name,
- const void *data1, const void *data2, const void *data3);
-extern void hwloc_disc_components_enable_others(struct hwloc_topology *topology);
-
-/* Compute the topology is_thissystem flag and find some callbacks based on enabled backends */
-extern void hwloc_backends_is_thissystem(struct hwloc_topology *topology);
-extern void hwloc_backends_find_callbacks(struct hwloc_topology *topology);
-
-/* Initialize the lists of components and backends used by a topology */
-extern void hwloc_topology_components_init(struct hwloc_topology *topology);
-/* Disable and destroy all backends used by a topology */
-extern void hwloc_backends_disable_all(struct hwloc_topology *topology);
-/* Cleanup the lists of components used by a topology */
-extern void hwloc_topology_components_fini(struct hwloc_topology *topology);
-
-/* Used by the core to setup/destroy the list of components */
-extern void hwloc_components_init(void); /* increases components refcount, should be called exactly once per topology (during init) */
-extern void hwloc_components_fini(void); /* decreases components refcount, should be called exactly once per topology (during destroy) */
-
-#endif /* PRIVATE_COMPONENTS_H */
-
### src/3rdparty/hwloc/include/private/cpuid-x86.h
@@ -1,108 +0,0 @@
-/*
- * Copyright © 2010-2012, 2014 Université Bordeaux
- * Copyright © 2010 Cisco Systems, Inc. All rights reserved.
- * Copyright © 2014 Inria. All rights reserved.
- *
- * See COPYING in top-level directory.
- */
-
-/* Internals for x86's cpuid. */
-
-#ifndef HWLOC_PRIVATE_CPUID_X86_H
-#define HWLOC_PRIVATE_CPUID_X86_H
-
-/* A macro for annotating memory as uninitialized when building with MSAN
- * (and otherwise having no effect). See below for why this is used with
- * our custom assembly.
- */
-#ifdef __has_feature
-#define HWLOC_HAS_FEATURE(name) __has_feature(name)
-#else
-#define HWLOC_HAS_FEATURE(name) 0
-#endif
-#if HWLOC_HAS_FEATURE(memory_sanitizer) || defined(MEMORY_SANITIZER)
-#include <sanitizer/msan_interface.h>
-#define HWLOC_ANNOTATE_MEMORY_IS_INITIALIZED(ptr, len) __msan_unpoison(ptr, len)
-#else
-#define HWLOC_ANNOTATE_MEMORY_IS_INITIALIZED(ptr, len)
-#endif
-
-#if (defined HWLOC_X86_32_ARCH) && (!defined HWLOC_HAVE_MSVC_CPUIDEX)
-static __hwloc_inline int hwloc_have_x86_cpuid(void)
-{
- int ret;
- unsigned tmp, tmp2;
- __asm__(
- "mov $0,%0\n\t" /* Not supported a priori */
-
- "pushfl \n\t" /* Save flags */
-
- "pushfl \n\t" \
- "pop %1 \n\t" /* Get flags */ \
-
-#define TRY_TOGGLE \
- "xor $0x00200000,%1\n\t" /* Try to toggle ID */ \
- "mov %1,%2\n\t" /* Save expected value */ \
- "push %1 \n\t" \
- "popfl \n\t" /* Try to toggle */ \
- "pushfl \n\t" \
- "pop %1 \n\t" \
- "cmp %1,%2\n\t" /* Compare with expected value */ \
- "jnz 0f\n\t" /* Unexpected, failure */ \
-
- TRY_TOGGLE /* Try to set/clear */
- TRY_TOGGLE /* Try to clear/set */
-
- "mov $1,%0\n\t" /* Passed the test! */
-
- "0: \n\t"
- "popfl \n\t" /* Restore flags */
-
- : "=r" (ret), "=&r" (tmp), "=&r" (tmp2));
- return ret;
-}
-#endif /* !defined HWLOC_X86_32_ARCH && !defined HWLOC_HAVE_MSVC_CPUIDEX*/
-#if (defined HWLOC_X86_64_ARCH) || (defined HWLOC_HAVE_MSVC_CPUIDEX)
-static __hwloc_inline int hwloc_have_x86_cpuid(void) { return 1; }
-#endif /* HWLOC_X86_64_ARCH */
-
-static __hwloc_inline void hwloc_x86_cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
-{
-#ifdef HWLOC_HAVE_MSVC_CPUIDEX
- int regs[4];
- __cpuidex(regs, *eax, *ecx);
- *eax = regs[0];
- *ebx = regs[1];
- *ecx = regs[2];
- *edx = regs[3];
-#else /* HWLOC_HAVE_MSVC_CPUIDEX */
- /* Note: gcc might want to use bx or the stack for %1 addressing, so we can't
- * use them :/ */
-#ifdef HWLOC_X86_64_ARCH
- hwloc_uint64_t sav_rbx;
- __asm__(
- "mov %%rbx,%2\n\t"
- "cpuid\n\t"
- "xchg %2,%%rbx\n\t"
- "movl %k2,%1\n\t"
- : "+a" (*eax), "=m" (*ebx), "=&r"(sav_rbx),
- "+c" (*ecx), "=&d" (*edx));
- /* MSAN does not recognize the effect of the above assembly on the memory operand
- * (`"=m"(*ebx)`). This may get improved in MSAN at some point in the future, e.g.
- * see https://github.com/llvm/llvm-project/pull/77393. */
- HWLOC_ANNOTATE_MEMORY_IS_INITIALIZED(ebx, sizeof *ebx);
-#elif defined(HWLOC_X86_32_ARCH)
- __asm__(
- "mov %%ebx,%1\n\t"
- "cpuid\n\t"
- "xchg %%ebx,%1\n\t"
- : "+a" (*eax), "=&SD" (*ebx), "+c" (*ecx), "=&d" (*edx));
- /* See above. */
- HWLOC_ANNOTATE_MEMORY_IS_INITIALIZED(ebx, sizeof *ebx);
-#else
-#error unknown architecture
-#endif
-#endif /* HWLOC_HAVE_MSVC_CPUIDEX */
-}
-
-#endif /* HWLOC_PRIVATE_X86_CPUID_H */
### src/3rdparty/hwloc/include/private/debug.h
@@ -1,95 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2020 Inria. All rights reserved.
- * Copyright © 2009, 2011 Université Bordeaux
- * Copyright © 2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/* The configuration file */
-
-#ifndef HWLOC_DEBUG_H
-#define HWLOC_DEBUG_H
-
-#include "private/autogen/config.h"
-#include "private/misc.h"
-
-#ifdef HWLOC_DEBUG
-#include <stdarg.h>
-#include <stdio.h>
-#endif
-
-#ifdef ANDROID
-extern void JNIDebug(char *text);
-#endif
-
-/* Compile-time assertion */
-#define HWLOC_BUILD_ASSERT(condition) ((void)sizeof(char[1 - 2*!(condition)]))
-
-#ifdef HWLOC_DEBUG
-static __hwloc_inline int hwloc_debug_enabled(void)
-{
- static int checked = 0;
- static int enabled = 1;
- if (!checked) {
- const char *env = getenv("HWLOC_DEBUG_VERBOSE");
- if (env)
- enabled = atoi(env);
- if (enabled)
- fprintf(stderr, "hwloc verbose debug enabled, may be disabled with HWLOC_DEBUG_VERBOSE=0 in the environment.\n");
- checked = 1;
- }
- return enabled;
-}
-#endif
-
-static __hwloc_inline void hwloc_debug(const char *s __hwloc_attribute_unused, ...) __hwloc_attribute_format(printf, 1, 2);
-static __hwloc_inline void hwloc_debug(const char *s __hwloc_attribute_unused, ...)
-{
-#ifdef HWLOC_DEBUG
- if (hwloc_debug_enabled()) {
-#ifdef ANDROID
- char buffer[256];
-#endif
- va_list ap;
- va_start(ap, s);
-#ifdef ANDROID
- vsprintf(buffer, s, ap);
- JNIDebug(buffer);
-#else
- vfprintf(stderr, s, ap);
-#endif
- va_end(ap);
- }
-#endif
-}
-
-#ifdef HWLOC_DEBUG
-#define hwloc_debug_bitmap(fmt, bitmap) do { \
-if (hwloc_debug_enabled()) { \
- char *s; \
- hwloc_bitmap_asprintf(&s, bitmap); \
- hwloc_debug(fmt, s); \
- free(s); \
-} } while (0)
-#define hwloc_debug_1arg_bitmap(fmt, arg1, bitmap) do { \
-if (hwloc_debug_enabled()) { \
- char *s; \
- hwloc_bitmap_asprintf(&s, bitmap); \
- hwloc_debug(fmt, arg1, s); \
- free(s); \
-} } while (0)
-#define hwloc_debug_2args_bitmap(fmt, arg1, arg2, bitmap) do { \
-if (hwloc_debug_enabled()) { \
- char *s; \
- hwloc_bitmap_asprintf(&s, bitmap); \
- hwloc_debug(fmt, arg1, arg2, s); \
- free(s); \
-} } while (0)
-#else
-#define hwloc_debug_bitmap(s, bitmap) do { } while(0)
-#define hwloc_debug_1arg_bitmap(s, arg1, bitmap) do { } while(0)
-#define hwloc_debug_2args_bitmap(s, arg1, arg2, bitmap) do { } while(0)
-#endif
-
-#endif /* HWLOC_DEBUG_H */
### src/3rdparty/hwloc/include/private/internal-components.h
@@ -1,42 +0,0 @@
-/*
- * Copyright © 2018-2020 Inria. All rights reserved.
- *
- * See COPYING in top-level directory.
- */
-
-/* List of components defined inside hwloc */
-
-#ifndef PRIVATE_INTERNAL_COMPONENTS_H
-#define PRIVATE_INTERNAL_COMPONENTS_H
-
-/* global discovery */
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xml_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_synthetic_component;
-
-/* CPU discovery */
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_aix_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_bgq_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_darwin_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_freebsd_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_hpux_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_linux_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_netbsd_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_noos_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_solaris_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_windows_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_x86_component;
-
-/* I/O discovery */
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_cuda_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_gl_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_nvml_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_rsmi_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_levelzero_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_opencl_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_pci_component;
-
-/* XML backend */
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xml_nolibxml_component;
-HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xml_libxml_component;
-
-#endif /* PRIVATE_INTERNAL_COMPONENTS_H */
### src/3rdparty/hwloc/include/private/misc.h
@@ -1,607 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2024 Inria. All rights reserved.
- * Copyright © 2009-2012 Université Bordeaux
- * Copyright © 2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-/* Misc macros and inlines. */
-
-#ifndef HWLOC_PRIVATE_MISC_H
-#define HWLOC_PRIVATE_MISC_H
-
-#include "hwloc/autogen/config.h"
-#include "private/autogen/config.h"
-#include "hwloc.h"
-
-#ifdef HWLOC_HAVE_DECL_STRNCASECMP
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#else
-#ifdef HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-#endif
-
-#define HWLOC_BITS_PER_LONG (HWLOC_SIZEOF_UNSIGNED_LONG * 8)
-#define HWLOC_BITS_PER_INT (HWLOC_SIZEOF_UNSIGNED_INT * 8)
-
-#if (HWLOC_BITS_PER_LONG != 32) && (HWLOC_BITS_PER_LONG != 64)
-#error "unknown size for unsigned long."
-#endif
-
-#if (HWLOC_BITS_PER_INT != 16) && (HWLOC_BITS_PER_INT != 32) && (HWLOC_BITS_PER_INT != 64)
-#error "unknown size for unsigned int."
-#endif
-
-/* internal-use-only value for when we don't know the type or don't have any value */
-#define HWLOC_OBJ_TYPE_NONE ((hwloc_obj_type_t) -1)
-
-/**
- * ffsl helpers.
- */
-
-#if defined(HWLOC_HAVE_BROKEN_FFS)
-
-/* System has a broken ffs().
- * We must check the before __GNUC__ or HWLOC_HAVE_FFSL
- */
-# define HWLOC_NO_FFS
-
-#elif defined(__GNUC__)
-
-# if (__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))
- /* Starting from 3.4, gcc has a long variant. */
-# define hwloc_ffsl(x) __builtin_ffsl(x)
-# else
-# define hwloc_ffs(x) __builtin_ffs(x)
-# define HWLOC_NEED_FFSL
-# endif
-
-#elif defined(HWLOC_HAVE_FFSL)
-
-# ifndef HWLOC_HAVE_DECL_FFSL
-extern int ffsl(long) __hwloc_attribute_const;
-# endif
-
-# define hwloc_ffsl(x) ffsl(x)
-
-#elif defined(HWLOC_HAVE_FFS)
-
-# ifndef HWLOC_HAVE_DECL_FFS
-extern int ffs(int) __hwloc_attribute_const;
-# endif
-
-# define hwloc_ffs(x) ffs(x)
-# define HWLOC_NEED_FFSL
-
-#else /* no ffs implementation */
-
-# define HWLOC_NO_FFS
-
-#endif
-
-#ifdef HWLOC_NO_FFS
-
-/* no ffs or it is known to be broken */
-static __hwloc_inline int
-hwloc_ffsl_manual(unsigned long x) __hwloc_attribute_const;
-static __hwloc_inline int
-hwloc_ffsl_manual(unsigned long x)
-{
- int i;
-
- if (!x)
- return 0;
-
- i = 1;
-#if HWLOC_BITS_PER_LONG >= 64
- if (!(x & 0xfffffffful)) {
- x >>= 32;
- i += 32;
- }
-#endif
- if (!(x & 0xffffu)) {
- x >>= 16;
- i += 16;
- }
- if (!(x & 0xff)) {
- x >>= 8;
- i += 8;
- }
- if (!(x & 0xf)) {
- x >>= 4;
- i += 4;
- }
- if (!(x & 0x3)) {
- x >>= 2;
- i += 2;
- }
- if (!(x & 0x1)) {
- x >>= 1;
- i += 1;
- }
-
- return i;
-}
-/* always define hwloc_ffsl as a macro, to avoid renaming breakage */
-#define hwloc_ffsl hwloc_ffsl_manual
-
-#elif defined(HWLOC_NEED_FFSL)
-
-/* We only have an int ffs(int) implementation, build a long one. */
-
-/* First make it 32 bits if it was only 16. */
-static __hwloc_inline int
-hwloc_ffs32(unsigned long x) __hwloc_attribute_const;
-static __hwloc_inline int
-hwloc_ffs32(unsigned long x)
-{
-#if HWLOC_BITS_PER_INT == 16
- int low_ffs, hi_ffs;
-
- low_ffs = hwloc_ffs(x & 0xfffful);
- if (low_ffs)
- return low_ffs;
-
- hi_ffs = hwloc_ffs(x >> 16);
- if (hi_ffs)
- return hi_ffs + 16;
-
- return 0;
-#else
- return hwloc_ffs(x);
-#endif
-}
-
-/* Then make it 64 bit if longs are. */
-static __hwloc_inline int
-hwloc_ffsl_from_ffs32(unsigned long x) __hwloc_attribute_const;
-static __hwloc_inline int
-hwloc_ffsl_from_ffs32(unsigned long x)
-{
-#if HWLOC_BITS_PER_LONG == 64
- int low_ffs, hi_ffs;
-
- low_ffs = hwloc_ffs32(x & 0xfffffffful);
- if (low_ffs)
- return low_ffs;
-
- hi_ffs = hwloc_ffs32(x >> 32);
- if (hi_ffs)
- return hi_ffs + 32;
-
- return 0;
-#else
- return hwloc_ffs32(x);
-#endif
-}
-/* always define hwloc_ffsl as a macro, to avoid renaming breakage */
-#define hwloc_ffsl hwloc_ffsl_from_ffs32
-
-#endif
-
-/**
- * flsl helpers.
- */
-#ifdef __GNUC__
-
-# if (__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))
-# define hwloc_flsl(x) ((x) ? (8*sizeof(long) - __builtin_clzl(x)) : 0)
-# else
-# define hwloc_fls(x) ((x) ? (8*sizeof(int) - __builtin_clz(x)) : 0)
-# define HWLOC_NEED_FLSL
-# endif
-
-#elif defined(HWLOC_HAVE_FLSL)
-
-# ifndef HWLOC_HAVE_DECL_FLSL
-extern int flsl(long) __hwloc_attribute_const;
-# endif
-
-# define hwloc_flsl(x) flsl(x)
-
-#elif defined(HWLOC_HAVE_CLZL)
-
-# ifndef HWLOC_HAVE_DECL_CLZL
-extern int clzl(long) __hwloc_attribute_const;
-# endif
-
-# define hwloc_flsl(x) ((x) ? (8*sizeof(long) - clzl(x)) : 0)
-
-#elif defined(HWLOC_HAVE_FLS)
-
-# ifndef HWLOC_HAVE_DECL_FLS
-extern int fls(int) __hwloc_attribute_const;
-# endif
-
-# define hwloc_fls(x) fls(x)
-# define HWLOC_NEED_FLSL
-
-#elif defined(HWLOC_HAVE_CLZ)
-
-# ifndef HWLOC_HAVE_DECL_CLZ
-extern int clz(int) __hwloc_attribute_const;
-# endif
-
-# define hwloc_fls(x) ((x) ? (8*sizeof(int) - clz(x)) : 0)
-# define HWLOC_NEED_FLSL
-
-#else /* no fls implementation */
-
-static __hwloc_inline int
-hwloc_flsl_manual(unsigned long x) __hwloc_attribute_const;
-static __hwloc_inline int
-hwloc_flsl_manual(unsigned long x)
-{
- int i = 0;
-
- if (!x)
- return 0;
-
- i = 1;
-#if HWLOC_BITS_PER_LONG >= 64
- if ((x & 0xffffffff00000000ul)) {
- x >>= 32;
- i += 32;
- }
-#endif
- if ((x & 0xffff0000u)) {
- x >>= 16;
- i += 16;
- }
- if ((x & 0xff00)) {
- x >>= 8;
- i += 8;
- }
- if ((x & 0xf0)) {
- x >>= 4;
- i += 4;
- }
- if ((x & 0xc)) {
- x >>= 2;
- i += 2;
- }
- if ((x & 0x2)) {
- x >>= 1;
- i += 1;
- }
-
- return i;
-}
-/* always define hwloc_flsl as a macro, to avoid renaming breakage */
-#define hwloc_flsl hwloc_flsl_manual
-
-#endif
-
-#ifdef HWLOC_NEED_FLSL
-
-/* We only have an int fls(int) implementation, build a long one. */
-
-/* First make it 32 bits if it was only 16. */
-static __hwloc_inline int
-hwloc_fls32(unsigned long x) __hwloc_attribute_const;
-static __hwloc_inline int
-hwloc_fls32(unsigned long x)
-{
-#if HWLOC_BITS_PER_INT == 16
- int low_fls, hi_fls;
-
- hi_fls = hwloc_fls(x >> 16);
- if (hi_fls)
- return hi_fls + 16;
-
- low_fls = hwloc_fls(x & 0xfffful);
- if (low_fls)
- return low_fls;
-
- return 0;
-#else
- return hwloc_fls(x);
-#endif
-}
-
-/* Then make it 64 bit if longs are. */
-static __hwloc_inline int
-hwloc_flsl_from_fls32(unsigned long x) __hwloc_attribute_const;
-static __hwloc_inline int
-hwloc_flsl_from_fls32(unsigned long x)
-{
-#if HWLOC_BITS_PER_LONG == 64
- int low_fls, hi_fls;
-
- hi_fls = hwloc_fls32(x >> 32);
- if (hi_fls)
- return hi_fls + 32;
-
- low_fls = hwloc_fls32(x & 0xfffffffful);
- if (low_fls)
- return low_fls;
-
- return 0;
-#else
- return hwloc_fls32(x);
-#endif
-}
-/* always define hwloc_flsl as a macro, to avoid renaming breakage */
-#define hwloc_flsl hwloc_flsl_from_fls32
-
-#endif
-
-static __hwloc_inline int
-hwloc_weight_long(unsigned long w) __hwloc_attribute_const;
-static __hwloc_inline int
-hwloc_weight_long(unsigned long w)
-{
-#if HWLOC_BITS_PER_LONG == 32
-#if (__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__) >= 4)
- return __builtin_popcount(w);
-#else
- unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
- res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
- res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
- res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
- return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
-#endif
-#else /* HWLOC_BITS_PER_LONG == 32 */
-#if (__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__) >= 4)
- return __builtin_popcountll(w);
-#else
- unsigned long res;
- res = (w & 0x5555555555555555ul) + ((w >> 1) & 0x5555555555555555ul);
- res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
- res = (res & 0x0F0F0F0F0F0F0F0Ful) + ((res >> 4) & 0x0F0F0F0F0F0F0F0Ful);
- res = (res & 0x00FF00FF00FF00FFul) + ((res >> 8) & 0x00FF00FF00FF00FFul);
- res = (res & 0x0000FFFF0000FFFFul) + ((res >> 16) & 0x0000FFFF0000FFFFul);
- return (res & 0x00000000FFFFFFFFul) + ((res >> 32) & 0x00000000FFFFFFFFul);
-#endif
-#endif /* HWLOC_BITS_PER_LONG == 64 */
-}
-
-#if !HAVE_DECL_STRTOULL && defined(HAVE_STRTOULL)
-unsigned long long int strtoull(const char *nptr, char **endptr, int base);
-#endif
-
-static __hwloc_inline int hwloc_strncasecmp(const char *s1, const char *s2, size_t n)
-{
-#ifdef HWLOC_HAVE_DECL_STRNCASECMP
- return strncasecmp(s1, s2, n);
-#else
- while (n) {
- char c1 = tolower(*s1), c2 = tolower(*s2);
- if (!c1 || !c2 || c1 != c2)
- return c1-c2;
- n--; s1++; s2++;
- }
- return 0;
-#endif
-}
-
-static __hwloc_inline hwloc_obj_type_t hwloc_cache_type_by_depth_type(unsigned depth, hwloc_obj_cache_type_t type)
-{
- if (type == HWLOC_OBJ_CACHE_INSTRUCTION) {
- if (depth >= 1 && depth <= 3)
- return HWLOC_OBJ_L1ICACHE + depth-1;
- else
- return HWLOC_OBJ_TYPE_NONE;
- } else {
- if (depth >= 1 && depth <= 5)
- return HWLOC_OBJ_L1CACHE + depth-1;
- else
- return HWLOC_OBJ_TYPE_NONE;
- }
-}
-
-#define HWLOC_BITMAP_EQUAL 0 /* Bitmaps are equal */
-#define HWLOC_BITMAP_INCLUDED 1 /* First bitmap included in second */
-#define HWLOC_BITMAP_CONTAINS 2 /* First bitmap contains second */
-#define HWLOC_BITMAP_INTERSECTS 3 /* Bitmaps intersect without any inclusion */
-#define HWLOC_BITMAP_DIFFERENT 4 /* Bitmaps do not intersect */
-
-/* Compare bitmaps \p bitmap1 and \p bitmap2 from an inclusion point of view. */
-HWLOC_DECLSPEC int hwloc_bitmap_compare_inclusion(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
-
-/* Return a stringified PCI class. */
-HWLOC_DECLSPEC extern const char * hwloc_pci_class_string(unsigned short class_id);
-
-/* Parse a PCI link speed (GT/s) string from Linux sysfs */
-#ifdef HWLOC_LINUX_SYS
-#include <stdlib.h> /* for atof() */
-static __hwloc_inline float
-hwloc_linux_pci_link_speed_from_string(const char *string)
-{
- /* don't parse Gen1 with atof() since it expects a localized string
- * while the kernel sysfs files aren't.
- */
- if (!strncmp(string, "2.5 ", 4))
- /* "2.5 GT/s" is Gen1 with 8/10 encoding */
- return 2.5 * .8;
-
- /* also hardwire Gen2 since it also has a specific encoding */
- if (!strncmp(string, "5 ", 2))
- /* "5 GT/s" is Gen2 with 8/10 encoding */
- return 5 * .8;
-
- /* handle Gen3+ in a generic way */
- return atof(string) * 128./130; /* Gen3+ encoding is 128/130 */
-}
-#endif
-
-/* Traverse children of a parent */
-#define for_each_child(child, parent) for(child = parent->first_child; child; child = child->next_sibling)
-#define for_each_memory_child(child, parent) for(child = parent->memory_first_child; child; child = child->next_sibling)
-#define for_each_io_child(child, parent) for(child = parent->io_first_child; child; child = child->next_sibling)
-#define for_each_misc_child(child, parent) for(child = parent->misc_first_child; child; child = child->next_sibling)
-
-/* Any object attached to normal children */
-static __hwloc_inline int hwloc__obj_type_is_normal (hwloc_obj_type_t type)
-{
- /* type contiguity is asserted in topology_check() */
- return type <= HWLOC_OBJ_GROUP || type == HWLOC_OBJ_DIE;
-}
-
-/* Any object attached to memory children, currently NUMA nodes or Memory-side caches */
-static __hwloc_inline int hwloc__obj_type_is_memory (hwloc_obj_type_t type)
-{
- /* type contiguity is asserted in topology_check() */
- return type == HWLOC_OBJ_NUMANODE || type == HWLOC_OBJ_MEMCACHE;
-}
-
-/* I/O or Misc object, without cpusets or nodesets. */
-static __hwloc_inline int hwloc__obj_type_is_special (hwloc_obj_type_t type)
-{
- /* type contiguity is asserted in topology_check() */
- return type >= HWLOC_OBJ_BRIDGE && type <= HWLOC_OBJ_MISC;
-}
-
-/* Any object attached to io children */
-static __hwloc_inline int hwloc__obj_type_is_io (hwloc_obj_type_t type)
-{
- /* type contiguity is asserted in topology_check() */
- return type >= HWLOC_OBJ_BRIDGE && type <= HWLOC_OBJ_OS_DEVICE;
-}
-
-/* Any CPU caches (not Memory-side caches) */
-static __hwloc_inline int
-hwloc__obj_type_is_cache(hwloc_obj_type_t type)
-{
- /* type contiguity is asserted in topology_check() */
- return (type >= HWLOC_OBJ_L1CACHE && type <= HWLOC_OBJ_L3ICACHE);
-}
-
-static __hwloc_inline int
-hwloc__obj_type_is_dcache(hwloc_obj_type_t type)
-{
- /* type contiguity is asserted in topology_check() */
- return (type >= HWLOC_OBJ_L1CACHE && type <= HWLOC_OBJ_L5CACHE);
-}
-
-/** \brief Check whether an object is a Instruction Cache. */
-static __hwloc_inline int
-hwloc__obj_type_is_icache(hwloc_obj_type_t type)
-{
- /* type contiguity is asserted in topology_check() */
- return (type >= HWLOC_OBJ_L1ICACHE && type <= HWLOC_OBJ_L3ICACHE);
-}
-
-#ifdef HAVE_USELOCALE
-#include "locale.h"
-#ifdef HAVE_XLOCALE_H
-#include "xlocale.h"
-#endif
-#define hwloc_localeswitch_declare locale_t __old_locale = (locale_t)0, __new_locale
-#define hwloc_localeswitch_init() do { \
- __new_locale = newlocale(LC_ALL_MASK, "C", (locale_t)0); \
- if (__new_locale != (locale_t)0) \
- __old_locale = uselocale(__new_locale); \
-} while (0)
-#define hwloc_localeswitch_fini() do { \
- if (__new_locale != (locale_t)0) { \
- uselocale(__old_locale); \
- freelocale(__new_locale); \
- } \
-} while(0)
-#else /* HAVE_USELOCALE */
-#if HWLOC_HAVE_ATTRIBUTE_UNUSED
-#define hwloc_localeswitch_declare int __dummy_nolocale __hwloc_attribute_unused
-#define hwloc_localeswitch_init()
-#else
-#define hwloc_localeswitch_declare int __dummy_nolocale
-#define hwloc_localeswitch_init() (void)__dummy_nolocale
-#endif
-#define hwloc_localeswitch_fini()
-#endif /* HAVE_USELOCALE */
-
-#if !HAVE_DECL_FABSF
-#define fabsf(f) fabs((double)(f))
-#endif
-
-#if !HAVE_DECL_MODFF
-#define modff(x,iptr) (float)modf((double)x,(double *)iptr)
-#endif
-
-#if HAVE_DECL__SC_PAGE_SIZE
-#define hwloc_getpagesize() sysconf(_SC_PAGE_SIZE)
-#elif HAVE_DECL__SC_PAGESIZE
-#define hwloc_getpagesize() sysconf(_SC_PAGESIZE)
-#elif defined HAVE_GETPAGESIZE
-#define hwloc_getpagesize() getpagesize()
-#else
-#undef hwloc_getpagesize
-#endif
-
-#if HWLOC_HAVE_ATTRIBUTE_FORMAT
-# define __hwloc_attribute_format(type, str, arg) __attribute__((__format__(type, str, arg)))
-#else
-# define __hwloc_attribute_format(type, str, arg)
-#endif
-
-#define hwloc_memory_size_printf_value(_size, _verbose) \
- ((_size) < (10ULL<<20) || (_verbose) ? (((_size)>>9)+1)>>1 : (_size) < (10ULL<<30) ? (((_size)>>19)+1)>>1 : (_size) < (10ULL<<40) ? (((_size)>>29)+1)>>1 : (((_size)>>39)+1)>>1)
-#define hwloc_memory_size_printf_unit(_size, _verbose) \
- ((_size) < (10ULL<<20) || (_verbose) ? "KB" : (_size) < (10ULL<<30) ? "MB" : (_size) < (10ULL<<40) ? "GB" : "TB")
-
-#ifdef HWLOC_WIN_SYS
-# ifndef HAVE_SSIZE_T
-typedef SSIZE_T ssize_t;
-# endif
-# if !HAVE_DECL_STRTOULL && !defined(HAVE_STRTOULL)
-# define strtoull _strtoui64
-# endif
-# ifndef S_ISREG
-# define S_ISREG(m) ((m) & S_IFREG)
-# endif
-# ifndef S_ISDIR
-# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-# endif
-# ifndef S_IRWXU
-# define S_IRWXU 00700
-# endif
-# ifndef HWLOC_HAVE_DECL_STRCASECMP
-# define strcasecmp _stricmp
-# endif
-# if !HAVE_DECL_SNPRINTF
-# define snprintf _snprintf
-# endif
-# if HAVE_DECL__STRDUP
-# define strdup _strdup
-# endif
-# if HAVE_DECL__PUTENV
-# define putenv _putenv
-# endif
-#endif
-
-static __inline float
-hwloc__pci_link_speed(unsigned generation, unsigned lanes)
-{
- float lanespeed;
- /*
- * These are single-direction bandwidths only.
- *
- * Gen1 used NRZ with 8/10 encoding.
- * PCIe Gen1 = 2.5GT/s signal-rate per lane x 8/10 = 0.25GB/s data-rate per lane
- * PCIe Gen2 = 5 GT/s signal-rate per lane x 8/10 = 0.5 GB/s data-rate per lane
- * Gen3 switched to NRZ with 128/130 encoding.
- * PCIe Gen3 = 8 GT/s signal-rate per lane x 128/130 = 1 GB/s data-rate per lane
- * PCIe Gen4 = 16 GT/s signal-rate per lane x 128/130 = 2 GB/s data-rate per lane
- * PCIe Gen5 = 32 GT/s signal-rate per lane x 128/130 = 4 GB/s data-rate per lane
- * Gen6 switched to PAM with with 242/256 FLIT (242B payload protected by 8B CRC + 6B FEC).
- * PCIe Gen6 = 64 GT/s signal-rate per lane x 242/256 = 8 GB/s data-rate per lane
- * PCIe Gen7 = 128GT/s signal-rate per lane x 242/256 = 16 GB/s data-rate per lane
- */
-
- /* lanespeed in Gbit/s */
- if (generation <= 2)
- lanespeed = 2.5f * generation * 0.8f;
- else if (generation <= 5)
- lanespeed = 8.0f * (1<<(generation-3)) * 128/130;
- else
- lanespeed = 8.0f * (1<<(generation-3)) * 242/256; /* assume Gen8 will be 256 GT/s and so on */
-
- /* linkspeed in GB/s */
- return lanespeed * lanes / 8;
-}
-
-#endif /* HWLOC_PRIVATE_MISC_H */
### src/3rdparty/hwloc/include/private/private.h
@@ -1,547 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2025 Inria. All rights reserved.
- * Copyright © 2009-2012, 2020 Université Bordeaux
- * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
- *
- * See COPYING in top-level directory.
- */
-
-/* Internal types and helpers. */
-
-
-#ifdef HWLOC_INSIDE_PLUGIN
-/*
- * these declarations are internal only, they are not available to plugins
- * (many functions below are internal static symbols).
- */
-#error This file should not be used in plugins
-#endif
-
-
-#ifndef HWLOC_PRIVATE_H
-#define HWLOC_PRIVATE_H
-
-#include "private/autogen/config.h"
-#include "hwloc.h"
-#include "hwloc/bitmap.h"
-#include "private/components.h"
-#include "private/misc.h"
-
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#ifdef HAVE_SYS_UTSNAME_H
-#include <sys/utsname.h>
-#endif
-#include <string.h>
-
-#define HWLOC_TOPOLOGY_ABI 0x20400 /* version of the layout of struct topology */
-
-struct hwloc_internal_location_s {
- enum hwloc_location_type_e type;
- union {
- struct {
- hwloc_obj_t obj; /* cached between refreshes */
- uint64_t gp_index;
- hwloc_obj_type_t type;
- } object; /* if type == HWLOC_LOCATION_TYPE_OBJECT */
- hwloc_cpuset_t cpuset; /* if type == HWLOC_LOCATION_TYPE_CPUSET */
- } location;
-};
-
-/*****************************************************
- * WARNING:
- * changes below in this structure (and its children)
- * should cause a bump of HWLOC_TOPOLOGY_ABI.
- *****************************************************/
-
-struct hwloc_topology {
- unsigned topology_abi;
-
- unsigned nb_levels; /* Number of horizontal levels */
- unsigned nb_levels_allocated; /* Number of levels allocated and zeroed in level_nbobjects and levels below */
- unsigned *level_nbobjects; /* Number of objects on each horizontal level */
- struct hwloc_obj ***levels; /* Direct access to levels, levels[l = 0 .. nblevels-1][0..level_nbobjects[l]] */
- unsigned long flags;
- int type_depth[HWLOC_OBJ_TYPE_MAX];
- enum hwloc_type_filter_e type_filter[HWLOC_OBJ_TYPE_MAX];
- int is_thissystem;
- int is_loaded;
- int modified; /* >0 if objects were added/removed recently, which means a reconnect is needed */
- hwloc_pid_t pid; /* Process ID the topology is view from, 0 for self */
- void *userdata;
- uint64_t next_gp_index;
-
- void *adopted_shmem_addr;
- size_t adopted_shmem_length;
-
-#define HWLOC_NR_SLEVELS 6
-#define HWLOC_SLEVEL_NUMANODE 0
-#define HWLOC_SLEVEL_BRIDGE 1
-#define HWLOC_SLEVEL_PCIDEV 2
-#define HWLOC_SLEVEL_OSDEV 3
-#define HWLOC_SLEVEL_MISC 4
-#define HWLOC_SLEVEL_MEMCACHE 5
- /* order must match negative depth, it's asserted in setup_defaults() */
-#define HWLOC_SLEVEL_FROM_DEPTH(x) (HWLOC_TYPE_DEPTH_NUMANODE-(x))
-#define HWLOC_SLEVEL_TO_DEPTH(x) (HWLOC_TYPE_DEPTH_NUMANODE-(x))
- struct hwloc_special_level_s {
- unsigned nbobjs;
- struct hwloc_obj **objs;
- struct hwloc_obj *first, *last; /* Temporarily used while listing object before building the objs array */
- } slevels[HWLOC_NR_SLEVELS];
-
- hwloc_bitmap_t allowed_cpuset;
- hwloc_bitmap_t allowed_nodeset;
-
- struct hwloc_binding_hooks {
- /* These are actually rather OS hooks since some of them are not about binding */
- int (*set_thisproc_cpubind)(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags);
- int (*get_thisproc_cpubind)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
- int (*set_thisthread_cpubind)(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags);
- int (*get_thisthread_cpubind)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
- int (*set_proc_cpubind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int flags);
- int (*get_proc_cpubind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
-#ifdef hwloc_thread_t
- int (*set_thread_cpubind)(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_const_cpuset_t set, int flags);
- int (*get_thread_cpubind)(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_cpuset_t set, int flags);
-#endif
-
- int (*get_thisproc_last_cpu_location)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
- int (*get_thisthread_last_cpu_location)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
- int (*get_proc_last_cpu_location)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
-
- int (*set_thisproc_membind)(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
- int (*get_thisproc_membind)(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
- int (*set_thisthread_membind)(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
- int (*get_thisthread_membind)(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
- int (*set_proc_membind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
- int (*get_proc_membind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
- int (*set_area_membind)(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
- int (*get_area_membind)(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
- int (*get_area_memlocation)(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, int flags);
- /* This has to return the same kind of pointer as alloc_membind, so that free_membind can be used on it */
- void *(*alloc)(hwloc_topology_t topology, size_t len);
- /* alloc_membind has to always succeed if !(flags & HWLOC_MEMBIND_STRICT).
- * see hwloc_alloc_or_fail which is convenient for that. */
- void *(*alloc_membind)(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
- int (*free_membind)(hwloc_topology_t topology, void *addr, size_t len);
-
- int (*get_allowed_resources)(hwloc_topology_t topology);
- } binding_hooks;
-
- struct hwloc_topology_support support;
-
- void (*userdata_export_cb)(void *reserved, struct hwloc_topology *topology, struct hwloc_obj *obj);
- void (*userdata_import_cb)(struct hwloc_topology *topology, struct hwloc_obj *obj, const char *name, const void *buffer, size_t length);
- int userdata_not_decoded;
-
- struct hwloc_internal_distances_s {
- char *name; /* FIXME: needs an API to set it from user */
-
- unsigned id; /* to match the container id field of public distances structure
- * not exported to XML, regenerated during _add()
- */
-
- /* if all objects have the same type, different_types is NULL and unique_type is valid.
- * otherwise unique_type is HWLOC_OBJ_TYPE_NONE and different_types contains individual objects types.
- */
- hwloc_obj_type_t unique_type;
- hwloc_obj_type_t *different_types;
-
- /* add union hwloc_obj_attr_u if we ever support groups */
- unsigned nbobjs;
- uint64_t *indexes; /* array of OS or GP indexes before we can convert them into objs.
- * OS indexes for distances covering only PUs or only NUMAnodes.
- */
-#define HWLOC_DIST_TYPE_USE_OS_INDEX(_type) ((_type) == HWLOC_OBJ_PU || (_type == HWLOC_OBJ_NUMANODE))
- uint64_t *values; /* distance matrices, ordered according to the above indexes/objs array.
- * distance from i to j is stored in slot i*nbnodes+j.
- */
- unsigned long kind;
-
-#define HWLOC_INTERNAL_DIST_FLAG_OBJS_VALID (1U<<0) /* if the objs array is valid below */
-#define HWLOC_INTERNAL_DIST_FLAG_NOT_COMMITTED (1U<<1) /* if the distances isn't in the list yet */
- unsigned iflags;
-
- /* objects are currently stored in physical_index order */
- hwloc_obj_t *objs; /* array of objects */
-
- struct hwloc_internal_distances_s *prev, *next;
- } *first_dist, *last_dist;
- unsigned next_dist_id;
-
- /* memory attributes */
- unsigned nr_memattrs;
- struct hwloc_internal_memattr_s {
- /* memattr info */
- char *name; /* TODO unit is implicit, in the documentation of standard attributes, or in the name? */
- unsigned long flags;
-#define HWLOC_IMATTR_FLAG_STATIC_NAME (1U<<0) /* no need to free name */
-#define HWLOC_IMATTR_FLAG_CACHE_VALID (1U<<1) /* target and initiator are valid */
-#define HWLOC_IMATTR_FLAG_CONVENIENCE (1U<<2) /* convenience attribute reporting values from non-memattr attributes (R/O and no actual targets stored) */
- unsigned iflags;
-
- /* array of values */
- unsigned nr_targets;
- struct hwloc_internal_memattr_target_s {
- /* target object */
- hwloc_obj_t obj; /* cached between refreshes */
- hwloc_obj_type_t type;
- unsigned os_index; /* only used temporarily during discovery when there's no obj/gp_index yet */
- hwloc_uint64_t gp_index;
-
- /* value if there are no initiator for this attr */
- hwloc_uint64_t noinitiator_value;
- /* initiators otherwise */
- unsigned nr_initiators;
- struct hwloc_internal_memattr_initiator_s {
- struct hwloc_internal_location_s initiator;
- hwloc_uint64_t value;
- } *initiators;
- } *targets;
- } *memattrs;
-
- /* hybridcpus */
- unsigned nr_cpukinds;
- unsigned nr_cpukinds_allocated;
- struct hwloc_internal_cpukind_s {
- hwloc_cpuset_t cpuset;
-#define HWLOC_CPUKIND_EFFICIENCY_UNKNOWN -1
- int efficiency;
- int forced_efficiency; /* returned by the hardware or OS if any */
- hwloc_uint64_t ranking_value; /* internal value for ranking */
- unsigned nr_infos;
- struct hwloc_info_s *infos;
- } *cpukinds;
-
- int grouping;
- int grouping_verbose;
- unsigned grouping_nbaccuracies;
- float grouping_accuracies[5];
- unsigned grouping_next_subkind;
-
- /* list of enabled backends. */
- struct hwloc_backend * backends;
- struct hwloc_backend * get_pci_busid_cpuset_backend; /* first backend that provides get_pci_busid_cpuset() callback */
- unsigned backend_phases;
- unsigned backend_excluded_phases;
-
- /* memory allocator for topology objects */
- struct hwloc_tma * tma;
-
-/*****************************************************
- * WARNING:
- * changes above in this structure (and its children)
- * should cause a bump of HWLOC_TOPOLOGY_ABI.
- *****************************************************/
-
- /*
- * temporary variables during discovery
- */
-
- /* set to 1 at the beginning of load() if the filter of any cpu cache type (L1 to L3i) is not NONE,
- * may be checked by backends before querying caches
- * (when they don't know the level of caches they are querying).
- */
- int want_some_cpu_caches;
-
- /* machine-wide memory.
- * temporarily stored there by OSes that only provide this without NUMA information,
- * and actually used later by the core.
- */
- struct hwloc_numanode_attr_s machine_memory;
-
- /* pci stuff */
- int pci_has_forced_locality;
- unsigned pci_forced_locality_nr;
- struct hwloc_pci_forced_locality_s {
- unsigned domain;
- unsigned bus_first, bus_last;
- hwloc_bitmap_t cpuset;
- } * pci_forced_locality;
- hwloc_uint64_t pci_locality_quirks;
-
- /* component blacklisting */
- unsigned nr_blacklisted_components;
- struct hwloc_topology_forced_component_s {
- struct hwloc_disc_component *component;
- unsigned phases;
- } *blacklisted_components;
-
- /* FIXME: keep until topo destroy and reuse for finding specific buses */
- struct hwloc_pci_locality_s {
- unsigned domain;
- unsigned bus_min;
- unsigned bus_max;
- hwloc_bitmap_t cpuset;
- hwloc_obj_t parent;
- struct hwloc_pci_locality_s *prev, *next;
- } *first_pci_locality, *last_pci_locality;
-};
-
-extern void hwloc_alloc_root_sets(hwloc_obj_t root);
-extern void hwloc_setup_pu_level(struct hwloc_topology *topology, unsigned nb_pus);
-extern int hwloc_get_sysctlbyname(const char *name, int64_t *n);
-extern int hwloc_get_sysctl(int name[], unsigned namelen, int64_t *n);
-
-/* returns the number of CPU from the OS (only valid if thissystem) */
-#define HWLOC_FALLBACK_NBPROCESSORS_INCLUDE_OFFLINE 1 /* by default we try to get only the online CPUs */
-extern int hwloc_fallback_nbprocessors(unsigned flags);
-/* returns the memory size from the OS (only valid if thissystem) */
-extern int64_t hwloc_fallback_memsize(void);
-
-extern int hwloc__object_cpusets_compare_first(hwloc_obj_t obj1, hwloc_obj_t obj2);
-extern void hwloc__reorder_children(hwloc_obj_t parent);
-
-extern void hwloc_topology_setup_defaults(struct hwloc_topology *topology);
-extern void hwloc_topology_clear(struct hwloc_topology *topology);
-
-#define _HWLOC_RECONNECT_FLAG_KEEPSTRUCTURE (1UL<<0)
-extern int hwloc__reconnect(struct hwloc_topology *topology, unsigned long flags);
-
-/* insert memory object as memory child of normal parent */
-extern struct hwloc_obj * hwloc__attach_memory_object(struct hwloc_topology *topology, hwloc_obj_t parent,
- hwloc_obj_t obj, const char *reason);
-
-extern hwloc_obj_t hwloc_get_obj_by_type_and_gp_index(hwloc_topology_t topology, hwloc_obj_type_t type, uint64_t gp_index);
-
-extern void hwloc_pci_discovery_init(struct hwloc_topology *topology);
-extern void hwloc_pci_discovery_prepare(struct hwloc_topology *topology);
-extern void hwloc_pci_discovery_exit(struct hwloc_topology *topology);
-
-/* Look for an object matching complete cpuset exactly, or insert one.
- * Return NULL on failure.
- * Return a good fallback (object above) on failure to insert.
- */
-extern hwloc_obj_t hwloc_find_insert_io_parent_by_complete_cpuset(struct hwloc_topology *topology, hwloc_cpuset_t cpuset);
-
-extern int hwloc__add_info(struct hwloc_info_s **infosp, unsigned *countp, const char *name, const char *value);
-extern int hwloc__add_info_nodup(struct hwloc_info_s **infosp, unsigned *countp, const char *name, const char *value, int replace);
-extern int hwloc__move_infos(struct hwloc_info_s **dst_infosp, unsigned *dst_countp, struct hwloc_info_s **src_infosp, unsigned *src_countp);
-extern int hwloc__tma_dup_infos(struct hwloc_tma *tma, struct hwloc_info_s **dst_infosp, unsigned *dst_countp, struct hwloc_info_s *src_infos, unsigned src_count);
-extern void hwloc__free_infos(struct hwloc_info_s *infos, unsigned count);
-
-/* set native OS binding hooks */
-extern void hwloc_set_native_binding_hooks(struct hwloc_binding_hooks *hooks, struct hwloc_topology_support *support);
-/* set either native OS binding hooks (if thissystem), or dummy ones */
-extern void hwloc_set_binding_hooks(struct hwloc_topology *topology);
-
-#if defined(HWLOC_LINUX_SYS)
-extern void hwloc_set_linuxfs_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_LINUX_SYS */
-
-#if defined(HWLOC_BGQ_SYS)
-extern void hwloc_set_bgq_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_BGQ_SYS */
-
-#ifdef HWLOC_SOLARIS_SYS
-extern void hwloc_set_solaris_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_SOLARIS_SYS */
-
-#ifdef HWLOC_AIX_SYS
-extern void hwloc_set_aix_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_AIX_SYS */
-
-#ifdef HWLOC_WIN_SYS
-extern void hwloc_set_windows_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_WIN_SYS */
-
-#ifdef HWLOC_DARWIN_SYS
-extern void hwloc_set_darwin_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_DARWIN_SYS */
-
-#ifdef HWLOC_FREEBSD_SYS
-extern void hwloc_set_freebsd_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_FREEBSD_SYS */
-
-#ifdef HWLOC_NETBSD_SYS
-extern void hwloc_set_netbsd_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_NETBSD_SYS */
-
-#ifdef HWLOC_HPUX_SYS
-extern void hwloc_set_hpux_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
-#endif /* HWLOC_HPUX_SYS */
-
-extern int hwloc_look_hardwired_fujitsu_k(struct hwloc_topology *topology);
-extern int hwloc_look_hardwired_fujitsu_fx10(struct hwloc_topology *topology);
-extern int hwloc_look_hardwired_fujitsu_fx100(struct hwloc_topology *topology);
-
-/* Insert uname-specific names/values in the object infos array.
- * If cached_uname isn't NULL, it is used as a struct utsname instead of recalling uname.
- * Any field that starts with \0 is ignored.
- */
-extern void hwloc_add_uname_info(struct hwloc_topology *topology, void *cached_uname);
-
-/* Free obj and its attributes assuming it's not linked to a parent and doesn't have any child */
-extern void hwloc_free_unlinked_object(hwloc_obj_t obj);
-
-/* Free obj and its children, assuming it's not linked to a parent */
-extern void hwloc_free_object_and_children(hwloc_obj_t obj);
-
-/* Free obj, its next siblings, and their children, assuming they're not linked to a parent */
-extern void hwloc_free_object_siblings_and_children(hwloc_obj_t obj);
-
-/* This can be used for the alloc field to get allocated data that can be freed by free() */
-void *hwloc_alloc_heap(hwloc_topology_t topology, size_t len);
-
-/* This can be used for the alloc field to get allocated data that can be freed by munmap() */
-void *hwloc_alloc_mmap(hwloc_topology_t topology, size_t len);
-
-/* This can be used for the free_membind field to free data using free() */
-int hwloc_free_heap(hwloc_topology_t topology, void *addr, size_t len);
-
-/* This can be used for the free_membind field to free data using munmap() */
-int hwloc_free_mmap(hwloc_topology_t topology, void *addr, size_t len);
-
-/* Allocates unbound memory or fail, depending on whether STRICT is requested
- * or not */
-static __hwloc_inline void *
-hwloc_alloc_or_fail(hwloc_topology_t topology, size_t len, int flags)
-{
- if (flags & HWLOC_MEMBIND_STRICT)
- return NULL;
- return hwloc_alloc(topology, len);
-}
-
-extern void hwloc_internal_distances_init(hwloc_topology_t topology);
-extern void hwloc_internal_distances_prepare(hwloc_topology_t topology);
-extern void hwloc_internal_distances_destroy(hwloc_topology_t topology);
-extern int hwloc_internal_distances_dup(hwloc_topology_t new, hwloc_topology_t old);
-extern void hwloc_internal_distances_refresh(hwloc_topology_t topology);
-extern void hwloc_internal_distances_invalidate_cached_objs(hwloc_topology_t topology);
-
-/* these distances_add() functions are higher-level than those in hwloc/plugins.h
- * but they may change in the future, hence they are not exported to plugins.
- */
-extern int hwloc_internal_distances_add_by_index(hwloc_topology_t topology, const char *name, hwloc_obj_type_t unique_type, hwloc_obj_type_t *different_types, unsigned nbobjs, uint64_t *indexes, uint64_t *values, unsigned long kind, unsigned long flags);
-extern int hwloc_internal_distances_add(hwloc_topology_t topology, const char *name, unsigned nbobjs, hwloc_obj_t *objs, uint64_t *values, unsigned long kind, unsigned long flags);
-
-extern void hwloc_internal_memattrs_init(hwloc_topology_t topology);
-extern void hwloc_internal_memattrs_prepare(hwloc_topology_t topology);
-extern void hwloc_internal_memattrs_destroy(hwloc_topology_t topology);
-extern void hwloc_internal_memattrs_need_refresh(hwloc_topology_t topology);
-extern void hwloc_internal_memattrs_refresh(hwloc_topology_t topology);
-extern int hwloc_internal_memattrs_dup(hwloc_topology_t new, hwloc_topology_t old);
-extern int hwloc_internal_memattr_set_value(hwloc_topology_t topology, hwloc_memattr_id_t id, hwloc_obj_type_t target_type, hwloc_uint64_t target_gp_index, unsigned target_os_index, struct hwloc_internal_location_s *initiator, hwloc_uint64_t value);
-extern int hwloc_internal_memattrs_guess_memory_tiers(hwloc_topology_t topology, int force_subtype);
-
-extern void hwloc_internal_cpukinds_init(hwloc_topology_t topology);
-extern int hwloc_internal_cpukinds_rank(hwloc_topology_t topology);
-extern void hwloc_internal_cpukinds_destroy(hwloc_topology_t topology);
-extern int hwloc_internal_cpukinds_dup(hwloc_topology_t new, hwloc_topology_t old);
-#define HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY (1<<0)
-extern int hwloc_internal_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t cpuset, int forced_efficiency, const struct hwloc_info_s *infos, unsigned nr_infos, unsigned long flags);
-extern void hwloc_internal_cpukinds_restrict(hwloc_topology_t topology);
-
-/* encode src buffer into target buffer.
- * targsize must be at least 4*((srclength+2)/3)+1.
- * target will be 0-terminated.
- */
-extern int hwloc_encode_to_base64(const char *src, size_t srclength, char *target, size_t targsize);
-/* decode src buffer into target buffer.
- * src is 0-terminated.
- * targsize must be at least srclength*3/4+1 (srclength not including \0)
- * but only srclength*3/4 characters will be meaningful
- * (the next one may be partially written during decoding, but it should be ignored).
- */
-extern int hwloc_decode_from_base64(char const *src, char *target, size_t targsize);
-
-/* On some systems, snprintf returns the size of written data, not the actually
- * required size. Sometimes it returns -1 on truncation too.
- * And sometimes it doesn't like NULL output buffers.
- * http://www.gnu.org/software/gnulib/manual/html_node/snprintf.html
- *
- * hwloc_snprintf behaves properly, but it's a bit overkill on the vast majority
- * of platforms, so don't enable it unless really needed.
- */
-#ifdef HWLOC_HAVE_CORRECT_SNPRINTF
-#define hwloc_snprintf snprintf
-#else
-extern int hwloc_snprintf(char *str, size_t size, const char *format, ...) __hwloc_attribute_format(printf, 3, 4);
-#endif
-
-/* Return the name of the currently running program, if supported.
- * If not NULL, must be freed by the caller.
- */
-extern char * hwloc_progname(struct hwloc_topology *topology);
-
-/* obj->attr->group.kind internal values.
- * the core will keep the smallest ones when merging two groups,
- * that's why user-given kinds are first.
- */
-/* first, user-given groups, should remain as long as possible */
-#define HWLOC_GROUP_KIND_USER 0 /* user-given, user may use subkind too */
-#define HWLOC_GROUP_KIND_SYNTHETIC 10 /* subkind is group depth within synthetic description */
-/* then, hardware-specific groups */
-#define HWLOC_GROUP_KIND_INTEL_KNL_SUBNUMA_CLUSTER 100 /* no subkind */
-#define HWLOC_GROUP_KIND_INTEL_EXTTOPOENUM_UNKNOWN 101 /* subkind is unknown level */
-#define HWLOC_GROUP_KIND_INTEL_MODULE 102 /* no subkind */
-#define HWLOC_GROUP_KIND_INTEL_TILE 103 /* no subkind */
-#define HWLOC_GROUP_KIND_INTEL_DIE 104 /* no subkind */
-#define HWLOC_GROUP_KIND_S390_BOOK 110 /* subkind 0 is book, subkind 1 is drawer (group of books) */
-#define HWLOC_GROUP_KIND_AMD_COMPUTE_UNIT 120 /* no subkind */
-#define HWLOC_GROUP_KIND_AMD_COMPLEX 121 /* no subkind */
-/* then, OS-specific groups */
-#define HWLOC_GROUP_KIND_SOLARIS_PG_HW_PERF 200 /* subkind is group width */
-#define HWLOC_GROUP_KIND_AIX_SDL_UNKNOWN 210 /* subkind is SDL level */
-#define HWLOC_GROUP_KIND_WINDOWS_PROCESSOR_GROUP 220 /* no subkind */
-#define HWLOC_GROUP_KIND_WINDOWS_RELATIONSHIP_UNKNOWN 221 /* no subkind */
-#define HWLOC_GROUP_KIND_LINUX_CLUSTER 222 /* no subkind */
-/* distance groups */
-#define HWLOC_GROUP_KIND_DISTANCE 900 /* subkind is round of adding these groups during distance based grouping */
-/* finally, hwloc-specific groups required to insert something else, should disappear as soon as possible */
-#define HWLOC_GROUP_KIND_IO 1000 /* no subkind */
-#define HWLOC_GROUP_KIND_MEMORY 1001 /* no subkind */
-
-/* memory allocator for topology objects */
-struct hwloc_tma {
- void * (*malloc)(struct hwloc_tma *, size_t);
- void *data;
- int dontfree; /* when set, free() or realloc() cannot be used, and tma->malloc() cannot fail */
-};
-
-static __hwloc_inline void *
-hwloc_tma_malloc(struct hwloc_tma *tma,
- size_t size)
-{
- if (tma) {
- return tma->malloc(tma, size);
- } else {
- return malloc(size);
- }
-}
-
-static __hwloc_inline void *
-hwloc_tma_calloc(struct hwloc_tma *tma,
- size_t size)
-{
- char *ptr = hwloc_tma_malloc(tma, size);
- if (ptr)
- memset(ptr, 0, size);
- return ptr;
-}
-
-static __hwloc_inline char *
-hwloc_tma_strdup(struct hwloc_tma *tma,
- const char *src)
-{
- size_t len = strlen(src);
- char *ptr = hwloc_tma_malloc(tma, len+1);
- if (ptr)
- memcpy(ptr, src, len+1);
- return ptr;
-}
-
-/* bitmap allocator to be used inside hwloc */
-extern hwloc_bitmap_t hwloc_bitmap_tma_dup(struct hwloc_tma *tma, hwloc_const_bitmap_t old);
-
-extern int hwloc__topology_dup(hwloc_topology_t *newp, hwloc_topology_t old, struct hwloc_tma *tma);
-extern void hwloc__topology_disadopt(hwloc_topology_t topology);
-
-#endif /* HWLOC_PRIVATE_H */
### src/3rdparty/hwloc/include/private/solaris-chiptype.h
@@ -1,43 +0,0 @@
-/*
- * Copyright © 2009-2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Copyright © 2017 Inria. All rights reserved.
- * $COPYRIGHT$
- *
- * Additional copyrights may follow
- *
- * $HEADER$
- */
-
-
-#ifdef HWLOC_INSIDE_PLUGIN
-/*
- * these declarations are internal only, they are not available to plugins
- * (functions below are internal static symbols).
- */
-#error This file should not be used in plugins
-#endif
-
-
-#ifndef HWLOC_PRIVATE_SOLARIS_CHIPTYPE_H
-#define HWLOC_PRIVATE_SOLARIS_CHIPTYPE_H
-
-struct hwloc_solaris_chip_info_s {
- char *model;
- char *type;
- /* L1i, L1d, L2, L3 */
-#define HWLOC_SOLARIS_CHIP_INFO_L1I 0
-#define HWLOC_SOLARIS_CHIP_INFO_L1D 1
-#define HWLOC_SOLARIS_CHIP_INFO_L2I 2
-#define HWLOC_SOLARIS_CHIP_INFO_L2D 3
-#define HWLOC_SOLARIS_CHIP_INFO_L3 4
- long cache_size[5]; /* cleared to -1 if we don't want of that cache */
- unsigned cache_linesize[5];
- unsigned cache_associativity[5];
- int l2_unified;
-};
-
-/* fills the structure with 0 on error */
-extern void hwloc_solaris_get_chip_info(struct hwloc_solaris_chip_info_s *info);
-
-#endif /* HWLOC_PRIVATE_SOLARIS_CHIPTYPE_H */
### src/3rdparty/hwloc/include/private/windows.h
@@ -1,30 +0,0 @@
-/*
- * Copyright © 2009 Université Bordeaux
- * Copyright © 2020-2022 Inria. All rights reserved.
- *
- * See COPYING in top-level directory.
- */
-
-#ifndef HWLOC_PRIVATE_WINDOWS_H
-#define HWLOC_PRIVATE_WINDOWS_H
-
-#ifndef _ANONYMOUS_UNION
-#ifdef __GNUC__
-#define _ANONYMOUS_UNION __extension__
-#else
-#define _ANONYMOUS_UNION
-#endif /* __GNUC__ */
-#endif /* _ANONYMOUS_UNION */
-
-#ifndef _ANONYMOUS_STRUCT
-#ifdef __GNUC__
-#define _ANONYMOUS_STRUCT __extension__
-#else
-#define _ANONYMOUS_STRUCT
-#endif /* __GNUC__ */
-#endif /* _ANONYMOUS_STRUCT */
-
-#define DUMMYUNIONNAME
-#define DUMMYSTRUCTNAME
-
-#endif /* HWLOC_PRIVATE_WINDOWS_H */
### src/3rdparty/hwloc/include/private/xml.h
@@ -1,109 +0,0 @@
-/*
- * Copyright © 2009-2017 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-#ifndef PRIVATE_XML_H
-#define PRIVATE_XML_H 1
-
-#include "hwloc.h"
-
-#include <sys/types.h>
-
-HWLOC_DECLSPEC int hwloc__xml_verbose(void);
-
-/**************
- * XML import *
- **************/
-
-typedef struct hwloc__xml_import_state_s {
- struct hwloc__xml_import_state_s *parent;
-
- /* globals shared between the entire stack of states during import */
- struct hwloc_xml_backend_data_s *global;
-
- /* opaque data used to store backend-specific data.
- * statically allocated to allow stack-allocation by the common code without knowing actual backend needs.
- * libxml is 3 ptrs. nolibxml is 3 ptr + one int.
- */
- char data[4 * SIZEOF_VOID_P];
-} * hwloc__xml_import_state_t;
-
-struct hwloc__xml_imported_v1distances_s {
- unsigned long kind;
- unsigned nbobjs;
- float *floats;
- struct hwloc__xml_imported_v1distances_s *prev, *next;
-};
-
-HWLOC_DECLSPEC int hwloc__xml_import_diff(hwloc__xml_import_state_t state, hwloc_topology_diff_t *firstdiffp);
-
-struct hwloc_xml_backend_data_s {
- /* xml backend parameters */
- int (*look_init)(struct hwloc_xml_backend_data_s *bdata, struct hwloc__xml_import_state_s *state);
- void (*look_done)(struct hwloc_xml_backend_data_s *bdata, int result);
- void (*backend_exit)(struct hwloc_xml_backend_data_s *bdata);
- int (*next_attr)(struct hwloc__xml_import_state_s * state, char **namep, char **valuep);
- int (*find_child)(struct hwloc__xml_import_state_s * state, struct hwloc__xml_import_state_s * childstate, char **tagp);
- int (*close_tag)(struct hwloc__xml_import_state_s * state); /* look for an explicit closing tag </name> */
- void (*close_child)(struct hwloc__xml_import_state_s * state);
- int (*get_content)(struct hwloc__xml_import_state_s * state, const char **beginp, size_t expected_length); /* return 0 on empty content (and sets beginp to empty string), 1 on actual content, -1 on error or unexpected content length */
- void (*close_content)(struct hwloc__xml_import_state_s * state);
- char * msgprefix;
- void *data; /* libxml2 doc, or nolibxml buffer */
- unsigned version_major, version_minor;
- unsigned nbnumanodes;
- hwloc_obj_t first_numanode, last_numanode; /* temporary cousin-list for handling v1distances */
- struct hwloc__xml_imported_v1distances_s *first_v1dist, *last_v1dist;
-};
-
-/**************
- * XML export *
- **************/
-
-typedef struct hwloc__xml_export_state_s {
- struct hwloc__xml_export_state_s *parent;
-
- void (*new_child)(struct hwloc__xml_export_state_s *parentstate, struct hwloc__xml_export_state_s *state, const char *name);
- void (*new_prop)(struct hwloc__xml_export_state_s *state, const char *name, const char *value);
- void (*add_content)(struct hwloc__xml_export_state_s *state, const char *buffer, size_t length);
- void (*end_object)(struct hwloc__xml_export_state_s *state, const char *name);
-
- struct hwloc__xml_export_data_s {
- hwloc_obj_t v1_memory_group; /* if we need to insert intermediate group above memory children when exporting to v1 */
- } *global;
-
- /* opaque data used to store backend-specific data.
- * statically allocated to allow stack-allocation by the common code without knowing actual backend needs.
- * libxml is 1 ptr. nolibxml is 1 ptr + 2 size_t + 3 ints.
- */
- char data[6 * SIZEOF_VOID_P];
-} * hwloc__xml_export_state_t;
-
-HWLOC_DECLSPEC void hwloc__xml_export_topology(hwloc__xml_export_state_t parentstate, hwloc_topology_t topology, unsigned long flags);
-
-HWLOC_DECLSPEC void hwloc__xml_export_diff(hwloc__xml_export_state_t parentstate, hwloc_topology_diff_t diff);
-
-/******************
- * XML components *
- ******************/
-
-struct hwloc_xml_callbacks {
- int (*backend_init)(struct hwloc_xml_backend_data_s *bdata, const char *xmlpath, const char *xmlbuffer, int xmlbuflen);
- int (*export_file)(struct hwloc_topology *topology, struct hwloc__xml_export_data_s *edata, const char *filename, unsigned long flags);
- int (*export_buffer)(struct hwloc_topology *topology, struct hwloc__xml_export_data_s *edata, char **xmlbuffer, int *buflen, unsigned long flags);
- void (*free_buffer)(void *xmlbuffer);
- int (*import_diff)(struct hwloc__xml_import_state_s *state, const char *xmlpath, const char *xmlbuffer, int xmlbuflen, hwloc_topology_diff_t *diff, char **refnamep);
- int (*export_diff_file)(union hwloc_topology_diff_u *diff, const char *refname, const char *filename);
- int (*export_diff_buffer)(union hwloc_topology_diff_u *diff, const char *refname, char **xmlbuffer, int *buflen);
-};
-
-struct hwloc_xml_component {
- struct hwloc_xml_callbacks *nolibxml_callbacks;
- struct hwloc_xml_callbacks *libxml_callbacks;
-};
-
-HWLOC_DECLSPEC void hwloc_xml_callbacks_register(struct hwloc_xml_component *component);
-HWLOC_DECLSPEC void hwloc_xml_callbacks_reset(void);
-
-#endif /* PRIVATE_XML_H */
### src/3rdparty/hwloc/src/base64.c
@@ -1,309 +0,0 @@
-/*
- * Copyright © 2012-2018 Inria. All rights reserved.
- * See COPYING in top-level directory.
- *
- * Modifications after import:
- * - removed all #if
- * - updated prototypes
- * - updated #include
- */
-
-/* include hwloc's config before anything else
- * so that extensions and features are properly enabled
- */
-#include "private/private.h"
-
-/* $OpenBSD: base64.c,v 1.5 2006/10/21 09:55:03 otto Exp $ */
-
-/*
- * Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * Portions Copyright (c) 1995 by International Business Machines, Inc.
- *
- * International Business Machines, Inc. (hereinafter called IBM) grants
- * permission under its copyrights to use, copy, modify, and distribute this
- * Software with or without fee, provided that the above copyright notice and
- * all paragraphs of this notice appear in all copies, and that the name of IBM
- * not be used in connection with the marketing of any product incorporating
- * the Software or modifications thereof, without specific, written prior
- * permission.
- *
- * To the extent it has a right to do so, IBM grants an immunity from suit
- * under its patents, if any, for the use, sale or manufacture of products to
- * the extent that such products are used for performing Domain Name System
- * dynamic updates in TCP/IP networks by means of the Software. No immunity is
- * granted for any product per se or for any other function of any product.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
- * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
- * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-/* OPENBSD ORIGINAL: lib/libc/net/base64.c */
-
-static const char Base64[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-static const char Pad64 = '=';
-
-/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
- The following encoding technique is taken from RFC 1521 by Borenstein
- and Freed. It is reproduced here in a slightly edited form for
- convenience.
-
- A 65-character subset of US-ASCII is used, enabling 6 bits to be
- represented per printable character. (The extra 65th character, "=",
- is used to signify a special processing function.)
-
- The encoding process represents 24-bit groups of input bits as output
- strings of 4 encoded characters. Proceeding from left to right, a
- 24-bit input group is formed by concatenating 3 8-bit input groups.
- These 24 bits are then treated as 4 concatenated 6-bit groups, each
- of which is translated into a single digit in the base64 alphabet.
-
- Each 6-bit group is used as an index into an array of 64 printable
- characters. The character referenced by the index is placed in the
- output string.
-
- Table 1: The Base64 Alphabet
-
- Value Encoding Value Encoding Value Encoding Value Encoding
- 0 A 17 R 34 i 51 z
- 1 B 18 S 35 j 52 0
- 2 C 19 T 36 k 53 1
- 3 D 20 U 37 l 54 2
- 4 E 21 V 38 m 55 3
- 5 F 22 W 39 n 56 4
- 6 G 23 X 40 o 57 5
- 7 H 24 Y 41 p 58 6
- 8 I 25 Z 42 q 59 7
- 9 J 26 a 43 r 60 8
- 10 K 27 b 44 s 61 9
- 11 L 28 c 45 t 62 +
- 12 M 29 d 46 u 63 /
- 13 N 30 e 47 v
- 14 O 31 f 48 w (pad) =
- 15 P 32 g 49 x
- 16 Q 33 h 50 y
-
- Special processing is performed if fewer than 24 bits are available
- at the end of the data being encoded. A full encoding quantum is
- always completed at the end of a quantity. When fewer than 24 input
- bits are available in an input group, zero bits are added (on the
- right) to form an integral number of 6-bit groups. Padding at the
- end of the data is performed using the '=' character.
-
- Since all base64 input is an integral number of octets, only the
- -------------------------------------------------
- following cases can arise:
-
- (1) the final quantum of encoding input is an integral
- multiple of 24 bits; here, the final unit of encoded
- output will be an integral multiple of 4 characters
- with no "=" padding,
- (2) the final quantum of encoding input is exactly 8 bits;
- here, the final unit of encoded output will be two
- characters followed by two "=" padding characters, or
- (3) the final quantum of encoding input is exactly 16 bits;
- here, the final unit of encoded output will be three
- characters followed by one "=" padding character.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-int
-hwloc_encode_to_base64(const char *src, size_t srclength, char *target, size_t targsize)
-{
- size_t datalength = 0;
- unsigned char input[3];
- unsigned char output[4];
- unsigned int i;
-
- while (2 < srclength) {
- input[0] = *src++;
- input[1] = *src++;
- input[2] = *src++;
- srclength -= 3;
-
- output[0] = input[0] >> 2;
- output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
- output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
- output[3] = input[2] & 0x3f;
-
- if (datalength + 4 > targsize)
- return (-1);
- target[datalength++] = Base64[output[0]];
- target[datalength++] = Base64[output[1]];
- target[datalength++] = Base64[output[2]];
- target[datalength++] = Base64[output[3]];
- }
-
- /* Now we worry about padding. */
- if (0 != srclength) {
- /* Get what's left. */
- input[0] = input[1] = input[2] = '\0';
- for (i = 0; i < srclength; i++)
- input[i] = *src++;
-
- output[0] = input[0] >> 2;
- output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
- output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
-
- if (datalength + 4 > targsize)
- return (-1);
- target[datalength++] = Base64[output[0]];
- target[datalength++] = Base64[output[1]];
- if (srclength == 1)
- target[datalength++] = Pad64;
- else
- target[datalength++] = Base64[output[2]];
- target[datalength++] = Pad64;
- }
- if (datalength >= targsize)
- return (-1);
- target[datalength] = '\0'; /* Returned value doesn't count \0. */
- return (int)(datalength);
-}
-
-/* skips all whitespace anywhere.
- converts characters, four at a time, starting at (or after)
- src from base - 64 numbers into three 8 bit bytes in the target area.
- it returns the number of data bytes stored at the target, or -1 on error.
- */
-
-int
-hwloc_decode_from_base64(char const *src, char *target, size_t targsize)
-{
- unsigned int tarindex, state;
- int ch;
- char *pos;
-
- state = 0;
- tarindex = 0;
-
- while ((ch = *src++) != '\0') {
- if (isspace(ch)) /* Skip whitespace anywhere. */
- continue;
-
- if (ch == Pad64)
- break;
-
- pos = strchr(Base64, ch);
- if (pos == 0) /* A non-base64 character. */
- return (-1);
-
- switch (state) {
- case 0:
- if (target) {
- if (tarindex >= targsize)
- return (-1);
- target[tarindex] = (char)(pos - Base64) << 2;
- }
- state = 1;
- break;
- case 1:
- if (target) {
- if (tarindex + 1 >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64) >> 4;
- target[tarindex+1] = ((pos - Base64) & 0x0f)
- << 4 ;
- }
- tarindex++;
- state = 2;
- break;
- case 2:
- if (target) {
- if (tarindex + 1 >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64) >> 2;
- target[tarindex+1] = ((pos - Base64) & 0x03)
- << 6;
- }
- tarindex++;
- state = 3;
- break;
- case 3:
- if (target) {
- if (tarindex >= targsize)
- return (-1);
- target[tarindex] |= (pos - Base64);
- }
- tarindex++;
- state = 0;
- break;
- }
- }
-
- /*
- * We are done decoding Base-64 chars. Let's see if we ended
- * on a byte boundary, and/or with erroneous trailing characters.
- */
-
- if (ch == Pad64) { /* We got a pad char. */
- ch = *src++; /* Skip it, get next. */
- switch (state) {
- case 0: /* Invalid = in first position */
- case 1: /* Invalid = in second position */
- return (-1);
-
- case 2: /* Valid, means one byte of info */
- /* Skip any number of spaces. */
- for (; ch != '\0'; ch = *src++)
- if (!isspace(ch))
- break;
- /* Make sure there is another trailing = sign. */
- if (ch != Pad64)
- return (-1);
- ch = *src++; /* Skip the = */
- /* Fall through to "single trailing =" case. */
- /* FALLTHROUGH */
-
- case 3: /* Valid, means two bytes of info */
- /*
- * We know this char is an =. Is there anything but
- * whitespace after it?
- */
- for (; ch != '\0'; ch = *src++)
- if (!isspace(ch))
- return (-1);
-
- /*
- * Now make sure for cases 2 and 3 that the "extra"
- * bits that slopped past the last full byte were
- * zeros. If we don't check them, they become a
- * subliminal channel.
- */
- if (target && target[tarindex] != 0)
- return (-1);
- }
- } else {
- /*
- * We ended by seeing the end of the string. Make sure we
- * have no partial bytes lying around.
- */
- if (state != 0)
- return (-1);
- }
-
- return (tarindex);
-}
### src/3rdparty/hwloc/src/bind.c
@@ -1,927 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2024 Inria. All rights reserved.
- * Copyright © 2009-2010, 2012 Université Bordeaux
- * Copyright © 2011-2015 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-#include "private/autogen/config.h"
-#include "hwloc.h"
-#include "private/private.h"
-#include "hwloc/helper.h"
-
-#ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-#endif
-/* <malloc.h> is only needed if we don't have posix_memalign() */
-#if defined(hwloc_getpagesize) && !defined(HAVE_POSIX_MEMALIGN) && defined(HAVE_MEMALIGN) && defined(HAVE_MALLOC_H)
-#include <malloc.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <errno.h>
-
-/* TODO: HWLOC_GNU_SYS,
- *
- * We could use glibc's sched_setaffinity generically when it is available
- *
- * Darwin and OpenBSD don't seem to have binding facilities.
- */
-
-#define HWLOC_CPUBIND_ALLFLAGS (HWLOC_CPUBIND_PROCESS|HWLOC_CPUBIND_THREAD|HWLOC_CPUBIND_STRICT|HWLOC_CPUBIND_NOMEMBIND)
-
-static hwloc_const_bitmap_t
-hwloc_fix_cpubind(hwloc_topology_t topology, hwloc_const_bitmap_t set)
-{
- hwloc_const_bitmap_t topology_set = hwloc_topology_get_topology_cpuset(topology);
- hwloc_const_bitmap_t complete_set = hwloc_topology_get_complete_cpuset(topology);
-
- if (hwloc_bitmap_iszero(set)) {
- errno = EINVAL;
- return NULL;
- }
-
- if (!hwloc_bitmap_isincluded(set, complete_set)) {
- errno = EINVAL;
- return NULL;
- }
-
- if (hwloc_bitmap_isincluded(topology_set, set))
- set = complete_set;
-
- return set;
-}
-
-int
-hwloc_set_cpubind(hwloc_topology_t topology, hwloc_const_bitmap_t set, int flags)
-{
- if (flags & ~HWLOC_CPUBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- set = hwloc_fix_cpubind(topology, set);
- if (!set)
- return -1;
-
- if (flags & HWLOC_CPUBIND_PROCESS) {
- if (topology->binding_hooks.set_thisproc_cpubind)
- return topology->binding_hooks.set_thisproc_cpubind(topology, set, flags);
- } else if (flags & HWLOC_CPUBIND_THREAD) {
- if (topology->binding_hooks.set_thisthread_cpubind)
- return topology->binding_hooks.set_thisthread_cpubind(topology, set, flags);
- } else {
- if (topology->binding_hooks.set_thisproc_cpubind) {
- int err = topology->binding_hooks.set_thisproc_cpubind(topology, set, flags);
- if (err >= 0 || errno != ENOSYS)
- return err;
- /* ENOSYS, fallback */
- }
- if (topology->binding_hooks.set_thisthread_cpubind)
- return topology->binding_hooks.set_thisthread_cpubind(topology, set, flags);
- }
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_get_cpubind(hwloc_topology_t topology, hwloc_bitmap_t set, int flags)
-{
- if (flags & ~HWLOC_CPUBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (flags & HWLOC_CPUBIND_PROCESS) {
- if (topology->binding_hooks.get_thisproc_cpubind)
- return topology->binding_hooks.get_thisproc_cpubind(topology, set, flags);
- } else if (flags & HWLOC_CPUBIND_THREAD) {
- if (topology->binding_hooks.get_thisthread_cpubind)
- return topology->binding_hooks.get_thisthread_cpubind(topology, set, flags);
- } else {
- if (topology->binding_hooks.get_thisproc_cpubind) {
- int err = topology->binding_hooks.get_thisproc_cpubind(topology, set, flags);
- if (err >= 0 || errno != ENOSYS)
- return err;
- /* ENOSYS, fallback */
- }
- if (topology->binding_hooks.get_thisthread_cpubind)
- return topology->binding_hooks.get_thisthread_cpubind(topology, set, flags);
- }
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_set_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_bitmap_t set, int flags)
-{
- if (flags & ~HWLOC_CPUBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- set = hwloc_fix_cpubind(topology, set);
- if (!set)
- return -1;
-
- if (topology->binding_hooks.set_proc_cpubind)
- return topology->binding_hooks.set_proc_cpubind(topology, pid, set, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_get_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, int flags)
-{
- if (flags & ~HWLOC_CPUBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (topology->binding_hooks.get_proc_cpubind)
- return topology->binding_hooks.get_proc_cpubind(topology, pid, set, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-#ifdef hwloc_thread_t
-int
-hwloc_set_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_const_bitmap_t set, int flags)
-{
- if (flags & ~HWLOC_CPUBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- set = hwloc_fix_cpubind(topology, set);
- if (!set)
- return -1;
-
- if (topology->binding_hooks.set_thread_cpubind)
- return topology->binding_hooks.set_thread_cpubind(topology, tid, set, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_get_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_bitmap_t set, int flags)
-{
- if (flags & ~HWLOC_CPUBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (topology->binding_hooks.get_thread_cpubind)
- return topology->binding_hooks.get_thread_cpubind(topology, tid, set, flags);
-
- errno = ENOSYS;
- return -1;
-}
-#endif
-
-int
-hwloc_get_last_cpu_location(hwloc_topology_t topology, hwloc_bitmap_t set, int flags)
-{
- if (flags & ~HWLOC_CPUBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (flags & HWLOC_CPUBIND_PROCESS) {
- if (topology->binding_hooks.get_thisproc_last_cpu_location)
- return topology->binding_hooks.get_thisproc_last_cpu_location(topology, set, flags);
- } else if (flags & HWLOC_CPUBIND_THREAD) {
- if (topology->binding_hooks.get_thisthread_last_cpu_location)
- return topology->binding_hooks.get_thisthread_last_cpu_location(topology, set, flags);
- } else {
- if (topology->binding_hooks.get_thisproc_last_cpu_location) {
- int err = topology->binding_hooks.get_thisproc_last_cpu_location(topology, set, flags);
- if (err >= 0 || errno != ENOSYS)
- return err;
- /* ENOSYS, fallback */
- }
- if (topology->binding_hooks.get_thisthread_last_cpu_location)
- return topology->binding_hooks.get_thisthread_last_cpu_location(topology, set, flags);
- }
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_get_proc_last_cpu_location(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, int flags)
-{
- if (flags & ~HWLOC_CPUBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (topology->binding_hooks.get_proc_last_cpu_location)
- return topology->binding_hooks.get_proc_last_cpu_location(topology, pid, set, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-#define HWLOC_MEMBIND_ALLFLAGS (HWLOC_MEMBIND_PROCESS|HWLOC_MEMBIND_THREAD|HWLOC_MEMBIND_STRICT|HWLOC_MEMBIND_MIGRATE|HWLOC_MEMBIND_NOCPUBIND|HWLOC_MEMBIND_BYNODESET)
-
-static hwloc_const_nodeset_t
-hwloc_fix_membind(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset)
-{
- hwloc_const_bitmap_t topology_nodeset = hwloc_topology_get_topology_nodeset(topology);
- hwloc_const_bitmap_t complete_nodeset = hwloc_topology_get_complete_nodeset(topology);
-
- if (hwloc_bitmap_iszero(nodeset)) {
- errno = EINVAL;
- return NULL;
- }
-
- if (!hwloc_bitmap_isincluded(nodeset, complete_nodeset)) {
- errno = EINVAL;
- return NULL;
- }
-
- if (hwloc_bitmap_isincluded(topology_nodeset, nodeset))
- return complete_nodeset;
-
- return nodeset;
-}
-
-static int
-hwloc_fix_membind_cpuset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_const_cpuset_t cpuset)
-{
- hwloc_const_bitmap_t topology_set = hwloc_topology_get_topology_cpuset(topology);
- hwloc_const_bitmap_t complete_set = hwloc_topology_get_complete_cpuset(topology);
- hwloc_const_bitmap_t complete_nodeset = hwloc_topology_get_complete_nodeset(topology);
-
- if (hwloc_bitmap_iszero(cpuset)) {
- errno = EINVAL;
- return -1;
- }
-
- if (!hwloc_bitmap_isincluded(cpuset, complete_set)) {
- errno = EINVAL;
- return -1;
- }
-
- if (hwloc_bitmap_isincluded(topology_set, cpuset)) {
- hwloc_bitmap_copy(nodeset, complete_nodeset);
- return 0;
- }
-
- hwloc_cpuset_to_nodeset(topology, cpuset, nodeset);
- return 0;
-}
-
-static __hwloc_inline int hwloc__check_membind_policy(hwloc_membind_policy_t policy)
-{
- if (policy == HWLOC_MEMBIND_DEFAULT
- || policy == HWLOC_MEMBIND_FIRSTTOUCH
- || policy == HWLOC_MEMBIND_BIND
- || policy == HWLOC_MEMBIND_INTERLEAVE
- || policy == HWLOC_MEMBIND_WEIGHTED_INTERLEAVE
- || policy == HWLOC_MEMBIND_NEXTTOUCH)
- return 0;
- return -1;
-}
-
-static int
-hwloc_set_membind_by_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- if ((flags & ~HWLOC_MEMBIND_ALLFLAGS) || hwloc__check_membind_policy(policy) < 0) {
- errno = EINVAL;
- return -1;
- }
-
- nodeset = hwloc_fix_membind(topology, nodeset);
- if (!nodeset)
- return -1;
-
- if (flags & HWLOC_MEMBIND_PROCESS) {
- if (topology->binding_hooks.set_thisproc_membind)
- return topology->binding_hooks.set_thisproc_membind(topology, nodeset, policy, flags);
- } else if (flags & HWLOC_MEMBIND_THREAD) {
- if (topology->binding_hooks.set_thisthread_membind)
- return topology->binding_hooks.set_thisthread_membind(topology, nodeset, policy, flags);
- } else {
- if (topology->binding_hooks.set_thisproc_membind) {
- int err = topology->binding_hooks.set_thisproc_membind(topology, nodeset, policy, flags);
- if (err >= 0 || errno != ENOSYS)
- return err;
- /* ENOSYS, fallback */
- }
- if (topology->binding_hooks.set_thisthread_membind)
- return topology->binding_hooks.set_thisthread_membind(topology, nodeset, policy, flags);
- }
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_set_membind(hwloc_topology_t topology, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
-{
- int ret;
-
- if (flags & HWLOC_MEMBIND_BYNODESET) {
- ret = hwloc_set_membind_by_nodeset(topology, set, policy, flags);
- } else {
- hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();
- if (hwloc_fix_membind_cpuset(topology, nodeset, set))
- ret = -1;
- else
- ret = hwloc_set_membind_by_nodeset(topology, nodeset, policy, flags);
- hwloc_bitmap_free(nodeset);
- }
- return ret;
-}
-
-static int
-hwloc_get_membind_by_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
-{
- if (flags & ~HWLOC_MEMBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (flags & HWLOC_MEMBIND_PROCESS) {
- if (topology->binding_hooks.get_thisproc_membind)
- return topology->binding_hooks.get_thisproc_membind(topology, nodeset, policy, flags);
- } else if (flags & HWLOC_MEMBIND_THREAD) {
- if (topology->binding_hooks.get_thisthread_membind)
- return topology->binding_hooks.get_thisthread_membind(topology, nodeset, policy, flags);
- } else {
- if (topology->binding_hooks.get_thisproc_membind) {
- int err = topology->binding_hooks.get_thisproc_membind(topology, nodeset, policy, flags);
- if (err >= 0 || errno != ENOSYS)
- return err;
- /* ENOSYS, fallback */
- }
- if (topology->binding_hooks.get_thisthread_membind)
- return topology->binding_hooks.get_thisthread_membind(topology, nodeset, policy, flags);
- }
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_get_membind(hwloc_topology_t topology, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags)
-{
- int ret;
-
- if (flags & HWLOC_MEMBIND_BYNODESET) {
- ret = hwloc_get_membind_by_nodeset(topology, set, policy, flags);
- } else {
- hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();
- ret = hwloc_get_membind_by_nodeset(topology, nodeset, policy, flags);
- if (!ret)
- hwloc_cpuset_from_nodeset(topology, set, nodeset);
- hwloc_bitmap_free(nodeset);
- }
-
- return ret;
-}
-
-static int
-hwloc_set_proc_membind_by_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- if ((flags & ~HWLOC_MEMBIND_ALLFLAGS) || hwloc__check_membind_policy(policy) < 0) {
- errno = EINVAL;
- return -1;
- }
-
- nodeset = hwloc_fix_membind(topology, nodeset);
- if (!nodeset)
- return -1;
-
- if (topology->binding_hooks.set_proc_membind)
- return topology->binding_hooks.set_proc_membind(topology, pid, nodeset, policy, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-
-int
-hwloc_set_proc_membind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
-{
- int ret;
-
- if (flags & HWLOC_MEMBIND_BYNODESET) {
- ret = hwloc_set_proc_membind_by_nodeset(topology, pid, set, policy, flags);
- } else {
- hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();
- if (hwloc_fix_membind_cpuset(topology, nodeset, set))
- ret = -1;
- else
- ret = hwloc_set_proc_membind_by_nodeset(topology, pid, nodeset, policy, flags);
- hwloc_bitmap_free(nodeset);
- }
-
- return ret;
-}
-
-static int
-hwloc_get_proc_membind_by_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
-{
- if (flags & ~HWLOC_MEMBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (topology->binding_hooks.get_proc_membind)
- return topology->binding_hooks.get_proc_membind(topology, pid, nodeset, policy, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_get_proc_membind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags)
-{
- int ret;
-
- if (flags & HWLOC_MEMBIND_BYNODESET) {
- ret = hwloc_get_proc_membind_by_nodeset(topology, pid, set, policy, flags);
- } else {
- hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();
- ret = hwloc_get_proc_membind_by_nodeset(topology, pid, nodeset, policy, flags);
- if (!ret)
- hwloc_cpuset_from_nodeset(topology, set, nodeset);
- hwloc_bitmap_free(nodeset);
- }
-
- return ret;
-}
-
-static int
-hwloc_set_area_membind_by_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- if ((flags & ~HWLOC_MEMBIND_ALLFLAGS) || hwloc__check_membind_policy(policy) < 0) {
- errno = EINVAL;
- return -1;
- }
-
- if (!len)
- /* nothing to do */
- return 0;
-
- nodeset = hwloc_fix_membind(topology, nodeset);
- if (!nodeset)
- return -1;
-
- if (topology->binding_hooks.set_area_membind)
- return topology->binding_hooks.set_area_membind(topology, addr, len, nodeset, policy, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_set_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
-{
- int ret;
-
- if (flags & HWLOC_MEMBIND_BYNODESET) {
- ret = hwloc_set_area_membind_by_nodeset(topology, addr, len, set, policy, flags);
- } else {
- hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();
- if (hwloc_fix_membind_cpuset(topology, nodeset, set))
- ret = -1;
- else
- ret = hwloc_set_area_membind_by_nodeset(topology, addr, len, nodeset, policy, flags);
- hwloc_bitmap_free(nodeset);
- }
-
- return ret;
-}
-
-static int
-hwloc_get_area_membind_by_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
-{
- if (flags & ~HWLOC_MEMBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (!len) {
- /* nothing to query */
- errno = EINVAL;
- return -1;
- }
-
- if (topology->binding_hooks.get_area_membind)
- return topology->binding_hooks.get_area_membind(topology, addr, len, nodeset, policy, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_get_area_membind(hwloc_topology_t topology, const void *addr, size_t len, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags)
-{
- int ret;
-
- if (flags & HWLOC_MEMBIND_BYNODESET) {
- ret = hwloc_get_area_membind_by_nodeset(topology, addr, len, set, policy, flags);
- } else {
- hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();
- ret = hwloc_get_area_membind_by_nodeset(topology, addr, len, nodeset, policy, flags);
- if (!ret)
- hwloc_cpuset_from_nodeset(topology, set, nodeset);
- hwloc_bitmap_free(nodeset);
- }
-
- return ret;
-}
-
-static int
-hwloc_get_area_memlocation_by_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, int flags)
-{
- if (flags & ~HWLOC_MEMBIND_ALLFLAGS) {
- errno = EINVAL;
- return -1;
- }
-
- if (!len)
- /* nothing to do */
- return 0;
-
- if (topology->binding_hooks.get_area_memlocation)
- return topology->binding_hooks.get_area_memlocation(topology, addr, len, nodeset, flags);
-
- errno = ENOSYS;
- return -1;
-}
-
-int
-hwloc_get_area_memlocation(hwloc_topology_t topology, const void *addr, size_t len, hwloc_cpuset_t set, int flags)
-{
- int ret;
-
- if (flags & HWLOC_MEMBIND_BYNODESET) {
- ret = hwloc_get_area_memlocation_by_nodeset(topology, addr, len, set, flags);
- } else {
- hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();
- ret = hwloc_get_area_memlocation_by_nodeset(topology, addr, len, nodeset, flags);
- if (!ret)
- hwloc_cpuset_from_nodeset(topology, set, nodeset);
- hwloc_bitmap_free(nodeset);
- }
-
- return ret;
-}
-
-void *
-hwloc_alloc_heap(hwloc_topology_t topology __hwloc_attribute_unused, size_t len)
-{
- void *p = NULL;
-#if defined(hwloc_getpagesize) && defined(HAVE_POSIX_MEMALIGN)
- errno = posix_memalign(&p, hwloc_getpagesize(), len);
- if (errno)
- p = NULL;
-#elif defined(hwloc_getpagesize) && defined(HAVE_MEMALIGN)
- p = memalign(hwloc_getpagesize(), len);
-#else
- p = malloc(len);
-#endif
- return p;
-}
-
-#ifdef MAP_ANONYMOUS
-void *
-hwloc_alloc_mmap(hwloc_topology_t topology __hwloc_attribute_unused, size_t len)
-{
- void * buffer = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- return buffer == MAP_FAILED ? NULL : buffer;
-}
-#endif
-
-int
-hwloc_free_heap(hwloc_topology_t topology __hwloc_attribute_unused, void *addr, size_t len __hwloc_attribute_unused)
-{
- free(addr);
- return 0;
-}
-
-#ifdef MAP_ANONYMOUS
-int
-hwloc_free_mmap(hwloc_topology_t topology __hwloc_attribute_unused, void *addr, size_t len)
-{
- if (!addr)
- return 0;
- return munmap(addr, len);
-}
-#endif
-
-void *
-hwloc_alloc(hwloc_topology_t topology, size_t len)
-{
- if (topology->binding_hooks.alloc)
- return topology->binding_hooks.alloc(topology, len);
- return hwloc_alloc_heap(topology, len);
-}
-
-static void *
-hwloc_alloc_membind_by_nodeset(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
-{
- void *p;
-
- if ((flags & ~HWLOC_MEMBIND_ALLFLAGS) || hwloc__check_membind_policy(policy) < 0) {
- errno = EINVAL;
- return NULL;
- }
-
- nodeset = hwloc_fix_membind(topology, nodeset);
- if (!nodeset)
- goto fallback;
- if (flags & HWLOC_MEMBIND_MIGRATE) {
- errno = EINVAL;
- goto fallback;
- }
-
- if (topology->binding_hooks.alloc_membind)
- return topology->binding_hooks.alloc_membind(topology, len, nodeset, policy, flags);
- else if (topology->binding_hooks.set_area_membind) {
- p = hwloc_alloc(topology, len);
- if (!p)
- return NULL;
- if (topology->binding_hooks.set_area_membind(topology, p, len, nodeset, policy, flags) && flags & HWLOC_MEMBIND_STRICT) {
- int error = errno;
- free(p);
- errno = error;
- return NULL;
- }
- return p;
- } else {
- errno = ENOSYS;
- }
-
-fallback:
- if (flags & HWLOC_MEMBIND_STRICT)
- /* Report error */
- return NULL;
- /* Never mind, allocate anyway */
- return hwloc_alloc(topology, len);
-}
-
-void *
-hwloc_alloc_membind(hwloc_topology_t topology, size_t len, hwloc_const_bitmap_t set, hwloc_membind_policy_t policy, int flags)
-{
- void *ret;
-
- if (flags & HWLOC_MEMBIND_BYNODESET) {
- ret = hwloc_alloc_membind_by_nodeset(topology, len, set, policy, flags);
- } else {
- hwloc_nodeset_t nodeset = hwloc_bitmap_alloc();
- if (hwloc_fix_membind_cpuset(topology, nodeset, set)) {
- if (flags & HWLOC_MEMBIND_STRICT)
- ret = NULL;
- else
- ret = hwloc_alloc(topology, len);
- } else
- ret = hwloc_alloc_membind_by_nodeset(topology, len, nodeset, policy, flags);
- hwloc_bitmap_free(nodeset);
- }
-
- return ret;
-}
-
-int
-hwloc_free(hwloc_topology_t topology, void *addr, size_t len)
-{
- if (topology->binding_hooks.free_membind)
- return topology->binding_hooks.free_membind(topology, addr, len);
- return hwloc_free_heap(topology, addr, len);
-}
-
-/*
- * Empty binding hooks always returning success
- */
-
-static int dontset_return_complete_cpuset(hwloc_topology_t topology, hwloc_cpuset_t set)
-{
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
- return 0;
-}
-
-static int dontset_thisthread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return 0;
-}
-static int dontget_thisthread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, int flags __hwloc_attribute_unused)
-{
- return dontset_return_complete_cpuset(topology, set);
-}
-static int dontset_thisproc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return 0;
-}
-static int dontget_thisproc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, int flags __hwloc_attribute_unused)
-{
- return dontset_return_complete_cpuset(topology, set);
-}
-static int dontset_proc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return 0;
-}
-static int dontget_proc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_bitmap_t cpuset, int flags __hwloc_attribute_unused)
-{
- return dontset_return_complete_cpuset(topology, cpuset);
-}
-#ifdef hwloc_thread_t
-static int dontset_thread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_thread_t tid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return 0;
-}
-static int dontget_thread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_thread_t tid __hwloc_attribute_unused, hwloc_bitmap_t cpuset, int flags __hwloc_attribute_unused)
-{
- return dontset_return_complete_cpuset(topology, cpuset);
-}
-#endif
-
-static int dontset_return_complete_nodeset(hwloc_topology_t topology, hwloc_nodeset_t set, hwloc_membind_policy_t *policy)
-{
- hwloc_bitmap_copy(set, hwloc_topology_get_complete_nodeset(topology));
- *policy = HWLOC_MEMBIND_MIXED;
- return 0;
-}
-
-static int dontset_thisproc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return 0;
-}
-static int dontget_thisproc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
-{
- return dontset_return_complete_nodeset(topology, set, policy);
-}
-
-static int dontset_thisthread_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return 0;
-}
-static int dontget_thisthread_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
-{
- return dontset_return_complete_nodeset(topology, set, policy);
-}
-
-static int dontset_proc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return 0;
-}
-static int dontget_proc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
-{
- return dontset_return_complete_nodeset(topology, set, policy);
-}
-
-static int dontset_area_membind(hwloc_topology_t topology __hwloc_attribute_unused, const void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return 0;
-}
-static int dontget_area_membind(hwloc_topology_t topology __hwloc_attribute_unused, const void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
-{
- return dontset_return_complete_nodeset(topology, set, policy);
-}
-static int dontget_area_memlocation(hwloc_topology_t topology __hwloc_attribute_unused, const void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_bitmap_t set, int flags __hwloc_attribute_unused)
-{
- hwloc_membind_policy_t policy;
- return dontset_return_complete_nodeset(topology, set, &policy);
-}
-
-static void * dontalloc_membind(hwloc_topology_t topology __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
- return malloc(size);
-}
-static int dontfree_membind(hwloc_topology_t topology __hwloc_attribute_unused, void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused)
-{
- free(addr);
- return 0;
-}
-
-static void hwloc_set_dummy_hooks(struct hwloc_binding_hooks *hooks,
- struct hwloc_topology_support *support __hwloc_attribute_unused)
-{
- hooks->set_thisproc_cpubind = dontset_thisproc_cpubind;
- hooks->get_thisproc_cpubind = dontget_thisproc_cpubind;
- hooks->set_thisthread_cpubind = dontset_thisthread_cpubind;
- hooks->get_thisthread_cpubind = dontget_thisthread_cpubind;
- hooks->set_proc_cpubind = dontset_proc_cpubind;
- hooks->get_proc_cpubind = dontget_proc_cpubind;
-#ifdef hwloc_thread_t
- hooks->set_thread_cpubind = dontset_thread_cpubind;
- hooks->get_thread_cpubind = dontget_thread_cpubind;
-#endif
- hooks->get_thisproc_last_cpu_location = dontget_thisproc_cpubind; /* cpubind instead of last_cpu_location is ok */
- hooks->get_thisthread_last_cpu_location = dontget_thisthread_cpubind; /* cpubind instead of last_cpu_location is ok */
- hooks->get_proc_last_cpu_location = dontget_proc_cpubind; /* cpubind instead of last_cpu_location is ok */
- /* TODO: get_thread_last_cpu_location */
- hooks->set_thisproc_membind = dontset_thisproc_membind;
- hooks->get_thisproc_membind = dontget_thisproc_membind;
- hooks->set_thisthread_membind = dontset_thisthread_membind;
- hooks->get_thisthread_membind = dontget_thisthread_membind;
- hooks->set_proc_membind = dontset_proc_membind;
- hooks->get_proc_membind = dontget_proc_membind;
- hooks->set_area_membind = dontset_area_membind;
- hooks->get_area_membind = dontget_area_membind;
- hooks->get_area_memlocation = dontget_area_memlocation;
- hooks->alloc_membind = dontalloc_membind;
- hooks->free_membind = dontfree_membind;
-}
-
-void
-hwloc_set_native_binding_hooks(struct hwloc_binding_hooks *hooks, struct hwloc_topology_support *support)
-{
-# ifdef HWLOC_LINUX_SYS
- hwloc_set_linuxfs_hooks(hooks, support);
-# endif /* HWLOC_LINUX_SYS */
-
-# ifdef HWLOC_BGQ_SYS
- hwloc_set_bgq_hooks(hooks, support);
-# endif /* HWLOC_BGQ_SYS */
-
-# ifdef HWLOC_AIX_SYS
- hwloc_set_aix_hooks(hooks, support);
-# endif /* HWLOC_AIX_SYS */
-
-# ifdef HWLOC_SOLARIS_SYS
- hwloc_set_solaris_hooks(hooks, support);
-# endif /* HWLOC_SOLARIS_SYS */
-
-# ifdef HWLOC_WIN_SYS
- hwloc_set_windows_hooks(hooks, support);
-# endif /* HWLOC_WIN_SYS */
-
-# ifdef HWLOC_DARWIN_SYS
- hwloc_set_darwin_hooks(hooks, support);
-# endif /* HWLOC_DARWIN_SYS */
-
-# ifdef HWLOC_FREEBSD_SYS
- hwloc_set_freebsd_hooks(hooks, support);
-# endif /* HWLOC_FREEBSD_SYS */
-
-# ifdef HWLOC_NETBSD_SYS
- hwloc_set_netbsd_hooks(hooks, support);
-# endif /* HWLOC_NETBSD_SYS */
-
-# ifdef HWLOC_HPUX_SYS
- hwloc_set_hpux_hooks(hooks, support);
-# endif /* HWLOC_HPUX_SYS */
-}
-
-/* If the represented system is actually not this system, use dummy binding hooks. */
-void
-hwloc_set_binding_hooks(struct hwloc_topology *topology)
-{
- if (topology->is_thissystem) {
- hwloc_set_native_binding_hooks(&topology->binding_hooks, &topology->support);
- /* every hook not set above will return ENOSYS */
- } else {
- /* not this system, use dummy binding hooks that do nothing (but don't return ENOSYS) */
- hwloc_set_dummy_hooks(&topology->binding_hooks, &topology->support);
-
- /* Linux has some hooks that also work in this case, but they are not strictly needed yet. */
- }
-
- /* if not is_thissystem, set_cpubind is fake
- * and get_cpubind returns the whole system cpuset,
- * so don't report that set/get_cpubind as supported
- */
- if (topology->is_thissystem) {
-#define DO(which,kind) \
- if (topology->binding_hooks.kind) \
- topology->support.which##bind->kind = 1;
- DO(cpu,set_thisproc_cpubind);
- DO(cpu,get_thisproc_cpubind);
- DO(cpu,set_proc_cpubind);
- DO(cpu,get_proc_cpubind);
- DO(cpu,set_thisthread_cpubind);
- DO(cpu,get_thisthread_cpubind);
-#ifdef hwloc_thread_t
- DO(cpu,set_thread_cpubind);
- DO(cpu,get_thread_cpubind);
-#endif
- DO(cpu,get_thisproc_last_cpu_location);
- DO(cpu,get_proc_last_cpu_location);
- DO(cpu,get_thisthread_last_cpu_location);
- DO(mem,set_thisproc_membind);
- DO(mem,get_thisproc_membind);
- DO(mem,set_thisthread_membind);
- DO(mem,get_thisthread_membind);
- DO(mem,set_proc_membind);
- DO(mem,get_proc_membind);
- DO(mem,set_area_membind);
- DO(mem,get_area_membind);
- DO(mem,get_area_memlocation);
- DO(mem,alloc_membind);
-#undef DO
- }
-}
### src/3rdparty/hwloc/src/bitmap.c
@@ -1,1760 +0,0 @@
-/*
- * Copyright © 2009 CNRS
- * Copyright © 2009-2024 Inria. All rights reserved.
- * Copyright © 2009-2011 Université Bordeaux
- * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-#include "private/autogen/config.h"
-#include "hwloc/autogen/config.h"
-#include "hwloc.h"
-#include "private/misc.h"
-#include "private/private.h"
-#include "private/debug.h"
-#include "hwloc/bitmap.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <assert.h>
-#include <errno.h>
-#include <ctype.h>
-
-/*
- * possible improvements:
- * - have a way to change the initial allocation size:
- * add hwloc_bitmap_set_foo() to changes a global here,
- * and make the hwloc core call based on the early number of PUs
- * - make HWLOC_BITMAP_PREALLOC_BITS configurable, and detectable
- * by parsing /proc/cpuinfo during configure on Linux.
- * - preallocate inside the bitmap structure (so that the whole structure is a cacheline for instance)
- * and allocate a dedicated array only later when reallocating larger
- * - add a bitmap->ulongs_empty_first which guarantees that some first ulongs are empty,
- * making tests much faster for big bitmaps since there's no need to look at first ulongs.
- * no need for ulongs_empty_first to be exactly the max number of empty ulongs,
- * clearing bits that were set earlier isn't very common.
- */
-
-/* magic number */
-#define HWLOC_BITMAP_MAGIC 0x20091007
-
-/* preallocated bits in every bitmap */
-#define HWLOC_BITMAP_PREALLOC_BITS 512
-#define HWLOC_BITMAP_PREALLOC_ULONGS (HWLOC_BITMAP_PREALLOC_BITS/HWLOC_BITS_PER_LONG)
-
-/* actual opaque type internals */
-struct hwloc_bitmap_s {
- unsigned ulongs_count; /* how many ulong bitmasks are valid, >= 1 */
- unsigned ulongs_allocated; /* how many ulong bitmasks are allocated, >= ulongs_count */
- unsigned long *ulongs;
- int infinite; /* set to 1 if all bits beyond ulongs are set */
-#ifdef HWLOC_DEBUG
- int magic;
-#endif
-};
-
-/* overzealous check in debug-mode, not as powerful as valgrind but still useful */
-#ifdef HWLOC_DEBUG
-#define HWLOC__BITMAP_CHECK(set) do { \
- assert((set)->magic == HWLOC_BITMAP_MAGIC); \
- assert((set)->ulongs_count >= 1); \
- assert((set)->ulongs_allocated >= (set)->ulongs_count); \
-} while (0)
-#else
-#define HWLOC__BITMAP_CHECK(set)
-#endif
-
-/* extract a subset from a set using an index or a cpu */
-#define HWLOC_SUBBITMAP_INDEX(cpu) ((cpu)/(HWLOC_BITS_PER_LONG))
-#define HWLOC_SUBBITMAP_CPU_ULBIT(cpu) ((cpu)%(HWLOC_BITS_PER_LONG))
-/* Read from a bitmap ulong without knowing whether x is valid.
- * Writers should make sure that x is valid and modify set->ulongs[x] directly.
- */
-#define HWLOC_SUBBITMAP_READULONG(set,x) ((x) < (set)->ulongs_count ? (set)->ulongs[x] : (set)->infinite ? HWLOC_SUBBITMAP_FULL : HWLOC_SUBBITMAP_ZERO)
-
-/* predefined subset values */
-#define HWLOC_SUBBITMAP_ZERO 0UL
-#define HWLOC_SUBBITMAP_FULL (~0UL)
-#define HWLOC_SUBBITMAP_ULBIT(bit) (1UL<<(bit))
-#define HWLOC_SUBBITMAP_CPU(cpu) HWLOC_SUBBITMAP_ULBIT(HWLOC_SUBBITMAP_CPU_ULBIT(cpu))
-#define HWLOC_SUBBITMAP_ULBIT_TO(bit) (HWLOC_SUBBITMAP_FULL>>(HWLOC_BITS_PER_LONG-1-(bit)))
-#define HWLOC_SUBBITMAP_ULBIT_FROM(bit) (HWLOC_SUBBITMAP_FULL<<(bit))
-#define HWLOC_SUBBITMAP_ULBIT_FROMTO(begin,end) (HWLOC_SUBBITMAP_ULBIT_TO(end) & HWLOC_SUBBITMAP_ULBIT_FROM(begin))
-
-struct hwloc_bitmap_s * hwloc_bitmap_alloc(void)
-{
- struct hwloc_bitmap_s * set;
-
- set = malloc(sizeof(struct hwloc_bitmap_s));
- if (!set)
- return NULL;
-
- set->ulongs_count = 1;
- set->ulongs_allocated = HWLOC_BITMAP_PREALLOC_ULONGS;
- set->ulongs = malloc(HWLOC_BITMAP_PREALLOC_ULONGS * sizeof(unsigned long));
- if (!set->ulongs) {
- free(set);
- return NULL;
- }
-
- set->ulongs[0] = HWLOC_SUBBITMAP_ZERO;
- set->infinite = 0;
-#ifdef HWLOC_DEBUG
- set->magic = HWLOC_BITMAP_MAGIC;
-#endif
- return set;
-}
-
-struct hwloc_bitmap_s * hwloc_bitmap_alloc_full(void)
-{
- struct hwloc_bitmap_s * set = hwloc_bitmap_alloc();
- if (set) {
- set->infinite = 1;
- set->ulongs[0] = HWLOC_SUBBITMAP_FULL;
- }
- return set;
-}
-
-void hwloc_bitmap_free(struct hwloc_bitmap_s * set)
-{
- if (!set)
- return;
-
- HWLOC__BITMAP_CHECK(set);
-#ifdef HWLOC_DEBUG
- set->magic = 0;
-#endif
-
- free(set->ulongs);
- free(set);
-}
-
-/* enlarge until it contains at least needed_count ulongs.
- */
-static int
-hwloc_bitmap_enlarge_by_ulongs(struct hwloc_bitmap_s * set, unsigned needed_count) __hwloc_attribute_warn_unused_result;
-static int
-hwloc_bitmap_enlarge_by_ulongs(struct hwloc_bitmap_s * set, unsigned needed_count)
-{
- unsigned tmp = 1U << hwloc_flsl((unsigned long) needed_count - 1);
- if (tmp > set->ulongs_allocated) {
- unsigned long *tmpulongs;
- tmpulongs = realloc(set->ulongs, tmp * sizeof(unsigned long));
- if (!tmpulongs)
- return -1;
- set->ulongs = tmpulongs;
- set->ulongs_allocated = tmp;
- }
- return 0;
-}
-
-/* enlarge until it contains at least needed_count ulongs,
- * and update new ulongs according to the infinite field.
- */
-static int
-hwloc_bitmap_realloc_by_ulongs(struct hwloc_bitmap_s * set, unsigned needed_count) __hwloc_attribute_warn_unused_result;
-static int
-hwloc_bitmap_realloc_by_ulongs(struct hwloc_bitmap_s * set, unsigned needed_count)
-{
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (needed_count <= set->ulongs_count)
- return 0;
-
- /* realloc larger if needed */
- if (hwloc_bitmap_enlarge_by_ulongs(set, needed_count) < 0)
- return -1;
-
- /* fill the newly allocated subset depending on the infinite flag */
- for(i=set->ulongs_count; i<needed_count; i++)
- set->ulongs[i] = set->infinite ? HWLOC_SUBBITMAP_FULL : HWLOC_SUBBITMAP_ZERO;
- set->ulongs_count = needed_count;
- return 0;
-}
-
-/* realloc until it contains at least cpu+1 bits */
-#define hwloc_bitmap_realloc_by_cpu_index(set, cpu) hwloc_bitmap_realloc_by_ulongs(set, ((cpu)/HWLOC_BITS_PER_LONG)+1)
-
-/* reset a bitmap to exactely the needed size.
- * the caller must reinitialize all ulongs and the infinite flag later.
- */
-static int
-hwloc_bitmap_reset_by_ulongs(struct hwloc_bitmap_s * set, unsigned needed_count) __hwloc_attribute_warn_unused_result;
-static int
-hwloc_bitmap_reset_by_ulongs(struct hwloc_bitmap_s * set, unsigned needed_count)
-{
- if (hwloc_bitmap_enlarge_by_ulongs(set, needed_count))
- return -1;
- set->ulongs_count = needed_count;
- return 0;
-}
-
-/* reset until it contains exactly cpu+1 bits (roundup to a ulong).
- * the caller must reinitialize all ulongs and the infinite flag later.
- */
-#define hwloc_bitmap_reset_by_cpu_index(set, cpu) hwloc_bitmap_reset_by_ulongs(set, ((cpu)/HWLOC_BITS_PER_LONG)+1)
-
-struct hwloc_bitmap_s * hwloc_bitmap_tma_dup(struct hwloc_tma *tma, const struct hwloc_bitmap_s * old)
-{
- struct hwloc_bitmap_s * new;
-
- if (!old)
- return NULL;
-
- HWLOC__BITMAP_CHECK(old);
-
- new = hwloc_tma_malloc(tma, sizeof(struct hwloc_bitmap_s));
- if (!new)
- return NULL;
-
- new->ulongs = hwloc_tma_malloc(tma, old->ulongs_allocated * sizeof(unsigned long));
- if (!new->ulongs) {
- free(new);
- return NULL;
- }
- new->ulongs_allocated = old->ulongs_allocated;
- new->ulongs_count = old->ulongs_count;
- memcpy(new->ulongs, old->ulongs, new->ulongs_count * sizeof(unsigned long));
- new->infinite = old->infinite;
-#ifdef HWLOC_DEBUG
- new->magic = HWLOC_BITMAP_MAGIC;
-#endif
- return new;
-}
-
-struct hwloc_bitmap_s * hwloc_bitmap_dup(const struct hwloc_bitmap_s * old)
-{
- return hwloc_bitmap_tma_dup(NULL, old);
-}
-
-int hwloc_bitmap_copy(struct hwloc_bitmap_s * dst, const struct hwloc_bitmap_s * src)
-{
- HWLOC__BITMAP_CHECK(dst);
- HWLOC__BITMAP_CHECK(src);
-
- if (hwloc_bitmap_reset_by_ulongs(dst, src->ulongs_count) < 0)
- return -1;
-
- memcpy(dst->ulongs, src->ulongs, src->ulongs_count * sizeof(unsigned long));
- dst->infinite = src->infinite;
- return 0;
-}
-
-/* Strings always use 32bit groups */
-#define HWLOC_PRIxSUBBITMAP "%08lx"
-#define HWLOC_BITMAP_SUBSTRING_SIZE 32
-#define HWLOC_BITMAP_SUBSTRING_FULL_VALUE 0xFFFFFFFFUL
-#define HWLOC_BITMAP_SUBSTRING_LENGTH (HWLOC_BITMAP_SUBSTRING_SIZE/4)
-#define HWLOC_BITMAP_STRING_PER_LONG (HWLOC_BITS_PER_LONG/HWLOC_BITMAP_SUBSTRING_SIZE)
-
-int hwloc_bitmap_snprintf(char * __hwloc_restrict buf, size_t buflen, const struct hwloc_bitmap_s * __hwloc_restrict set)
-{
- ssize_t size = buflen;
- char *tmp = buf;
- int res, ret = 0;
- int needcomma = 0;
- int i;
- unsigned long accum = 0;
- int accumed = 0;
-#if HWLOC_BITS_PER_LONG == HWLOC_BITMAP_SUBSTRING_SIZE
- const unsigned long accum_mask = ~0UL;
-#else /* HWLOC_BITS_PER_LONG != HWLOC_BITMAP_SUBSTRING_SIZE */
- const unsigned long accum_mask = ((1UL << HWLOC_BITMAP_SUBSTRING_SIZE) - 1) << (HWLOC_BITS_PER_LONG - HWLOC_BITMAP_SUBSTRING_SIZE);
- int merge_with_infinite_prefix = 0;
-#endif /* HWLOC_BITS_PER_LONG != HWLOC_BITMAP_SUBSTRING_SIZE */
-
- HWLOC__BITMAP_CHECK(set);
-
- /* mark the end in case we do nothing later */
- if (buflen > 0)
- tmp[0] = '\0';
-
- if (set->infinite) {
- res = hwloc_snprintf(tmp, size, "0xf...f");
- needcomma = 1;
- if (res < 0)
- return -1;
- ret += res;
- if (res >= size)
- res = size>0 ? (int)size - 1 : 0;
- tmp += res;
- size -= res;
-#if HWLOC_BITS_PER_LONG > HWLOC_BITMAP_SUBSTRING_SIZE
- merge_with_infinite_prefix = 1;
-#endif
- }
-
- i=(int) set->ulongs_count-1;
-
- if (set->infinite) {
- /* ignore starting FULL since we have 0xf...f already */
- while (i>=0 && set->ulongs[i] == HWLOC_SUBBITMAP_FULL)
- i--;
- } else {
- /* ignore starting ZERO except the last one */
- while (i>=0 && set->ulongs[i] == HWLOC_SUBBITMAP_ZERO)
- i--;
- }
-
- while (i>=0 || accumed) {
- unsigned long value;
-
- /* Refill accumulator */
- if (!accumed) {
- accum = set->ulongs[i--];
- accumed = HWLOC_BITS_PER_LONG;
- }
- value = (accum & accum_mask) >> (HWLOC_BITS_PER_LONG - HWLOC_BITMAP_SUBSTRING_SIZE);
-
-#if HWLOC_BITS_PER_LONG > HWLOC_BITMAP_SUBSTRING_SIZE
- if (merge_with_infinite_prefix && value == HWLOC_BITMAP_SUBSTRING_FULL_VALUE) {
- /* first full subbitmap merged with infinite prefix */
- res = 0;
- } else
-#endif
- if (value) {
- /* print the whole subset if not empty */
- res = hwloc_snprintf(tmp, size, needcomma ? ",0x" HWLOC_PRIxSUBBITMAP : "0x" HWLOC_PRIxSUBBITMAP, value);
- needcomma = 1;
- } else if (i == -1 && accumed == HWLOC_BITMAP_SUBSTRING_SIZE) {
- /* print a single 0 to mark the last subset */
- res = hwloc_snprintf(tmp, size, needcomma ? ",0x0" : "0x0");
- } else if (needcomma) {
- res = hwloc_snprintf(tmp, size, ",");
- } else {
- res = 0;
- }
- if (res < 0)
- return -1;
- ret += res;
-
-#if HWLOC_BITS_PER_LONG == HWLOC_BITMAP_SUBSTRING_SIZE
- accum = 0;
- accumed = 0;
-#else
- accum <<= HWLOC_BITMAP_SUBSTRING_SIZE;
- accumed -= HWLOC_BITMAP_SUBSTRING_SIZE;
- merge_with_infinite_prefix = 0;
-#endif
-
- if (res >= size)
- res = size>0 ? (int)size - 1 : 0;
-
- tmp += res;
- size -= res;
- }
-
- /* if didn't display anything, display 0x0 */
- if (!ret) {
- res = hwloc_snprintf(tmp, size, "0x0");
- if (res < 0)
- return -1;
- ret += res;
- }
-
- return ret;
-}
-
-int hwloc_bitmap_asprintf(char ** strp, const struct hwloc_bitmap_s * __hwloc_restrict set)
-{
- int len;
- char *buf;
-
- HWLOC__BITMAP_CHECK(set);
-
- len = hwloc_bitmap_snprintf(NULL, 0, set);
- buf = malloc(len+1);
- if (!buf)
- return -1;
- *strp = buf;
- return hwloc_bitmap_snprintf(buf, len+1, set);
-}
-
-int hwloc_bitmap_sscanf(struct hwloc_bitmap_s *set, const char * __hwloc_restrict string)
-{
- const char * current = string;
- unsigned long accum = 0;
- int count = 0;
- int ulongcount;
- int infinite = 0;
-
- /* count how many substrings there are */
- count++;
- while ((current = strchr(current+1, ',')) != NULL)
- count++;
-
- current = string;
- if (!strncmp("0xf...f", current, 7)) {
- current += 7;
- if (*current != ',') {
- /* special case for infinite/full bitmap */
- hwloc_bitmap_fill(set);
- return 0;
- }
- current++;
- infinite = 1;
- count--;
- }
-
- ulongcount = (count + HWLOC_BITMAP_STRING_PER_LONG - 1) / HWLOC_BITMAP_STRING_PER_LONG;
- if (hwloc_bitmap_reset_by_ulongs(set, ulongcount) < 0)
- return -1;
-
- set->infinite = 0; /* will be updated later */
-
-#if HWLOC_BITS_PER_LONG != HWLOC_BITMAP_SUBSTRING_SIZE
- if (infinite && (count % HWLOC_BITMAP_STRING_PER_LONG) != 0) {
- /* accumulate substrings of the first ulong that are hidden in the infinite prefix */
- int i;
- for(i = (count % HWLOC_BITMAP_STRING_PER_LONG); i < HWLOC_BITMAP_STRING_PER_LONG; i++)
- accum |= (HWLOC_BITMAP_SUBSTRING_FULL_VALUE << (i*HWLOC_BITMAP_SUBSTRING_SIZE));
- }
-#endif
-
- while (*current != '\0') {
- unsigned long val;
- char *next;
- val = strtoul(current, &next, 16);
-
- assert(count > 0);
- count--;
-
- accum |= (val << ((count * HWLOC_BITMAP_SUBSTRING_SIZE) % HWLOC_BITS_PER_LONG));
- if (!(count % HWLOC_BITMAP_STRING_PER_LONG)) {
- set->ulongs[count / HWLOC_BITMAP_STRING_PER_LONG] = accum;
- accum = 0;
- }
-
- if (*next != ',') {
- if (*next || count > 0)
- goto failed;
- else
- break;
- }
- current = (const char*) next+1;
- }
-
- set->infinite = infinite; /* set at the end, to avoid spurious realloc with filled new ulongs */
-
- return 0;
-
- failed:
- /* failure to parse */
- hwloc_bitmap_zero(set);
- return -1;
-}
-
-int hwloc_bitmap_list_snprintf(char * __hwloc_restrict buf, size_t buflen, const struct hwloc_bitmap_s * __hwloc_restrict set)
-{
- int prev = -1;
- ssize_t size = buflen;
- char *tmp = buf;
- int res, ret = 0;
- int needcomma = 0;
-
- HWLOC__BITMAP_CHECK(set);
-
- /* mark the end in case we do nothing later */
- if (buflen > 0)
- tmp[0] = '\0';
-
- while (1) {
- int begin, end;
-
- begin = hwloc_bitmap_next(set, prev);
- if (begin == -1)
- break;
- end = hwloc_bitmap_next_unset(set, begin);
-
- if (end == begin+1) {
- res = hwloc_snprintf(tmp, size, needcomma ? ",%d" : "%d", begin);
- } else if (end == -1) {
- res = hwloc_snprintf(tmp, size, needcomma ? ",%d-" : "%d-", begin);
- } else {
- res = hwloc_snprintf(tmp, size, needcomma ? ",%d-%d" : "%d-%d", begin, end-1);
- }
- if (res < 0)
- return -1;
- ret += res;
-
- if (res >= size)
- res = size>0 ? (int)size - 1 : 0;
-
- tmp += res;
- size -= res;
- needcomma = 1;
-
- if (end == -1)
- break;
- else
- prev = end - 1;
- }
-
- return ret;
-}
-
-int hwloc_bitmap_list_asprintf(char ** strp, const struct hwloc_bitmap_s * __hwloc_restrict set)
-{
- int len;
- char *buf;
-
- HWLOC__BITMAP_CHECK(set);
-
- len = hwloc_bitmap_list_snprintf(NULL, 0, set);
- buf = malloc(len+1);
- if (!buf)
- return -1;
- *strp = buf;
- return hwloc_bitmap_list_snprintf(buf, len+1, set);
-}
-
-int hwloc_bitmap_list_sscanf(struct hwloc_bitmap_s *set, const char * __hwloc_restrict string)
-{
- const char * current = string;
- char *next;
- long begin = -1, val;
-
- hwloc_bitmap_zero(set);
-
- while (*current != '\0') {
-
- /* ignore empty ranges */
- while (*current == ',' || *current == ' ')
- current++;
-
- val = strtoul(current, &next, 0);
- /* make sure we got at least one digit */
- if (next == current)
- goto failed;
-
- if (begin != -1) {
- /* finishing a range */
- if (hwloc_bitmap_set_range(set, begin, val) < 0)
- goto failed;
- begin = -1;
-
- } else if (*next == '-') {
- /* starting a new range */
- if (*(next+1) == '\0') {
- /* infinite range */
- if (hwloc_bitmap_set_range(set, val, -1) < 0)
- goto failed;
- break;
- } else {
- /* normal range */
- begin = val;
- }
-
- } else if (*next == ',' || *next == ' ' || *next == '\0') {
- /* single digit */
- hwloc_bitmap_set(set, val);
- }
-
- if (*next == '\0')
- break;
- current = next+1;
- }
-
- return 0;
-
- failed:
- /* failure to parse */
- hwloc_bitmap_zero(set);
- return -1;
-}
-
-int hwloc_bitmap_taskset_snprintf(char * __hwloc_restrict buf, size_t buflen, const struct hwloc_bitmap_s * __hwloc_restrict set)
-{
- ssize_t size = buflen;
- char *tmp = buf;
- int res, ret = 0;
-#if HWLOC_BITS_PER_LONG == 64
- int merge_with_infinite_prefix = 0;
-#endif
- int started = 0;
- int i;
-
- HWLOC__BITMAP_CHECK(set);
-
- /* mark the end in case we do nothing later */
- if (buflen > 0)
- tmp[0] = '\0';
-
- if (set->infinite) {
- res = hwloc_snprintf(tmp, size, "0xf...f");
- started = 1;
- if (res < 0)
- return -1;
- ret += res;
- if (res >= size)
- res = size>0 ? (int)size - 1 : 0;
- tmp += res;
- size -= res;
-#if HWLOC_BITS_PER_LONG == 64
- merge_with_infinite_prefix = 1;
-#endif
- }
-
- i=set->ulongs_count-1;
-
- if (set->infinite) {
- /* ignore starting FULL since we have 0xf...f already */
- while (i>=0 && set->ulongs[i] == HWLOC_SUBBITMAP_FULL)
- i--;
- } else {
- /* ignore starting ZERO except the last one */
- while (i>=1 && set->ulongs[i] == HWLOC_SUBBITMAP_ZERO)
- i--;
- }
-
- while (i>=0) {
- unsigned long val = set->ulongs[i--];
- if (started) {
- /* print the whole subset */
-#if HWLOC_BITS_PER_LONG == 64
- if (merge_with_infinite_prefix && (val & 0xffffffff00000000UL) == 0xffffffff00000000UL) {
- res = hwloc_snprintf(tmp, size, "%08lx", val & 0xffffffffUL);
- } else {
- res = hwloc_snprintf(tmp, size, "%016lx", val);
- }
-#else
- res = hwloc_snprintf(tmp, size, "%08lx", val);
-#endif
- } else if (val || i == -1) {
- res = hwloc_snprintf(tmp, size, "0x%lx", val);
- started = 1;
- } else {
- res = 0;
- }
- if (res < 0)
- return -1;
- ret += res;
- if (res >= size)
- res = size>0 ? (int)size - 1 : 0;
- tmp += res;
- size -= res;
-#if HWLOC_BITS_PER_LONG == 64
- merge_with_infinite_prefix = 0;
-#endif
- }
-
- /* if didn't display anything, display 0x0 */
- if (!ret) {
- res = hwloc_snprintf(tmp, size, "0x0");
- if (res < 0)
- return -1;
- ret += res;
- }
-
- return ret;
-}
-
-int hwloc_bitmap_taskset_asprintf(char ** strp, const struct hwloc_bitmap_s * __hwloc_restrict set)
-{
- int len;
- char *buf;
-
- HWLOC__BITMAP_CHECK(set);
-
- len = hwloc_bitmap_taskset_snprintf(NULL, 0, set);
- buf = malloc(len+1);
- if (!buf)
- return -1;
- *strp = buf;
- return hwloc_bitmap_taskset_snprintf(buf, len+1, set);
-}
-
-int hwloc_bitmap_taskset_sscanf(struct hwloc_bitmap_s *set, const char * __hwloc_restrict string)
-{
- const char * current = string;
- int chars;
- int count;
- int infinite = 0;
-
- if (!strncmp("0xf...f", current, 7)) {
- /* infinite bitmap */
- infinite = 1;
- current += 7;
- if (*current == '\0') {
- /* special case for infinite/full bitmap */
- hwloc_bitmap_fill(set);
- return 0;
- }
- } else {
- /* finite bitmap */
- if (!strncmp("0x", current, 2))
- current += 2;
- if (*current == '\0') {
- /* special case for empty bitmap */
- hwloc_bitmap_zero(set);
- return 0;
- }
- }
- /* we know there are other characters now */
-
- chars = (int)strlen(current);
- count = (chars * 4 + HWLOC_BITS_PER_LONG - 1) / HWLOC_BITS_PER_LONG;
-
- if (hwloc_bitmap_reset_by_ulongs(set, count) < 0)
- return -1;
- set->infinite = 0;
-
- while (*current != '\0') {
- int tmpchars;
- char ustr[17];
- unsigned long val;
- char *next;
-
- tmpchars = chars % (HWLOC_BITS_PER_LONG/4);
- if (!tmpchars)
- tmpchars = (HWLOC_BITS_PER_LONG/4);
-
- memcpy(ustr, current, tmpchars);
- ustr[tmpchars] = '\0';
- val = strtoul(ustr, &next, 16);
- if (*next != '\0')
- goto failed;
-
- set->ulongs[count-1] = val;
- if (infinite && tmpchars != HWLOC_BITS_PER_LONG/4) {
- /* infinite prefix with partial substring, fill remaining bits */
- set->ulongs[count-1] |= (~0ULL)<<(4*tmpchars);
- }
-
- current += tmpchars;
- chars -= tmpchars;
- count--;
- }
-
- set->infinite = infinite; /* set at the end, to avoid spurious realloc with filled new ulongs */
-
- return 0;
-
- failed:
- /* failure to parse */
- hwloc_bitmap_zero(set);
- return -1;
-}
-
-static void hwloc_bitmap__zero(struct hwloc_bitmap_s *set)
-{
- unsigned i;
- for(i=0; i<set->ulongs_count; i++)
- set->ulongs[i] = HWLOC_SUBBITMAP_ZERO;
- set->infinite = 0;
-}
-
-void hwloc_bitmap_zero(struct hwloc_bitmap_s * set)
-{
- HWLOC__BITMAP_CHECK(set);
-
- HWLOC_BUILD_ASSERT(HWLOC_BITMAP_PREALLOC_ULONGS >= 1);
- if (hwloc_bitmap_reset_by_ulongs(set, 1) < 0) {
- /* cannot fail since we preallocate some ulongs.
- * if we ever preallocate nothing, we'll reset to 0 ulongs.
- */
- }
- hwloc_bitmap__zero(set);
-}
-
-static void hwloc_bitmap__fill(struct hwloc_bitmap_s * set)
-{
- unsigned i;
- for(i=0; i<set->ulongs_count; i++)
- set->ulongs[i] = HWLOC_SUBBITMAP_FULL;
- set->infinite = 1;
-}
-
-void hwloc_bitmap_fill(struct hwloc_bitmap_s * set)
-{
- HWLOC__BITMAP_CHECK(set);
-
- HWLOC_BUILD_ASSERT(HWLOC_BITMAP_PREALLOC_ULONGS >= 1);
- if (hwloc_bitmap_reset_by_ulongs(set, 1) < 0) {
- /* cannot fail since we pre-allocate some ulongs.
- * if we ever pre-allocate nothing, we'll reset to 0 ulongs.
- */
- }
- hwloc_bitmap__fill(set);
-}
-
-int hwloc_bitmap_from_ulong(struct hwloc_bitmap_s *set, unsigned long mask)
-{
- HWLOC__BITMAP_CHECK(set);
-
- HWLOC_BUILD_ASSERT(HWLOC_BITMAP_PREALLOC_ULONGS >= 1);
- if (hwloc_bitmap_reset_by_ulongs(set, 1) < 0) {
- /* cannot fail since we pre-allocate some ulongs.
- * if ever pre-allocate nothing, we may have to return a failure.
- */
- }
- set->ulongs[0] = mask; /* there's always at least one ulong allocated */
- set->infinite = 0;
- return 0;
-}
-
-int hwloc_bitmap_from_ith_ulong(struct hwloc_bitmap_s *set, unsigned i, unsigned long mask)
-{
- unsigned j;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (hwloc_bitmap_reset_by_ulongs(set, i+1) < 0)
- return -1;
-
- set->ulongs[i] = mask;
- for(j=0; j<i; j++)
- set->ulongs[j] = HWLOC_SUBBITMAP_ZERO;
- set->infinite = 0;
- return 0;
-}
-
-int hwloc_bitmap_from_ulongs(struct hwloc_bitmap_s *set, unsigned nr, const unsigned long *masks)
-{
- unsigned j;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (hwloc_bitmap_reset_by_ulongs(set, nr) < 0)
- return -1;
-
- for(j=0; j<nr; j++)
- set->ulongs[j] = masks[j];
- set->infinite = 0;
- return 0;
-}
-
-unsigned long hwloc_bitmap_to_ulong(const struct hwloc_bitmap_s *set)
-{
- HWLOC__BITMAP_CHECK(set);
-
- return set->ulongs[0]; /* there's always at least one ulong allocated */
-}
-
-unsigned long hwloc_bitmap_to_ith_ulong(const struct hwloc_bitmap_s *set, unsigned i)
-{
- HWLOC__BITMAP_CHECK(set);
-
- return HWLOC_SUBBITMAP_READULONG(set, i);
-}
-
-int hwloc_bitmap_to_ulongs(const struct hwloc_bitmap_s *set, unsigned nr, unsigned long *masks)
-{
- unsigned j;
-
- HWLOC__BITMAP_CHECK(set);
-
- for(j=0; j<nr; j++)
- masks[j] = HWLOC_SUBBITMAP_READULONG(set, j);
- return 0;
-}
-
-int hwloc_bitmap_nr_ulongs(const struct hwloc_bitmap_s *set)
-{
- unsigned last;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (set->infinite)
- return -1;
-
- last = hwloc_bitmap_last(set);
- return (last + HWLOC_BITS_PER_LONG)/HWLOC_BITS_PER_LONG;
-}
-
-int hwloc_bitmap_only(struct hwloc_bitmap_s * set, unsigned cpu)
-{
- unsigned index_ = HWLOC_SUBBITMAP_INDEX(cpu);
-
- HWLOC__BITMAP_CHECK(set);
-
- if (hwloc_bitmap_reset_by_cpu_index(set, cpu) < 0)
- return -1;
-
- hwloc_bitmap__zero(set);
- set->ulongs[index_] |= HWLOC_SUBBITMAP_CPU(cpu);
- return 0;
-}
-
-int hwloc_bitmap_allbut(struct hwloc_bitmap_s * set, unsigned cpu)
-{
- unsigned index_ = HWLOC_SUBBITMAP_INDEX(cpu);
-
- HWLOC__BITMAP_CHECK(set);
-
- if (hwloc_bitmap_reset_by_cpu_index(set, cpu) < 0)
- return -1;
-
- hwloc_bitmap__fill(set);
- set->ulongs[index_] &= ~HWLOC_SUBBITMAP_CPU(cpu);
- return 0;
-}
-
-int hwloc_bitmap_set(struct hwloc_bitmap_s * set, unsigned cpu)
-{
- unsigned index_ = HWLOC_SUBBITMAP_INDEX(cpu);
-
- HWLOC__BITMAP_CHECK(set);
-
- /* nothing to do if setting inside the infinite part of the bitmap */
- if (set->infinite && cpu >= set->ulongs_count * HWLOC_BITS_PER_LONG)
- return 0;
-
- if (hwloc_bitmap_realloc_by_cpu_index(set, cpu) < 0)
- return -1;
-
- set->ulongs[index_] |= HWLOC_SUBBITMAP_CPU(cpu);
- return 0;
-}
-
-int hwloc_bitmap_set_range(struct hwloc_bitmap_s * set, unsigned begincpu, int _endcpu)
-{
- unsigned i;
- unsigned beginset,endset;
- unsigned endcpu = (unsigned) _endcpu;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (endcpu < begincpu)
- return 0;
- if (set->infinite && begincpu >= set->ulongs_count * HWLOC_BITS_PER_LONG)
- /* setting only in the already-set infinite part, nothing to do */
- return 0;
-
- if (_endcpu == -1) {
- /* infinite range */
-
- /* make sure we can play with the ulong that contains begincpu */
- if (hwloc_bitmap_realloc_by_cpu_index(set, begincpu) < 0)
- return -1;
-
- /* update the ulong that contains begincpu */
- beginset = HWLOC_SUBBITMAP_INDEX(begincpu);
- set->ulongs[beginset] |= HWLOC_SUBBITMAP_ULBIT_FROM(HWLOC_SUBBITMAP_CPU_ULBIT(begincpu));
- /* set ulongs after begincpu if any already allocated */
- for(i=beginset+1; i<set->ulongs_count; i++)
- set->ulongs[i] = HWLOC_SUBBITMAP_FULL;
- /* mark the infinity as set */
- set->infinite = 1;
- } else {
- /* finite range */
-
- /* ignore the part of the range that overlaps with the already-set infinite part */
- if (set->infinite && endcpu >= set->ulongs_count * HWLOC_BITS_PER_LONG)
- endcpu = set->ulongs_count * HWLOC_BITS_PER_LONG - 1;
- /* make sure we can play with the ulongs that contain begincpu and endcpu */
- if (hwloc_bitmap_realloc_by_cpu_index(set, endcpu) < 0)
- return -1;
-
- /* update first and last ulongs */
- beginset = HWLOC_SUBBITMAP_INDEX(begincpu);
- endset = HWLOC_SUBBITMAP_INDEX(endcpu);
- if (beginset == endset) {
- set->ulongs[beginset] |= HWLOC_SUBBITMAP_ULBIT_FROMTO(HWLOC_SUBBITMAP_CPU_ULBIT(begincpu), HWLOC_SUBBITMAP_CPU_ULBIT(endcpu));
- } else {
- set->ulongs[beginset] |= HWLOC_SUBBITMAP_ULBIT_FROM(HWLOC_SUBBITMAP_CPU_ULBIT(begincpu));
- set->ulongs[endset] |= HWLOC_SUBBITMAP_ULBIT_TO(HWLOC_SUBBITMAP_CPU_ULBIT(endcpu));
- }
- /* set ulongs in the middle of the range */
- for(i=beginset+1; i<endset; i++)
- set->ulongs[i] = HWLOC_SUBBITMAP_FULL;
- }
-
- return 0;
-}
-
-int hwloc_bitmap_set_ith_ulong(struct hwloc_bitmap_s *set, unsigned i, unsigned long mask)
-{
- HWLOC__BITMAP_CHECK(set);
-
- if (hwloc_bitmap_realloc_by_ulongs(set, i+1) < 0)
- return -1;
-
- set->ulongs[i] = mask;
- return 0;
-}
-
-int hwloc_bitmap_clr(struct hwloc_bitmap_s * set, unsigned cpu)
-{
- unsigned index_ = HWLOC_SUBBITMAP_INDEX(cpu);
-
- HWLOC__BITMAP_CHECK(set);
-
- /* nothing to do if clearing inside the infinitely-unset part of the bitmap */
- if (!set->infinite && cpu >= set->ulongs_count * HWLOC_BITS_PER_LONG)
- return 0;
-
- if (hwloc_bitmap_realloc_by_cpu_index(set, cpu) < 0)
- return -1;
-
- set->ulongs[index_] &= ~HWLOC_SUBBITMAP_CPU(cpu);
- return 0;
-}
-
-int hwloc_bitmap_clr_range(struct hwloc_bitmap_s * set, unsigned begincpu, int _endcpu)
-{
- unsigned i;
- unsigned beginset,endset;
- unsigned endcpu = (unsigned) _endcpu;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (endcpu < begincpu)
- return 0;
-
- if (!set->infinite && begincpu >= set->ulongs_count * HWLOC_BITS_PER_LONG)
- /* clearing only in the already-unset infinite part, nothing to do */
- return 0;
-
- if (_endcpu == -1) {
- /* infinite range */
-
- /* make sure we can play with the ulong that contains begincpu */
- if (hwloc_bitmap_realloc_by_cpu_index(set, begincpu) < 0)
- return -1;
-
- /* update the ulong that contains begincpu */
- beginset = HWLOC_SUBBITMAP_INDEX(begincpu);
- set->ulongs[beginset] &= ~HWLOC_SUBBITMAP_ULBIT_FROM(HWLOC_SUBBITMAP_CPU_ULBIT(begincpu));
- /* clear ulong after begincpu if any already allocated */
- for(i=beginset+1; i<set->ulongs_count; i++)
- set->ulongs[i] = HWLOC_SUBBITMAP_ZERO;
- /* mark the infinity as unset */
- set->infinite = 0;
- } else {
- /* finite range */
-
- /* ignore the part of the range that overlaps with the already-unset infinite part */
- if (!set->infinite && endcpu >= set->ulongs_count * HWLOC_BITS_PER_LONG)
- endcpu = set->ulongs_count * HWLOC_BITS_PER_LONG - 1;
- /* make sure we can play with the ulongs that contain begincpu and endcpu */
- if (hwloc_bitmap_realloc_by_cpu_index(set, endcpu) < 0)
- return -1;
-
- /* update first and last ulongs */
- beginset = HWLOC_SUBBITMAP_INDEX(begincpu);
- endset = HWLOC_SUBBITMAP_INDEX(endcpu);
- if (beginset == endset) {
- set->ulongs[beginset] &= ~HWLOC_SUBBITMAP_ULBIT_FROMTO(HWLOC_SUBBITMAP_CPU_ULBIT(begincpu), HWLOC_SUBBITMAP_CPU_ULBIT(endcpu));
- } else {
- set->ulongs[beginset] &= ~HWLOC_SUBBITMAP_ULBIT_FROM(HWLOC_SUBBITMAP_CPU_ULBIT(begincpu));
- set->ulongs[endset] &= ~HWLOC_SUBBITMAP_ULBIT_TO(HWLOC_SUBBITMAP_CPU_ULBIT(endcpu));
- }
- /* clear ulongs in the middle of the range */
- for(i=beginset+1; i<endset; i++)
- set->ulongs[i] = HWLOC_SUBBITMAP_ZERO;
- }
-
- return 0;
-}
-
-int hwloc_bitmap_isset(const struct hwloc_bitmap_s * set, unsigned cpu)
-{
- unsigned index_ = HWLOC_SUBBITMAP_INDEX(cpu);
-
- HWLOC__BITMAP_CHECK(set);
-
- return (HWLOC_SUBBITMAP_READULONG(set, index_) & HWLOC_SUBBITMAP_CPU(cpu)) != 0;
-}
-
-int hwloc_bitmap_iszero(const struct hwloc_bitmap_s *set)
-{
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (set->infinite)
- return 0;
- for(i=0; i<set->ulongs_count; i++)
- if (set->ulongs[i] != HWLOC_SUBBITMAP_ZERO)
- return 0;
- return 1;
-}
-
-int hwloc_bitmap_isfull(const struct hwloc_bitmap_s *set)
-{
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (!set->infinite)
- return 0;
- for(i=0; i<set->ulongs_count; i++)
- if (set->ulongs[i] != HWLOC_SUBBITMAP_FULL)
- return 0;
- return 1;
-}
-
-int hwloc_bitmap_isequal (const struct hwloc_bitmap_s *set1, const struct hwloc_bitmap_s *set2)
-{
- unsigned count1 = set1->ulongs_count;
- unsigned count2 = set2->ulongs_count;
- unsigned min_count = count1 < count2 ? count1 : count2;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- for(i=0; i<min_count; i++)
- if (set1->ulongs[i] != set2->ulongs[i])
- return 0;
-
- if (count1 != count2) {
- unsigned long w1 = set1->infinite ? HWLOC_SUBBITMAP_FULL : HWLOC_SUBBITMAP_ZERO;
- unsigned long w2 = set2->infinite ? HWLOC_SUBBITMAP_FULL : HWLOC_SUBBITMAP_ZERO;
- for(i=min_count; i<count1; i++) {
- if (set1->ulongs[i] != w2)
- return 0;
- }
- for(i=min_count; i<count2; i++) {
- if (set2->ulongs[i] != w1)
- return 0;
- }
- }
-
- if (set1->infinite != set2->infinite)
- return 0;
-
- return 1;
-}
-
-int hwloc_bitmap_intersects (const struct hwloc_bitmap_s *set1, const struct hwloc_bitmap_s *set2)
-{
- unsigned count1 = set1->ulongs_count;
- unsigned count2 = set2->ulongs_count;
- unsigned min_count = count1 < count2 ? count1 : count2;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- for(i=0; i<min_count; i++)
- if (set1->ulongs[i] & set2->ulongs[i])
- return 1;
-
- if (count1 != count2) {
- if (set2->infinite) {
- for(i=min_count; i<set1->ulongs_count; i++)
- if (set1->ulongs[i])
- return 1;
- }
- if (set1->infinite) {
- for(i=min_count; i<set2->ulongs_count; i++)
- if (set2->ulongs[i])
- return 1;
- }
- }
-
- if (set1->infinite && set2->infinite)
- return 1;
-
- return 0;
-}
-
-int hwloc_bitmap_isincluded (const struct hwloc_bitmap_s *sub_set, const struct hwloc_bitmap_s *super_set)
-{
- unsigned super_count = super_set->ulongs_count;
- unsigned sub_count = sub_set->ulongs_count;
- unsigned min_count = super_count < sub_count ? super_count : sub_count;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(sub_set);
- HWLOC__BITMAP_CHECK(super_set);
-
- for(i=0; i<min_count; i++)
- if (super_set->ulongs[i] != (super_set->ulongs[i] | sub_set->ulongs[i]))
- return 0;
-
- if (super_count != sub_count) {
- if (!super_set->infinite)
- for(i=min_count; i<sub_count; i++)
- if (sub_set->ulongs[i])
- return 0;
- if (sub_set->infinite)
- for(i=min_count; i<super_count; i++)
- if (super_set->ulongs[i] != HWLOC_SUBBITMAP_FULL)
- return 0;
- }
-
- if (sub_set->infinite && !super_set->infinite)
- return 0;
-
- return 1;
-}
-
-int hwloc_bitmap_or (struct hwloc_bitmap_s *res, const struct hwloc_bitmap_s *set1, const struct hwloc_bitmap_s *set2)
-{
- /* cache counts so that we can reset res even if it's also set1 or set2 */
- unsigned count1 = set1->ulongs_count;
- unsigned count2 = set2->ulongs_count;
- unsigned max_count = count1 > count2 ? count1 : count2;
- unsigned min_count = count1 + count2 - max_count;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(res);
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- if (hwloc_bitmap_reset_by_ulongs(res, max_count) < 0)
- return -1;
-
- for(i=0; i<min_count; i++)
- res->ulongs[i] = set1->ulongs[i] | set2->ulongs[i];
-
- if (count1 != count2) {
- if (min_count < count1) {
- if (set2->infinite) {
- res->ulongs_count = min_count;
- } else {
- for(i=min_count; i<max_count; i++)
- res->ulongs[i] = set1->ulongs[i];
- }
- } else {
- if (set1->infinite) {
- res->ulongs_count = min_count;
- } else {
- for(i=min_count; i<max_count; i++)
- res->ulongs[i] = set2->ulongs[i];
- }
- }
- }
-
- res->infinite = set1->infinite || set2->infinite;
- return 0;
-}
-
-int hwloc_bitmap_and (struct hwloc_bitmap_s *res, const struct hwloc_bitmap_s *set1, const struct hwloc_bitmap_s *set2)
-{
- /* cache counts so that we can reset res even if it's also set1 or set2 */
- unsigned count1 = set1->ulongs_count;
- unsigned count2 = set2->ulongs_count;
- unsigned max_count = count1 > count2 ? count1 : count2;
- unsigned min_count = count1 + count2 - max_count;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(res);
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- if (hwloc_bitmap_reset_by_ulongs(res, max_count) < 0)
- return -1;
-
- for(i=0; i<min_count; i++)
- res->ulongs[i] = set1->ulongs[i] & set2->ulongs[i];
-
- if (count1 != count2) {
- if (min_count < count1) {
- if (set2->infinite) {
- for(i=min_count; i<max_count; i++)
- res->ulongs[i] = set1->ulongs[i];
- } else {
- res->ulongs_count = min_count;
- }
- } else {
- if (set1->infinite) {
- for(i=min_count; i<max_count; i++)
- res->ulongs[i] = set2->ulongs[i];
- } else {
- res->ulongs_count = min_count;
- }
- }
- }
-
- res->infinite = set1->infinite && set2->infinite;
- return 0;
-}
-
-int hwloc_bitmap_andnot (struct hwloc_bitmap_s *res, const struct hwloc_bitmap_s *set1, const struct hwloc_bitmap_s *set2)
-{
- /* cache counts so that we can reset res even if it's also set1 or set2 */
- unsigned count1 = set1->ulongs_count;
- unsigned count2 = set2->ulongs_count;
- unsigned max_count = count1 > count2 ? count1 : count2;
- unsigned min_count = count1 + count2 - max_count;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(res);
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- if (hwloc_bitmap_reset_by_ulongs(res, max_count) < 0)
- return -1;
-
- for(i=0; i<min_count; i++)
- res->ulongs[i] = set1->ulongs[i] & ~set2->ulongs[i];
-
- if (count1 != count2) {
- if (min_count < count1) {
- if (!set2->infinite) {
- for(i=min_count; i<max_count; i++)
- res->ulongs[i] = set1->ulongs[i];
- } else {
- res->ulongs_count = min_count;
- }
- } else {
- if (set1->infinite) {
- for(i=min_count; i<max_count; i++)
- res->ulongs[i] = ~set2->ulongs[i];
- } else {
- res->ulongs_count = min_count;
- }
- }
- }
-
- res->infinite = set1->infinite && !set2->infinite;
- return 0;
-}
-
-int hwloc_bitmap_xor (struct hwloc_bitmap_s *res, const struct hwloc_bitmap_s *set1, const struct hwloc_bitmap_s *set2)
-{
- /* cache counts so that we can reset res even if it's also set1 or set2 */
- unsigned count1 = set1->ulongs_count;
- unsigned count2 = set2->ulongs_count;
- unsigned max_count = count1 > count2 ? count1 : count2;
- unsigned min_count = count1 + count2 - max_count;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(res);
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- if (hwloc_bitmap_reset_by_ulongs(res, max_count) < 0)
- return -1;
-
- for(i=0; i<min_count; i++)
- res->ulongs[i] = set1->ulongs[i] ^ set2->ulongs[i];
-
- if (count1 != count2) {
- if (min_count < count1) {
- unsigned long w2 = set2->infinite ? HWLOC_SUBBITMAP_FULL : HWLOC_SUBBITMAP_ZERO;
- for(i=min_count; i<max_count; i++)
- res->ulongs[i] = set1->ulongs[i] ^ w2;
- } else {
- unsigned long w1 = set1->infinite ? HWLOC_SUBBITMAP_FULL : HWLOC_SUBBITMAP_ZERO;
- for(i=min_count; i<max_count; i++)
- res->ulongs[i] = set2->ulongs[i] ^ w1;
- }
- }
-
- res->infinite = (!set1->infinite) != (!set2->infinite);
- return 0;
-}
-
-int hwloc_bitmap_not (struct hwloc_bitmap_s *res, const struct hwloc_bitmap_s *set)
-{
- unsigned count = set->ulongs_count;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(res);
- HWLOC__BITMAP_CHECK(set);
-
- if (hwloc_bitmap_reset_by_ulongs(res, count) < 0)
- return -1;
-
- for(i=0; i<count; i++)
- res->ulongs[i] = ~set->ulongs[i];
-
- res->infinite = !set->infinite;
- return 0;
-}
-
-int hwloc_bitmap_first(const struct hwloc_bitmap_s * set)
-{
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set);
-
- for(i=0; i<set->ulongs_count; i++) {
- /* subsets are unsigned longs, use ffsl */
- unsigned long w = set->ulongs[i];
- if (w)
- return hwloc_ffsl(w) - 1 + HWLOC_BITS_PER_LONG*i;
- }
-
- if (set->infinite)
- return set->ulongs_count * HWLOC_BITS_PER_LONG;
-
- return -1;
-}
-
-int hwloc_bitmap_first_unset(const struct hwloc_bitmap_s * set)
-{
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set);
-
- for(i=0; i<set->ulongs_count; i++) {
- /* subsets are unsigned longs, use ffsl */
- unsigned long w = ~set->ulongs[i];
- if (w)
- return hwloc_ffsl(w) - 1 + HWLOC_BITS_PER_LONG*i;
- }
-
- if (!set->infinite)
- return set->ulongs_count * HWLOC_BITS_PER_LONG;
-
- return -1;
-}
-
-int hwloc_bitmap_last(const struct hwloc_bitmap_s * set)
-{
- int i;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (set->infinite)
- return -1;
-
- for(i=(int)set->ulongs_count-1; i>=0; i--) {
- /* subsets are unsigned longs, use flsl */
- unsigned long w = set->ulongs[i];
- if (w)
- return hwloc_flsl(w) - 1 + HWLOC_BITS_PER_LONG*i;
- }
-
- return -1;
-}
-
-int hwloc_bitmap_last_unset(const struct hwloc_bitmap_s * set)
-{
- int i;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (!set->infinite)
- return -1;
-
- for(i=(int)set->ulongs_count-1; i>=0; i--) {
- /* subsets are unsigned longs, use flsl */
- unsigned long w = ~set->ulongs[i];
- if (w)
- return hwloc_flsl(w) - 1 + HWLOC_BITS_PER_LONG*i;
- }
-
- return -1;
-}
-
-int hwloc_bitmap_next(const struct hwloc_bitmap_s * set, int prev_cpu)
-{
- unsigned i = HWLOC_SUBBITMAP_INDEX(prev_cpu + 1);
-
- HWLOC__BITMAP_CHECK(set);
-
- if (i >= set->ulongs_count) {
- if (set->infinite)
- return prev_cpu + 1;
- else
- return -1;
- }
-
- for(; i<set->ulongs_count; i++) {
- /* subsets are unsigned longs, use ffsl */
- unsigned long w = set->ulongs[i];
-
- /* if the prev cpu is in the same word as the possible next one,
- we need to mask out previous cpus */
- if (prev_cpu >= 0 && HWLOC_SUBBITMAP_INDEX((unsigned) prev_cpu) == i)
- w &= ~HWLOC_SUBBITMAP_ULBIT_TO(HWLOC_SUBBITMAP_CPU_ULBIT(prev_cpu));
-
- if (w)
- return hwloc_ffsl(w) - 1 + HWLOC_BITS_PER_LONG*i;
- }
-
- if (set->infinite)
- return set->ulongs_count * HWLOC_BITS_PER_LONG;
-
- return -1;
-}
-
-int hwloc_bitmap_next_unset(const struct hwloc_bitmap_s * set, int prev_cpu)
-{
- unsigned i = HWLOC_SUBBITMAP_INDEX(prev_cpu + 1);
-
- HWLOC__BITMAP_CHECK(set);
-
- if (i >= set->ulongs_count) {
- if (!set->infinite)
- return prev_cpu + 1;
- else
- return -1;
- }
-
- for(; i<set->ulongs_count; i++) {
- /* subsets are unsigned longs, use ffsl */
- unsigned long w = ~set->ulongs[i];
-
- /* if the prev cpu is in the same word as the possible next one,
- we need to mask out previous cpus */
- if (prev_cpu >= 0 && HWLOC_SUBBITMAP_INDEX((unsigned) prev_cpu) == i)
- w &= ~HWLOC_SUBBITMAP_ULBIT_TO(HWLOC_SUBBITMAP_CPU_ULBIT(prev_cpu));
-
- if (w)
- return hwloc_ffsl(w) - 1 + HWLOC_BITS_PER_LONG*i;
- }
-
- if (!set->infinite)
- return set->ulongs_count * HWLOC_BITS_PER_LONG;
-
- return -1;
-}
-
-int hwloc_bitmap_singlify(struct hwloc_bitmap_s * set)
-{
- unsigned i;
- int found = 0;
-
- HWLOC__BITMAP_CHECK(set);
-
- for(i=0; i<set->ulongs_count; i++) {
- if (found) {
- set->ulongs[i] = HWLOC_SUBBITMAP_ZERO;
- continue;
- } else {
- /* subsets are unsigned longs, use ffsl */
- unsigned long w = set->ulongs[i];
- if (w) {
- int _ffs = hwloc_ffsl(w);
- set->ulongs[i] = HWLOC_SUBBITMAP_CPU(_ffs-1);
- found = 1;
- }
- }
- }
-
- if (set->infinite) {
- if (found) {
- set->infinite = 0;
- } else {
- /* set the first non allocated bit */
- unsigned first = set->ulongs_count * HWLOC_BITS_PER_LONG;
- set->infinite = 0; /* do not let realloc fill the newly allocated sets */
- return hwloc_bitmap_set(set, first);
- }
- }
-
- return 0;
-}
-
-int hwloc_bitmap_compare_first(const struct hwloc_bitmap_s * set1, const struct hwloc_bitmap_s * set2)
-{
- unsigned count1 = set1->ulongs_count;
- unsigned count2 = set2->ulongs_count;
- unsigned max_count = count1 > count2 ? count1 : count2;
- unsigned min_count = count1 + count2 - max_count;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- for(i=0; i<min_count; i++) {
- unsigned long w1 = set1->ulongs[i];
- unsigned long w2 = set2->ulongs[i];
- if (w1 || w2) {
- int _ffs1 = hwloc_ffsl(w1);
- int _ffs2 = hwloc_ffsl(w2);
- /* if both have a bit set, compare for real */
- if (_ffs1 && _ffs2)
- return _ffs1-_ffs2;
- /* one is empty, and it is considered higher, so reverse-compare them */
- return _ffs2-_ffs1;
- }
- }
-
- if (count1 != count2) {
- if (min_count < count2) {
- for(i=min_count; i<count2; i++) {
- unsigned long w2 = set2->ulongs[i];
- if (set1->infinite)
- return -!(w2 & 1);
- else if (w2)
- return 1;
- }
- } else {
- for(i=min_count; i<count1; i++) {
- unsigned long w1 = set1->ulongs[i];
- if (set2->infinite)
- return !(w1 & 1);
- else if (w1)
- return -1;
- }
- }
- }
-
- return !!set1->infinite - !!set2->infinite;
-}
-
-int hwloc_bitmap_compare(const struct hwloc_bitmap_s * set1, const struct hwloc_bitmap_s * set2)
-{
- unsigned count1 = set1->ulongs_count;
- unsigned count2 = set2->ulongs_count;
- unsigned max_count = count1 > count2 ? count1 : count2;
- unsigned min_count = count1 + count2 - max_count;
- int i;
-
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- if ((!set1->infinite) != (!set2->infinite))
- return !!set1->infinite - !!set2->infinite;
-
- if (count1 != count2) {
- if (min_count < count2) {
- unsigned long val1 = set1->infinite ? HWLOC_SUBBITMAP_FULL : HWLOC_SUBBITMAP_ZERO;
- for(i=(int)max_count-1; i>=(int) min_count; i--) {
- unsigned long val2 = set2->ulongs[i];
- if (val1 == val2)
- continue;
- return val1 < val2 ? -1 : 1;
- }
- } else {
- unsigned long val2 = set2->infinite ? HWLOC_SUBBITMAP_FULL : HWLOC_SUBBITMAP_ZERO;
- for(i=(int)max_count-1; i>=(int) min_count; i--) {
- unsigned long val1 = set1->ulongs[i];
- if (val1 == val2)
- continue;
- return val1 < val2 ? -1 : 1;
- }
- }
- }
-
- for(i=(int)min_count-1; i>=0; i--) {
- unsigned long val1 = set1->ulongs[i];
- unsigned long val2 = set2->ulongs[i];
- if (val1 == val2)
- continue;
- return val1 < val2 ? -1 : 1;
- }
-
- return 0;
-}
-
-int hwloc_bitmap_weight(const struct hwloc_bitmap_s * set)
-{
- int weight = 0;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set);
-
- if (set->infinite)
- return -1;
-
- for(i=0; i<set->ulongs_count; i++)
- weight += hwloc_weight_long(set->ulongs[i]);
- return weight;
-}
-
-int hwloc_bitmap_compare_inclusion(const struct hwloc_bitmap_s * set1, const struct hwloc_bitmap_s * set2)
-{
- unsigned max_count = set1->ulongs_count > set2->ulongs_count ? set1->ulongs_count : set2->ulongs_count;
- int result = HWLOC_BITMAP_EQUAL; /* means empty sets return equal */
- int empty1 = 1;
- int empty2 = 1;
- unsigned i;
-
- HWLOC__BITMAP_CHECK(set1);
- HWLOC__BITMAP_CHECK(set2);
-
- for(i=0; i<max_count; i++) {
- unsigned long val1 = HWLOC_SUBBITMAP_READULONG(set1, (unsigned) i);
- unsigned long val2 = HWLOC_SUBBITMAP_READULONG(set2, (unsigned) i);
-
- if (!val1) {
- if (!val2)
- /* both empty, no change */
- continue;
-
- /* val1 empty, val2 not */
- if (result == HWLOC_BITMAP_CONTAINS) {
- if (!empty2)
- return HWLOC_BITMAP_INTERSECTS;
- result = HWLOC_BITMAP_DIFFERENT;
- } else if (result == HWLOC_BITMAP_EQUAL) {
- result = HWLOC_BITMAP_INCLUDED;
- }
- /* no change otherwise */
-
- } else if (!val2) {
- /* val2 empty, val1 not */
- if (result == HWLOC_BITMAP_INCLUDED) {
- if (!empty1)
- return HWLOC_BITMAP_INTERSECTS;
- result = HWLOC_BITMAP_DIFFERENT;
- } else if (result == HWLOC_BITMAP_EQUAL) {
- result = HWLOC_BITMAP_CONTAINS;
- }
- /* no change otherwise */
-
- } else if (val1 == val2) {
- /* equal and not empty */
- if (result == HWLOC_BITMAP_DIFFERENT)
- return HWLOC_BITMAP_INTERSECTS;
- /* equal/contains/included unchanged */
-
- } else if ((val1 & val2) == val1) {
- /* included and not empty */
- if (result == HWLOC_BITMAP_CONTAINS || result == HWLOC_BITMAP_DIFFERENT)
- return HWLOC_BITMAP_INTERSECTS;
- /* equal/included unchanged */
- result = HWLOC_BITMAP_INCLUDED;
-
- } else if ((val1 & val2) == val2) {
- /* contains and not empty */
- if (result == HWLOC_BITMAP_INCLUDED || result == HWLOC_BITMAP_DIFFERENT)
- return HWLOC_BITMAP_INTERSECTS;
- /* equal/contains unchanged */
- result = HWLOC_BITMAP_CONTAINS;
-
- } else if ((val1 & val2) != 0) {
- /* intersects and not empty */
- return HWLOC_BITMAP_INTERSECTS;
-
- } else {
- /* different and not empty */
-
- /* equal/included/contains with non-empty sets means intersects */
- if (result == HWLOC_BITMAP_EQUAL && !empty1 /* implies !empty2 */)
- return HWLOC_BITMAP_INTERSECTS;
- if (result == HWLOC_BITMAP_INCLUDED && !empty1)
- return HWLOC_BITMAP_INTERSECTS;
- if (result == HWLOC_BITMAP_CONTAINS && !empty2)
- return HWLOC_BITMAP_INTERSECTS;
- /* otherwise means different */
- result = HWLOC_BITMAP_DIFFERENT;
- }
-
- empty1 &= !val1;
- empty2 &= !val2;
- }
-
- if (!set1->infinite) {
- if (set2->infinite) {
- /* set2 infinite only */
- if (result == HWLOC_BITMAP_CONTAINS) {
- if (!empty2)
- return HWLOC_BITMAP_INTERSECTS;
- result = HWLOC_BITMAP_DIFFERENT;
- } else if (result == HWLOC_BITMAP_EQUAL) {
- result = HWLOC_BITMAP_INCLUDED;
- }
- /* no change otherwise */
- }
- } else if (!set2->infinite) {
- /* set1 infinite only */
- if (result == HWLOC_BITMAP_INCLUDED) {
- if (!empty1)
- return HWLOC_BITMAP_INTERSECTS;
- result = HWLOC_BITMAP_DIFFERENT;
- } else if (result == HWLOC_BITMAP_EQUAL) {
- result = HWLOC_BITMAP_CONTAINS;
- }
- /* no change otherwise */
- } else {
- /* both infinite */
- if (result == HWLOC_BITMAP_DIFFERENT)
- return HWLOC_BITMAP_INTERSECTS;
- /* equal/contains/included unchanged */
- }
-
- return result;
-}
### src/3rdparty/hwloc/src/components.c
@@ -1,1090 +0,0 @@
-/*
- * Copyright © 2009-2022 Inria. All rights reserved.
- * Copyright © 2012 Université Bordeaux
- * See COPYING in top-level directory.
- */
-
-#include "private/autogen/config.h"
-#include "hwloc.h"
-#include "private/private.h"
-#include "private/xml.h"
-#include "private/misc.h"
-
-#define HWLOC_COMPONENT_STOP_NAME "stop"
-#define HWLOC_COMPONENT_EXCLUDE_CHAR '-'
-#define HWLOC_COMPONENT_SEPS ","
-#define HWLOC_COMPONENT_PHASESEP_CHAR ':'
-
-/* list of all registered discovery components, sorted by priority, higher priority first.
- * noos is last because its priority is 0.
- * others' priority is 10.
- */
-static struct hwloc_disc_component * hwloc_disc_components = NULL;
-
-static unsigned hwloc_components_users = 0; /* first one initializes, last ones destroys */
-
-static int hwloc_components_verbose = 0;
-#ifdef HWLOC_HAVE_PLUGINS
-static int hwloc_plugins_verbose = 0;
-static const char * hwloc_plugins_blacklist = NULL;
-#endif
-
-/* hwloc_components_mutex serializes:
- * - loading/unloading plugins, and modifications of the hwloc_plugins list
- * - calls to ltdl, including in hwloc_check_plugin_namespace()
- * - registration of components with hwloc_disc_component_register()
- * and hwloc_xml_callbacks_register()
- */
-#ifdef HWLOC_WIN_SYS
-/* Basic mutex on top of InterlockedCompareExchange() on windows,
- * Far from perfect, but easy to maintain, and way enough given that this code will never be needed for real. */
-#include <windows.h>
-static LONG hwloc_components_mutex = 0;
-#define HWLOC_COMPONENTS_LOCK() do { \
- while (InterlockedCompareExchange(&hwloc_components_mutex, 1, 0) != 0) \
- SwitchToThread(); \
-} while (0)
-#define HWLOC_COMPONENTS_UNLOCK() do { \
- assert(hwloc_components_mutex == 1); \
- hwloc_components_mutex = 0; \
-} while (0)
-
-#elif defined HWLOC_HAVE_PTHREAD_MUTEX
-/* pthread mutex if available (except on windows) */
-#include <pthread.h>
-static pthread_mutex_t hwloc_components_mutex = PTHREAD_MUTEX_INITIALIZER;
-#define HWLOC_COMPONENTS_LOCK() pthread_mutex_lock(&hwloc_components_mutex)
-#define HWLOC_COMPONENTS_UNLOCK() pthread_mutex_unlock(&hwloc_components_mutex)
-
-#else /* HWLOC_WIN_SYS || HWLOC_HAVE_PTHREAD_MUTEX */
-#error No mutex implementation available
-#endif
-
-
-#ifdef HWLOC_HAVE_PLUGINS
-
-#ifdef HWLOC_HAVE_LTDL
-/* ltdl-based plugin load */
-#include <ltdl.h>
-typedef lt_dlhandle hwloc_dlhandle;
-#define hwloc_dlinit lt_dlinit
-#define hwloc_dlexit lt_dlexit
-#define hwloc_dlopenext lt_dlopenext
-#define hwloc_dlclose lt_dlclose
-#define hwloc_dlerror lt_dlerror
-#define hwloc_dlsym lt_dlsym
-#define hwloc_dlforeachfile lt_dlforeachfile
-
-#else /* !HWLOC_HAVE_LTDL */
-/* no-ltdl plugin load relies on less portable libdl */
-#include <dlfcn.h>
-typedef void * hwloc_dlhandle;
-static __hwloc_inline int hwloc_dlinit(void) { return 0; }
-static __hwloc_inline int hwloc_dlexit(void) { return 0; }
-#define hwloc_dlclose dlclose
-#define hwloc_dlerror dlerror
-#define hwloc_dlsym dlsym
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <unistd.h>
-
-static hwloc_dlhandle hwloc_dlopenext(const char *_filename)
-{
- hwloc_dlhandle handle;
- char *filename = NULL;
- if (asprintf(&filename, "%s.so", _filename) < 0)
- return NULL;
- handle = dlopen(filename, RTLD_NOW|RTLD_LOCAL);
- free(filename);
- return handle;
-}
-
-static int
-hwloc_dlforeachfile(const char *_paths,
- int (*func)(const char *filename, void *data),
- void *data)
-{
- char *paths = NULL, *path;
-
- paths = strdup(_paths);
- if (!paths)
- return -1;
-
- path = paths;
- while (*path) {
- char *colon;
- DIR *dir;
- struct dirent *dirent;
-
- colon = strchr(path, ':');
- if (colon)
- *colon = '\0';
-
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Looking under %s\n", path);
-
- dir = opendir(path);
- if (!dir)
- goto next;
-
- while ((dirent = readdir(dir)) != NULL) {
- char *abs_name, *suffix;
- struct stat stbuf;
- int err;
-
- err = asprintf(&abs_name, "%s/%s", path, dirent->d_name);
- if (err < 0)
- continue;
-
- err = stat(abs_name, &stbuf);
- if (err < 0) {
- free(abs_name);
- continue;
- }
- if (!S_ISREG(stbuf.st_mode)) {
- free(abs_name);
- continue;
- }
-
- /* Only keep .so files, and remove that suffix to get the component basename */
- suffix = strrchr(abs_name, '.');
- if (!suffix || strcmp(suffix, ".so")) {
- free(abs_name);
- continue;
- }
- *suffix = '\0';
-
- err = func(abs_name, data);
- if (err) {
- free(abs_name);
- continue;
- }
-
- free(abs_name);
- }
-
- closedir(dir);
-
- next:
- if (!colon)
- break;
- path = colon+1;
- }
-
- free(paths);
- return 0;
-}
-#endif /* !HWLOC_HAVE_LTDL */
-
-/* array of pointers to dynamically loaded plugins */
-static struct hwloc__plugin_desc {
- char *name;
- struct hwloc_component *component;
- char *filename;
- hwloc_dlhandle handle;
- struct hwloc__plugin_desc *next;
-} *hwloc_plugins = NULL;
-
-static int
-hwloc__dlforeach_cb(const char *filename, void *_data __hwloc_attribute_unused)
-{
- const char *basename;
- hwloc_dlhandle handle;
- struct hwloc_component *component;
- struct hwloc__plugin_desc *desc, **prevdesc;
- char *componentsymbolname;
-
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin dlforeach found `%s'\n", filename);
-
- basename = strrchr(filename, '/');
- if (!basename)
- basename = filename;
- else
- basename++;
-
- if (hwloc_plugins_blacklist && strstr(hwloc_plugins_blacklist, basename)) {
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin `%s' is blacklisted in the environment\n", basename);
- goto out;
- }
-
- /* dlopen and get the component structure */
- handle = hwloc_dlopenext(filename);
- if (!handle) {
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Failed to load plugin: %s\n", hwloc_dlerror());
- goto out;
- }
-
- componentsymbolname = malloc(strlen(basename)+10+1);
- if (!componentsymbolname) {
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Failed to allocation component `%s' symbol\n",
- basename);
- goto out_with_handle;
- }
- sprintf(componentsymbolname, "%s_component", basename);
- component = hwloc_dlsym(handle, componentsymbolname);
- if (!component) {
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Failed to find component symbol `%s'\n",
- componentsymbolname);
- free(componentsymbolname);
- goto out_with_handle;
- }
- if (component->abi != HWLOC_COMPONENT_ABI) {
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin symbol ABI %u instead of %d\n",
- component->abi, HWLOC_COMPONENT_ABI);
- free(componentsymbolname);
- goto out_with_handle;
- }
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin contains expected symbol `%s'\n",
- componentsymbolname);
- free(componentsymbolname);
-
- if (HWLOC_COMPONENT_TYPE_DISC == component->type) {
- if (strncmp(basename, "hwloc_", 6)) {
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin name `%s' doesn't match its type DISCOVERY\n", basename);
- goto out_with_handle;
- }
- } else if (HWLOC_COMPONENT_TYPE_XML == component->type) {
- if (strncmp(basename, "hwloc_xml_", 10)) {
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin name `%s' doesn't match its type XML\n", basename);
- goto out_with_handle;
- }
- } else {
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin name `%s' has invalid type %u\n",
- basename, (unsigned) component->type);
- goto out_with_handle;
- }
-
- /* allocate a plugin_desc and queue it */
- desc = malloc(sizeof(*desc));
- if (!desc)
- goto out_with_handle;
- desc->name = strdup(basename);
- desc->filename = strdup(filename);
- desc->component = component;
- desc->handle = handle;
- desc->next = NULL;
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin descriptor `%s' ready\n", basename);
-
- /* append to the list */
- prevdesc = &hwloc_plugins;
- while (*prevdesc)
- prevdesc = &((*prevdesc)->next);
- *prevdesc = desc;
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Plugin descriptor `%s' queued\n", basename);
- return 0;
-
- out_with_handle:
- hwloc_dlclose(handle);
- out:
- return 0;
-}
-
-static void
-hwloc_plugins_exit(void)
-{
- struct hwloc__plugin_desc *desc, *next;
-
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Closing all plugins\n");
-
- desc = hwloc_plugins;
- while (desc) {
- next = desc->next;
- hwloc_dlclose(desc->handle);
- free(desc->name);
- free(desc->filename);
- free(desc);
- desc = next;
- }
- hwloc_plugins = NULL;
-
- hwloc_dlexit();
-}
-
-static int
-hwloc_plugins_init(void)
-{
- const char *verboseenv;
- const char *path = HWLOC_PLUGINS_PATH;
- const char *env;
- int err;
-
- verboseenv = getenv("HWLOC_PLUGINS_VERBOSE");
- hwloc_plugins_verbose = verboseenv ? atoi(verboseenv) : 0;
-
- hwloc_plugins_blacklist = getenv("HWLOC_PLUGINS_BLACKLIST");
-
- err = hwloc_dlinit();
- if (err)
- goto out;
-
- env = getenv("HWLOC_PLUGINS_PATH");
- if (env)
- path = env;
-
- hwloc_plugins = NULL;
-
- if (hwloc_plugins_verbose)
- fprintf(stderr, "hwloc: Starting plugin dlforeach in %s\n", path);
- err = hwloc_dlforeachfile(path, hwloc__dlforeach_cb, NULL);
- if (err)
- goto out_with_init;
-
- return 0;
-
- out_with_init:
- hwloc_plugins_exit();
- out:
- return -1;
-}
-
-#endif /* HWLOC_HAVE_PLUGINS */
-
-static int
-hwloc_disc_component_register(struct hwloc_disc_component *component,
- const char *filename)
-{
- struct hwloc_disc_component **prev;
-
- /* check that the component name is valid */
- if (!strcmp(component->name, HWLOC_COMPONENT_STOP_NAME)) {
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Cannot register discovery component with reserved name `" HWLOC_COMPONENT_STOP_NAME "'\n");
- return -1;
- }
- if (strchr(component->name, HWLOC_COMPONENT_EXCLUDE_CHAR)
- || strchr(component->name, HWLOC_COMPONENT_PHASESEP_CHAR)
- || strcspn(component->name, HWLOC_COMPONENT_SEPS) != strlen(component->name)) {
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Cannot register discovery component with name `%s' containing reserved characters `%c" HWLOC_COMPONENT_SEPS "'\n",
- component->name, HWLOC_COMPONENT_EXCLUDE_CHAR);
- return -1;
- }
-
- /* check that the component phases are valid */
- if (!component->phases
- || (component->phases != HWLOC_DISC_PHASE_GLOBAL
- && component->phases & ~(HWLOC_DISC_PHASE_CPU
- |HWLOC_DISC_PHASE_MEMORY
- |HWLOC_DISC_PHASE_PCI
- |HWLOC_DISC_PHASE_IO
- |HWLOC_DISC_PHASE_MISC
- |HWLOC_DISC_PHASE_ANNOTATE
- |HWLOC_DISC_PHASE_TWEAK))) {
- if (HWLOC_SHOW_CRITICAL_ERRORS())
- fprintf(stderr, "hwloc: Cannot register discovery component `%s' with invalid phases 0x%x\n",
- component->name, component->phases);
- return -1;
- }
-
- prev = &hwloc_disc_components;
- while (NULL != *prev) {
- if (!strcmp((*prev)->name, component->name)) {
- /* if two components have the same name, only keep the highest priority one */
- if ((*prev)->priority < component->priority) {
- /* drop the existing component */
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Dropping previously registered discovery component `%s', priority %u lower than new one %u\n",
- (*prev)->name, (*prev)->priority, component->priority);
- *prev = (*prev)->next;
- } else {
- /* drop the new one */
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Ignoring new discovery component `%s', priority %u lower than previously registered one %u\n",
- component->name, component->priority, (*prev)->priority);
- return -1;
- }
- }
- prev = &((*prev)->next);
- }
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Registered discovery component `%s' phases 0x%x with priority %u (%s%s)\n",
- component->name, component->phases, component->priority,
- filename ? "from plugin " : "statically build", filename ? filename : "");
-
- prev = &hwloc_disc_components;
- while (NULL != *prev) {
- if ((*prev)->priority < component->priority)
- break;
- prev = &((*prev)->next);
- }
- component->next = *prev;
- *prev = component;
- return 0;
-}
-
-#include "static-components.h"
-
-static void (**hwloc_component_finalize_cbs)(unsigned long);
-static unsigned hwloc_component_finalize_cb_count;
-
-void
-hwloc_components_init(void)
-{
-#ifdef HWLOC_HAVE_PLUGINS
- struct hwloc__plugin_desc *desc;
-#endif
- const char *verboseenv;
- unsigned i;
-
- HWLOC_COMPONENTS_LOCK();
- assert((unsigned) -1 != hwloc_components_users);
- if (0 != hwloc_components_users++) {
- HWLOC_COMPONENTS_UNLOCK();
- return;
- }
-
- verboseenv = getenv("HWLOC_COMPONENTS_VERBOSE");
- hwloc_components_verbose = verboseenv ? atoi(verboseenv) : 0;
-
-#ifdef HWLOC_HAVE_PLUGINS
- hwloc_plugins_init();
-#endif
-
- hwloc_component_finalize_cbs = NULL;
- hwloc_component_finalize_cb_count = 0;
- /* count the max number of finalize callbacks */
- for(i=0; NULL != hwloc_static_components[i]; i++)
- hwloc_component_finalize_cb_count++;
-#ifdef HWLOC_HAVE_PLUGINS
- for(desc = hwloc_plugins; NULL != desc; desc = desc->next)
- hwloc_component_finalize_cb_count++;
-#endif
- if (hwloc_component_finalize_cb_count) {
- hwloc_component_finalize_cbs = calloc(hwloc_component_finalize_cb_count,
- sizeof(*hwloc_component_finalize_cbs));
- assert(hwloc_component_finalize_cbs);
- /* forget that max number and recompute the real one below */
- hwloc_component_finalize_cb_count = 0;
- }
-
- /* hwloc_static_components is created by configure in static-components.h */
- for(i=0; NULL != hwloc_static_components[i]; i++) {
- if (hwloc_static_components[i]->flags) {
- if (HWLOC_SHOW_CRITICAL_ERRORS())
- fprintf(stderr, "hwloc: Ignoring static component with invalid flags %lx\n",
- hwloc_static_components[i]->flags);
- continue;
- }
-
- /* initialize the component */
- if (hwloc_static_components[i]->init && hwloc_static_components[i]->init(0) < 0) {
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Ignoring static component, failed to initialize\n");
- continue;
- }
- /* queue ->finalize() callback if any */
- if (hwloc_static_components[i]->finalize)
- hwloc_component_finalize_cbs[hwloc_component_finalize_cb_count++] = hwloc_static_components[i]->finalize;
-
- /* register for real now */
- if (HWLOC_COMPONENT_TYPE_DISC == hwloc_static_components[i]->type)
- hwloc_disc_component_register(hwloc_static_components[i]->data, NULL);
- else if (HWLOC_COMPONENT_TYPE_XML == hwloc_static_components[i]->type)
- hwloc_xml_callbacks_register(hwloc_static_components[i]->data);
- else
- assert(0);
- }
-
- /* dynamic plugins */
-#ifdef HWLOC_HAVE_PLUGINS
- for(desc = hwloc_plugins; NULL != desc; desc = desc->next) {
- if (desc->component->flags) {
- if (HWLOC_SHOW_CRITICAL_ERRORS())
- fprintf(stderr, "hwloc: Ignoring plugin `%s' component with invalid flags %lx\n",
- desc->name, desc->component->flags);
- continue;
- }
-
- /* initialize the component */
- if (desc->component->init && desc->component->init(0) < 0) {
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Ignoring plugin `%s', failed to initialize\n", desc->name);
- continue;
- }
- /* queue ->finalize() callback if any */
- if (desc->component->finalize)
- hwloc_component_finalize_cbs[hwloc_component_finalize_cb_count++] = desc->component->finalize;
-
- /* register for real now */
- if (HWLOC_COMPONENT_TYPE_DISC == desc->component->type)
- hwloc_disc_component_register(desc->component->data, desc->filename);
- else if (HWLOC_COMPONENT_TYPE_XML == desc->component->type)
- hwloc_xml_callbacks_register(desc->component->data);
- else
- assert(0);
- }
-#endif
-
- HWLOC_COMPONENTS_UNLOCK();
-}
-
-void
-hwloc_topology_components_init(struct hwloc_topology *topology)
-{
- topology->nr_blacklisted_components = 0;
- topology->blacklisted_components = NULL;
-
- topology->backends = NULL;
- topology->backend_phases = 0;
- topology->backend_excluded_phases = 0;
-}
-
-/* look for name among components, ignoring things after `:' */
-static struct hwloc_disc_component *
-hwloc_disc_component_find(const char *name, const char **endp)
-{
- struct hwloc_disc_component *comp;
- size_t length;
- const char *end = strchr(name, HWLOC_COMPONENT_PHASESEP_CHAR);
- if (end) {
- length = end-name;
- if (endp)
- *endp = end+1;
- } else {
- length = strlen(name);
- if (endp)
- *endp = NULL;
- }
-
- comp = hwloc_disc_components;
- while (NULL != comp) {
- if (!strncmp(name, comp->name, length))
- return comp;
- comp = comp->next;
- }
- return NULL;
-}
-
-static unsigned
-hwloc_phases_from_string(const char *s)
-{
- if (!s)
- return ~0U;
- if (s[0]<'0' || s[0]>'9') {
- if (!strcasecmp(s, "global"))
- return HWLOC_DISC_PHASE_GLOBAL;
- else if (!strcasecmp(s, "cpu"))
- return HWLOC_DISC_PHASE_CPU;
- if (!strcasecmp(s, "memory"))
- return HWLOC_DISC_PHASE_MEMORY;
- if (!strcasecmp(s, "pci"))
- return HWLOC_DISC_PHASE_PCI;
- if (!strcasecmp(s, "io"))
- return HWLOC_DISC_PHASE_IO;
- if (!strcasecmp(s, "misc"))
- return HWLOC_DISC_PHASE_MISC;
- if (!strcasecmp(s, "annotate"))
- return HWLOC_DISC_PHASE_ANNOTATE;
- if (!strcasecmp(s, "tweak"))
- return HWLOC_DISC_PHASE_TWEAK;
- return 0;
- }
- return (unsigned) strtoul(s, NULL, 0);
-}
-
-static int
-hwloc_disc_component_blacklist_one(struct hwloc_topology *topology,
- const char *name)
-{
- struct hwloc_topology_forced_component_s *blacklisted;
- struct hwloc_disc_component *comp;
- unsigned phases;
- unsigned i;
-
- if (!strcmp(name, "linuxpci") || !strcmp(name, "linuxio")) {
- /* replace linuxpci and linuxio with linux (with IO phases)
- * for backward compatibility with pre-v2.0 and v2.0 respectively */
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Replacing deprecated component `%s' with `linux' IO phases in blacklisting\n", name);
- comp = hwloc_disc_component_find("linux", NULL);
- phases = HWLOC_DISC_PHASE_PCI | HWLOC_DISC_PHASE_IO | HWLOC_DISC_PHASE_MISC | HWLOC_DISC_PHASE_ANNOTATE;
-
- } else {
- /* normal lookup */
- const char *end;
- comp = hwloc_disc_component_find(name, &end);
- phases = hwloc_phases_from_string(end);
- }
- if (!comp) {
- errno = EINVAL;
- return -1;
- }
-
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Blacklisting component `%s` phases 0x%x\n", comp->name, phases);
-
- for(i=0; i<topology->nr_blacklisted_components; i++) {
- if (topology->blacklisted_components[i].component == comp) {
- topology->blacklisted_components[i].phases |= phases;
- return 0;
- }
- }
-
- blacklisted = realloc(topology->blacklisted_components, (topology->nr_blacklisted_components+1)*sizeof(*blacklisted));
- if (!blacklisted)
- return -1;
-
- blacklisted[topology->nr_blacklisted_components].component = comp;
- blacklisted[topology->nr_blacklisted_components].phases = phases;
- topology->blacklisted_components = blacklisted;
- topology->nr_blacklisted_components++;
- return 0;
-}
-
-int
-hwloc_topology_set_components(struct hwloc_topology *topology,
- unsigned long flags,
- const char *name)
-{
- if (topology->is_loaded) {
- errno = EBUSY;
- return -1;
- }
-
- if (flags & ~HWLOC_TOPOLOGY_COMPONENTS_FLAG_BLACKLIST) {
- errno = EINVAL;
- return -1;
- }
-
- /* this flag is strictly required for now */
- if (flags != HWLOC_TOPOLOGY_COMPONENTS_FLAG_BLACKLIST) {
- errno = EINVAL;
- return -1;
- }
-
- if (!strncmp(name, "all", 3) && name[3] == HWLOC_COMPONENT_PHASESEP_CHAR) {
- topology->backend_excluded_phases = hwloc_phases_from_string(name+4);
- return 0;
- }
-
- return hwloc_disc_component_blacklist_one(topology, name);
-}
-
-/* used by set_xml(), set_synthetic(), ... environment variables, ... to force the first backend */
-int
-hwloc_disc_component_force_enable(struct hwloc_topology *topology,
- int envvar_forced,
- const char *name,
- const void *data1, const void *data2, const void *data3)
-{
- struct hwloc_disc_component *comp;
- struct hwloc_backend *backend;
-
- if (topology->is_loaded) {
- errno = EBUSY;
- return -1;
- }
-
- comp = hwloc_disc_component_find(name, NULL);
- if (!comp) {
- errno = ENOSYS;
- return -1;
- }
-
- backend = comp->instantiate(topology, comp, 0U /* force-enabled don't get any phase blacklisting */,
- data1, data2, data3);
- if (backend) {
- int err;
- backend->envvar_forced = envvar_forced;
- if (topology->backends)
- hwloc_backends_disable_all(topology);
- err = hwloc_backend_enable(backend);
-
- if (comp->phases == HWLOC_DISC_PHASE_GLOBAL) {
- char *env = getenv("HWLOC_ANNOTATE_GLOBAL_COMPONENTS");
- if (env && atoi(env))
- topology->backend_excluded_phases &= ~HWLOC_DISC_PHASE_ANNOTATE;
- }
-
- return err;
- } else
- return -1;
-}
-
-static int
-hwloc_disc_component_try_enable(struct hwloc_topology *topology,
- struct hwloc_disc_component *comp,
- int envvar_forced,
- unsigned blacklisted_phases)
-{
- struct hwloc_backend *backend;
-
- if (!(comp->phases & ~(topology->backend_excluded_phases | blacklisted_phases))) {
- /* all this backend phases are already excluded, exclude the backend entirely */
- if (hwloc_components_verbose)
- /* do not warn if envvar_forced since system-wide HWLOC_COMPONENTS must be silently ignored after set_xml() etc.
- */
- fprintf(stderr, "hwloc: Excluding discovery component `%s' phases 0x%x, conflicts with excludes 0x%x\n",
- comp->name, comp->phases, topology->backend_excluded_phases);
- return -1;
- }
-
- backend = comp->instantiate(topology, comp, topology->backend_excluded_phases | blacklisted_phases,
- NULL, NULL, NULL);
- if (!backend) {
- if (hwloc_components_verbose || (envvar_forced && HWLOC_SHOW_CRITICAL_ERRORS()))
- fprintf(stderr, "hwloc: Failed to instantiate discovery component `%s'\n", comp->name);
- return -1;
- }
-
- backend->phases &= ~blacklisted_phases;
- backend->envvar_forced = envvar_forced;
- return hwloc_backend_enable(backend);
-}
-
-void
-hwloc_disc_components_enable_others(struct hwloc_topology *topology)
-{
- struct hwloc_disc_component *comp;
- struct hwloc_backend *backend;
- int tryall = 1;
- const char *_env;
- char *env; /* we'll to modify the env value, so duplicate it */
- unsigned i;
-
- _env = getenv("HWLOC_COMPONENTS");
- env = _env ? strdup(_env) : NULL;
-
- /* blacklist disabled components */
- if (env) {
- char *curenv = env;
- size_t s;
-
- while (*curenv) {
- s = strcspn(curenv, HWLOC_COMPONENT_SEPS);
- if (s) {
- char c;
-
- if (curenv[0] != HWLOC_COMPONENT_EXCLUDE_CHAR)
- goto nextname;
-
- /* save the last char and replace with \0 */
- c = curenv[s];
- curenv[s] = '\0';
-
- /* blacklist it, and just ignore failures to allocate */
- hwloc_disc_component_blacklist_one(topology, curenv+1);
-
- /* remove that blacklisted name from the string */
- for(i=0; i<s; i++)
- curenv[i] = *HWLOC_COMPONENT_SEPS;
-
- /* restore chars (the second loop below needs env to be unmodified) */
- curenv[s] = c;
- }
-
- nextname:
- curenv += s;
- if (*curenv)
- /* Skip comma */
- curenv++;
- }
- }
-
- /* enable explicitly listed components */
- if (env) {
- char *curenv = env;
- size_t s;
-
- while (*curenv) {
- s = strcspn(curenv, HWLOC_COMPONENT_SEPS);
- if (s) {
- char c;
- const char *name;
-
- if (!strncmp(curenv, HWLOC_COMPONENT_STOP_NAME, s)) {
- tryall = 0;
- break;
- }
-
- /* save the last char and replace with \0 */
- c = curenv[s];
- curenv[s] = '\0';
-
- name = curenv;
- if (!strcmp(name, "linuxpci") || !strcmp(name, "linuxio")) {
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Replacing deprecated component `%s' with `linux' in envvar forcing\n", name);
- name = "linux";
- }
-
- comp = hwloc_disc_component_find(name, NULL /* we enable the entire component, phases must be blacklisted separately */);
- if (comp) {
- unsigned blacklisted_phases = 0U;
- for(i=0; i<topology->nr_blacklisted_components; i++)
- if (comp == topology->blacklisted_components[i].component) {
- blacklisted_phases = topology->blacklisted_components[i].phases;
- break;
- }
- if (comp->phases & ~blacklisted_phases)
- hwloc_disc_component_try_enable(topology, comp, 1 /* envvar forced */, blacklisted_phases);
- } else {
- if (HWLOC_SHOW_CRITICAL_ERRORS())
- fprintf(stderr, "hwloc: Cannot find discovery component `%s'\n", name);
- }
-
- /* restore chars (the second loop below needs env to be unmodified) */
- curenv[s] = c;
- }
-
- curenv += s;
- if (*curenv)
- /* Skip comma */
- curenv++;
- }
- }
-
- /* env is still the same, the above loop didn't modify it */
-
- /* now enable remaining components (except the explicitly '-'-listed ones) */
- if (tryall) {
- comp = hwloc_disc_components;
- while (NULL != comp) {
- unsigned blacklisted_phases = 0U;
- if (!comp->enabled_by_default)
- goto nextcomp;
- /* check if this component was blacklisted by the application */
- for(i=0; i<topology->nr_blacklisted_components; i++)
- if (comp == topology->blacklisted_components[i].component) {
- blacklisted_phases = topology->blacklisted_components[i].phases;
- break;
- }
-
- if (!(comp->phases & ~blacklisted_phases)) {
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Excluding blacklisted discovery component `%s' phases 0x%x\n",
- comp->name, comp->phases);
- goto nextcomp;
- }
-
- hwloc_disc_component_try_enable(topology, comp, 0 /* defaults, not envvar forced */, blacklisted_phases);
-nextcomp:
- comp = comp->next;
- }
- }
-
- if (hwloc_components_verbose) {
- /* print a summary */
- int first = 1;
- backend = topology->backends;
- fprintf(stderr, "hwloc: Final list of enabled discovery components: ");
- while (backend != NULL) {
- fprintf(stderr, "%s%s(0x%x)", first ? "" : ",", backend->component->name, backend->phases);
- backend = backend->next;
- first = 0;
- }
- fprintf(stderr, "\n");
- }
-
- free(env);
-}
-
-void
-hwloc_components_fini(void)
-{
- unsigned i;
-
- HWLOC_COMPONENTS_LOCK();
- assert(0 != hwloc_components_users);
- if (0 != --hwloc_components_users) {
- HWLOC_COMPONENTS_UNLOCK();
- return;
- }
-
- for(i=0; i<hwloc_component_finalize_cb_count; i++)
- hwloc_component_finalize_cbs[hwloc_component_finalize_cb_count-i-1](0);
- free(hwloc_component_finalize_cbs);
- hwloc_component_finalize_cbs = NULL;
- hwloc_component_finalize_cb_count = 0;
-
- /* no need to unlink/free the list of components, they'll be unloaded below */
-
- hwloc_disc_components = NULL;
- hwloc_xml_callbacks_reset();
-
-#ifdef HWLOC_HAVE_PLUGINS
- hwloc_plugins_exit();
-#endif
-
- HWLOC_COMPONENTS_UNLOCK();
-}
-
-struct hwloc_backend *
-hwloc_backend_alloc(struct hwloc_topology *topology,
- struct hwloc_disc_component *component)
-{
- struct hwloc_backend * backend = malloc(sizeof(*backend));
- if (!backend) {
- errno = ENOMEM;
- return NULL;
- }
- backend->component = component;
- backend->topology = topology;
- /* filter-out component phases that are excluded */
- backend->phases = component->phases & ~topology->backend_excluded_phases;
- if (backend->phases != component->phases && hwloc_components_verbose)
- fprintf(stderr, "hwloc: Trying discovery component `%s' with phases 0x%x instead of 0x%x\n",
- component->name, backend->phases, component->phases);
- backend->flags = 0;
- backend->discover = NULL;
- backend->get_pci_busid_cpuset = NULL;
- backend->disable = NULL;
- backend->is_thissystem = -1;
- backend->next = NULL;
- backend->envvar_forced = 0;
- return backend;
-}
-
-static void
-hwloc_backend_disable(struct hwloc_backend *backend)
-{
- if (backend->disable)
- backend->disable(backend);
- free(backend);
-}
-
-int
-hwloc_backend_enable(struct hwloc_backend *backend)
-{
- struct hwloc_topology *topology = backend->topology;
- struct hwloc_backend **pprev;
-
- /* check backend flags */
- if (backend->flags) {
- if (HWLOC_SHOW_CRITICAL_ERRORS())
- fprintf(stderr, "hwloc: Cannot enable discovery component `%s' phases 0x%x with unknown flags %lx\n",
- backend->component->name, backend->component->phases, backend->flags);
- return -1;
- }
-
- /* make sure we didn't already enable this backend, we don't want duplicates */
- pprev = &topology->backends;
- while (NULL != *pprev) {
- if ((*pprev)->component == backend->component) {
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Cannot enable discovery component `%s' phases 0x%x twice\n",
- backend->component->name, backend->component->phases);
- hwloc_backend_disable(backend);
- errno = EBUSY;
- return -1;
- }
- pprev = &((*pprev)->next);
- }
-
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Enabling discovery component `%s' with phases 0x%x (among 0x%x)\n",
- backend->component->name, backend->phases, backend->component->phases);
-
- /* enqueue at the end */
- pprev = &topology->backends;
- while (NULL != *pprev)
- pprev = &((*pprev)->next);
- backend->next = *pprev;
- *pprev = backend;
-
- topology->backend_phases |= backend->component->phases;
- topology->backend_excluded_phases |= backend->component->excluded_phases;
- return 0;
-}
-
-void
-hwloc_backends_is_thissystem(struct hwloc_topology *topology)
-{
- struct hwloc_backend *backend;
- const char *local_env;
-
- /*
- * If the application changed the backend with set_foo(),
- * it may use set_flags() update the is_thissystem flag here.
- * If it changes the backend with environment variables below,
- * it may use HWLOC_THISSYSTEM envvar below as well.
- */
-
- topology->is_thissystem = 1;
-
- /* apply thissystem from normally-given backends (envvar_forced=0, either set_foo() or defaults) */
- backend = topology->backends;
- while (backend != NULL) {
- if (backend->envvar_forced == 0 && backend->is_thissystem != -1) {
- assert(backend->is_thissystem == 0);
- topology->is_thissystem = 0;
- }
- backend = backend->next;
- }
-
- /* override set_foo() with flags */
- if (topology->flags & HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM)
- topology->is_thissystem = 1;
-
- /* now apply envvar-forced backend (envvar_forced=1) */
- backend = topology->backends;
- while (backend != NULL) {
- if (backend->envvar_forced == 1 && backend->is_thissystem != -1) {
- assert(backend->is_thissystem == 0);
- topology->is_thissystem = 0;
- }
- backend = backend->next;
- }
-
- /* override with envvar-given flag */
- local_env = getenv("HWLOC_THISSYSTEM");
- if (local_env)
- topology->is_thissystem = atoi(local_env);
-}
-
-void
-hwloc_backends_find_callbacks(struct hwloc_topology *topology)
-{
- struct hwloc_backend *backend = topology->backends;
- /* use the first backend's get_pci_busid_cpuset callback */
- topology->get_pci_busid_cpuset_backend = NULL;
- while (backend != NULL) {
- if (backend->get_pci_busid_cpuset) {
- topology->get_pci_busid_cpuset_backend = backend;
- return;
- }
- backend = backend->next;
- }
- return;
-}
-
-void
-hwloc_backends_disable_all(struct hwloc_topology *topology)
-{
- struct hwloc_backend *backend;
-
- while (NULL != (backend = topology->backends)) {
- struct hwloc_backend *next = backend->next;
- if (hwloc_components_verbose)
- fprintf(stderr, "hwloc: Disabling discovery component `%s'\n",
- backend->component->name);
- hwloc_backend_disable(backend);
- topology->backends = next;
- }
- topology->backends = NULL;
- topology->backend_excluded_phases = 0;
-}
-
-void
-hwloc_topology_components_fini(struct hwloc_topology *topology)
-{
- /* hwloc_backends_disable_all() must have been called earlier */
- assert(!topology->backends);
-
- free(topology->blacklisted_components);
-}
### src/3rdparty/hwloc/src/cpukinds.c
@@ -1,662 +0,0 @@
-/*
- * Copyright © 2020-2024 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-#include "private/autogen/config.h"
-#include "hwloc.h"
-#include "private/private.h"
-#include "private/debug.h"
-
-
-/*****************
- * Basics
- */
-
-void
-hwloc_internal_cpukinds_init(struct hwloc_topology *topology)
-{
- topology->cpukinds = NULL;
- topology->nr_cpukinds = 0;
- topology->nr_cpukinds_allocated = 0;
-}
-
-void
-hwloc_internal_cpukinds_destroy(struct hwloc_topology *topology)
-{
- unsigned i;
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- hwloc_bitmap_free(kind->cpuset);
- hwloc__free_infos(kind->infos, kind->nr_infos);
- }
- free(topology->cpukinds);
- topology->cpukinds = NULL;
- topology->nr_cpukinds = 0;
-}
-
-int
-hwloc_internal_cpukinds_dup(hwloc_topology_t new, hwloc_topology_t old)
-{
- struct hwloc_tma *tma = new->tma;
- struct hwloc_internal_cpukind_s *kinds;
- unsigned i;
-
- if (!old->nr_cpukinds)
- return 0;
-
- kinds = hwloc_tma_malloc(tma, old->nr_cpukinds * sizeof(*kinds));
- if (!kinds)
- return -1;
- new->cpukinds = kinds;
- new->nr_cpukinds = old->nr_cpukinds;
- new->nr_cpukinds_allocated = old->nr_cpukinds;
- memcpy(kinds, old->cpukinds, old->nr_cpukinds * sizeof(*kinds));
-
- for(i=0;i<old->nr_cpukinds; i++) {
- kinds[i].cpuset = hwloc_bitmap_tma_dup(tma, old->cpukinds[i].cpuset);
- if (!kinds[i].cpuset) {
- new->nr_cpukinds = i;
- goto failed;
- }
- if (hwloc__tma_dup_infos(tma,
- &kinds[i].infos, &kinds[i].nr_infos,
- old->cpukinds[i].infos, old->cpukinds[i].nr_infos) < 0) {
- assert(!tma || !tma->dontfree); /* this tma cannot fail to allocate */
- hwloc_bitmap_free(kinds[i].cpuset);
- new->nr_cpukinds = i;
- goto failed;
- }
- }
-
- return 0;
-
- failed:
- hwloc_internal_cpukinds_destroy(new);
- return -1;
-}
-
-void
-hwloc_internal_cpukinds_restrict(hwloc_topology_t topology)
-{
- unsigned i;
- int removed = 0;
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- hwloc_bitmap_and(kind->cpuset, kind->cpuset, hwloc_get_root_obj(topology)->cpuset);
- if (hwloc_bitmap_iszero(kind->cpuset)) {
- hwloc_bitmap_free(kind->cpuset);
- hwloc__free_infos(kind->infos, kind->nr_infos);
- memmove(kind, kind+1, (topology->nr_cpukinds - i - 1)*sizeof(*kind));
- i--;
- topology->nr_cpukinds--;
- removed = 1;
- }
- }
- if (removed)
- hwloc_internal_cpukinds_rank(topology);
-}
-
-
-/********************
- * Registering
- */
-
-static __hwloc_inline int
-hwloc__cpukind_check_duplicate_info(struct hwloc_internal_cpukind_s *kind,
- const char *name, const char *value)
-{
- unsigned i;
- for(i=0; i<kind->nr_infos; i++)
- if (!strcmp(kind->infos[i].name, name)
- && !strcmp(kind->infos[i].value, value))
- return 1;
- return 0;
-}
-
-static __hwloc_inline void
-hwloc__cpukind_add_infos(struct hwloc_internal_cpukind_s *kind,
- const struct hwloc_info_s *infos, unsigned nr_infos)
-{
- unsigned i;
- for(i=0; i<nr_infos; i++) {
- if (hwloc__cpukind_check_duplicate_info(kind, infos[i].name, infos[i].value))
- continue;
- hwloc__add_info(&kind->infos, &kind->nr_infos, infos[i].name, infos[i].value);
- }
-}
-
-int
-hwloc_internal_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t cpuset,
- int forced_efficiency,
- const struct hwloc_info_s *infos, unsigned nr_infos,
- unsigned long flags)
-{
- struct hwloc_internal_cpukind_s *kinds;
- unsigned i, max, bits, oldnr, newnr;
-
- if (hwloc_bitmap_iszero(cpuset)) {
- hwloc_bitmap_free(cpuset);
- errno = EINVAL;
- return -1;
- }
-
- if (flags & ~HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY) {
- errno = EINVAL;
- return -1;
- }
-
- /* TODO: for now, only windows provides a forced efficiency.
- * if another backend ever provides a conflicting value, the first backend value will be kept.
- * (user-provided values are not an issue, they are meant to overwrite)
- */
-
- /* If we have N kinds currently, we may need 2N+1 kinds after inserting the new one:
- * - each existing kind may get split into which PUs are in the new kind and which aren't.
- * - some PUs might not have been in any kind yet.
- */
- max = 2 * topology->nr_cpukinds + 1;
- /* Allocate the power-of-two above 2N+1. */
- bits = hwloc_flsl(max-1) + 1;
- max = 1U<<bits;
- /* Allocate 8 minimum to avoid multiple reallocs */
- if (max < 8)
- max = 8;
-
- /* Create or enlarge the array of kinds if needed */
- kinds = topology->cpukinds;
- if (max > topology->nr_cpukinds_allocated) {
- kinds = realloc(kinds, max * sizeof(*kinds));
- if (!kinds) {
- hwloc_bitmap_free(cpuset);
- return -1;
- }
- memset(&kinds[topology->nr_cpukinds_allocated], 0, (max - topology->nr_cpukinds_allocated) * sizeof(*kinds));
- topology->nr_cpukinds_allocated = max;
- topology->cpukinds = kinds;
- }
-
- newnr = oldnr = topology->nr_cpukinds;
- for(i=0; i<oldnr; i++) {
- int res = hwloc_bitmap_compare_inclusion(cpuset, kinds[i].cpuset);
- if (res == HWLOC_BITMAP_INTERSECTS || res == HWLOC_BITMAP_INCLUDED) {
- /* new kind with intersection of cpusets and union of infos */
- kinds[newnr].cpuset = hwloc_bitmap_alloc();
- kinds[newnr].efficiency = HWLOC_CPUKIND_EFFICIENCY_UNKNOWN;
- kinds[newnr].forced_efficiency = forced_efficiency;
- hwloc_bitmap_and(kinds[newnr].cpuset, cpuset, kinds[i].cpuset);
- hwloc__cpukind_add_infos(&kinds[newnr], kinds[i].infos, kinds[i].nr_infos);
- hwloc__cpukind_add_infos(&kinds[newnr], infos, nr_infos);
- /* remove cpuset PUs from the existing kind that we just split */
- hwloc_bitmap_andnot(kinds[i].cpuset, kinds[i].cpuset, kinds[newnr].cpuset);
- /* clear cpuset PUs that were taken care of */
- hwloc_bitmap_andnot(cpuset, cpuset, kinds[newnr].cpuset);
-
- newnr++;
-
- } else if (res == HWLOC_BITMAP_CONTAINS
- || res == HWLOC_BITMAP_EQUAL) {
- /* append new info to existing smaller (or equal) kind */
- hwloc__cpukind_add_infos(&kinds[i], infos, nr_infos);
- if ((flags & HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY)
- || kinds[i].forced_efficiency == HWLOC_CPUKIND_EFFICIENCY_UNKNOWN)
- kinds[i].forced_efficiency = forced_efficiency;
- /* clear cpuset PUs that were taken care of */
- hwloc_bitmap_andnot(cpuset, cpuset, kinds[i].cpuset);
-
- } else {
- assert(res == HWLOC_BITMAP_DIFFERENT);
- /* nothing to do */
- }
-
- /* don't compare with anything else if already empty */
- if (hwloc_bitmap_iszero(cpuset))
- break;
- }
-
- /* add a final kind with remaining PUs if any */
- if (!hwloc_bitmap_iszero(cpuset)) {
- kinds[newnr].cpuset = cpuset;
- kinds[newnr].efficiency = HWLOC_CPUKIND_EFFICIENCY_UNKNOWN;
- kinds[newnr].forced_efficiency = forced_efficiency;
- hwloc__cpukind_add_infos(&kinds[newnr], infos, nr_infos);
- newnr++;
- } else {
- hwloc_bitmap_free(cpuset);
- }
-
- topology->nr_cpukinds = newnr;
- return 0;
-}
-
-int
-hwloc_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t _cpuset,
- int forced_efficiency,
- unsigned nr_infos, struct hwloc_info_s *infos,
- unsigned long flags)
-{
- hwloc_bitmap_t cpuset;
- int err;
-
- if (flags) {
- errno = EINVAL;
- return -1;
- }
-
- if (!_cpuset || hwloc_bitmap_iszero(_cpuset)) {
- errno = EINVAL;
- return -1;
- }
-
- cpuset = hwloc_bitmap_dup(_cpuset);
- if (!cpuset)
- return -1;
-
- if (forced_efficiency < 0)
- forced_efficiency = HWLOC_CPUKIND_EFFICIENCY_UNKNOWN;
-
- err = hwloc_internal_cpukinds_register(topology, cpuset, forced_efficiency, infos, nr_infos, HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY);
- if (err < 0)
- return err;
-
- hwloc_internal_cpukinds_rank(topology);
- return 0;
-}
-
-
-/*********************
- * Ranking
- */
-
-static int
-hwloc__cpukinds_check_duplicate_rankings(struct hwloc_topology *topology)
-{
- unsigned i,j;
- for(i=0; i<topology->nr_cpukinds; i++)
- for(j=i+1; j<topology->nr_cpukinds; j++)
- if (topology->cpukinds[i].ranking_value == topology->cpukinds[j].ranking_value)
- /* if any duplicate, fail */
- return -1;
- return 0;
-}
-
-static int
-hwloc__cpukinds_try_rank_by_forced_efficiency(struct hwloc_topology *topology)
-{
- unsigned i;
-
- hwloc_debug("Trying to rank cpukinds by forced efficiency...\n");
- for(i=0; i<topology->nr_cpukinds; i++) {
- if (topology->cpukinds[i].forced_efficiency == HWLOC_CPUKIND_EFFICIENCY_UNKNOWN)
- /* if any unknown, fail */
- return -1;
- topology->cpukinds[i].ranking_value = topology->cpukinds[i].forced_efficiency;
- }
-
- return hwloc__cpukinds_check_duplicate_rankings(topology);
-}
-
-struct hwloc_cpukinds_info_summary {
- int have_max_freq;
- int have_base_freq;
- int have_intel_core_type;
- struct hwloc_cpukind_info_summary {
- unsigned intel_core_type; /* 1 for atom, 2 for core */
- unsigned max_freq, base_freq; /* MHz, hence < 100000 */
- } * summaries;
-};
-
-static void
-hwloc__cpukinds_summarize_info(struct hwloc_topology *topology,
- struct hwloc_cpukinds_info_summary *summary)
-{
- unsigned i, j;
-
- summary->have_max_freq = 1;
- summary->have_base_freq = 1;
- summary->have_intel_core_type = 1;
-
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- for(j=0; j<kind->nr_infos; j++) {
- struct hwloc_info_s *info = &kind->infos[j];
- if (!strcmp(info->name, "FrequencyMaxMHz")) {
- summary->summaries[i].max_freq = atoi(info->value);
- } else if (!strcmp(info->name, "FrequencyBaseMHz")) {
- summary->summaries[i].base_freq = atoi(info->value);
- } else if (!strcmp(info->name, "CoreType")) {
- if (!strcmp(info->value, "IntelAtom"))
- summary->summaries[i].intel_core_type = 1;
- else if (!strcmp(info->value, "IntelCore"))
- summary->summaries[i].intel_core_type = 2;
- }
- }
- hwloc_debug("cpukind #%u has intel_core_type %u max_freq %u base_freq %u\n",
- i, summary->summaries[i].intel_core_type,
- summary->summaries[i].max_freq, summary->summaries[i].base_freq);
- if (!summary->summaries[i].base_freq)
- summary->have_base_freq = 0;
- if (!summary->summaries[i].max_freq)
- summary->have_max_freq = 0;
- if (!summary->summaries[i].intel_core_type)
- summary->have_intel_core_type = 0;
- }
-}
-
-enum hwloc_cpukinds_ranking {
- HWLOC_CPUKINDS_RANKING_DEFAULT, /* forced + frequency on ARM, forced + coretype_frequency otherwise */
- HWLOC_CPUKINDS_RANKING_NO_FORCED_EFFICIENCY, /* default without forced */
- HWLOC_CPUKINDS_RANKING_FORCED_EFFICIENCY,
- HWLOC_CPUKINDS_RANKING_CORETYPE_FREQUENCY, /* either coretype or frequency or both */
- HWLOC_CPUKINDS_RANKING_CORETYPE_FREQUENCY_STRICT, /* both coretype and frequency are required */
- HWLOC_CPUKINDS_RANKING_CORETYPE,
- HWLOC_CPUKINDS_RANKING_FREQUENCY,
- HWLOC_CPUKINDS_RANKING_FREQUENCY_MAX,
- HWLOC_CPUKINDS_RANKING_FREQUENCY_BASE,
- HWLOC_CPUKINDS_RANKING_NONE
-};
-
-static int
-hwloc__cpukinds_try_rank_by_info(struct hwloc_topology *topology,
- enum hwloc_cpukinds_ranking heuristics,
- struct hwloc_cpukinds_info_summary *summary)
-{
- unsigned i;
-
- if (HWLOC_CPUKINDS_RANKING_CORETYPE_FREQUENCY_STRICT == heuristics) {
- hwloc_debug("Trying to rank cpukinds by coretype+frequency_strict...\n");
- /* we need intel_core_type AND (base or max freq) for all kinds */
- if (!summary->have_intel_core_type
- || (!summary->have_max_freq && !summary->have_base_freq))
- return -1;
- /* rank first by coretype (Core>>Atom) then by frequency, base if available, max otherwise */
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- if (summary->have_base_freq)
- kind->ranking_value = (summary->summaries[i].intel_core_type << 20) + summary->summaries[i].base_freq;
- else
- kind->ranking_value = (summary->summaries[i].intel_core_type << 20) + summary->summaries[i].max_freq;
- }
-
- } else if (HWLOC_CPUKINDS_RANKING_CORETYPE_FREQUENCY == heuristics) {
- hwloc_debug("Trying to rank cpukinds by coretype+frequency...\n");
- /* we need intel_core_type OR (base or max freq) for all kinds */
- if (!summary->have_intel_core_type
- && (!summary->have_max_freq && !summary->have_base_freq))
- return -1;
- /* rank first by coretype (Core>>Atom) then by frequency, base if available, max otherwise */
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- if (summary->have_base_freq)
- kind->ranking_value = (summary->summaries[i].intel_core_type << 20) + summary->summaries[i].base_freq;
- else
- kind->ranking_value = (summary->summaries[i].intel_core_type << 20) + summary->summaries[i].max_freq;
- }
-
- } else if (HWLOC_CPUKINDS_RANKING_CORETYPE == heuristics) {
- hwloc_debug("Trying to rank cpukinds by coretype...\n");
- /* we need intel_core_type */
- if (!summary->have_intel_core_type)
- return -1;
- /* rank by coretype (Core>>Atom) */
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- kind->ranking_value = (summary->summaries[i].intel_core_type << 20);
- }
-
- } else if (HWLOC_CPUKINDS_RANKING_FREQUENCY == heuristics) {
- hwloc_debug("Trying to rank cpukinds by frequency...\n");
- /* we need base or max freq for all kinds */
- if (!summary->have_max_freq && !summary->have_base_freq)
- return -1;
- /* rank first by frequency, base if available, max otherwise */
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- if (summary->have_base_freq)
- kind->ranking_value = summary->summaries[i].base_freq;
- else
- kind->ranking_value = summary->summaries[i].max_freq;
- }
-
- } else if (HWLOC_CPUKINDS_RANKING_FREQUENCY_MAX == heuristics) {
- hwloc_debug("Trying to rank cpukinds by frequency max...\n");
- /* we need max freq for all kinds */
- if (!summary->have_max_freq)
- return -1;
- /* rank first by frequency, base if available, max otherwise */
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- kind->ranking_value = summary->summaries[i].max_freq;
- }
-
- } else if (HWLOC_CPUKINDS_RANKING_FREQUENCY_BASE == heuristics) {
- hwloc_debug("Trying to rank cpukinds by frequency base...\n");
- /* we need max freq for all kinds */
- if (!summary->have_base_freq)
- return -1;
- /* rank first by frequency, base if available, max otherwise */
- for(i=0; i<topology->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[i];
- kind->ranking_value = summary->summaries[i].base_freq;
- }
-
- } else assert(0);
-
- return hwloc__cpukinds_check_duplicate_rankings(topology);
-}
-
-static int hwloc__cpukinds_compare_ranking_values(const void *_a, const void *_b)
-{
- const struct hwloc_internal_cpukind_s *a = _a;
- const struct hwloc_internal_cpukind_s *b = _b;
- uint64_t arv = a->ranking_value;
- uint64_t brv = b->ranking_value;
- return arv < brv ? -1 : arv > brv ? 1 : 0;
-}
-
-/* this function requires ranking values to be unique */
-static void
-hwloc__cpukinds_finalize_ranking(struct hwloc_topology *topology)
-{
- unsigned i;
- /* sort */
- qsort(topology->cpukinds, topology->nr_cpukinds, sizeof(*topology->cpukinds), hwloc__cpukinds_compare_ranking_values);
- /* define our own efficiency between 0 and N-1 */
- for(i=0; i<topology->nr_cpukinds; i++)
- topology->cpukinds[i].efficiency = i;
-}
-
-int
-hwloc_internal_cpukinds_rank(struct hwloc_topology *topology)
-{
- enum hwloc_cpukinds_ranking heuristics;
- char *env;
- unsigned i;
- int err;
-
- if (!topology->nr_cpukinds)
- return 0;
-
- if (topology->nr_cpukinds == 1) {
- topology->cpukinds[0].efficiency = 0;
- return 0;
- }
-
- heuristics = HWLOC_CPUKINDS_RANKING_DEFAULT;
- env = getenv("HWLOC_CPUKINDS_RANKING");
- if (env) {
- if (!strcmp(env, "default"))
- heuristics = HWLOC_CPUKINDS_RANKING_DEFAULT;
- else if (!strcmp(env, "none"))
- heuristics = HWLOC_CPUKINDS_RANKING_NONE;
- else if (!strcmp(env, "coretype+frequency"))
- heuristics = HWLOC_CPUKINDS_RANKING_CORETYPE_FREQUENCY;
- else if (!strcmp(env, "coretype+frequency_strict"))
- heuristics = HWLOC_CPUKINDS_RANKING_CORETYPE_FREQUENCY_STRICT;
- else if (!strcmp(env, "coretype"))
- heuristics = HWLOC_CPUKINDS_RANKING_CORETYPE;
- else if (!strcmp(env, "frequency"))
- heuristics = HWLOC_CPUKINDS_RANKING_FREQUENCY;
- else if (!strcmp(env, "frequency_max"))
- heuristics = HWLOC_CPUKINDS_RANKING_FREQUENCY_MAX;
- else if (!strcmp(env, "frequency_base"))
- heuristics = HWLOC_CPUKINDS_RANKING_FREQUENCY_BASE;
- else if (!strcmp(env, "forced_efficiency"))
- heuristics = HWLOC_CPUKINDS_RANKING_FORCED_EFFICIENCY;
- else if (!strcmp(env, "no_forced_efficiency"))
- heuristics = HWLOC_CPUKINDS_RANKING_NO_FORCED_EFFICIENCY;
- else if (HWLOC_SHOW_CRITICAL_ERRORS())
- fprintf(stderr, "hwloc: Failed to recognize HWLOC_CPUKINDS_RANKING value %s\n", env);
- }
-
- if (heuristics == HWLOC_CPUKINDS_RANKING_DEFAULT
- || heuristics == HWLOC_CPUKINDS_RANKING_NO_FORCED_EFFICIENCY) {
- /* default is forced_efficiency first */
- struct hwloc_cpukinds_info_summary summary;
-
- if (heuristics == HWLOC_CPUKINDS_RANKING_DEFAULT)
- hwloc_debug("Using default ranking strategy...\n");
- else
- hwloc_debug("Using custom ranking strategy from HWLOC_CPUKINDS_RANKING=%s\n", env);
-
- if (heuristics != HWLOC_CPUKINDS_RANKING_NO_FORCED_EFFICIENCY) {
- err = hwloc__cpukinds_try_rank_by_forced_efficiency(topology);
- if (!err)
- goto ready;
- }
-
- summary.summaries = calloc(topology->nr_cpukinds, sizeof(*summary.summaries));
- if (!summary.summaries)
- goto failed;
- hwloc__cpukinds_summarize_info(topology, &summary);
-
- err = hwloc__cpukinds_try_rank_by_info(topology, HWLOC_CPUKINDS_RANKING_CORETYPE_FREQUENCY, &summary);
- free(summary.summaries);
- if (!err)
- goto ready;
-
- } else if (heuristics == HWLOC_CPUKINDS_RANKING_FORCED_EFFICIENCY) {
- hwloc_debug("Using custom ranking strategy from HWLOC_CPUKINDS_RANKING=%s\n", env);
-
- err = hwloc__cpukinds_try_rank_by_forced_efficiency(topology);
- if (!err)
- goto ready;
-
- } else if (heuristics != HWLOC_CPUKINDS_RANKING_NONE) {
- /* custom heuristics */
- struct hwloc_cpukinds_info_summary summary;
-
- hwloc_debug("Using custom ranking strategy from HWLOC_CPUKINDS_RANKING=%s\n", env);
-
- summary.summaries = calloc(topology->nr_cpukinds, sizeof(*summary.summaries));
- if (!summary.summaries)
- goto failed;
- hwloc__cpukinds_summarize_info(topology, &summary);
-
- err = hwloc__cpukinds_try_rank_by_info(topology, heuristics, &summary);
- free(summary.summaries);
- if (!err)
- goto ready;
- }
-
- failed:
- /* failed to rank, clear efficiencies */
- for(i=0; i<topology->nr_cpukinds; i++)
- topology->cpukinds[i].efficiency = HWLOC_CPUKIND_EFFICIENCY_UNKNOWN;
- hwloc_debug("Failed to rank cpukinds.\n\n");
- return 0;
-
- ready:
- for(i=0; i<topology->nr_cpukinds; i++)
- hwloc_debug("cpukind #%u got ranking value %llu\n", i, (unsigned long long) topology->cpukinds[i].ranking_value);
- hwloc__cpukinds_finalize_ranking(topology);
-#ifdef HWLOC_DEBUG
- for(i=0; i<topology->nr_cpukinds; i++)
- assert(topology->cpukinds[i].efficiency == (int) i);
-#endif
- hwloc_debug("\n");
- return 0;
-}
-
-
-/*****************
- * Consulting
- */
-
-int
-hwloc_cpukinds_get_nr(hwloc_topology_t topology, unsigned long flags)
-{
- if (flags) {
- errno = EINVAL;
- return -1;
- }
-
- return topology->nr_cpukinds;
-}
-
-int
-hwloc_cpukinds_get_info(hwloc_topology_t topology,
- unsigned id,
- hwloc_bitmap_t cpuset,
- int *efficiencyp,
- unsigned *nr_infosp, struct hwloc_info_s **infosp,
- unsigned long flags)
-{
- struct hwloc_internal_cpukind_s *kind;
-
- if (flags) {
- errno = EINVAL;
- return -1;
- }
-
- if (id >= topology->nr_cpukinds) {
- errno = ENOENT;
- return -1;
- }
-
- kind = &topology->cpukinds[id];
-
- if (cpuset)
- hwloc_bitmap_copy(cpuset, kind->cpuset);
-
- if (efficiencyp)
- *efficiencyp = kind->efficiency;
-
- if (nr_infosp && infosp) {
- *nr_infosp = kind->nr_infos;
- *infosp = kind->infos;
- }
- return 0;
-}
-
-int
-hwloc_cpukinds_get_by_cpuset(hwloc_topology_t topology,
- hwloc_const_bitmap_t cpuset,
- unsigned long flags)
-{
- unsigned id;
-
- if (flags) {
- errno = EINVAL;
- return -1;
- }
-
- if (!cpuset || hwloc_bitmap_iszero(cpuset)) {
- errno = EINVAL;
- return -1;
- }
-
- for(id=0; id<topology->nr_cpukinds; id++) {
- struct hwloc_internal_cpukind_s *kind = &topology->cpukinds[id];
- int res = hwloc_bitmap_compare_inclusion(cpuset, kind->cpuset);
- if (res == HWLOC_BITMAP_EQUAL || res == HWLOC_BITMAP_INCLUDED) {
- return (int) id;
- } else if (res == HWLOC_BITMAP_INTERSECTS || res == HWLOC_BITMAP_CONTAINS) {
- errno = EXDEV;
- return -1;
- }
- }
-
- errno = ENOENT;
- return -1;
-}
### src/3rdparty/hwloc/src/diff.c
@@ -1,564 +0,0 @@
-/*
- * Copyright © 2013-2023 Inria. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-#include "private/autogen/config.h"
-#include "private/private.h"
-#include "private/misc.h"
-
-int hwloc_topology_diff_destroy(hwloc_topology_diff_t diff)
-{
- hwloc_topology_diff_t next;
- while (diff) {
- next = diff->generic.next;
- switch (diff->generic.type) {
- default:
- break;
- case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR:
- switch (diff->obj_attr.diff.generic.type) {
- default:
- break;
- case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_NAME:
- case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO:
- free(diff->obj_attr.diff.string.name);
- free(diff->obj_attr.diff.string.oldvalue);
- free(diff->obj_attr.diff.string.newvalue);
- break;
- }
- break;
- }
- free(diff);
- diff = next;
- }
- return 0;
-}
-
-/************************
- * Computing diffs
- */
-
-static void hwloc_append_diff(hwloc_topology_diff_t newdiff,
- hwloc_topology_diff_t *firstdiffp,
- hwloc_topology_diff_t *lastdiffp)
-{
- if (*firstdiffp)
- (*lastdiffp)->generic.next = newdiff;
- else
- *firstdiffp = newdiff;
- *lastdiffp = newdiff;
- newdiff->generic.next = NULL;
-}
-
-static int hwloc_append_diff_too_complex(hwloc_obj_t obj1,
- hwloc_topology_diff_t *firstdiffp,
- hwloc_topology_diff_t *lastdiffp)
-{
- hwloc_topology_diff_t newdiff;
- newdiff = malloc(sizeof(*newdiff));
- if (!newdiff)
- return -1;
-
- newdiff->too_complex.type = HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX;
- newdiff->too_complex.obj_depth = obj1->depth;
- newdiff->too_complex.obj_index = obj1->logical_index;
- hwloc_append_diff(newdiff, firstdiffp, lastdiffp);
- return 0;
-}
-
-static int hwloc_append_diff_obj_attr_string(hwloc_obj_t obj,
- hwloc_topology_diff_obj_attr_type_t type,
- const char *name,
- const char *oldvalue,
- const char *newvalue,
- hwloc_topology_diff_t *firstdiffp,
- hwloc_topology_diff_t *lastdiffp)
-{
- hwloc_topology_diff_t newdiff;
- newdiff = malloc(sizeof(*newdiff));
- if (!newdiff)
- return -1;
-
- newdiff->obj_attr.type = HWLOC_TOPOLOGY_DIFF_OBJ_ATTR;
- newdiff->obj_attr.obj_depth = obj->depth;
- newdiff->obj_attr.obj_index = obj->logical_index;
- newdiff->obj_attr.diff.string.type = type;
- newdiff->obj_attr.diff.string.name = name ? strdup(name) : NULL;
- newdiff->obj_attr.diff.string.oldvalue = oldvalue ? strdup(oldvalue) : NULL;
- newdiff->obj_attr.diff.string.newvalue = newvalue ? strdup(newvalue) : NULL;
- hwloc_append_diff(newdiff, firstdiffp, lastdiffp);
- return 0;
-}
-
-static int hwloc_append_diff_obj_attr_uint64(hwloc_obj_t obj,
- hwloc_topology_diff_obj_attr_type_t type,
- hwloc_uint64_t idx,
- hwloc_uint64_t oldvalue,
- hwloc_uint64_t newvalue,
- hwloc_topology_diff_t *firstdiffp,
- hwloc_topology_diff_t *lastdiffp)
-{
- hwloc_topology_diff_t newdiff;
- newdiff = malloc(sizeof(*newdiff));
- if (!newdiff)
- return -1;
-
- newdiff->obj_attr.type = HWLOC_TOPOLOGY_DIFF_OBJ_ATTR;
- newdiff->obj_attr.obj_depth = obj->depth;
- newdiff->obj_attr.obj_index = obj->logical_index;
- newdiff->obj_attr.diff.uint64.type = type;
- newdiff->obj_attr.diff.uint64.index = idx;
- newdiff->obj_attr.diff.uint64.oldvalue = oldvalue;
- newdiff->obj_attr.diff.uint64.newvalue = newvalue;
- hwloc_append_diff(newdiff, firstdiffp, lastdiffp);
- return 0;
-}
-
-static int
-hwloc_diff_trees(hwloc_topology_t topo1, hwloc_obj_t obj1,
- hwloc_topology_t topo2, hwloc_obj_t obj2,
- unsigned flags,
- hwloc_topology_diff_t *firstdiffp, hwloc_topology_diff_t *lastdiffp)
-{
- unsigned i;
- int err;
- hwloc_obj_t child1, child2;
-
- if (obj1->depth != obj2->depth)
- goto out_too_complex;
-
- if (obj1->type != obj2->type)
- goto out_too_complex;
- if ((!obj1->subtype) != (!obj2->subtype)
- || (obj1->subtype && strcmp(obj1->subtype, obj2->subtype)))
- goto out_too_complex;
-
- if (obj1->os_index != obj2->os_index)
- /* we could allow different os_index for non-PU non-NUMAnode objects
- * but it's likely useless anyway */
- goto out_too_complex;
-
-#define _SETS_DIFFERENT(_set1, _set2) \
- ( ( !(_set1) != !(_set2) ) \
- || ( (_set1) && !hwloc_bitmap_isequal(_set1, _set2) ) )
-#define SETS_DIFFERENT(_set, _obj1, _obj2) _SETS_DIFFERENT((_obj1)->_set, (_obj2)->_set)
- if (SETS_DIFFERENT(cpuset, obj1, obj2)
- || SETS_DIFFERENT(complete_cpuset, obj1, obj2)
- || SETS_DIFFERENT(nodeset, obj1, obj2)
- || SETS_DIFFERENT(complete_nodeset, obj1, obj2))
- goto out_too_complex;
-
- /* no need to check logical_index, sibling_rank, symmetric_subtree,
- * the parents did it */
-
- /* gp_index don't have to be strictly identical */
-
- if ((!obj1->name) != (!obj2->name)
- || (obj1->name && strcmp(obj1->name, obj2->name))) {
- err = hwloc_append_diff_obj_attr_string(obj1,
- HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_NAME,
- NULL,
- obj1->name,
- obj2->name,
- firstdiffp, lastdiffp);
- if (err < 0)
- return err;
- }
-
- /* type-specific attrs */
- switch (obj1->type) {
- default:
- break;
- case HWLOC_OBJ_NUMANODE:
- if (obj1->attr->numanode.local_memory != obj2->attr->numanode.local_memory) {
- err = hwloc_append_diff_obj_attr_uint64(obj1,
- HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_SIZE,
- 0,
- obj1->attr->numanode.local_memory,
- obj2->attr->numanode.local_memory,
- firstdiffp, lastdiffp);
- if (err < 0)
- return err;
- }
- /* ignore memory page_types */
- break;
- case HWLOC_OBJ_L1CACHE:
- case HWLOC_OBJ_L2CACHE:
- case HWLOC_OBJ_L3CACHE:
- case HWLOC_OBJ_L4CACHE:
- case HWLOC_OBJ_L5CACHE:
- case HWLOC_OBJ_L1ICACHE:
- case HWLOC_OBJ_L2ICACHE:
- case HWLOC_OBJ_L3ICACHE:
- if (memcmp(obj1->attr, obj2->attr, sizeof(obj1->attr->cache)))
- goto out_too_complex;
- break;
- case HWLOC_OBJ_GROUP:
- if (memcmp(obj1->attr, obj2->attr, sizeof(obj1->attr->group)))
- goto out_too_complex;
- break;
- case HWLOC_OBJ_PCI_DEVICE:
- if (memcmp(obj1->attr, obj2->attr, sizeof(obj1->attr->pcidev)))
- goto out_too_complex;
- break;
- case HWLOC_OBJ_BRIDGE:
- if (memcmp(obj1->attr, obj2->attr, sizeof(obj1->attr->bridge)))
- goto out_too_complex;
- break;
- case HWLOC_OBJ_OS_DEVICE:
- if (memcmp(obj1->attr, obj2->attr, sizeof(obj1->attr->osdev)))
- goto out_too_complex;
- break;
- }
-
- /* infos */
- if (obj1->infos_count != obj2->infos_count)
- goto out_too_complex;
- for(i=0; i<obj1->infos_count; i++) {
- struct hwloc_info_s *info1 = &obj1->infos[i], *info2 = &obj2->infos[i];
- if (strcmp(info1->name, info2->name))
- goto out_too_complex;
- if (strcmp(info1->value, info2->value)) {
- err = hwloc_append_diff_obj_attr_string(obj1,
- HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO,
- info1->name,
- info1->value,
- info2->value,
- firstdiffp, lastdiffp);
- if (err < 0)
- return err;
- }
- }
-
- /* ignore userdata */
-
- /* children */
- for(child1 = obj1->first_child, child2 = obj2->first_child;
- child1 != NULL && child2 != NULL;
- child1 = child1->next_sibling, child2 = child2->next_sibling) {
- err = hwloc_diff_trees(topo1, child1,
- topo2, child2,
- flags,
- firstdiffp, lastdiffp);
- if (err < 0)
- return err;
- }
- if (child1 || child2)
- goto out_too_complex;
-
- /* memory children */
- for(child1 = obj1->memory_first_child, child2 = obj2->memory_first_child;
- child1 != NULL && child2 != NULL;
- child1 = child1->next_sibling, child2 = child2->next_sibling) {
- err = hwloc_diff_trees(topo1, child1,
- topo2, child2,
- flags,
- firstdiffp, lastdiffp);
- if (err < 0)
- return err;
- }
- if (child1 || child2)
- goto out_too_complex;
-
- /* I/O children */
- for(child1 = obj1->io_first_child, child2 = obj2->io_first_child;
- child1 != NULL && child2 != NULL;
- child1 = child1->next_sibling, child2 = child2->next_sibling) {
- err = hwloc_diff_trees(topo1, child1,
- topo2, child2,
- flags,
- firstdiffp, lastdiffp);
- if (err < 0)
- return err;
- }
- if (child1 || child2)
- goto out_too_complex;
-
- /* misc children */
- for(child1 = obj1->misc_first_child, child2 = obj2->misc_first_child;
- child1 != NULL && child2 != NULL;
- child1 = child1->next_sibling, child2 = child2->next_sibling) {
- err = hwloc_diff_trees(topo1, child1,
- topo2, child2,
- flags,
- firstdiffp, lastdiffp);
- if (err < 0)
- return err;
- }
- if (child1 || child2)
- goto out_too_complex;
-
- return 0;
-
-out_too_complex:
- hwloc_append_diff_too_complex(obj1, firstdiffp, lastdiffp);
- return 0;
-}
-
-int hwloc_topology_diff_build(hwloc_topology_t topo1,
- hwloc_topology_t topo2,
- unsigned long flags,
- hwloc_topology_diff_t *diffp)
-{
- hwloc_topology_diff_t lastdiff, tmpdiff;
- struct hwloc_internal_distances_s *dist1, *dist2;
- unsigned i;
- int err;
-
- if (!topo1->is_loaded || !topo2->is_loaded) {
- errno = EINVAL;
- return -1;
- }
-
- if (flags != 0) {
- errno = EINVAL;
- return -1;
- }
-
- *diffp = NULL;
- err = hwloc_diff_trees(topo1, hwloc_get_root_obj(topo1),
- topo2, hwloc_get_root_obj(topo2),
- flags,
- diffp, &lastdiff);
- if (!err) {
- tmpdiff = *diffp;
- while (tmpdiff) {
- if (tmpdiff->generic.type == HWLOC_TOPOLOGY_DIFF_TOO_COMPLEX) {
- err = 1;
- break;
- }
- tmpdiff = tmpdiff->generic.next;
- }
- }
-
- if (!err) {
- if (SETS_DIFFERENT(allowed_cpuset, topo1, topo2)
- || SETS_DIFFERENT(allowed_nodeset, topo1, topo2))
- goto roottoocomplex;
- }
-
- if (!err) {
- /* distances */
- hwloc_internal_distances_refresh(topo1);
- hwloc_internal_distances_refresh(topo2);
- dist1 = topo1->first_dist;
- dist2 = topo2->first_dist;
- while (dist1 || dist2) {
- if (!!dist1 != !!dist2)
- goto roottoocomplex;
- if (dist1->unique_type != dist2->unique_type
- || dist1->different_types || dist2->different_types /* too lazy to support this case */
- || dist1->nbobjs != dist2->nbobjs
- || dist1->kind != dist2->kind
- || memcmp(dist1->values, dist2->values, dist1->nbobjs * dist1->nbobjs * sizeof(*dist1->values)))
- goto roottoocomplex;
- for(i=0; i<dist1->nbobjs; i++)
- /* gp_index isn't enforced above. so compare logical_index instead, which is enforced. requires distances refresh() above */
- if (dist1->objs[i]->logical_index != dist2->objs[i]->logical_index)
- goto roottoocomplex;
- dist1 = dist1->next;
- dist2 = dist2->next;
- }
- }
-
- if (!err) {
- /* memattrs */
- hwloc_internal_memattrs_refresh(topo1);
- hwloc_internal_memattrs_refresh(topo2);
- if (topo1->nr_memattrs != topo2->nr_memattrs)
- goto roottoocomplex;
- for(i=0; i<topo1->nr_memattrs; i++) {
- struct hwloc_internal_memattr_s *imattr1 = &topo1->memattrs[i], *imattr2 = &topo2->memattrs[i];
- unsigned j;
- if (strcmp(imattr1->name, imattr2->name)
- || imattr1->flags != imattr2->flags
- || imattr1->nr_targets != imattr2->nr_targets)
- goto roottoocomplex;
- if (i == HWLOC_MEMATTR_ID_CAPACITY
- || i == HWLOC_MEMATTR_ID_LOCALITY)
- /* no need to check virtual attributes, there were refreshed from other topology attributes, checked above */
- continue;
- for(j=0; j<imattr1->nr_targets; j++) {
- struct hwloc_internal_memattr_target_s *imtg1 = &imattr1->targets[j], *imtg2 = &imattr2->targets[j];
- if (imtg1->type != imtg2->type)
- goto roottoocomplex;
- if (imtg1->obj->logical_index != imtg2->obj->logical_index)
- goto roottoocomplex;
- if (imattr1->flags & HWLOC_MEMATTR_FLAG_NEED_INITIATOR) {
- unsigned k;
- for(k=0; k<imtg1->nr_initiators; k++) {
- struct hwloc_internal_memattr_initiator_s *imi1 = &imtg1->initiators[k], *imi2 = &imtg2->initiators[k];
- if (imi1->value != imi2->value
- || imi1->initiator.type != imi2->initiator.type)
- goto roottoocomplex;
- if (imi1->initiator.type == HWLOC_LOCATION_TYPE_CPUSET) {
- if (!hwloc_bitmap_isequal(imi1->initiator.location.cpuset, imi2->initiator.location.cpuset))
- goto roottoocomplex;
- } else if (imi1->initiator.type == HWLOC_LOCATION_TYPE_OBJECT) {
- if (imi1->initiator.location.object.type != imi2->initiator.location.object.type)
- goto roottoocomplex;
- if (imi1->initiator.location.object.obj->logical_index != imi2->initiator.location.object.obj->logical_index)
- goto roottoocomplex;
- } else {
- assert(0);
- }
- }
- } else {
- if (imtg1->noinitiator_value != imtg2->noinitiator_value)
- goto roottoocomplex;
- }
- }
- }
- }
-
- if (!err) {
- /* cpukinds */
- if (topo1->nr_cpukinds != topo2->nr_cpukinds)
- goto roottoocomplex;
- for(i=0; i<topo1->nr_cpukinds; i++) {
- struct hwloc_internal_cpukind_s *ic1 = &topo1->cpukinds[i];
- struct hwloc_internal_cpukind_s *ic2 = &topo2->cpukinds[i];
- unsigned j;
- if (!hwloc_bitmap_isequal(ic1->cpuset, ic2->cpuset)
- || ic1->efficiency != ic2->efficiency
- || ic1->forced_efficiency != ic2->forced_efficiency
- || ic1->ranking_value != ic2->ranking_value
- || ic1->nr_infos != ic2->nr_infos)
- goto roottoocomplex;
- for(j=0; j<ic1->nr_infos; j++) {
- struct hwloc_info_s *info1 = &ic1->infos[j], *info2 = &ic2->infos[j];
- if (strcmp(info1->name, info2->name)
- || strcmp(info1->value, info2->value)) {
- goto roottoocomplex;
- }
- }
- }
- }
-
- return err;
-
- roottoocomplex:
- hwloc_append_diff_too_complex(hwloc_get_root_obj(topo1), diffp, &lastdiff);
- return 1;
-}
-
-/********************
- * Applying diffs
- */
-
-static int
-hwloc_apply_diff_one(hwloc_topology_t topology,
- hwloc_topology_diff_t diff,
- unsigned long flags)
-{
- int reverse = !!(flags & HWLOC_TOPOLOGY_DIFF_APPLY_REVERSE);
-
- switch (diff->generic.type) {
- case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR: {
- struct hwloc_topology_diff_obj_attr_s *obj_attr = &diff->obj_attr;
- hwloc_obj_t obj = hwloc_get_obj_by_depth(topology, obj_attr->obj_depth, obj_attr->obj_index);
- if (!obj)
- return -1;
-
- switch (obj_attr->diff.generic.type) {
- case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_SIZE: {
- hwloc_obj_t tmpobj;
- hwloc_uint64_t oldvalue = reverse ? obj_attr->diff.uint64.newvalue : obj_attr->diff.uint64.oldvalue;
- hwloc_uint64_t newvalue = reverse ? obj_attr->diff.uint64.oldvalue : obj_attr->diff.uint64.newvalue;
- hwloc_uint64_t valuediff = newvalue - oldvalue;
- if (obj->type != HWLOC_OBJ_NUMANODE)
- return -1;
- if (obj->attr->numanode.local_memory != oldvalue)
- return -1;
- obj->attr->numanode.local_memory = newvalue;
- tmpobj = obj;
- while (tmpobj) {
- tmpobj->total_memory += valuediff;
- tmpobj = tmpobj->parent;
- }
- break;
- }
- case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_NAME: {
- const char *oldvalue = reverse ? obj_attr->diff.string.newvalue : obj_attr->diff.string.oldvalue;
- const char *newvalue = reverse ? obj_attr->diff.string.oldvalue : obj_attr->diff.string.newvalue;
- if (!obj->name || strcmp(obj->name, oldvalue))
- return -1;
- free(obj->name);
- obj->name = strdup(newvalue);
- break;
- }
- case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO: {
- const char *name = obj_attr->diff.string.name;
- const char *oldvalue = reverse ? obj_attr->diff.string.newvalue : obj_attr->diff.string.oldvalue;
- const char *newvalue = reverse ? obj_attr->diff.string.oldvalue : obj_attr->diff.string.newvalue;
- unsigned i;
- int found = 0;
- for(i=0; i<obj->infos_count; i++) {
- struct hwloc_info_s *info = &obj->infos[i];
- if (!strcmp(info->name, name)
- && !strcmp(info->value, oldvalue)) {
- free(info->value);
- info->value = strdup(newvalue);
- found = 1;
- break;
- }
- }
- if (!found)
- return -1;
- break;
- }
- default:
- return -1;
- }
-
- break;
- }
- default:
- return -1;
- }
-
- return 0;
-}
-
-int hwloc_topology_diff_apply(hwloc_topology_t topology,
- hwloc_topology_diff_t diff,
- unsigned long flags)
-{
- hwloc_topology_diff_t tmpdiff, tmpdiff2;
- int err, nr;
-
- if (!topology->is_loaded) {
- errno = EINVAL;
- return -1;
- }
- if (topology->adopted_shmem_addr) {
- errno = EPERM;
- return -1;
- }
-
- if (flags & ~HWLOC_TOPOLOGY_DIFF_APPLY_REVERSE) {
- errno = EINVAL;
- return -1;
- }
-
- tmpdiff = diff;
- nr = 0;
- while (tmpdiff) {
- nr++;
- err = hwloc_apply_diff_one(topology, tmpdiff, flags);
- if (err < 0)
- goto cancel;
- tmpdiff = tmpdiff->generic.next;
- }
- return 0;
-
-cancel:
- tmpdiff2 = tmpdiff;
- tmpdiff = diff;
- while (tmpdiff != tmpdiff2) {
- hwloc_apply_diff_one(topology, tmpdiff, flags ^ HWLOC_TOPOLOGY_DIFF_APPLY_REVERSE);
- tmpdiff = tmpdiff->generic.next;
- }
- errno = EINVAL;
- return -nr; /* return the index (starting at 1) of the first element that couldn't be applied */
-}
### src/3rdparty/hwloc/src/distances.c
@@ -1,1495 +0,0 @@
-/*
- * Copyright © 2010-2025 Inria. All rights reserved.
- * Copyright © 2011-2012 Université Bordeaux
- * Copyright © 2011 Cisco Systems, Inc. All rights reserved.
- * See COPYING in top-level directory.
- */
-
-#include "private/autogen/config.h"
-#include "hwloc.h"
-#include "private/private.h"
-#include "private/debug.h"
-#include "private/misc.h"
-
-#include <float.h>
-#include <math.h>
-
-static struct hwloc_internal_distances_s *
-hwloc__internal_distances_from_public(hwloc_topology_t topology, struct hwloc_distances_s *distances);
-
-static void
-hwloc__groups_by_distances(struct hwloc_topology *topology, unsigned nbobjs, struct hwloc_obj **objs, uint64_t *values, unsigned long kind, unsigned nbaccuracies, float *accuracies, int needcheck);
-
-static void
-hwloc_internal_distances_restrict(hwloc_obj_t *objs,
- uint64_t *indexes,
- hwloc_obj_type_t *different_types,
- uint64_t *values,
- unsigned nbobjs, unsigned disappeared);
-
-static void
-hwloc_internal_distances_print_matrix(struct hwloc_internal_distances_s *dist)
-{
- unsigned nbobjs = dist->nbobjs;
- hwloc_obj_t *objs = dist->objs;
- hwloc_uint64_t *values = dist->values;
- int gp = !HWLOC_DIST_TYPE_USE_OS_INDEX(dist->unique_type);
- unsigned i, j;
-
- fprintf(stderr, "%s", gp ? "gp_index" : "os_index");
- for(j=0; j<nbobjs; j++)
- fprintf(stderr, " % 5d", (int)(gp ? objs[j]->gp_index : objs[j]->os_index));
- fprintf(stderr, "\n");
- for(i=0; i<nbobjs; i++) {
- fprintf(stderr, " % 5d", (int)(gp ? objs[i]->gp_index : objs[i]->os_index));
- for(j=0; j<nbobjs; j++)
- fprintf(stderr, " % 5lld", (long long) values[i*nbobjs + j]);
- fprintf(stderr, "\n");
- }
-}
-
-/******************************************************
- * Global init, prepare, destroy, dup
- */
-
-/* called during topology init() */
-void hwloc_internal_distances_init(struct hwloc_topology *topology)
-{
- topology->first_dist = topology->last_dist = NULL;
- topology->next_dist_id = 0;
-}
-
-/* called at the beginning of load() */
-void hwloc_internal_distances_prepare(struct hwloc_topology *topology)
-{
- char *env;
- hwloc_localeswitch_declare;
-
- topology->grouping = 1;
- if (topology->type_filter[HWLOC_OBJ_GROUP] == HWLOC_TYPE_FILTER_KEEP_NONE)
- topology->grouping = 0;
- env = getenv("HWLOC_GROUPING");
- if (env && !atoi(env))
- topology->grouping = 0;
-
- if (topology->grouping) {
- topology->grouping_next_subkind = 0;
-
- HWLOC_BUILD_ASSERT(sizeof(topology->grouping_accuracies)/sizeof(*topology->grouping_accuracies) == 5);
- topology->grouping_accuracies[0] = 0.0f;
- topology->grouping_accuracies[1] = 0.01f;
- topology->grouping_accuracies[2] = 0.02f;
- topology->grouping_accuracies[3] = 0.05f;
- topology->grouping_accuracies[4] = 0.1f;
- topology->grouping_nbaccuracies = 5;
-
- hwloc_localeswitch_init();
- env = getenv("HWLOC_GROUPING_ACCURACY");
- if (!env) {
- /* only use 0.0 */
- topology->grouping_nbaccuracies = 1;
- } else if (strcmp(env, "try")) {
- /* use the given value */
- topology->grouping_nbaccuracies = 1;
- topology->grouping_accuracies[0] = (float) atof(env);
- } /* otherwise try all values */
- hwloc_localeswitch_fini();
-
- topology->grouping_verbose = 0;
- env = getenv("HWLOC_GROUPING_VERBOSE");
- if (env)
- topology->grouping_verbose = atoi(env);
- }
-}
-
-static void hwloc_internal_distances_free(struct hwloc_internal_distances_s *dist)
-{
- free(dist->name);
- free(dist->different_types);
- free(dist->indexes);
- free(dist->objs);
- free(dist->values);
- free(dist);
-}
-
-/* called during topology destroy */
-void hwloc_internal_distances_destroy(struct hwloc_topology * topology)
-{
- struct hwloc_internal_distances_s *dist, *next = topology->first_dist;
- while ((dist = next) != NULL) {
- next = dist->next;
- hwloc_internal_distances_free(dist);
- }
- topology->first_dist = topology->last_dist = NULL;
-}
-
-static int hwloc_internal_distances_dup_one(struct hwloc_topology *new, struct hwloc_internal_distances_s *olddist)
-{
- struct hwloc_tma *tma = new->tma;
- struct hwloc_internal_distances_s *newdist;
- unsigned nbobjs = olddist->nbobjs;
-
- newdist = hwloc_tma_malloc(tma, sizeof(*newdist));
- if (!newdist)
- return -1;
- if (olddist->name) {
- newdist->name = hwloc_tma_strdup(tma, olddist->name);
- if (!newdist->name) {
- assert(!tma || !tma->dontfree); /* this tma cannot fail to allocate */
- hwloc_internal_distances_free(newdist);
- return -1;
- }
- } else {
- newdist->name = NULL;
- }
-
- if (olddist->different_types) {
- newdist->different_types = hwloc_tma_malloc(tma, nbobjs * sizeof(*newdist->different_types));
- if (!newdist->different_types) {
- assert(!tma || !tma->dontfree); /* this tma cannot fail to allocate */
- hwloc_internal_distances_free(newdist);
- return -1;
- }
- memcpy(newdist->different_types, olddist->different_types, nbobjs * sizeof(*newdist->different_types));
- } else
- newdist->different_types = NULL;
- newdist->unique_type = olddist->unique_type;
- newdist->nbobjs = nbobjs;
- newdist->kind = olddist->kind;
- newdist->id = olddist->id;
-
- newdist->indexes = hwloc_tma_malloc(tma, nbobjs * sizeof(*newdist->indexes));
- newdist->objs = hwloc_tma_calloc(tma, nbobjs * sizeof(*newdist->objs));
- newdist->iflags = olddist->iflags & ~HWLOC_INTERNAL_DIST_FLAG_OBJS_VALID; /* must be revalidated after dup() */
- newdist->values = hwloc_tma_malloc(tma, nbobjs*nbobjs * sizeof(*newdist->values));
- if (!newdist->indexes || !newdist->objs || !newdist->values) {
- assert(!tma || !tma->dontfree); /* this tma cannot fail to allocate */
- hwloc_internal_distances_free(newdist);
- return -1;
- }
-
- memcpy(newdist->indexes, olddist->indexes, nbobjs * sizeof(*newdist->indexes));
- memcpy(newdist->values, olddist->values, nbobjs*nbobjs * sizeof(*newdist->values));
-
- newdist->next = NULL;
- newdist->prev = new->last_dist;
- if (new->last_dist)
- new->last_dist->next = newdist;
- else
- new->first_dist = newdist;
- new->last_dist = newdist;
-
- return 0;
-}
-
-/* This function may be called with topology->tma set, it cannot free() or realloc() */
-int hwloc_internal_distances_dup(struct hwloc_topology *new, struct hwloc_topology *old)
-{
- struct hwloc_internal_distances_s *olddist;
- int err;
- new->next_dist_id = old->next_dist_id;
- for(olddist = old->first_dist; olddist; olddist = olddist->next) {
- err = hwloc_internal_distances_dup_one(new, olddist);
- if (err < 0)
- return err;
- }
- return 0;
-}
-
-/******************************************************
- * Remove distances from the topology
- */
-
-int hwloc_distances_remove(hwloc_topology_t topology)
-{
- if (!topology->is_loaded) {
- errno = EINVAL;
- return -1;
- }
- if (topology->adopted_shmem_addr) {
- errno = EPERM;
- return -1;
- }
- hwloc_internal_distances_destroy(topology);
- return 0;
-}
-
-int hwloc_distances_remove_by_depth(hwloc_topology_t topology, int depth)
-{
- struct hwloc_internal_distances_s *dist, *next;
- hwloc_obj_type_t type;
-
- if (!topology->is_loaded) {
- errno = EINVAL;
- return -1;
- }
- if (topology->adopted_shmem_addr) {
- errno = EPERM;
- return -1;
- }
-
- /* switch back to types since we don't support groups for now */
- type = hwloc_get_depth_type(topology, depth);
- if (type == (hwloc_obj_type_t)-1) {
- errno = EINVAL;
- return -1;
- }
-
- next = topology->first_dist;
- while ((dist = next) != NULL) {
- next = dist->next;
- if (dist->unique_type == type) {
- if (next)
- next->prev = dist->prev;
- else
- topology->last_dist = dist->prev;
- if (dist->prev)
- dist->prev->next = dist->next;
- else
- topology->first_dist = dist->next;
- hwloc_internal_distances_free(dist);
- }
- }
-
- return 0;
-}
-
-int hwloc_distances_release_remove(hwloc_topology_t topology,
- struct hwloc_distances_s *distances)
-{
- struct hwloc_internal_distances_s *dist = hwloc__internal_distances_from_public(topology, distances);
- if (!dist) {
- errno = EINVAL;
- return -1;
- }
- if (dist->prev)
- dist->prev->next = dist->next;
- else
- topology->first_dist = dist->next;
- if (dist->next)
- dist->next->prev = dist->prev;
- else
- topology->last_dist = dist->prev;
- hwloc_internal_distances_free(dist);
- hwloc_distances_release(topology, distances);
- return 0;
-}
-
-/*********************************************************
- * Backend functions for adding distances to the topology
- */
-
-/* cancel a distances handle. only needed internally for now */
-static void
-hwloc_backend_distances_add__cancel(struct hwloc_internal_distances_s *dist)
-{
- /* everything is set to NULL in hwloc_backend_distances_add_create() */
- free(dist->name);
- free(dist->indexes);
- free(dist->objs);
- free(dist->different_types);
- free(dist->values);
- free(dist);
-}
-
-/* prepare a distances handle for later commit in the topology.
- * we duplicate the caller's name.
- */
-hwloc_backend_distances_add_handle_t
-hwloc_backend_distances_add_create(hwloc_topology_t topology,
- const char *name, unsigned long kind, unsigned long flags)
-{
- struct hwloc_internal_distances_s *dist;
-
- if (flags) {
- errno = EINVAL;
- goto err;
- }
-
- dist = calloc(1, sizeof(*dist));
- if (!dist)
- goto err;
-
- if (name) {
- dist->name = strdup(name); /* ignore failure */
- if (!dist->name)
- goto err_with_dist;
- }
-
- dist->kind = kind;
- dist->iflags = HWLOC_INTERNAL_DIST_FLAG_NOT_COMMITTED;
-
- dist->unique_type = HWLOC_OBJ_TYPE_NONE;
- dist->different_types = NULL;
- dist->nbobjs = 0;
- dist->indexes = NULL;
- dist->objs = NULL;
- dist->values = NULL;
-
- dist->id = topology->next_dist_id++;
- return dist;
-
- err_with_dist:
- hwloc_backend_distances_add__cancel(dist);
- err:
- return NULL;
-}
-
-/* attach objects and values to a distances handle.
- * on success, objs and values arrays are attached and will be freed with the distances.
- * on failure, the handle is freed.
- */
-int
-hwloc_backend_distances_add_values(hwloc_topology_t topology __hwloc_attribute_unused,
- hwloc_backend_distances_add_handle_t handle,
- unsigned nbobjs, hwloc_obj_t *objs,
- hwloc_uint64_t *values,
- unsigned long flags)
-{
- struct hwloc_internal_distances_s *dist = handle;
- hwloc_obj_type_t unique_type, *different_types = NULL;
- hwloc_uint64_t *indexes = NULL;
- unsigned i, disappeared = 0;
-
- if (dist->nbobjs || !(dist->iflags & HWLOC_INTERNAL_DIST_FLAG_NOT_COMMITTED)) {
- /* target distances is already set */
- errno = EINVAL;
- goto err;
- }
-
- if (flags || nbobjs < 2 || !objs || !values) {
- errno = EINVAL;
- goto err;
- }
-
- /* is there any NULL object? (useful in case of problem during insert in backends) */
- for(i=0; i<nbobjs; i++)
- if (!objs[i])
- disappeared++;
- if (disappeared) {
- /* some objects are NULL */
- if (disappeared == nbobjs) {
- /* nothing left, drop the matrix */
- errno = ENOENT;
- goto err;
- }
- /* restrict the matrix */
- hwloc_internal_distances_restrict(objs, NULL, NULL, values, nbobjs, disappeared);
- nbobjs -= disappeared;
- }
-
- indexes = malloc(nbobjs * sizeof(*indexes));
- if (!indexes)
- goto err;
-
- unique_type = objs[0]->type;
- for(i=1; i<nbobjs; i++)
- if (objs[i]->type != unique_type) {
- unique_type = HWLOC_OBJ_TYPE_NONE;
- break;
- }
- if (unique_type == HWLOC_OBJ_TYPE_NONE) {
- /* heterogeneous types */
- different_types = malloc(nbobjs * sizeof(*different_types));
- if (!different_types)
- goto err_with_indexes;
- for(i=0; i<nbobjs; i++)
- different_types[i] = objs[i]->type;
- }
-
- dist->nbobjs = nbobjs;
- dist->objs = objs;
- dist->iflags |= HWLOC_INTERNAL_DIST_FLAG_OBJS_VALID;
- dist->indexes = indexes;
- dist->unique_type = unique_type;
- dist->different_types = different_types;
- dist->values = values;
-
- if (different_types)
- dist->kind |= HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES;
-
- if (HWLOC_DIST_TYPE_USE_OS_INDEX(dist->unique_type)) {
- for(i=0; i<nbobjs; i++)
- dist->indexes[i] = objs[i]->os_index;
- } else {
- for(i=0; i<nbobjs; i++)
- dist->indexes[i] = objs[i]->gp_index;
- }
-
- return 0;
-
- err_with_indexes:
- free(indexes);
- err:
- hwloc_backend_distances_add__cancel(dist);
- return -1;
-}
-
-/* attach objects and values to a distance handle.
- * on success, objs and values arrays are attached and will be freed with the distances.
- * on failure, the handle is freed.
- */
-static int
-hwloc_backend_distances_add_values_by_index(hwloc_topology_t topology __hwloc_attribute_unused,
- hwloc_backend_distances_add_handle_t handle,
- unsigned nbobjs, hwloc_obj_type_t unique_type, hwloc_obj_type_t *different_types, hwloc_uint64_t *indexes,
- hwloc_uint64_t *values)
-{
- struct hwloc_internal_distances_s *dist = handle;
- hwloc_obj_t *objs;
-
- if (dist->nbobjs || !(dist->iflags & HWLOC_INTERNAL_DIST_FLAG_NOT_COMMITTED)) {
- /* target distances is already set */
- errno = EINVAL;
- goto err;
- }
- if (nbobjs < 2 || !indexes || !values || (unique_type == HWLOC_OBJ_TYPE_NONE && !different_types)) {
- errno = EINVAL;
- goto err;
- }
-
- objs = malloc(nbobjs * sizeof(*objs));
- if (!objs)
- goto err;
-
- dist->nbobjs = nbobjs;
- dist->objs = objs;
- dist->indexes = indexes;
- dist->unique_type = unique_type;
- dist->different_types = different_types;
- dist->values = values;
-
- if (different_types)
- dist->kind |= HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES;
-
- return 0;
-
- err:
- hwloc_backend_distances_add__cancel(dist);
- return -1;
-}
-
-/* commit a distances handle.
- * on failure, the handle is freed with its objects and values arrays.
- */
-int
-hwloc_backend_distances_add_commit(hwloc_topology_t topology,
- hwloc_backend_distances_add_handle_t handle,
- unsigned long flags)
-{
- struct hwloc_internal_distances_s *dist = handle;
-
- if (!dist->nbobjs || !(dist->iflags & HWLOC_INTERNAL_DIST_FLAG_NOT_COMMITTED)) {
- /* target distances not ready for commit */
- errno = EINVAL;
- goto err;
- }
-
- if ((flags & HWLOC_DISTANCES_ADD_FLAG_GROUP) && !dist->objs) {
- /* cannot group without objects,
- * and we don't group from XML anyway since the hwloc that generated the XML should have grouped already.
- */
- errno = EINVAL;
- goto err;
- }
-
- if (topology->grouping && (flags & HWLOC_DISTANCES_ADD_FLAG_GROUP) && !dist->different_types) {
- float full_accuracy = 0.f;
- float *accuracies;
- unsigned nbaccuracies;
-
- if (flags & HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE) {
- accuracies = topology->grouping_accuracies;
- nbaccuracies = topology->grouping_nbaccuracies;
- } else {
- accuracies = &full_accuracy;
- nbaccuracies = 1;
- }
-
- if (topology->grouping_verbose) {
- fprintf(stderr, "Trying to group objects using distance matrix:\n");
- hwloc_internal_distances_print_matrix(dist);
- }
-
- hwloc__groups_by_distances(topology, dist->nbobjs, dist->objs, dist->values,
- dist->kind, nbaccuracies, accuracies, 1 /* check the first matrix */);
- }
-
- if (topology->last_dist)
- topology->last_dist->next = dist;
- else
- topology->first_dist = dist;
- dist->prev = topology->last_dist;
- dist->next = NULL;
- topology->last_dist = dist;
-
- dist->iflags &= ~HWLOC_INTERNAL_DIST_FLAG_NOT_COMMITTED;
- return 0;
-
- err:
- hwloc_backend_distances_add__cancel(dist);
- return -1;
-}
-
-/* all-in-one backend function not exported to plugins, only used by XML for now */
-int hwloc_internal_distances_add_by_index(hwloc_topology_t topology, const char *name,
- hwloc_obj_type_t unique_type, hwloc_obj_type_t *different_types, unsigned nbobjs, uint64_t *indexes, uint64_t *values,
- unsigned long kind, unsigned long flags)
-{
- hwloc_backend_distances_add_handle_t handle;
- int err;
-
- handle = hwloc_backend_distances_add_create(topology, name, kind, 0);
- if (!handle)
- goto err;
-
- err = hwloc_backend_distances_add_values_by_index(topology, handle,
- nbobjs, unique_type, different_types, indexes,
- values);
- if (err < 0)
- goto err;
-
- /* arrays are now attached to the handle */
- indexes = NULL;
- different_types = NULL;
- values = NULL;
-
- err = hwloc_backend_distances_add_commit(topology, handle, flags);
- if (err < 0)
- goto err;
-
- return 0;
-
- err:
- free(indexes);
- free(different_types);
- free(values);
- return -1;
-}
-
-/* all-in-one backend function not exported to plugins, used by OS backends */
-int hwloc_internal_distances_add(hwloc_topology_t topology, const char *name,
- unsigned nbobjs, hwloc_obj_t *objs, uint64_t *values,
- unsigned long kind, unsigned long flags)
-{
- hwloc_backend_distances_add_handle_t handle;
- int err;
-
- handle = hwloc_backend_distances_add_create(topology, name, kind, 0);
- if (!handle)
- goto err;
-
- err = hwloc_backend_distances_add_values(topology, handle,
- nbobjs, objs,
- values,
- 0);
- if (err < 0)
- goto err;
-
- /* arrays are now attached to the handle */
- objs = NULL;
- values = NULL;
-
- err = hwloc_backend_distances_add_commit(topology, handle, flags);
- if (err < 0)
- goto err;
-
- return 0;
-
- err:
- free(objs);
- free(values);
- return -1;
-}
-
-/********************************
- * User API for adding distances
- */
-
-#define HWLOC_DISTANCES_KIND_FROM_ALL (HWLOC_DISTANCES_KIND_FROM_OS|HWLOC_DISTANCES_KIND_FROM_USER)
-#define HWLOC_DISTANCES_KIND_MEANS_ALL (HWLOC_DISTANCES_KIND_MEANS_LATENCY|HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH)
-#define HWLOC_DISTANCES_KIND_ALL (HWLOC_DISTANCES_KIND_FROM_ALL|HWLOC_DISTANCES_KIND_MEANS_ALL|HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES)
-#define HWLOC_DISTANCES_ADD_FLAG_ALL (HWLOC_DISTANCES_ADD_FLAG_GROUP|HWLOC_DISTANCES_ADD_FLAG_GROUP_INACCURATE)
-
-void * hwloc_distances_add_create(hwloc_topology_t topology,
- const char *name, unsigned long kind,
- unsigned long flags)
-{
- if (!topology->is_loaded) {
- errno = EINVAL;
- return NULL;
- }
- if (topology->adopted_shmem_addr) {
- errno = EPERM;
- return NULL;
- }
- if ((kind & ~HWLOC_DISTANCES_KIND_ALL)
- || hwloc_weight_long(kind & HWLOC_DISTANCES_KIND_FROM_ALL) > 1
- || hwloc_weight_long(kind & HWLOC_DISTANCES_KIND_MEANS_ALL) > 1) {
- errno = EINVAL;
- return NULL;
- }
-
- return hwloc_backend_distances_add_create(topology, name, kind, flags);
-}
-
-int hwloc_distances_add_values(hwloc_topology_t topology,
- void *handle,
- unsigned nbobjs, hwloc_obj_t *objs,
- hwloc_uint64_t *values,
- unsigned long flags)
-{
- unsigned i;
- uint64_t *_values;
- hwloc_obj_t *_objs;
- int err;
-
- /* no strict need to check for duplicates, things shouldn't break */
-
- for(i=1; i<nbobjs; i++)
- if (!objs[i]) {
- errno = EINVAL;
- goto out;
- }
-
- /* copy the input arrays and give them to the topology */
- _objs = malloc(nbobjs*sizeof(hwloc_obj_t));
- _values = malloc(nbobjs*nbobjs*sizeof(*_values));
- if (!_objs || !_values)
- goto out_with_arrays;
-
- memcpy(_objs, objs, nbobjs*sizeof(hwloc_obj_t));
- memcpy(_values, values, nbobjs*nbobjs*sizeof(*_values));
-
- err = hwloc_backend_distances_add_values(topology, handle, nbobjs, _objs, _values, flags);
- if (err < 0) {
- /* handle was canceled inside hwloc_backend_distances_add_values */
- handle = NULL;
- goto out_with_arrays;
- }
-
- return 0;
-
- out_with_arrays:
- free(_objs);
- free(_values);
- out:
- if (handle)
- hwloc_backend_distances_add__cancel(handle);
- return -1;
-}
-
-int
-hwloc_distances_add_commit(hwloc_topology_t topology,
- void *handle,
- unsigned long flags)
-{
- int err;
-
- if (flags & ~HWLOC_DISTANCES_ADD_FLAG_ALL) {
- errno = EINVAL;
- goto out;
- }
-
- err = hwloc_backend_distances_add_commit(topology, handle, flags);
- if (err < 0) {
- /* handle was canceled inside hwloc_backend_distances_add_commit */
- handle = NULL;
- goto out;
- }
-
- /* in case we added some groups, see if we need to reconnect */
- hwloc__reconnect(topology, 0);
-
- return 0;
-
- out:
- if (handle)
- hwloc_backend_distances_add__cancel(handle);
- return -1;
-}
-
-/* deprecated all-in-one user function */
-int hwloc_distances_add(hwloc_topology_t topology,
- unsigned nbobjs, hwloc_obj_t *objs, hwloc_uint64_t *values,
- unsigned long kind, unsigned long flags)
-{
- void *handle;
- int err;
-
- handle = hwloc_distances_add_create(topology, NULL, kind, 0);
- if (!handle)
- return -1;
-
- err = hwloc_distances_add_values(topology, handle, nbobjs, objs, values, 0);
- if (err < 0)
- return -1;
-
- err = hwloc_distances_add_commit(topology, handle, flags);
- if (err < 0)
- return -1;
-
- return 0;
-}
-
-/******************************************************
- * Refresh objects in distances
- */
-
-static void
-hwloc_internal_distances_restrict(hwloc_obj_t *objs,
- uint64_t *indexes,
- hwloc_obj_type_t *different_types,
- uint64_t *values,
- unsigned nbobjs, unsigned disappeared)
-{
- unsigned i, newi;
- unsigned j, newj;
-
- for(i=0, newi=0; i<nbobjs; i++)
- if (objs[i]) {
- for(j=0, newj=0; j<nbobjs; j++)
- if (objs[j]) {
- values[newi*(nbobjs-disappeared)+newj] = values[i*nbobjs+j];
- newj++;
- }
- newi++;
- }
-
- for(i=0, newi=0; i<nbobjs; i++)
- if (objs[i]) {
- objs[newi] = objs[i];
- if (indexes)
- indexes[newi] = indexes[i];
- if (different_types)
- different_types[newi] = different_types[i];
- newi++;
- }
-}
-
-static int
-hwloc_internal_distances_refresh_one(hwloc_topology_t topology,
- struct hwloc_internal_distances_s *dist)
-{
- hwloc_obj_type_t unique_type = dist->unique_type;
- hwloc_obj_type_t *different_types = dist->different_types;
- unsigned nbobjs = dist->nbobjs;
- hwloc_obj_t *objs = dist->objs;
- uint64_t *indexes = dist->indexes;
- unsigned disappeared = 0;
- unsigned i;
-
- if (dist->iflags & HWLOC_INTERNAL_DIST_FLAG_OBJS_VALID)
- return 0;
-
- for(i=0; i<nbobjs; i++) {
- hwloc_obj_t obj;
- /* TODO use cpuset/nodeset to find pus/numas from the root?
- * faster than traversing the entire level?
- */
- if (HWLOC_DIST_TYPE_USE_OS_INDEX(unique_type)) {
- if (unique_type == HWLOC_OBJ_PU)
- obj = hwloc_get_pu_obj_by_os_index(topology, (unsigned) indexes[i]);
- else if (unique_type == HWLOC_OBJ_NUMANODE)
- obj = hwloc_get_numanode_obj_by_os_index(topology, (unsigned) indexes[i]);
- else
- abort();
- } else {
- obj = hwloc_get_obj_by_type_and_gp_index(topology, different_types ? different_types[i] : unique_type, indexes[i]);
- }
- objs[i] = obj;
- if (!obj)
- disappeared++;
- }
-
- if (nbobjs-disappeared < 2)
- /* became useless, drop */
- return -1;
-
- if (disappeared) {
- hwloc_internal_distances_restrict(objs, dist->indexes, dist->different_types, dist->values, nbobjs, disappeared);
- dist->nbobjs -= disappeared;
- }
-
- dist->iflags |= HWLOC_INTERNAL_DIST_FLAG_OBJS_VALID;
- return 0;
-}
-
-/* This function may be called with topology->tma set, it cannot free() or realloc() */
-void
-hwloc_internal_distances_refresh(hwloc_topology_t topology)
-{
- struct hwloc_internal_distances_s *dist, *next;
-
- for(dist = topology->first_dist; dist; dist = next) {
- next = dist->next;
-
- if (hwloc_internal_distances_refresh_one(topology, dist) < 0) {
- assert(!topology->tma || !topology->tma->dontfree); /* this tma cannot fail to allocate */
- if (dist->prev)
- dist->prev->next = next;
- else
- topology->first_dist = next;
- if (next)
- next->prev = dist->prev;
- else
- topology->last_dist = dist->prev;
- hwloc_internal_distances_free(dist);
- continue;
- }
- }
-}
-
-void
-hwloc_internal_distances_invalidate_cached_objs(hwloc_topology_t topology)
-{
- struct hwloc_internal_distances_s *dist;
- for(dist = topology->first_dist; dist; dist = dist->next)
- dist->iflags &= ~HWLOC_INTERNAL_DIST_FLAG_OBJS_VALID;
-}
-
-/******************************************************
- * User API for getting distances
- */
-
-/* what we actually allocate for user queries, even if we only
- * return the distances part of it.
- */
-struct hwloc_distances_container_s {
- unsigned id;
- struct hwloc_distances_s distances;
-};
-
-#define HWLOC_DISTANCES_CONTAINER_OFFSET ((uintptr_t)(&((struct hwloc_distances_container_s*)NULL)->distances) - (uintptr_t)NULL)
-#define HWLOC_DISTANCES_CONTAINER(_d) (struct hwloc_distances_container_s *) ( ((char*)_d) - HWLOC_DISTANCES_CONTAINER_OFFSET )
-
-static struct hwloc_internal_distances_s *
-hwloc__internal_distances_from_public(hwloc_topology_t topology, struct hwloc_distances_s *distances)
-{
- struct hwloc_distances_container_s *cont = HWLOC_DISTANCES_CONTAINER(distances);
- struct hwloc_internal_distances_s *dist;
- for(dist = topology->first_dist; dist; dist = dist->next)
- if (dist->id == cont->id)
- return dist;
- return NULL;
-}
-
-void
-hwloc_distances_release(hwloc_topology_t topology __hwloc_attribute_unused,
- struct hwloc_distances_s *distances)
-{
- struct hwloc_distances_container_s *cont = HWLOC_DISTANCES_CONTAINER(distances);
- free(distances->values);
- free(distances->objs);
- free(cont);
-}
-
-const char *
-hwloc_distances_get_name(hwloc_topology_t topology, struct hwloc_distances_s *distances)
-{
- struct hwloc_internal_distances_s *dist = hwloc__internal_distances_from_public(topology, distances);
- return dist ? dist->name : NULL;
-}
-
-static struct hwloc_distances_s *
-hwloc_distances_get_one(hwloc_topology_t topology __hwloc_attribute_unused,
- struct hwloc_internal_distances_s *dist)
-{
- struct hwloc_distances_container_s *cont;
- struct hwloc_distances_s *distances;
- unsigned nbobjs;
-
- cont = malloc(sizeof(*cont));
- if (!cont)
- return NULL;
- distances = &cont->distances;
-
- nbobjs = distances->nbobjs = dist->nbobjs;
-
- distances->objs = malloc(nbobjs * sizeof(hwloc_obj_t));
- if (!distances->objs)
- goto out;
- memcpy(distances->objs, dist->objs, nbobjs * sizeof(hwloc_obj_t));
-
- distances->values = malloc(nbobjs * nbobjs * sizeof(*distances->values));
- if (!distances->values)
- goto out_with_objs;
- memcpy(distances->values, dist->values, nbobjs*nbobjs*sizeof(*distances->values));
-
- distances->kind = dist->kind;
-
- cont->id = dist->id;
- return distances;
-
- out_with_objs:
- free(distances->objs);
- out:
- free(cont);
- return NULL;
-}
-
-static int
-hwloc__distances_get(hwloc_topology_t topology,
- const char *name, hwloc_obj_type_t type,
- unsigned *nrp, struct hwloc_distances_s **distancesp,
- unsigned long kind, unsigned long flags __hwloc_attribute_unused)
-{
- struct hwloc_internal_distances_s *dist;
- unsigned nr = 0, i;
-
- /* We could return the internal arrays (as const),
- * but it would require to prevent removing distances between get() and free().
- * Not performance critical anyway.
- */
-
- if (flags) {
- errno = EINVAL;
- return -1;
- }
-
- /* we could refresh only the distances that match, but we won't have many distances anyway,
- * so performance is totally negligible.
- *
- * This is also useful in multithreaded apps that modify the topology.
- * They can call any valid hwloc_distances_get() to force a refresh after
- * changing the topology, so that future concurrent get() won't cause
- * concurrent refresh().
- */
- hwloc_internal_distances_refresh(topology);
-
- for(dist = topology->first_dist; dist; dist = dist->next) {
- unsigned long kind_from = kind & HWLOC_DISTANCES_KIND_FROM_ALL;
- unsigned long kind_means = kind & HWLOC_DISTANCES_KIND_MEANS_ALL;
-
- if (name && (!dist->name || strcmp(name, dist->name)))
- continue;
-
- if (type != HWLOC_OBJ_TYPE_NONE && type != dist->unique_type)
- continue;
-
- if (kind_from && !(kind_from & dist->kind))
- continue;
- if (kind_means && !(kind_means & dist->kind))
- continue;
-
- if (nr < *nrp) {
- struct hwloc_distances_s *distances = hwloc_distances_get_one(topology, dist);
- if (!distances)
- goto error;
- distancesp[nr] = distances;
- }
- nr++;
- }
-
- for(i=nr; i<*nrp; i++)
- distancesp[i] = NULL;
- *nrp = nr;
- return 0;
-
- error:
- for(i=0; i<nr; i++)
- hwloc_distances_release(topology, distancesp[i]);
- return -1;
-}
-
-int
-hwloc_distances_get(hwloc_topology_t topology,
- unsigned *nrp, struct hwloc_distances_s **distancesp,
- unsigned long kind, unsigned long flags)
-{
- if (flags || !topology->is_loaded) {
- errno = EINVAL;
- return -1;
- }
-
- return hwloc__distances_get(topology, NULL, HWLOC_OBJ_TYPE_NONE, nrp, distancesp, kind, flags);
-}
-
-int
-hwloc_distances_get_by_depth(hwloc_topology_t topology, int depth,
- unsigned *nrp, struct hwloc_distances_s **distancesp,
- unsigned long kind, unsigned long flags)
-{
- hwloc_obj_type_t type;
-
- if (flags || !topology->is_loaded) {
- errno = EINVAL;
- return -1;
- }
-
- /* FIXME: passing the depth of a group level may return group distances at a different depth */
- type = hwloc_get_depth_type(topology, depth);
- if (type == (hwloc_obj_type_t)-1) {
- errno = EINVAL;
- return -1;
- }
-
- return hwloc__distances_get(topology, NULL, type, nrp, distancesp, kind, flags);
-}
-
-int
-hwloc_distances_get_by_name(hwloc_topology_t topology, const char *name,
- unsigned *nrp, struct hwloc_distances_s **distancesp,
- unsigned long flags)
-{
- if (flags || !topology->is_loaded) {
- errno = EINVAL;
- return -1;
- }
-
- return hwloc__distances_get(topology, name, HWLOC_OBJ_TYPE_NONE, nrp, distancesp, HWLOC_DISTANCES_KIND_ALL, flags);
-}
-
-int
-hwloc_distances_get_by_type(hwloc_topology_t topology, hwloc_obj_type_t type,
- unsigned *nrp, struct hwloc_distances_s **distancesp,
- unsigned long kind, unsigned long flags)
-{
- if (flags || !topology->is_loaded) {
- errno = EINVAL;
- return -1;
- }
-
- return hwloc__distances_get(topology, NULL, type, nrp, distancesp, kind, flags);
-}
-
-/******************************************************
- * Grouping objects according to distances
- */
-
-static int hwloc_compare_values(uint64_t a, uint64_t b, float accuracy)
-{
- if (accuracy != 0.0f && fabsf((float)a-(float)b) < (float)a * accuracy)
- return 0;
- return a < b ? -1 : a == b ? 0 : 1;
-}
-
-/*
- * Place objects in groups if they are in a transitive graph of minimal values.
- * Return how many groups were created, or 0 if some incomplete distance graphs were found.
- */
-static unsigned
-hwloc__find_groups_by_min_distance(unsigned nbobjs,
- uint64_t *_values,
- float accuracy,
- unsigned *groupids,
- int verbose)
-{
- uint64_t min_distance = UINT64_MAX;
- unsigned groupid = 1;
- unsigned i,j,k;
- unsigned skipped = 0;
-
-#define VALUE(i, j) _values[(i) * nbobjs + (j)]
-
- memset(groupids, 0, nbobjs*sizeof(*groupids));
-
- /* find the minimal distance */
- for(i=0; i<nbobjs; i++)
- for(j=0; j<nbobjs; j++) /* check the entire matrix, it may not be perfectly symmetric depending on the accuracy */
- if (i != j && VALUE(i, j) < min_distance) /* no accuracy here, we want the real minimal */
- min_distance = VALUE(i, j);
- hwloc_debug(" found minimal distance %llu between objects\n", (unsigned long long) min_distance);
-
- if (min_distance == UINT64_MAX)
- return 0;
-
- /* build groups of objects connected with this distance */
- for(i=0; i<nbobjs; i++) {
- unsigned size;
- unsigned firstfound;
-
- /* if already grouped, skip */
- if (groupids[i])
- continue;
-
- /* start a new group */
- groupids[i] = groupid;
- size = 1;
- firstfound = i;
-
- while (firstfound != (unsigned)-1) {
- /* we added new objects to the group, the first one was firstfound.
- * rescan all connections from these new objects (starting at first found) to any other objects,
- * so as to find new objects minimally-connected by transivity.
- */
- unsigned newfirstfound = (unsigned)-1;
- for(j=firstfound; j<nbobjs; j++)
- if (groupids[j] == groupid)
- for(k=0; k<nbobjs; k++)
- if (!groupids[k] && !hwloc_compare_values(VALUE(j, k), min_distance, accuracy)) {
- groupids[k] = groupid;
- size++;
- if (newfirstfound == (unsigned)-1)
- newfirstfound = k;
- if (i == j)
- hwloc_debug(" object %u is minimally connected to %u\n", k, i);
- else
- hwloc_debug(" object %u is minimally connected to %u through %u\n", k, i, j);
- }
- firstfound = newfirstfound;
- }
-
- if (size == 1) {
- /* cancel this useless group, ignore this object and try from the next one */
- groupids[i] = 0;
- skipped++;
- continue;
- }
-
- /* valid this group */
- groupid++;
- if (verbose)
- fprintf(stderr, " Found transitive graph with %u objects with minimal distance %llu accuracy %f\n",
- size, (unsigned long long) min_distance, accuracy);
- }
-
- if (groupid == 2 && !skipped)
- /* we created a single group containing all objects, ignore it */
- return 0;
-
- /* return the last id, since it's also the number of used group ids */
- return groupid-1;
-}
-
-/* check that the matrix is ok */
-static int
-hwloc__check_grouping_matrix(unsigned nbobjs, uint64_t *_values, float accuracy, int verbose)
-{
- unsigned i,j;
- for(i=0; i<nbobjs; i++) {
- for(j=i+1; j<nbobjs; j++) {
- /* should be symmetric */
- if (hwloc_compare_values(VALUE(i, j), VALUE(j, i), accuracy)) {
- if (verbose)
- fprintf(stderr, " Distance matrix asymmetric ([%u,%u]=%llu != [%u,%u]=%llu), aborting\n",
- i, j, (unsigned long long) VALUE(i, j), j, i, (unsigned long long) VALUE(j, i));
- return -1;
- }
- /* diagonal is smaller than everything else */
- if (hwloc_compare_values(VALUE(i, j), VALUE(i, i), accuracy) <= 0) {
- if (verbose)
- fprintf(stderr, " Distance to self not strictly minimal ([%u,%u]=%llu <= [%u,%u]=%llu), aborting\n",
- i, j, (unsigned long long) VALUE(i, j), i, i, (unsigned long long) VALUE(i, i));
- return -1;
- }
- }
- }
- return 0;
-}
-
-/*
- * Look at object physical distances to group them.
- */
-static void
-hwloc__groups_by_distances(struct hwloc_topology *topology,
- unsigned nbobjs,
- struct hwloc_obj **objs,
- uint64_t *_values,
- unsigned long kind,
- unsigned nbaccuracies,
- float *accuracies,
- int needcheck)
-{
- unsigned *groupids;
- unsigned nbgroups = 0;
- unsigned i,j;
- int verbose = topology->grouping_verbose;
- hwloc_obj_t *groupobjs;
- unsigned * groupsizes;
- uint64_t *groupvalues;
- unsigned failed = 0;
-
- if (nbobjs <= 2)
- return;
-
- if (!(kind & HWLOC_DISTANCES_KIND_MEANS_LATENCY))
- /* don't know use to use those for grouping */
- /* TODO hwloc__find_groups_by_max_distance() for bandwidth */
- return;
-
- groupids = malloc(nbobjs * sizeof(*groupids));
- if (!groupids)
- return;
-
- for(i=0; i<nbaccuracies; i++) {
- if (verbose)
- fprintf(stderr, "Trying to group %u %s objects according to physical distances with accuracy %f\n",
- nbobjs, hwloc_obj_type_string(objs[0]->type), accuracies[i]);
- if (needcheck && hwloc__check_grouping_matrix(nbobjs, _values, accuracies[i], verbose) < 0)
- continue;
- nbgroups = hwloc__find_groups_by_min_distance(nbobjs, _values, accuracies[i], groupids, verbose);
- if (nbgroups)
- break;
- }
- if (!nbgroups)
- goto out_with_groupids;
-
- groupobjs = malloc(nbgroups * sizeof(*groupobjs));
- groupsizes = malloc(nbgroups * sizeof(*groupsizes));
- groupvalues = malloc(nbgroups * nbgroups * sizeof(*groupvalues));
- if (!groupobjs || !groupsizes || !groupvalues)
- goto out_with_groups;
-
- /* create new Group objects and record their size */
- memset(&(groupsizes[0]), 0, sizeof(groupsizes[0]) * nbgroups);
- for(i=0; i<nbgroups; i++) {
- /* create the Group object */
- hwloc_obj_t group_obj, res_obj;
- group_obj = hwloc_alloc_setup_object(topology, HWLOC_OBJ_GROUP, HWLOC_UNKNOWN_INDEX);
- group_obj->cpuset = hwloc_bitmap_alloc();
- group_obj->attr->group.kind = HWLOC_GROUP_KIND_DISTANCE;
- group_obj->attr->group.subkind = topology->grouping_next_subkind;
- for (j=0; j<nbobjs; j++)
- if (groupids[j] == i+1) {
- /* assemble the group sets */
- hwloc_obj_add_other_obj_sets(group_obj, objs[j]);
- groupsizes[i]++;
- }
- hwloc_debug_1arg_bitmap("adding Group object with %u objects and cpuset %s\n",
- groupsizes[i], group_obj->cpuset);
- res_obj = hwloc__insert_object_by_cpuset(topology, NULL, group_obj,
- (kind & HWLOC_DISTANCES_KIND_FROM_USER) ? "distances:fromuser:group" : "distances:group");
- /* res_obj may be NULL on failure to insert. */
- if (!res_obj)
- failed++;
- /* or it may be different from groupobjs if we got groups from XML import before grouping */
- groupobjs[i] = res_obj;
- }
- topology->grouping_next_subkind++;
-
- if (failed)
- /* don't try to group above if we got a NULL group here, just keep this incomplete level */
- goto out_with_groups;
-
- /* factorize values */
- memset(&(groupvalues[0]), 0, sizeof(groupvalues[0]) * nbgroups * nbgroups);
-#undef VALUE
-#define VALUE(i, j) _values[(i) * nbobjs + (j)]
-#define GROUP_VALUE(i, j) groupvalues[(i) * nbgroups + (j)]
- for(i=0; i<nbobjs; i++)
- if (groupids[i])
- for(j=0; j<nbobjs; j++)
- if (groupids[j])
- GROUP_VALUE(groupids[i]-1, groupids[j]-1) += VALUE(i, j);
- for(i=0; i<nbgroups; i++)
- for(j=0; j<nbgroups; j++) {
- unsigned groupsize = groupsizes[i]*groupsizes[j];
- GROUP_VALUE(i, j) /= groupsize;
- }
-#ifdef HWLOC_DEBUG
- hwloc_debug("%s", "generated new distance matrix between groups:\n");
- hwloc_debug("%s", " index");
- for(j=0; j<nbgroups; j++)
- hwloc_debug(" % 5d", (int) j); /* print index because os_index is -1 for Groups */
- hwloc_debug("%s", "\n");
- for(i=0; i<nbgroups; i++) {
- hwloc_debug(" % 5d", (int) i);
- for(j=0; j<nbgroups; j++)
- hwloc_debug(" %llu", (unsigned long long) GROUP_VALUE(i, j));
- hwloc_debug("%s", "\n");
- }
-#endif
-
- hwloc__groups_by_distances(topology, nbgroups, groupobjs, groupvalues, kind, nbaccuracies, accuracies, 0 /* no need to check generated matrix */);
-
- out_with_groups:
- free(groupobjs);
- free(groupsizes);
- free(groupvalues);
- out_with_groupids:
- free(groupids);
-}
-
-static int
-hwloc__distances_transform_remove_null(struct hwloc_distances_s *distances)
-{
- hwloc_uint64_t *values = distances->values;
- hwloc_obj_t *objs = distances->objs;
- unsigned i, nb, nbobjs = distances->nbobjs;
- hwloc_obj_type_t unique_type;
-
- for(i=0, nb=0; i<nbobjs; i++)
- if (objs[i])
- nb++;
-
- if (nb < 2) {
- errno = EINVAL;
- return -1;
- }
-
- if (nb == nbobjs)
- return 0;
-
- hwloc_internal_distances_restrict(objs, NULL, NULL, values, nbobjs, nbobjs-nb);
- distances->nbobjs = nb;
-
- /* update HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES for convenience */
- unique_type = objs[0]->type;
- for(i=1; i<nb; i++)
- if (objs[i]->type != unique_type) {
- unique_type = HWLOC_OBJ_TYPE_NONE;
- break;
- }
- if (unique_type == HWLOC_OBJ_TYPE_NONE)
- distances->kind |= HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES;
- else
- distances->kind &= ~HWLOC_DISTANCES_KIND_HETEROGENEOUS_TYPES;
-
- return 0;
-}
-
-static int
-hwloc__distances_transform_links(struct hwloc_distances_s *distances)
-{
- /* FIXME: we should look for the greatest common denominator
- * but we just use the smallest positive value, that's enough for current use-cases.
- * We'll return -1 in other cases.
- */
- hwloc_uint64_t divider, *values = distances->values;
- unsigned i, nbobjs = distances->nbobjs;
-
- if (!(distances->kind & HWLOC_DISTANCES_KIND_MEANS_BANDWIDTH)) {
- errno = EINVAL;
- return -1;
- }
-
- for(i=0; i<nbobjs; i++)
- values[i*nbobjs+i] = 0;
-
- /* find the smallest positive value */
- divider = 0;
- for(i=0; i<nbobjs*nbobjs; i++)
- if (values[i] && (!divider || values[i] < divider))
- divider = values[i];
-
- if (!divider)
- /* only zeroes? do nothing */
- return 0;
-
- /* check it divides all values */
- for(i=0; i<nbobjs*nbobjs; i++)
- if (values[i]%divider) {
- errno = ENOENT;
- return -1;
- }
-
- /* ok, now divide for real */
- for(i=0; i<nbobjs*nbobjs; i++)
- values[i] /= divider;
-
- return 0;
-}
-
-static __hwloc_inline int is_nvswitch(hwloc_obj_t obj)
-{
- return obj && obj->subtype && !strcmp(obj->subtype, "NVSwitch");
-}
-
-static int
-hwloc__distances_transform_merge_switch_ports(struct hwloc_distances_s *distances)
-{
- hwloc_obj_t *objs = distances->objs;
- hwloc_uint64_t *values = distances->values;
- unsigned first, i, j, nbobjs = distances->nbobjs;
-
- /* find the first port */
- first = (unsigned) -1;
- for(i=0; i<nbobjs; i++)
- if (is_nvswitch(objs[i])) {
- first = i;
- break;
- }
- if (first == (unsigned)-1) {
- errno = ENOENT;
- return -1;
- }
-
- for(j=i+1; j<nbobjs; j++) {
- if (is_nvswitch(objs[j])) {
- /* another port, merge it */
- unsigned k;
- for(k=0; k<nbobjs; k++) {
- if (k==i || k==j)
- continue;
- values[k*nbobjs+i] += values[k*nbobjs+j];
- values[k*nbobjs+j] = 0;
- values[i*nbobjs+k] += values[j*nbobjs+k];
- values[j*nbobjs+k] = 0;
- }
- values[i*nbobjs+i] += values[j*nbobjs+j];
- values[j*nbobjs+j] = 0;
- }
- /* the caller will also call REMOVE_NULL to remove other ports */
- objs[j] = NULL;
- }
-
- return 0;
-}
-
-static int
-hwloc__distances_transform_transitive_closure(struct hwloc_distances_s *distances)
-{
- hwloc_obj_t *objs = distances->objs;
- hwloc_uint64_t *values = distances->values;
- unsigned nbobjs = distances->nbobjs;
- unsigned i, j, k;
-
- for(i=0; i<nbobjs; i++) {
- hwloc_uint64_t bw_i2sw = 0;
- if (is_nvswitch(objs[i]))
- continue;
- /* count our BW to the switch */
- for(k=0; k<nbobjs; k++)
- if (is_nvswitch(objs[k]))
- bw_i2sw += values[i*nbobjs+k];
-
- for(j=0; j<nbobjs; j++) {
- hwloc_uint64_t bw_sw2j = 0;
- if (i == j || is_nvswitch(objs[j]))
- continue;
- /* count our BW from the switch */
- for(k=0; k<nbobjs; k++)
- if (is_nvswitch(objs[k]))
- bw_sw2j += values[k*nbobjs+j];
-
- /* bandwidth from i to j now gets indirect bandwidth too, min(i2sw,sw2j) */
- values[i*nbobjs+j] += bw_i2sw > bw_sw2j ? bw_sw2j : bw_i2sw;
- }
- }
-
- return 0;
-}
-
-int
-hwloc_distances_transform(hwloc_topology_t topology __hwloc_attribute_unused,
- struct hwloc_distances_s *distances,
- enum hwloc_distances_transform_e transform,
- void *transform_attr,
- unsigned long flags)
-{
- if (flags || transform_attr) {
- errno = EINVAL;
- return -1;
- }
-
- switch (transform) {
- case HWLOC_DISTANCES_TRANSFORM_REMOVE_NULL:
- return hwloc__distances_transform_remove_null(distances);
- case HWLOC_DISTANCES_TRANSFORM_LINKS:
- return hwloc__distances_transform_links(distances);
- case HWLOC_DISTANCES_TRANSFORM_MERGE_SWITCH_PORTS:
- {
- int err;
- err = hwloc__distances_transform_merge_switch_ports(distances);
- if (!err)
- err = hwloc__distances_transform_remove_null(distances);
- return err;
- }
- case HWLOC_DISTANCES_TRANSFORM_TRANSITIVE_CLOSURE:
- return hwloc__distances_transform_transitive_closure(distances);
- default:
- errno = EINVAL;
- return -1;
- }
-}
### src/3rdparty/hwloc/src/memattrs.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/misc.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/pci-common.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/shmem.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/static-components.h
[binary or diff unavailable]
### src/3rdparty/hwloc/src/topology-noos.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/topology-synthetic.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/topology-windows.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/topology-x86.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/topology-xml-nolibxml.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/topology-xml.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/topology.c
[binary or diff unavailable]
### src/3rdparty/hwloc/src/traversal.c
[binary or diff unavailable]
### src/backend/cpu/cpu.cmake
[binary or diff unavailable]Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.