Skip to content

Commit 4960975

Browse files
authored
Merge pull request #615 from bgoglin/3.0-osdev-type
Rework OS device subtype for 3.0
2 parents a331e44 + c4850ca commit 4960975

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+698
-359
lines changed

NEWS

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ Version 3.0.0
3030
+ PCI domains are now always 32bits.
3131
+ The "programming interface" of PCI devices is now exposed
3232
in PCI object attributes.
33-
+ "Block" OS devices are now "Storage" (for actual Block devices)
34-
or "Memory" (for Linux DAX and CXL devices, etc).
33+
+ The OS device "type" attribute is now a bitmask.
34+
- "Block" OS devices are now "Storage" (for actual Block devices)
35+
and/or "Memory" (for Linux DAX and CXL devices, etc).
36+
- Some "CoProcessors" are also "GPUs" (e.g. CUDA devices),
37+
and some GPUs are also CoProcessors (e.g. RSMI).
38+
- "OpenFabrics" devices are now also "Network".
39+
- BXI interfaces are now "Network" instead of "OpenFabrics".
40+
- See "OS devices" in the documentation for details.
3541
+ The "Backend" info attribute of OS devices is now in the topology
3642
root object together with other backends.
3743
+ The array and count of info attributes are now embedded in the new

doc/examples/gpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* - getting CUDA and OpenCL attributes
44
* - displaying the locality of the GPU
55
*
6-
* Copyright © 2009-2019 Inria. All rights reserved.
6+
* Copyright © 2009-2023 Inria. All rights reserved.
77
* Copyright © 2009-2011,2017 Université Bordeaux
88
* Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
99
* See COPYING in top-level directory.
@@ -36,7 +36,7 @@ int main(void)
3636
obj = hwloc_get_obj_by_type(topology, HWLOC_OBJ_OS_DEVICE, i);
3737
printf("%s:\n", obj->name);
3838

39-
/* obj->attr->osdev.type is HWLOC_OBJ_OSDEV_COPROC */
39+
/* obj->attr->osdev.type is HWLOC_OBJ_OSDEV_COPROC|HWLOC_OBJ_OSDEV_GPU */
4040

4141
s = hwloc_obj_get_info_by_name(obj, "Backend");
4242
/* obj->subtype also contains CUDA or OpenCL since v2.0 */

doc/hwloc.doxy

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,44 +1652,46 @@ components when I/O discovery is enabled and supported.
16521652
<li><em>sda</em> or <em>nvme0n1</em> (Linux component)</li>
16531653
</ul>
16541654
</li>
1655-
<li>Non-volatile, special-purpose or CXL memory devices (::HWLOC_OBJ_OSDEV_MEMORY)
1655+
<li>Non-volatile, high-bandwidth, or special-purpose or CXL memory devices (::HWLOC_OBJ_OSDEV_MEMORY, with also ::HWLOC_OBJ_OSDEV_STORAGE if non-volatile)
16561656
<ul>
16571657
<li><em>dax2.0</em> or <em>mem0</em> (Linux component)</li>
16581658
</ul>
16591659
<li>Network interfaces (::HWLOC_OBJ_OSDEV_NETWORK)
16601660
<ul>
16611661
<li><em>eth0</em>, <em>wlan0</em>, <em>ib0</em> (Linux component)</li>
16621662
<li><em>hsn0</em> with "Slingshot" subtype for HPE Cray HSNs (Linux component).</li>
1663+
<li><em>bxi0</em> with "BXI" subtype for Atos/Bull BXI HCAs (Linux component).</li>
1664+
<li>OpenFabrics devices as explained below.
16631665
</ul>
16641666
</li>
1665-
<li>OpenFabrics (InfiniBand, Omni-Path, usNIC, etc) HCAs (::HWLOC_OBJ_OSDEV_OPENFABRICS)
1667+
<li>OpenFabrics (InfiniBand, Omni-Path, usNIC, etc) HCAs (::HWLOC_OBJ_OSDEV_OPENFABRICS and ::HWLOC_OBJ_OSDEV_NETWORK)
16661668
<ul>
16671669
<li><em>mlx5_0</em>, <em>hfi1_0</em>, <em>qib0</em>, <em>usnic_0</em> (Linux component)</li>
1668-
<li><em>bxi0</em> with "BXI" subtype for Atos/Bull BXI HCAs (Linux component) even if those are not really OpenFabrics.</li>
16691670
</ul>
16701671
</li>
1671-
<li>GPUs (::HWLOC_OBJ_OSDEV_GPU)
1672+
<li>GPUs (::HWLOC_OBJ_OSDEV_GPU and possibly ::HWLOC_OBJ_OSDEV_COPROC)
16721673
<ul>
1673-
<li><em>rsmi0</em> for the first RSMI device
1674-
("RSMI" subtype, from the RSMI component, using the AMD ROCm SMI library)</li>
1675-
<li><em>nvml0</em> for the first NVML device
1676-
("NVML" subtype, from the NVML component, using the NVIDIA Management Library)</li>
16771674
<li><em>:0.0</em> for the first display
16781675
("Display" subtype, from the GL component, using the NV-CONTROL X extension library, NVCtrl)</li>
16791676
<li><em>card0</em> and <em>renderD128</em> for DRM device files
16801677
(from the Linux component, filtered-out by default because considered non-important)</li>
1678+
<li>Any GPU that may be used as a co-processor as explained below.
16811679
</ul>
16821680
</li>
1683-
<li>Co-Processors (::HWLOC_OBJ_OSDEV_COPROC)
1681+
<li>Co-Processors (::HWLOC_OBJ_OSDEV_COPROC and possibly ::HWLOC_OBJ_OSDEV_GPU)
16841682
<ul>
16851683
<li><em>opencl0d0</em> for the first device of the first OpenCL platform,
16861684
<em>opencl1d3</em> for the fourth device of the second OpenCL platform
16871685
("OpenCL" subtype, from the OpenCL component)</li>
16881686
<li><em>ze0</em> for the first Level Zero device
16891687
("LevelZero" subtype, from the levelzero component, using the oneAPI Level Zero library),
16901688
and <em>ze0.1</em> for its second subdevice (if any).</li>
1689+
<li><em>rsmi0</em> for the first RSMI device
1690+
("RSMI" subtype, from the RSMI component, using the AMD ROCm SMI library)</li>
16911691
<li><em>cuda0</em> for the first NVIDIA CUDA device
16921692
("CUDA" subtype, from the CUDA component, using the NVIDIA CUDA Library)</li>
1693+
<li><em>nvml0</em> for the first NVML device
1694+
("NVML" subtype, from the NVML component, using the NVIDIA Management Library)</li>
16931695
<li><em>ve0</em> for the first NEC Vector Engine device
16941696
("VectorEngine" subtype, from the Linux component)</li>
16951697
</ul>
@@ -1911,8 +1913,10 @@ for instance their <tt>logical_index</tt> or <tt>os_index</tt>
19111913

19121914
The kind of object is first described by the <tt>obj->type</tt>
19131915
generic attribute (an integer).
1914-
OS devices also have a specific <tt>obj->attr->osdev.type</tt> integer
1916+
OS devices also have a specific <tt>obj->attr->osdev.type</tt> bitmask
19151917
for distinguishing between NICs, GPUs, etc.
1918+
For instance a GPU coprocessor has both ::HWLOC_OBJ_OSDEV_COPROC and
1919+
::HWLOC_OBJ_OSDEV_GPU bits in this bitmask (see also \ref iodevices_osdev).
19161920

19171921
Objects may also have an optional <tt>obj->subtype</tt> pointing
19181922
to a better description string (displayed by lstopo either
@@ -1933,10 +1937,9 @@ subtype <tt>Cluster</tt>, <tt>Module</tt>, <tt>Tile</tt>, <tt>Compute Unit</tt>,
19331937
</li>
19341938
<li>OS devices (see also \ref iodevices_osdev):
19351939
<ul>
1936-
<li>Co-processor: subtype <tt>OpenCL</tt>, <tt>LevelZero</tt>, <tt>CUDA</tt>, or <tt>VectorEngine</tt>.</li>
1937-
<li>GPU: subtype <tt>RSMI</tt> (AMD GPU) or <tt>NVML</tt> (NVIDIA GPU).</li>
1938-
<li>OpenFabrics: subtype <tt>BXI</tt> (Bull/Atos BXI HCA).</li>
1939-
<li>Network: subtype <tt>Slingshot</tt> (HPE Cray Slingshot Cassini HSN).</li>
1940+
<li>subtype <tt>OpenCL</tt>, <tt>LevelZero</tt>, <tt>CUDA</tt>, <tt>VectorEngine</tt>,
1941+
<tt>RSMI</tt> (AMD GPU) or <tt>NVML</tt> (NVIDIA GPU) for GPU and/or CoProcessor OS devices.</li>
1942+
<li>Network: subtype <tt>Slingshot</tt> (HPE Cray Slingshot Cassini HSN) or <tt>BXI</tt> (Bull/Atos BXI HCA).</li>
19401943
<li>Storage: subtype <tt>Disk</tt>, <tt>Tape</tt>, or <tt>Removable Media Device</tt>.</li>
19411944
<li>Memory: <tt>NVM</tt> (non-volatile memory), <tt>SPM</tt> (specific-purpose memory), <tt>CXLMem</tt> (CXL volatile ou persistent memory).</li>
19421945
</ul>
@@ -2129,7 +2132,7 @@ and SectorSize (in bytes).
21292132
in a CXL Type-3 device.
21302133
Sizes are in KiB (1024 bytes).
21312134
</dd>
2132-
<dt>GPUVendor, GPUModel (GPU or Co-Processor OS devices)</dt>
2135+
<dt>GPUVendor, GPUModel (GPU and/or Co-Processor OS devices)</dt>
21332136
<dd>The vendor and model names of the GPU device.
21342137
</dd>
21352138
<dt>OpenCLDeviceType, OpenCLPlatformIndex,</dt>

hwloc/topology-cuda.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ hwloc_cuda_discover(struct hwloc_backend *backend, struct hwloc_disc_status *dst
103103
snprintf(cuda_name, sizeof(cuda_name), "cuda%d", i);
104104
cuda_device->name = strdup(cuda_name);
105105
cuda_device->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
106-
cuda_device->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
106+
cuda_device->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
107107

108108
cuda_device->subtype = strdup("CUDA");
109109
hwloc_obj_add_info(cuda_device, "GPUVendor", "NVIDIA Corporation");

hwloc/topology-levelzero.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ hwloc_levelzero_discover(struct hwloc_backend *backend, struct hwloc_disc_status
707707
snprintf(buffer, sizeof(buffer), "ze%u", zeidx); // ze0d0 ?
708708
osdev->name = strdup(buffer);
709709
osdev->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
710-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
710+
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
711711
osdev->subtype = strdup("LevelZero");
712712

713713
snprintf(buffer, sizeof(buffer), "%u", i);
@@ -735,7 +735,7 @@ hwloc_levelzero_discover(struct hwloc_backend *backend, struct hwloc_disc_status
735735
snprintf(tmp, sizeof(tmp), "ze%u.%u", zeidx, k);
736736
subosdevs[k]->name = strdup(tmp);
737737
subosdevs[k]->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
738-
subosdevs[k]->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
738+
subosdevs[k]->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
739739
subosdevs[k]->subtype = strdup("LevelZero");
740740
snprintf(tmp, sizeof(tmp), "%u", k);
741741
hwloc_obj_add_info(subosdevs[k], "LevelZeroSubdeviceID", tmp);

hwloc/topology-linux.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,7 +3856,13 @@ annotate_dax_parent(hwloc_obj_t obj, const char *name, int fsroot_fd)
38563856
}
38573857

38583858
/* we'll convert SPM (specific-purpose memory) into a HBM subtype later by looking at memattrs */
3859-
type = strstr(begin, "ndbus") ? "NVM" : "SPM";
3859+
if (strstr(begin, "ndbus")) {
3860+
type = "NVM";
3861+
if (obj->type == HWLOC_OBJ_OS_DEVICE)
3862+
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_STORAGE;
3863+
} else {
3864+
type = "SPM";
3865+
}
38603866
hwloc_obj_add_info(obj, "DAXType", type);
38613867

38623868
/* try to get some CXL info from the region */
@@ -6355,7 +6361,7 @@ hwloc_linuxfs_lookup_dax_class(struct hwloc_backend *backend, unsigned osdev_fla
63556361
continue;
63566362

63576363
obj = hwloc_linux_add_os_device(backend, parent, HWLOC_OBJ_OSDEV_MEMORY, dirent->d_name);
6358-
6364+
/* annotate_dax_parent() will add HWLOC_OBJ_OSDEV_STORAGE if NVM */
63596365
annotate_dax_parent(obj, dirent->d_name, root_fd);
63606366

63616367
hwloc_linuxfs_dax_class_fillinfos(backend, root_fd, obj, path);
@@ -6561,7 +6567,7 @@ hwloc_linuxfs_lookup_infiniband_class(struct hwloc_backend *backend, unsigned os
65616567
if (!parent)
65626568
continue;
65636569

6564-
obj = hwloc_linux_add_os_device(backend, parent, HWLOC_OBJ_OSDEV_OPENFABRICS, dirent->d_name);
6570+
obj = hwloc_linux_add_os_device(backend, parent, HWLOC_OBJ_OSDEV_NETWORK | HWLOC_OBJ_OSDEV_OPENFABRICS, dirent->d_name);
65656571

65666572
hwloc_linuxfs_infiniband_class_fillinfos(root_fd, obj, path);
65676573
}
@@ -6615,7 +6621,7 @@ hwloc_linuxfs_lookup_bxi_class(struct hwloc_backend *backend, unsigned osdev_fla
66156621
if (!parent)
66166622
continue;
66176623

6618-
obj = hwloc_linux_add_os_device(backend, parent, HWLOC_OBJ_OSDEV_OPENFABRICS, dirent->d_name);
6624+
obj = hwloc_linux_add_os_device(backend, parent, HWLOC_OBJ_OSDEV_NETWORK, dirent->d_name);
66196625

66206626
hwloc_linuxfs_bxi_class_fillinfos(root_fd, obj, path);
66216627
}
@@ -6849,6 +6855,7 @@ hwloc_linuxfs_cxlmem_fillinfos(int root_fd,
68496855
snprintf(tmp, sizeof(tmp), "%llu", value / 1024);
68506856
hwloc_obj_add_info(obj, "CXLPMEMSize", tmp);
68516857
}
6858+
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_STORAGE;
68526859
}
68536860

68546861
snprintf(path, sizeof(path), "%s/serial", osdevpath);
@@ -6883,7 +6890,7 @@ hwloc_linuxfs_lookup_cxlmem(struct hwloc_backend *backend, unsigned osdev_flags)
68836890
continue;
68846891

68856892
obj = hwloc_linux_add_os_device(backend, parent, HWLOC_OBJ_OSDEV_MEMORY, dirent->d_name);
6886-
6893+
/* hwloc_linuxfs_cxlmem_fillinfos() will add HWLOC_OBJ_OSDEV_STORAGE if PMEM */
68876894
hwloc_linuxfs_cxlmem_fillinfos(root_fd, obj, path);
68886895
}
68896896
closedir(dir);

hwloc/topology-nvml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ hwloc_nvml_discover(struct hwloc_backend *backend, struct hwloc_disc_status *dst
222222
osdev->name = strdup(buffer);
223223
osdev->subtype = strdup("NVML");
224224
osdev->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
225-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_GPU;
225+
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
226226

227227
hwloc_obj_add_info(osdev, "GPUVendor", "NVIDIA Corporation");
228228

hwloc/topology-opencl.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,23 @@ hwloc_opencl_discover(struct hwloc_backend *backend, struct hwloc_disc_status *d
120120
snprintf(buffer, sizeof(buffer), "opencl%ud%u", j, i);
121121
osdev->name = strdup(buffer);
122122
osdev->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
123-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
124123

125124
osdev->subtype = strdup("OpenCL");
126125

127126
/* in theory, we should handle cases such GPU|Accelerator|CPU for strange platforms/devices */
128-
if (type & CL_DEVICE_TYPE_GPU)
127+
if (type & CL_DEVICE_TYPE_GPU) {
129128
hwloc_obj_add_info(osdev, "OpenCLDeviceType", "GPU");
130-
else if (type & CL_DEVICE_TYPE_ACCELERATOR)
129+
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
130+
} else if (type & CL_DEVICE_TYPE_ACCELERATOR) {
131131
hwloc_obj_add_info(osdev, "OpenCLDeviceType", "Accelerator");
132-
else if (type & HWLOC_CL_DEVICE_TYPE_CUSTOM)
132+
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
133+
} else if (type & HWLOC_CL_DEVICE_TYPE_CUSTOM) {
133134
hwloc_obj_add_info(osdev, "OpenCLDeviceType", "Custom"); /* Custom cannot be combined with any other type */
134-
else
135+
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
136+
} else {
135137
hwloc_obj_add_info(osdev, "OpenCLDeviceType", "Unknown");
138+
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
139+
}
136140

137141
buffer[0] = '\0';
138142
clGetDeviceInfo(device_ids[i], CL_DEVICE_VENDOR, sizeof(buffer), buffer, NULL);

hwloc/topology-rsmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ hwloc_rsmi_discover(struct hwloc_backend *backend, struct hwloc_disc_status *dst
294294
osdev->name = strdup(buffer);
295295
osdev->subtype = strdup("RSMI");
296296
osdev->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
297-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_GPU;
297+
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_GPU | HWLOC_OBJ_OSDEV_COPROC;
298298

299299
hwloc_obj_add_info(osdev, "GPUVendor", "AMD");
300300

hwloc/topology-xml.c

Lines changed: 87 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,14 @@ hwloc__xml_import_object_attr(struct hwloc_topology *topology,
384384
else if (!strcmp(name, "osdev_type")) {
385385
switch (obj->type) {
386386
case HWLOC_OBJ_OS_DEVICE: {
387-
unsigned osdev_type;
388-
if (sscanf(value, "%u", &osdev_type) != 1) {
387+
unsigned long osdev_type;
388+
if (sscanf(value, "%lu", &osdev_type) != 1) {
389389
if (hwloc__xml_verbose())
390390
fprintf(stderr, "%s: ignoring invalid osdev_type format string %s\n",
391391
state->global->msgprefix, value);
392-
} else
393-
obj->attr->osdev.type = (hwloc_obj_osdev_type_t) osdev_type;
392+
} else {
393+
obj->attr->osdev.type = osdev_type; /* v2 types will be updated later in hwloc__xml_import_object() */
394+
}
394395
break;
395396
}
396397
default:
@@ -843,6 +844,64 @@ hwloc__xml_import_object(hwloc_topology_t topology,
843844
}
844845
}
845846

847+
if (data->version_major < 3 && obj->type == HWLOC_OBJ_OS_DEVICE) {
848+
unsigned long oldtype = obj->attr->osdev.type;
849+
switch (oldtype) {
850+
case 0: /* v2 Block */
851+
if ((obj->name && !strncmp(obj->name, "dax", 3))) {
852+
/* DAX is MEMORY, and STORAGE if NVM */
853+
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_MEMORY;
854+
if (obj->subtype && !strcmp(obj->subtype, "NVM"))
855+
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_STORAGE;
856+
} else if (obj->subtype && !strcmp(obj->subtype, "CXLMem")) {
857+
/* CXL is MEMORY, and STORAGE if there's some PMEM */
858+
const char *info = hwloc_obj_get_info_by_name(obj, "CXLPMEMSize");
859+
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_MEMORY;
860+
if (info)
861+
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_STORAGE;
862+
} else {
863+
/* anything else is STORAGE */
864+
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_STORAGE;
865+
}
866+
break;
867+
case 1: /* v2 GPU */
868+
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_GPU;
869+
if (obj->name && (!strncmp(obj->name, "rsmi", 4) || !strncmp(obj->name, "nvml", 4) /* no RSMI/NVML subtype for v2.5 */))
870+
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_COPROC;
871+
break;
872+
case 2: /* v2 Net */
873+
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_NETWORK;
874+
break;
875+
case 3: /* v2 OFED */
876+
/* everything is NET and OFED, except BXI which became NET only */
877+
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_NETWORK;
878+
if (!obj->subtype || strcmp(obj->subtype, "BXI"))
879+
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_OPENFABRICS;
880+
break;
881+
case 4: /* v2 DMA */
882+
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_DMA;
883+
break;
884+
case 5: /* v2 COPROC */
885+
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
886+
if (obj->subtype) {
887+
/* CUDA and L0 are also GPU, and OpenCL GPU obviously */
888+
if (!strcmp(obj->subtype, "CUDA") || !strcmp(obj->subtype, "LevelZero"))
889+
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_GPU;
890+
else if (!strcmp(obj->subtype, "OpenCL")) {
891+
const char *info = hwloc_obj_get_info_by_name(obj, "OpenCLDeviceType");
892+
if (info && !strcmp(info, "GPU"))
893+
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_GPU;
894+
}
895+
}
896+
break;
897+
default:
898+
/* unrecognized, no type */
899+
obj->attr->osdev.type = 0;
900+
break;
901+
}
902+
}
903+
904+
/* filter AFTER having updated the osdevice attribute from v2 */
846905
if (!hwloc_filter_check_keep_object(topology, obj)) {
847906
/* Ignore this object instead of inserting it.
848907
*
@@ -859,13 +918,6 @@ hwloc__xml_import_object(hwloc_topology_t topology,
859918
/* insert_object_by_parent() doesn't merge during insert, so obj is still valid */
860919
}
861920

862-
if (data->version_major < 3 && obj->type == HWLOC_OBJ_OS_DEVICE) {
863-
if (obj->attr->osdev.type == HWLOC_OBJ_OSDEV_STORAGE
864-
&& ((obj->name && !strncmp(obj->name, "dax", 3))
865-
|| (obj->subtype && !strcmp(obj->subtype, "CXLMem"))))
866-
obj->attr->osdev.type = HWLOC_OBJ_OSDEV_MEMORY;
867-
}
868-
869921
/* process object subnodes, if we found one win the above loop */
870922
while (tag) {
871923
int ret;
@@ -2215,11 +2267,30 @@ hwloc__xml_export_object_contents (hwloc__xml_export_state_t state, hwloc_topolo
22152267
state->new_prop(state, "pci_link_speed", tmp);
22162268
break;
22172269
case HWLOC_OBJ_OS_DEVICE:
2218-
if (v2export && obj->attr->osdev.type == HWLOC_OBJ_OSDEV_MEMORY)
2219-
sprintf(tmp, "%d", (int) HWLOC_OBJ_OSDEV_STORAGE);
2220-
else
2221-
sprintf(tmp, "%d", (int) obj->attr->osdev.type);
2222-
state->new_prop(state, "osdev_type", tmp);
2270+
if (v2export) {
2271+
if (obj->attr->osdev.type & (HWLOC_OBJ_OSDEV_STORAGE|HWLOC_OBJ_OSDEV_MEMORY)) {
2272+
state->new_prop(state, "osdev_type", "0"); /* v2 Block */
2273+
} else if (obj->attr->osdev.type & HWLOC_OBJ_OSDEV_OPENFABRICS) {
2274+
state->new_prop(state, "osdev_type", "3"); /* v2 OFED */
2275+
} else if (obj->attr->osdev.type & HWLOC_OBJ_OSDEV_NETWORK) {
2276+
if (obj->subtype && !strcmp(obj->subtype, "BXI"))
2277+
state->new_prop(state, "osdev_type", "3"); /* v2 OFED */
2278+
else
2279+
state->new_prop(state, "osdev_type", "2"); /* v2 Net */
2280+
} else if (obj->attr->osdev.type & HWLOC_OBJ_OSDEV_DMA) {
2281+
state->new_prop(state, "osdev_type", "4"); /* v2 DMA */
2282+
} else if (obj->attr->osdev.type & HWLOC_OBJ_OSDEV_COPROC) {
2283+
if (obj->name && (!strncmp(obj->name, "nvml", 4) || !strncmp(obj->name, "rsmi", 4)))
2284+
state->new_prop(state, "osdev_type", "1"); /* v2 GPU */
2285+
else
2286+
state->new_prop(state, "osdev_type", "5"); /* v2 CoProc */
2287+
} else if (obj->attr->osdev.type & HWLOC_OBJ_OSDEV_GPU) {
2288+
state->new_prop(state, "osdev_type", "1"); /* v2 GPU */
2289+
}
2290+
} else {
2291+
sprintf(tmp, "%lu", obj->attr->osdev.type);
2292+
state->new_prop(state, "osdev_type", tmp);
2293+
}
22232294
break;
22242295
default:
22252296
break;

0 commit comments

Comments
 (0)