Skip to content

Commit 5ec2613

Browse files
committed
API: rename the OSDEV "type" attribute to "types"
The main reason is to break codes to force people to look at how to read this new bitmask instead of the former single value. Fortunately most programs don't use OS devs hence it shouldn't be a big issue. Signed-off-by: Brice Goglin <[email protected]>
1 parent 523e946 commit 5ec2613

35 files changed

+129
-130
lines changed

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ 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-
+ The OS device "type" attribute is now a bitmask.
33+
+ The OS device "type" attribute is now a bitmask named "types".
3434
- "Block" OS devices are now "Storage" (for actual Block devices)
3535
and/or "Memory" (for Linux DAX and CXL devices, etc).
3636
- Some "CoProcessors" are also "GPUs" (e.g. CUDA devices),

doc/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ man3_object_types_DATA = \
283283
$(DOX_MAN_DIR)/man3/HWLOC_OBJ_OSDEV_OPENFABRICS.3 \
284284
$(DOX_MAN_DIR)/man3/HWLOC_OBJ_OSDEV_COPROC.3 \
285285
$(DOX_MAN_DIR)/man3/hwloc_obj_osdev_type_e.3 \
286-
$(DOX_MAN_DIR)/man3/hwloc_obj_osdev_type_t.3 \
286+
$(DOX_MAN_DIR)/man3/hwloc_obj_osdev_types_t.3 \
287287
$(DOX_MAN_DIR)/man3/hwloc_compare_types.3 \
288288
$(DOX_MAN_DIR)/man3/HWLOC_TYPE_UNORDERED.3
289289

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-2023 Inria. All rights reserved.
6+
* Copyright © 2009-2024 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|HWLOC_OBJ_OSDEV_GPU */
39+
/* obj->attr->osdev.types 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: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4683,8 +4683,8 @@ and/or running against.
46834683

46844684
\section upgrade_to_api_3x_osdev OS device type is now a bitmask
46854685

4686-
The OS device "type" attribute is now a bitmask instead of a single value,
4687-
and many existing devices now combine two values.
4686+
The OS device "type" attribute is now a bitmask named "types".
4687+
Instead of a single value, many existing devices now combine two values.
46884688
<ul>
46894689
<li>"Block" OS devices are now "Storage" (for actual Block devices)
46904690
and/or "Memory" (for Linux DAX and CXL devices, etc).
@@ -4696,11 +4696,10 @@ and many existing devices now combine two values.
46964696
See \ref iodevices_osdev for details.
46974697
<br/>
46984698

4699-
<b>This change does not cause compile failures but things will very likely break at runtime.</b>
47004699
Codes looking OS device types should be updated as follows:
47014700
\verbatim
47024701
#if HWLOC_API_VERSION >= 0x30000
4703-
if (obj->type == HWLOC_OBJ_OS_DEVICE && obj->attr->osdev.type & HWLOC_OSDEV_TYPE_GPU)
4702+
if (obj->type == HWLOC_OBJ_OS_DEVICE && obj->attr->osdev.types & HWLOC_OSDEV_TYPE_GPU)
47044703
/* obj is a 3.x GPU OS device */
47054704
#else
47064705
if (obj->type == HWLOC_OBJ_OS_DEVICE && obj->attr->osdev.type == HWLOC_OSDEV_TYPE_GPU)

hwloc/topology-cuda.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2011 Université Bordeaux
3-
* Copyright © 2012-2023 Inria. All rights reserved.
3+
* Copyright © 2012-2024 Inria. All rights reserved.
44
* See COPYING in top-level directory.
55
*/
66

@@ -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 | HWLOC_OBJ_OSDEV_GPU;
106+
cuda_device->attr->osdev.types = 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-gl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2012-2013 Blue Brain Project, BBP/EPFL. All rights reserved.
3-
* Copyright © 2012-2023 Inria. All rights reserved.
3+
* Copyright © 2012-2024 Inria. All rights reserved.
44
* See COPYING in top-level directory.
55
*/
66

@@ -122,7 +122,7 @@ hwloc_gl_discover(struct hwloc_backend *backend, struct hwloc_disc_status *dstat
122122
osdev = hwloc_alloc_setup_object(topology, HWLOC_OBJ_OS_DEVICE, HWLOC_UNKNOWN_INDEX);
123123
osdev->name = strdup(name);
124124
osdev->subtype = strdup("Display");
125-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_GPU;
125+
osdev->attr->osdev.types = HWLOC_OBJ_OSDEV_GPU;
126126
hwloc_obj_add_info(osdev, "GPUVendor", "NVIDIA Corporation");
127127
if (productname)
128128
hwloc_obj_add_info(osdev, "GPUModel", productname);

hwloc/topology-levelzero.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ hwloc_levelzero_discover(struct hwloc_backend *backend, struct hwloc_disc_status
718718
snprintf(buffer, sizeof(buffer), "ze%u", zeidx); // ze0d0 ?
719719
osdev->name = strdup(buffer);
720720
osdev->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
721-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
721+
osdev->attr->osdev.types = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
722722
osdev->subtype = strdup("LevelZero");
723723

724724
snprintf(buffer, sizeof(buffer), "%u", i);
@@ -746,7 +746,7 @@ hwloc_levelzero_discover(struct hwloc_backend *backend, struct hwloc_disc_status
746746
snprintf(tmp, sizeof(tmp), "ze%u.%u", zeidx, k);
747747
subosdevs[k]->name = strdup(tmp);
748748
subosdevs[k]->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
749-
subosdevs[k]->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
749+
subosdevs[k]->attr->osdev.types = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
750750
subosdevs[k]->subtype = strdup("LevelZero");
751751
snprintf(tmp, sizeof(tmp), "%u", k);
752752
hwloc_obj_add_info(subosdevs[k], "LevelZeroSubdeviceID", tmp);

hwloc/topology-linux.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,7 +3957,7 @@ annotate_dax_parent(hwloc_obj_t obj, const char *name, int fsroot_fd)
39573957
if (strstr(begin, "ndbus")) {
39583958
type = "NVM";
39593959
if (obj->type == HWLOC_OBJ_OS_DEVICE)
3960-
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_STORAGE;
3960+
obj->attr->osdev.types |= HWLOC_OBJ_OSDEV_STORAGE;
39613961
} else {
39623962
type = "SPM";
39633963
}
@@ -6262,12 +6262,12 @@ hwloc_linuxfs_find_osdev_parent(struct hwloc_backend *backend, int root_fd,
62626262
}
62636263

62646264
static hwloc_obj_t
6265-
hwloc_linux_add_os_device(struct hwloc_backend *backend, struct hwloc_obj *pcidev, hwloc_obj_osdev_type_t type, const char *name)
6265+
hwloc_linux_add_os_device(struct hwloc_backend *backend, struct hwloc_obj *pcidev, hwloc_obj_osdev_types_t type, const char *name)
62666266
{
62676267
struct hwloc_topology *topology = backend->topology;
62686268
struct hwloc_obj *obj = hwloc_alloc_setup_object(topology, HWLOC_OBJ_OS_DEVICE, HWLOC_UNKNOWN_INDEX);
62696269
obj->name = strdup(name);
6270-
obj->attr->osdev.type = type;
6270+
obj->attr->osdev.types = type;
62716271

62726272
hwloc_insert_object_by_parent(topology, pcidev, obj);
62736273
/* insert_object_by_parent() doesn't merge during insert, so obj is still valid */
@@ -7076,7 +7076,7 @@ hwloc_linuxfs_cxlmem_fillinfos(int root_fd,
70767076
snprintf(tmp, sizeof(tmp), "%lluKiB", value / 1024);
70777077
hwloc_obj_add_info(obj, "CXLPMEMSize", tmp);
70787078
}
7079-
obj->attr->osdev.type |= HWLOC_OBJ_OSDEV_STORAGE;
7079+
obj->attr->osdev.types |= HWLOC_OBJ_OSDEV_STORAGE;
70807080
}
70817081

70827082
snprintf(path, sizeof(path), "%s/serial", osdevpath);

hwloc/topology-nvml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ hwloc_nvml_discover(struct hwloc_backend *backend, struct hwloc_disc_status *dst
238238
osdev->name = strdup(buffer);
239239
osdev->subtype = strdup("NVML");
240240
osdev->depth = HWLOC_TYPE_DEPTH_UNKNOWN;
241-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
241+
osdev->attr->osdev.types = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
242242

243243
hwloc_obj_add_info(osdev, "GPUVendor", "NVIDIA Corporation");
244244

hwloc/topology-opencl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2012-2023 Inria. All rights reserved.
2+
* Copyright © 2012-2024 Inria. All rights reserved.
33
* Copyright © 2013, 2018 Université Bordeaux. All right reserved.
44
* See COPYING in top-level directory.
55
*/
@@ -126,16 +126,16 @@ hwloc_opencl_discover(struct hwloc_backend *backend, struct hwloc_disc_status *d
126126
/* in theory, we should handle cases such GPU|Accelerator|CPU for strange platforms/devices */
127127
if (type & CL_DEVICE_TYPE_GPU) {
128128
hwloc_obj_add_info(osdev, "OpenCLDeviceType", "GPU");
129-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
129+
osdev->attr->osdev.types = HWLOC_OBJ_OSDEV_COPROC | HWLOC_OBJ_OSDEV_GPU;
130130
} else if (type & CL_DEVICE_TYPE_ACCELERATOR) {
131131
hwloc_obj_add_info(osdev, "OpenCLDeviceType", "Accelerator");
132-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
132+
osdev->attr->osdev.types = HWLOC_OBJ_OSDEV_COPROC;
133133
} else if (type & HWLOC_CL_DEVICE_TYPE_CUSTOM) {
134134
hwloc_obj_add_info(osdev, "OpenCLDeviceType", "Custom"); /* Custom cannot be combined with any other type */
135-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
135+
osdev->attr->osdev.types = HWLOC_OBJ_OSDEV_COPROC;
136136
} else {
137137
hwloc_obj_add_info(osdev, "OpenCLDeviceType", "Unknown");
138-
osdev->attr->osdev.type = HWLOC_OBJ_OSDEV_COPROC;
138+
osdev->attr->osdev.types = HWLOC_OBJ_OSDEV_COPROC;
139139
}
140140

141141
buffer[0] = '\0';

0 commit comments

Comments
 (0)