Skip to content

Commit 1d99344

Browse files
authored
[SYCL] Add ext_intel_device_id to sycl_ext_intel_device_info (#7010)
This adds the ability to query the device ID of a device, which must be equal to the PCI device ID for PCI devices. An important use case of this feature is detecting the GPU architecture, which is necessary in applications that have dedicated code paths for different architectures. Querying the device ID is implemented for Level Zero and OpenCL as well.
1 parent b91b732 commit 1d99344

File tree

13 files changed

+61
-1
lines changed

13 files changed

+61
-1
lines changed

sycl/doc/extensions/supported/sycl_ext_intel_device_info.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,44 @@ The Feature Test Macro SYCL\_EXT\_INTEL\_DEVICE\_INFO will be defined as one of
1717
| 2 | Device UUID is supported |
1818
| 3 | HW threads per EU device query is supported |
1919
| 4 | Free device memory query is supported |
20+
| 5 | Device ID is supported |
21+
22+
23+
24+
# Device ID #
25+
26+
A new device descriptor will be added which will provide the device ID.
27+
28+
If the implementation is driven primarily by a PCI device with a PCI device ID, the device ID must be that PCI device ID. Otherwise, the choice of what to return may be dictated by operating system or platform policies - but should uniquely identify both the device version and any major configuration options (for example, core count in the case of multi-core devices).
29+
30+
## Version ##
31+
32+
The extension supports this query in version 5 and later.
33+
34+
## Device Information Descriptors ##
35+
36+
| Device Descriptors | Return Type | Description |
37+
| ------------------ | ----------- | ----------- |
38+
| ext\:\:intel\:\:info\:\:device\:\:device\_id | uint32\_t| Returns the device ID.|
39+
40+
41+
## Aspects ##
42+
43+
A new aspect, ext\_intel\_device\_id, will be added.
44+
45+
46+
## Error Condition ##
47+
48+
An invalid object runtime error will be thrown if the device does not support aspect\:\:ext\_intel\_device\_id.
49+
50+
## Example Usage ##
51+
52+
The device ID can be obtained using the standard get\_info() interface.
53+
54+
if (dev.has(aspect::ext_intel_device_id)) {
55+
auto deviceID = dev.get_info<ext::intel::info::device::device_id>();
56+
}
57+
2058

2159

2260
# Device UUID #

sycl/include/sycl/detail/pi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ typedef enum {
264264
// Intel UUID extension.
265265
PI_DEVICE_INFO_UUID = 0x106A,
266266
// These are Intel-specific extensions.
267+
PI_DEVICE_INFO_DEVICE_ID = 0x4251,
267268
PI_DEVICE_INFO_PCI_ADDRESS = 0x10020,
268269
PI_DEVICE_INFO_GPU_EU_COUNT = 0x10021,
269270
PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 0x10022,

sycl/include/sycl/feature_test.hpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ __SYCL_INLINE_VER_NAMESPACE(_V1) {
2929
// Feature test macro definitions
3030

3131
// TODO: Move these feature-test macros to compiler driver.
32-
#define SYCL_EXT_INTEL_DEVICE_INFO 3
32+
#define SYCL_EXT_INTEL_DEVICE_INFO 5
3333
#define SYCL_EXT_ONEAPI_SUB_GROUP_MASK 1
3434
#define SYCL_EXT_ONEAPI_LOCAL_MEMORY 1
3535
#define SYCL_EXT_ONEAPI_MATRIX 1

sycl/include/sycl/info/aspects.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ __SYCL_ASPECT(ext_intel_gpu_hw_threads_per_eu, 33)
3333
__SYCL_ASPECT(ext_oneapi_cuda_async_barrier, 34)
3434
__SYCL_ASPECT(ext_oneapi_bfloat16, 35)
3535
__SYCL_ASPECT(ext_intel_free_memory, 36)
36+
__SYCL_ASPECT(ext_intel_device_id, 37)

sycl/include/sycl/info/ext_intel_device_traits.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF
33
#define __SYCL_PARAM_TRAITS_TEMPLATE_SPEC __SYCL_PARAM_TRAITS_SPEC
44
#endif
5+
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, device_id, pi_uint32, PI_DEVICE_INFO_DEVICE_ID)
56
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, pci_address, std::string, PI_DEVICE_INFO_PCI_ADDRESS)
67
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, gpu_eu_count, pi_uint32, PI_DEVICE_INFO_GPU_EU_COUNT)
78
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, gpu_eu_simd_width, pi_uint32, PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH)

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
19281928
}
19291929

19301930
// TODO: Investigate if this information is available on CUDA.
1931+
case PI_DEVICE_INFO_DEVICE_ID:
19311932
case PI_DEVICE_INFO_PCI_ADDRESS:
19321933
case PI_DEVICE_INFO_GPU_EU_COUNT:
19331934
case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
790790
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_IL_VERSION)
791791

792792
// Intel-specific extensions
793+
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_DEVICE_ID)
793794
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_PCI_ADDRESS)
794795
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_GPU_EU_COUNT)
795796
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH)

sycl/plugins/hip/pi_hip.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,7 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
18191819
case PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES:
18201820
// TODO: Investigate if this information is available on HIP.
18211821
case PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
1822+
case PI_DEVICE_INFO_DEVICE_ID:
18221823
case PI_DEVICE_INFO_PCI_ADDRESS:
18231824
case PI_DEVICE_INFO_GPU_EU_COUNT:
18241825
case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,6 +3141,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
31413141
}
31423142

31433143
// intel extensions for GPU information
3144+
case PI_DEVICE_INFO_DEVICE_ID:
3145+
return ReturnValue(
3146+
pi_uint32{Device->ZeDeviceProperties->deviceId});
31443147
case PI_DEVICE_INFO_PCI_ADDRESS: {
31453148
if (getenv("ZES_ENABLE_SYSMAN") == nullptr) {
31463149
zePrint("Set SYCL_ENABLE_PCI=1 to obtain PCI data.\n");

sycl/source/detail/device_impl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ bool device_impl::has(aspect Aspect) const {
314314
return get_info<info::device::usm_restricted_shared_allocations>();
315315
case aspect::usm_system_allocations:
316316
return get_info<info::device::usm_system_allocations>();
317+
case aspect::ext_intel_device_id:
318+
return getPlugin().call_nocheck<detail::PiApiKind::piDeviceGetInfo>(
319+
MDevice, PI_DEVICE_INFO_DEVICE_ID, 0,
320+
nullptr, &return_size) == PI_SUCCESS;
317321
case aspect::ext_intel_pci_address:
318322
return getPlugin().call_nocheck<detail::PiApiKind::piDeviceGetInfo>(
319323
MDevice, PI_DEVICE_INFO_PCI_ADDRESS, 0, nullptr, &return_size) ==

sycl/source/detail/device_info.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,13 @@ inline bool get_device_info_host<info::device::ext_intel_mem_channel>() {
14161416
// Specializations for intel extensions for Level Zero low-level
14171417
// detail device descriptors (not support on host).
14181418
template <>
1419+
inline uint32_t
1420+
get_device_info_host<ext::intel::info::device::device_id>() {
1421+
throw runtime_error(
1422+
"Obtaining the device ID is not supported on HOST device",
1423+
PI_ERROR_INVALID_DEVICE);
1424+
}
1425+
template <>
14191426
inline std::string
14201427
get_device_info_host<ext::intel::info::device::pci_address>() {
14211428
throw runtime_error(

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4162,6 +4162,7 @@ _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device21gpu_hw_threads_per_euE
41624162
_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device23gpu_subslices_per_sliceEEENS0_6detail19is_device_info_descIT_E11return_typeEv
41634163
_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device25gpu_eu_count_per_subsliceEEENS0_6detail19is_device_info_descIT_E11return_typeEv
41644164
_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device4uuidEEENS0_6detail19is_device_info_descIT_E11return_typeEv
4165+
_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device9device_idEEENS0_6detail19is_device_info_descIT_E11return_typeEv
41654166
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi1EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv
41664167
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi2EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv
41674168
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi3EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
??$get_info@Ucontext@kernel@info@_V1@sycl@@@kernel@_V1@sycl@@QEBA?AVcontext@12@XZ
4141
??$get_info@Ucontext@queue@info@_V1@sycl@@@queue@_V1@sycl@@QEBA?AVcontext@12@XZ
4242
??$get_info@Udevice@queue@info@_V1@sycl@@@queue@_V1@sycl@@QEBA?AVdevice@12@XZ
43+
??$get_info@Udevice_id@device@info@intel@ext@_V1@sycl@@@device@_V1@sycl@@QEBAIXZ
4344
??$get_info@Udevice_type@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA?AW4device_type@info@12@XZ
4445
??$get_info@Udevices@context@info@_V1@sycl@@@context@_V1@sycl@@QEBA?AV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@std@@XZ
4546
??$get_info@Udouble_fp_config@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA?AV?$vector@W4fp_config@info@_V1@sycl@@V?$allocator@W4fp_config@info@_V1@sycl@@@std@@@std@@XZ

0 commit comments

Comments
 (0)