diff --git a/sycl/doc/extensions/supported/sycl_ext_intel_device_info.md b/sycl/doc/extensions/supported/sycl_ext_intel_device_info.md index dfde231255108..47f3124deac6d 100644 --- a/sycl/doc/extensions/supported/sycl_ext_intel_device_info.md +++ b/sycl/doc/extensions/supported/sycl_ext_intel_device_info.md @@ -17,6 +17,44 @@ The Feature Test Macro SYCL\_EXT\_INTEL\_DEVICE\_INFO will be defined as one of | 2 | Device UUID is supported | | 3 | HW threads per EU device query is supported | | 4 | Free device memory query is supported | +| 5 | Device ID is supported | + + + +# Device ID # + +A new device descriptor will be added which will provide the device ID. + +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). + +## Version ## + +The extension supports this query in version 5 and later. + +## Device Information Descriptors ## + +| Device Descriptors | Return Type | Description | +| ------------------ | ----------- | ----------- | +| ext\:\:intel\:\:info\:\:device\:\:device\_id | uint32\_t| Returns the device ID.| + + +## Aspects ## + +A new aspect, ext\_intel\_device\_id, will be added. + + +## Error Condition ## + +An invalid object runtime error will be thrown if the device does not support aspect\:\:ext\_intel\_device\_id. + +## Example Usage ## + +The device ID can be obtained using the standard get\_info() interface. + + if (dev.has(aspect::ext_intel_device_id)) { + auto deviceID = dev.get_info(); + } + # Device UUID # diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 6aeb8728db90a..d79025bf7d306 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -264,6 +264,7 @@ typedef enum { // Intel UUID extension. PI_DEVICE_INFO_UUID = 0x106A, // These are Intel-specific extensions. + PI_DEVICE_INFO_DEVICE_ID = 0x4251, PI_DEVICE_INFO_PCI_ADDRESS = 0x10020, PI_DEVICE_INFO_GPU_EU_COUNT = 0x10021, PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 0x10022, diff --git a/sycl/include/sycl/feature_test.hpp.in b/sycl/include/sycl/feature_test.hpp.in index 3ae4e1b73a96b..7391ed1b083da 100644 --- a/sycl/include/sycl/feature_test.hpp.in +++ b/sycl/include/sycl/feature_test.hpp.in @@ -29,7 +29,7 @@ __SYCL_INLINE_VER_NAMESPACE(_V1) { // Feature test macro definitions // TODO: Move these feature-test macros to compiler driver. -#define SYCL_EXT_INTEL_DEVICE_INFO 3 +#define SYCL_EXT_INTEL_DEVICE_INFO 5 #define SYCL_EXT_ONEAPI_SUB_GROUP_MASK 1 #define SYCL_EXT_ONEAPI_LOCAL_MEMORY 1 #define SYCL_EXT_ONEAPI_MATRIX 1 diff --git a/sycl/include/sycl/info/aspects.def b/sycl/include/sycl/info/aspects.def index 223b36496f6a8..692728f5afec4 100644 --- a/sycl/include/sycl/info/aspects.def +++ b/sycl/include/sycl/info/aspects.def @@ -33,3 +33,4 @@ __SYCL_ASPECT(ext_intel_gpu_hw_threads_per_eu, 33) __SYCL_ASPECT(ext_oneapi_cuda_async_barrier, 34) __SYCL_ASPECT(ext_oneapi_bfloat16, 35) __SYCL_ASPECT(ext_intel_free_memory, 36) +__SYCL_ASPECT(ext_intel_device_id, 37) diff --git a/sycl/include/sycl/info/ext_intel_device_traits.def b/sycl/include/sycl/info/ext_intel_device_traits.def index ee36ec711c45c..fbc2008b28404 100644 --- a/sycl/include/sycl/info/ext_intel_device_traits.def +++ b/sycl/include/sycl/info/ext_intel_device_traits.def @@ -2,6 +2,7 @@ #define __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF #define __SYCL_PARAM_TRAITS_TEMPLATE_SPEC __SYCL_PARAM_TRAITS_SPEC #endif +__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, device_id, pi_uint32, PI_DEVICE_INFO_DEVICE_ID) __SYCL_PARAM_TRAITS_SPEC(ext::intel, device, pci_address, std::string, PI_DEVICE_INFO_PCI_ADDRESS) __SYCL_PARAM_TRAITS_SPEC(ext::intel, device, gpu_eu_count, pi_uint32, PI_DEVICE_INFO_GPU_EU_COUNT) __SYCL_PARAM_TRAITS_SPEC(ext::intel, device, gpu_eu_simd_width, pi_uint32, PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH) diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 0bd8e593f2a65..c547bccfd46cc 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -1928,6 +1928,7 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, } // TODO: Investigate if this information is available on CUDA. + case PI_DEVICE_INFO_DEVICE_ID: case PI_DEVICE_INFO_PCI_ADDRESS: case PI_DEVICE_INFO_GPU_EU_COUNT: case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH: diff --git a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp index 00daaddbb37aa..4a656729fc433 100644 --- a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp +++ b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp @@ -790,6 +790,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_IL_VERSION) // Intel-specific extensions + CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_DEVICE_ID) CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_PCI_ADDRESS) CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_GPU_EU_COUNT) CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH) diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index 6bbb39f4d05df..002e10c918124 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -1819,6 +1819,7 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name, case PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: // TODO: Investigate if this information is available on HIP. case PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: + case PI_DEVICE_INFO_DEVICE_ID: case PI_DEVICE_INFO_PCI_ADDRESS: case PI_DEVICE_INFO_GPU_EU_COUNT: case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH: diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 8c486c13d5e21..0b2ff391c86ab 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -3141,6 +3141,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, } // intel extensions for GPU information + case PI_DEVICE_INFO_DEVICE_ID: + return ReturnValue( + pi_uint32{Device->ZeDeviceProperties->deviceId}); case PI_DEVICE_INFO_PCI_ADDRESS: { if (getenv("ZES_ENABLE_SYSMAN") == nullptr) { zePrint("Set SYCL_ENABLE_PCI=1 to obtain PCI data.\n"); diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index b73e1fd46f285..9580830993ba5 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -314,6 +314,10 @@ bool device_impl::has(aspect Aspect) const { return get_info(); case aspect::usm_system_allocations: return get_info(); + case aspect::ext_intel_device_id: + return getPlugin().call_nocheck( + MDevice, PI_DEVICE_INFO_DEVICE_ID, 0, + nullptr, &return_size) == PI_SUCCESS; case aspect::ext_intel_pci_address: return getPlugin().call_nocheck( MDevice, PI_DEVICE_INFO_PCI_ADDRESS, 0, nullptr, &return_size) == diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index b62f9aa8a8e56..1428cd336fb2f 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1416,6 +1416,13 @@ inline bool get_device_info_host() { // Specializations for intel extensions for Level Zero low-level // detail device descriptors (not support on host). template <> +inline uint32_t +get_device_info_host() { + throw runtime_error( + "Obtaining the device ID is not supported on HOST device", + PI_ERROR_INVALID_DEVICE); +} +template <> inline std::string get_device_info_host() { throw runtime_error( diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index a17fe783f3b60..5e6e430d8a81c 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -4162,6 +4162,7 @@ _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device21gpu_hw_threads_per_euE _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device23gpu_subslices_per_sliceEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device25gpu_eu_count_per_subsliceEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device4uuidEEENS0_6detail19is_device_info_descIT_E11return_typeEv +_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device9device_idEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi1EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi2EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv _ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi3EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index f956826db5f31..728146a226b6b 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -40,6 +40,7 @@ ??$get_info@Ucontext@kernel@info@_V1@sycl@@@kernel@_V1@sycl@@QEBA?AVcontext@12@XZ ??$get_info@Ucontext@queue@info@_V1@sycl@@@queue@_V1@sycl@@QEBA?AVcontext@12@XZ ??$get_info@Udevice@queue@info@_V1@sycl@@@queue@_V1@sycl@@QEBA?AVdevice@12@XZ +??$get_info@Udevice_id@device@info@intel@ext@_V1@sycl@@@device@_V1@sycl@@QEBAIXZ ??$get_info@Udevice_type@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA?AW4device_type@info@12@XZ ??$get_info@Udevices@context@info@_V1@sycl@@@context@_V1@sycl@@QEBA?AV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@std@@XZ ??$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