From ac2df19edd1b79940258baff94d9ed993e628dde Mon Sep 17 00:00:00 2001 From: rbegam Date: Wed, 21 Apr 2021 11:40:01 -0700 Subject: [PATCH 01/21] [SYCL] Adds support for device UUID as a SYCL extension. This includes support for only level_zero. The llvm/sycl/docs/extensions/IntelGPU/IntelGPUDeviceInfo.md doc has been modified with a brief description of the extension. A new aspect is added to indicate if the support is available. This also fixes the mismatched return types of few other intel specific ext. Signed-off-by: rbegam --- .../extensions/IntelGPU/IntelGPUDeviceInfo.md | 35 ++++++++++++++++++- sycl/include/CL/sycl/aspects.hpp | 1 + sycl/include/CL/sycl/detail/pi.h | 5 +++ sycl/include/CL/sycl/feature_test.hpp | 2 +- sycl/include/CL/sycl/info/device_traits.def | 1 + sycl/include/CL/sycl/info/info_desc.hpp | 3 +- sycl/plugins/cuda/pi_cuda.cpp | 1 + sycl/plugins/level_zero/pi_level_zero.cpp | 2 ++ sycl/plugins/opencl/pi_opencl.cpp | 4 ++- sycl/source/detail/device_impl.cpp | 5 +++ sycl/source/detail/device_info.hpp | 20 +++++++---- sycl/test/abi/sycl_symbols_linux.dump | 1 + 12 files changed, 70 insertions(+), 10 deletions(-) diff --git a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md index 8468ea5d98c97..6f76cb2a80d43 100644 --- a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +++ b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md @@ -11,7 +11,40 @@ This proposal details what is required to provide this information as a SYCL ext The Feature Test Macro will be defined as: - #define SYCL_EXT_INTEL_DEVICE_INFO 1 + #define SYCL_EXT_INTEL_DEVICE_INFO 2 + + +# Device UUID # + +A new device descriptor will be added which will provide the device Universal Unique ID (UUID). + +This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. + + +## Device Information Descriptors ## + +| Device Descriptors | Return Type | Description | +| ------------------ | ----------- | ----------- | +| info\:\:device\:\:ext\_intel\_device\_info\_uuid | std\:\:array\ | For Level Zero BE, returns the device UUID| + + +## Aspects ## + +A new aspect, ext\_intel\_device\_info\_uuid, will be added. + +## Error Condition ## + +An invalid object runtime error will be thrown if the device does not support aspect\:\:ext\_intel\_device\_info\_uuid. + + +## Example Usage ## + +The PCI address can be obtained using the standard get\_info() interface. + + if (dev.has(aspect::ext_intel_device_info_uuid)) { + auto BDF = dev.get_info(); + } + # PCI Address # diff --git a/sycl/include/CL/sycl/aspects.hpp b/sycl/include/CL/sycl/aspects.hpp index 24513ed3e515d..7177a9cdc6860 100644 --- a/sycl/include/CL/sycl/aspects.hpp +++ b/sycl/include/CL/sycl/aspects.hpp @@ -41,6 +41,7 @@ enum class aspect { ext_intel_mem_channel = 25, usm_atomic_host_allocations = 26, usm_atomic_shared_allocations = 27, + ext_intel_device_info_uuid = 28, }; } // namespace sycl diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 393b5964568ff..92356aaa63960 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -53,6 +53,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -64,6 +65,8 @@ using pi_uint64 = uint64_t; using pi_bool = pi_uint32; using pi_bitfield = pi_uint64; using pi_native_handle = uintptr_t; +using pi_byte_array = std::array; + // // NOTE: prefer to map 1:1 to OpenCL so that no translation is needed @@ -278,6 +281,8 @@ typedef enum { CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, PI_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL, + // Intel UUID extension. + PI_DEVICE_INFO_UUID = CL_DEVICE_UUID_KHR, // These are Intel-specific extensions. PI_DEVICE_INFO_PCI_ADDRESS = 0x10020, PI_DEVICE_INFO_GPU_EU_COUNT = 0x10021, diff --git a/sycl/include/CL/sycl/feature_test.hpp b/sycl/include/CL/sycl/feature_test.hpp index ea3f7f2e264a9..634fd9379f721 100644 --- a/sycl/include/CL/sycl/feature_test.hpp +++ b/sycl/include/CL/sycl/feature_test.hpp @@ -13,7 +13,7 @@ namespace sycl { // Feature test macro definitions // TODO: Move these feature-test macros to compiler driver. -#define SYCL_EXT_INTEL_DEVICE_INFO 1 +#define SYCL_EXT_INTEL_DEVICE_INFO 2 #define SYCL_EXT_ONEAPI_MATRIX 1 } // namespace sycl diff --git a/sycl/include/CL/sycl/info/device_traits.def b/sycl/include/CL/sycl/info/device_traits.def index f3d4dd6b1d1b3..870f06e6b686f 100644 --- a/sycl/include/CL/sycl/info/device_traits.def +++ b/sycl/include/CL/sycl/info/device_traits.def @@ -93,3 +93,4 @@ __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_gpu_subslices_per_slice, pi_uint32) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_gpu_eu_count_per_subslice, pi_uint32) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_max_mem_bandwidth, pi_uint64) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_mem_channel, bool) +__SYCL_PARAM_TRAITS_SPEC(device, ext_intel_device_info_uuid, pi_byte_array) diff --git a/sycl/include/CL/sycl/info/info_desc.hpp b/sycl/include/CL/sycl/info/info_desc.hpp index f221638c9af99..05690db553317 100644 --- a/sycl/include/CL/sycl/info/info_desc.hpp +++ b/sycl/include/CL/sycl/info/info_desc.hpp @@ -131,7 +131,8 @@ enum class device : cl_device_info { usm_shared_allocations = PI_USM_SINGLE_SHARED_SUPPORT, usm_restricted_shared_allocations = PI_USM_CROSS_SHARED_SUPPORT, usm_system_allocator = PI_USM_SYSTEM_SHARED_SUPPORT, - + // uuid extension + ext_intel_device_info_uuid = PI_DEVICE_INFO_UUID, // intel extensions ext_intel_pci_address = PI_DEVICE_INFO_PCI_ADDRESS, ext_intel_gpu_eu_count = PI_DEVICE_INFO_GPU_EU_COUNT, diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 1c8daf6e4b835..f719c9c86fa1f 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -1518,6 +1518,7 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, case PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: + case PI_DEVICE_INFO_UUID: return PI_INVALID_VALUE; default: diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index a22b1a729dfc8..ba4a091083e7b 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -1656,6 +1656,8 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, return ReturnValue(Device->Platform); case PI_DEVICE_INFO_VENDOR_ID: return ReturnValue(pi_uint32{Device->ZeDeviceProperties.vendorId}); + case PI_DEVICE_INFO_UUID: + return ReturnValue(Device->ZeDeviceProperties.uuid.id); case PI_DEVICE_INFO_EXTENSIONS: { // Convention adopted from OpenCL: // "Returns a space separated list of extension names (the extension diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index f1a074b3fc65d..762bca1f94e10 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -169,8 +169,8 @@ pi_result piDeviceGetInfo(pi_device device, pi_device_info paramName, size_t paramValueSize, void *paramValue, size_t *paramValueSizeRet) { switch (paramName) { - // Intel GPU EU device-specific information extensions. // TODO: Check regularly to see if support in enabled in OpenCL. + // Intel GPU EU device-specific information extensions. case PI_DEVICE_INFO_PCI_ADDRESS: case PI_DEVICE_INFO_GPU_EU_COUNT: case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH: @@ -178,6 +178,8 @@ pi_result piDeviceGetInfo(pi_device device, pi_device_info paramName, case PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: + // Intel UUID extension. + case PI_DEVICE_INFO_UUID: return PI_INVALID_VALUE; default: diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 172c19be83344..dfef571631ea5 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -297,6 +297,11 @@ bool device_impl::has(aspect Aspect) const { MDevice, PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, sizeof(pi_device_type), &device_type, &return_size) == PI_SUCCESS; + case aspect::ext_intel_device_info_uuid: + return getPlugin().call_nocheck( + MDevice, PI_DEVICE_INFO_UUID, + sizeof(pi_device_type), &device_type, + &return_size) == PI_SUCCESS; case aspect::ext_intel_max_mem_bandwidth: // currently not supported return false; diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index bf3eb0561ef7a..4a7cc1e261efd 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1045,45 +1045,53 @@ get_device_info_host() { PI_INVALID_DEVICE); } template <> -inline cl_uint get_device_info_host() { +inline pi_uint32 get_device_info_host() { throw runtime_error("Obtaining the EU count is not supported on HOST device", PI_INVALID_DEVICE); } template <> -inline cl_uint +inline pi_uint32 get_device_info_host() { throw runtime_error( "Obtaining the EU SIMD width is not supported on HOST device", PI_INVALID_DEVICE); } template <> -inline cl_uint get_device_info_host() { +inline pi_uint32 get_device_info_host() { throw runtime_error( "Obtaining the number of slices is not supported on HOST device", PI_INVALID_DEVICE); } template <> -inline cl_uint +inline pi_uint32 get_device_info_host() { throw runtime_error("Obtaining the number of subslices per slice is not " "supported on HOST device", PI_INVALID_DEVICE); } template <> -inline cl_uint +inline pi_uint32 get_device_info_host() { throw runtime_error( "Obtaining the EU count per subslice is not supported on HOST device", PI_INVALID_DEVICE); } template <> -inline cl_ulong +inline pi_uint64 get_device_info_host() { throw runtime_error( "Obtaining the maximum memory bandwidth is not supported on HOST device", PI_INVALID_DEVICE); } +template <> +inline pi_byte_array +get_device_info_host() { + throw runtime_error( + "Obtaining the device uuid is not supported on HOST device", + PI_INVALID_DEVICE); +} + } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 2016f1ae315c0..465f1efbffee6 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -4120,6 +4120,7 @@ _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4168EEENS3_12param_traitsIS4_XT_E _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4169EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4188EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4189EEENS3_12param_traitsIS4_XT_EE11return_typeEv +_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4202EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65568EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65569EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65570EEENS3_12param_traitsIS4_XT_EE11return_typeEv From 2408ff39925c5d2a02994e6350a564a56bec9fa3 Mon Sep 17 00:00:00 2001 From: rbegam Date: Thu, 6 May 2021 15:49:44 -0700 Subject: [PATCH 02/21] changed pi interface. Signed-off-by: rbegam --- .../extensions/IntelGPU/IntelGPUDeviceInfo.md | 8 ++++---- sycl/include/CL/sycl/detail/pi.h | 5 ++--- sycl/include/CL/sycl/info/device_traits.def | 2 +- sycl/source/detail/device_impl.cpp | 19 +++++++++++++++---- sycl/source/detail/device_info.hpp | 2 +- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md index 6f76cb2a80d43..6daa46e376754 100644 --- a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +++ b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md @@ -18,14 +18,14 @@ The Feature Test Macro will be defined as: A new device descriptor will be added which will provide the device Universal Unique ID (UUID). -This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. +This new device descriptor is currently only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior would be to expose the UUIDs of all supported GPU devices which enables detection of total number of unique devices. ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | | ------------------ | ----------- | ----------- | -| info\:\:device\:\:ext\_intel\_device\_info\_uuid | std\:\:array\ | For Level Zero BE, returns the device UUID| +| info\:\:device\:\:ext\_intel\_device\_info\_uuid | std\:\:array\ | Returns the device UUID| ## Aspects ## @@ -39,10 +39,10 @@ An invalid object runtime error will be thrown if the device does not support as ## Example Usage ## -The PCI address can be obtained using the standard get\_info() interface. +The UUID can be obtained using the standard get\_info() interface. if (dev.has(aspect::ext_intel_device_info_uuid)) { - auto BDF = dev.get_info(); + auto UUID = dev.get_info(); } diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 92356aaa63960..a467755e06af5 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -52,8 +52,8 @@ #include #include #include -#include #include +#include #ifdef __cplusplus extern "C" { @@ -65,8 +65,7 @@ using pi_uint64 = uint64_t; using pi_bool = pi_uint32; using pi_bitfield = pi_uint64; using pi_native_handle = uintptr_t; -using pi_byte_array = std::array; - +using pi_uint8_ptr = uint8_t *; // // NOTE: prefer to map 1:1 to OpenCL so that no translation is needed diff --git a/sycl/include/CL/sycl/info/device_traits.def b/sycl/include/CL/sycl/info/device_traits.def index 870f06e6b686f..9dde378bfefde 100644 --- a/sycl/include/CL/sycl/info/device_traits.def +++ b/sycl/include/CL/sycl/info/device_traits.def @@ -93,4 +93,4 @@ __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_gpu_subslices_per_slice, pi_uint32) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_gpu_eu_count_per_subslice, pi_uint32) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_max_mem_bandwidth, pi_uint64) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_mem_channel, bool) -__SYCL_PARAM_TRAITS_SPEC(device, ext_intel_device_info_uuid, pi_byte_array) +__SYCL_PARAM_TRAITS_SPEC(device, ext_intel_device_info_uuid, pi_uint8_ptr) diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index dfef571631ea5..f82a8304d6caf 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -298,10 +298,21 @@ bool device_impl::has(aspect Aspect) const { sizeof(pi_device_type), &device_type, &return_size) == PI_SUCCESS; case aspect::ext_intel_device_info_uuid: - return getPlugin().call_nocheck( - MDevice, PI_DEVICE_INFO_UUID, - sizeof(pi_device_type), &device_type, - &return_size) == PI_SUCCESS; + { + auto Result = + getPlugin().call_nocheck( + MDevice, PI_DEVICE_INFO_UUID, sizeof(pi_device_type), &device_type, + &return_size); + if (Result != PI_SUCCESS) { + return false; + } + + pi_uint8_ptr uuid = static_cast(malloc( + return_size * sizeof(uint8_t))); + return getPlugin().call_nocheck( + MDevice, PI_DEVICE_INFO_UUID, sizeof(pi_uint8_ptr), uuid, + &return_size) == PI_SUCCESS; + } case aspect::ext_intel_max_mem_bandwidth: // currently not supported return false; diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 4a7cc1e261efd..98cd1ae04aeb6 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1085,7 +1085,7 @@ get_device_info_host() { } template <> -inline pi_byte_array +inline pi_uint8_ptr get_device_info_host() { throw runtime_error( "Obtaining the device uuid is not supported on HOST device", From 8fbefa8ef709d4938f8cbf26cd65a3f033abd5cc Mon Sep 17 00:00:00 2001 From: rbegam Date: Thu, 6 May 2021 15:57:44 -0700 Subject: [PATCH 03/21] clang formatted. Signed-off-by: rbegam --- sycl/source/detail/device_impl.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index f82a8304d6caf..581d346415b3d 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -297,22 +297,20 @@ bool device_impl::has(aspect Aspect) const { MDevice, PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, sizeof(pi_device_type), &device_type, &return_size) == PI_SUCCESS; - case aspect::ext_intel_device_info_uuid: - { - auto Result = - getPlugin().call_nocheck( - MDevice, PI_DEVICE_INFO_UUID, sizeof(pi_device_type), &device_type, - &return_size); - if (Result != PI_SUCCESS) { - return false; - } - - pi_uint8_ptr uuid = static_cast(malloc( - return_size * sizeof(uint8_t))); - return getPlugin().call_nocheck( - MDevice, PI_DEVICE_INFO_UUID, sizeof(pi_uint8_ptr), uuid, - &return_size) == PI_SUCCESS; + case aspect::ext_intel_device_info_uuid: { + auto Result = getPlugin().call_nocheck( + MDevice, PI_DEVICE_INFO_UUID, sizeof(pi_device_type), &device_type, + &return_size); + if (Result != PI_SUCCESS) { + return false; } + + pi_uint8_ptr uuid = + static_cast(malloc(return_size * sizeof(uint8_t))); + return getPlugin().call_nocheck( + MDevice, PI_DEVICE_INFO_UUID, sizeof(pi_uint8_ptr), uuid, + &return_size) == PI_SUCCESS; + } case aspect::ext_intel_max_mem_bandwidth: // currently not supported return false; From 6f8510a869b30a26ae8fded9886bb1ee47300383 Mon Sep 17 00:00:00 2001 From: rbegam Date: Mon, 10 May 2021 12:29:21 -0700 Subject: [PATCH 04/21] modified the doc. Signed-off-by: rbegam --- .../extensions/IntelGPU/IntelGPUDeviceInfo.md | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md index 6daa46e376754..c96c3f8a1f7e2 100644 --- a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +++ b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md @@ -9,9 +9,12 @@ This proposal details what is required to provide this information as a SYCL ext ## Feature Test Macro ## -The Feature Test Macro will be defined as: +The Feature Test Macro will be defined as one of the values defined in the table below. The existence of this macro can be tested to determine if the implementation supports this feature, or applications can test the macro's value to determine which of the extension's APIs the implementation supports. - #define SYCL_EXT_INTEL_DEVICE_INFO 2 +| Value | Description | +| ----- | ----------- | +| 1 | Initial extension version\. Base features are supported | +| 2 | Device UUID is supported | # Device UUID # @@ -21,11 +24,16 @@ A new device descriptor will be added which will provide the device Universal Un This new device descriptor is currently only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior would be to expose the UUIDs of all supported GPU devices which enables detection of total number of unique devices. +## Version ## + +The extension supports this query in version 2 and later. + + ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | | ------------------ | ----------- | ----------- | -| info\:\:device\:\:ext\_intel\_device\_info\_uuid | std\:\:array\ | Returns the device UUID| +| info\:\:device\:\:ext\_intel\_device\_info\_uuid | uint8\_t \* | Returns the device UUID| ## Aspects ## @@ -56,6 +64,11 @@ This new device descriptor is only available for devices in the Level Zero platf **Note:** The environment variable SYCL\_ENABLE\_PCI must be set to 1 to obtain the PCI address. +## Version ## + +All versions of the extension support this query. + + ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | @@ -89,6 +102,11 @@ A new device descriptor will be added which will provide the physical SIMD width This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. +## Version ## + +All versions of the extension support this query. + + ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | @@ -124,6 +142,11 @@ This new device descriptor will provide the same information as "max\_compute\_u This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. +## Version ## + +All versions of the extension support this query. + + ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | @@ -157,6 +180,11 @@ A new device descriptor will be added which will provide the number of slices on This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. +## Version ## + +All versions of the extension support this query. + + ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | @@ -189,6 +217,11 @@ A new device descriptor will be added which will provide the number of subslices This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. +## Version ## + +All versions of the extension support this query. + + ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | @@ -221,6 +254,11 @@ A new device descriptor will be added which will provide the number of EUs per s This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. +## Version ## + +All versions of the extension support this query. + + ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | @@ -253,6 +291,11 @@ A new device descriptor will be added which will provide the maximum memory band This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. +## Version ## + +All versions of the extension support this query. + + ## Device Information Descriptors ## | Device Descriptors | Return Type | Description | From 08cfa319623ce09ddbef52281f70aa565908780c Mon Sep 17 00:00:00 2001 From: rbegam Date: Mon, 10 May 2021 12:40:01 -0700 Subject: [PATCH 05/21] adds macro name. Signed-off-by: rbegam --- sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md index c96c3f8a1f7e2..fb90d4dbdd61e 100644 --- a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +++ b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md @@ -9,7 +9,7 @@ This proposal details what is required to provide this information as a SYCL ext ## Feature Test Macro ## -The Feature Test Macro will be defined as one of the values defined in the table below. The existence of this macro can be tested to determine if the implementation supports this feature, or applications can test the macro's value to determine which of the extension's APIs the implementation supports. +The Feature Test Macro `SYCL\_EXT\_INTEL\_DEVICE\_INFO` will be defined as one of the values defined in the table below. The existence of this macro can be tested to determine if the implementation supports this feature, or applications can test the macro's value to determine which of the extension's APIs the implementation supports. | Value | Description | | ----- | ----------- | From d75028cd354038beb9ae6c331fa5681a687c1c90 Mon Sep 17 00:00:00 2001 From: rbegam Date: Mon, 10 May 2021 12:44:06 -0700 Subject: [PATCH 06/21] remove typo. Signed-off-by: rbegam --- sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md index fb90d4dbdd61e..3eeeb8c623c8f 100644 --- a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +++ b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md @@ -9,7 +9,7 @@ This proposal details what is required to provide this information as a SYCL ext ## Feature Test Macro ## -The Feature Test Macro `SYCL\_EXT\_INTEL\_DEVICE\_INFO` will be defined as one of the values defined in the table below. The existence of this macro can be tested to determine if the implementation supports this feature, or applications can test the macro's value to determine which of the extension's APIs the implementation supports. +The Feature Test Macro SYCL\_EXT\_INTEL\_DEVICE\_INFO will be defined as one of the values defined in the table below. The existence of this macro can be tested to determine if the implementation supports this feature, or applications can test the macro's value to determine which of the extension's APIs the implementation supports. | Value | Description | | ----- | ----------- | From d4874cf838a302de529a5e2cb96d6472cd82cbcf Mon Sep 17 00:00:00 2001 From: rbegam Date: Thu, 13 May 2021 15:37:37 -0700 Subject: [PATCH 07/21] minor modifications. Signed-off-by: rbegam --- sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md | 2 +- sycl/include/CL/sycl/detail/pi.h | 2 +- sycl/source/detail/device_impl.cpp | 11 +++++++---- sycl/source/detail/device_info.hpp | 12 ++++++------ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md index 3eeeb8c623c8f..1ecf02fc31447 100644 --- a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +++ b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md @@ -33,7 +33,7 @@ The extension supports this query in version 2 and later. | Device Descriptors | Return Type | Description | | ------------------ | ----------- | ----------- | -| info\:\:device\:\:ext\_intel\_device\_info\_uuid | uint8\_t \* | Returns the device UUID| +| info\:\:device\:\:ext\_intel\_device\_info\_uuid | std\:\:array\ | Returns the device UUID| ## Aspects ## diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index a467755e06af5..ff99d93f09464 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -52,7 +52,7 @@ #include #include #include -#include + #include #ifdef __cplusplus diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 581d346415b3d..767916eb8dcd0 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -305,11 +305,14 @@ bool device_impl::has(aspect Aspect) const { return false; } - pi_uint8_ptr uuid = - static_cast(malloc(return_size * sizeof(uint8_t))); + assert(return_size <= 16); + std::byte uuid[16]; + + //pi_uint8_ptr uuid = + // static_cast(malloc(return_size * sizeof(uint8_t))); return getPlugin().call_nocheck( - MDevice, PI_DEVICE_INFO_UUID, sizeof(pi_uint8_ptr), uuid, - &return_size) == PI_SUCCESS; + MDevice, PI_DEVICE_INFO_UUID, 16 * sizeof(std::byte), uuid, + nullptr) == PI_SUCCESS; } case aspect::ext_intel_max_mem_bandwidth: // currently not supported diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 98cd1ae04aeb6..c5b03b3a1f3b5 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1045,39 +1045,39 @@ get_device_info_host() { PI_INVALID_DEVICE); } template <> -inline pi_uint32 get_device_info_host() { +inline cl_uint get_device_info_host() { throw runtime_error("Obtaining the EU count is not supported on HOST device", PI_INVALID_DEVICE); } template <> -inline pi_uint32 +inline cl_uint get_device_info_host() { throw runtime_error( "Obtaining the EU SIMD width is not supported on HOST device", PI_INVALID_DEVICE); } template <> -inline pi_uint32 get_device_info_host() { +inline cl_uint get_device_info_host() { throw runtime_error( "Obtaining the number of slices is not supported on HOST device", PI_INVALID_DEVICE); } template <> -inline pi_uint32 +inline cl_uint get_device_info_host() { throw runtime_error("Obtaining the number of subslices per slice is not " "supported on HOST device", PI_INVALID_DEVICE); } template <> -inline pi_uint32 +inline cl_uint get_device_info_host() { throw runtime_error( "Obtaining the EU count per subslice is not supported on HOST device", PI_INVALID_DEVICE); } template <> -inline pi_uint64 +inline cl_ulong get_device_info_host() { throw runtime_error( "Obtaining the maximum memory bandwidth is not supported on HOST device", From 36ebffb5dd9ab234f5f0c4eabcd98bb642f9b910 Mon Sep 17 00:00:00 2001 From: rbegam Date: Fri, 14 May 2021 15:01:37 -0700 Subject: [PATCH 08/21] change sycl return type and add a test case. Signed-off-by: rbegam --- sycl/include/CL/sycl/info/device_traits.def | 2 +- sycl/include/CL/sycl/info/info_desc.hpp | 5 +++++ sycl/source/detail/device_info.hpp | 2 +- .../on-device/extensions/intel-ext-device.cpp | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/sycl/include/CL/sycl/info/device_traits.def b/sycl/include/CL/sycl/info/device_traits.def index 9dde378bfefde..4fe3f0ace377c 100644 --- a/sycl/include/CL/sycl/info/device_traits.def +++ b/sycl/include/CL/sycl/info/device_traits.def @@ -93,4 +93,4 @@ __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_gpu_subslices_per_slice, pi_uint32) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_gpu_eu_count_per_subslice, pi_uint32) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_max_mem_bandwidth, pi_uint64) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_mem_channel, bool) -__SYCL_PARAM_TRAITS_SPEC(device, ext_intel_device_info_uuid, pi_uint8_ptr) +__SYCL_PARAM_TRAITS_SPEC(device, ext_intel_device_info_uuid, info::array_type) diff --git a/sycl/include/CL/sycl/info/info_desc.hpp b/sycl/include/CL/sycl/info/info_desc.hpp index 05690db553317..c1ca776fd637e 100644 --- a/sycl/include/CL/sycl/info/info_desc.hpp +++ b/sycl/include/CL/sycl/info/info_desc.hpp @@ -12,6 +12,9 @@ #include #include +#include +#include + __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { @@ -22,6 +25,8 @@ class platform; // TODO: stop using OpenCL directly, use PI. namespace info { +using array_type = std::array; + // Information descriptors // A.1 Platform information descriptors enum class platform { diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index c5b03b3a1f3b5..956b91fbc8941 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1085,7 +1085,7 @@ get_device_info_host() { } template <> -inline pi_uint8_ptr +inline info::array_type get_device_info_host() { throw runtime_error( "Obtaining the device uuid is not supported on HOST device", diff --git a/sycl/test/on-device/extensions/intel-ext-device.cpp b/sycl/test/on-device/extensions/intel-ext-device.cpp index 55e08749fd774..2582fa957ad44 100644 --- a/sycl/test/on-device/extensions/intel-ext-device.cpp +++ b/sycl/test/on-device/extensions/intel-ext-device.cpp @@ -19,6 +19,8 @@ #include #include +#include +#include using namespace cl::sycl; @@ -101,6 +103,20 @@ int main(int argc, char **argv) { std::cout << "Failed!" << std::endl; return 1; } + } + + if (SYCL_EXT_INTEL_DEVICE_INFO >= 2) { + if (dev.has(aspect::ext_intel_device_info_uuid)) { + auto uuid = dev.get_info(); + + std::cout << "size = " << sizeof(uuid) << std::endl; + + if (sizeof(uuid) != 16 * sizeof(std::byte)) { + std::cout << "Error: Incorrect size of UUID." << std::endl; + std::cout << "Failed!" << std::endl; + return 1; + } + } } // SYCL_EXT_INTEL_DEVICE_INFO } std::cout << std::endl; From ffe610cd39157b45201f2482487a1983d4c44ead Mon Sep 17 00:00:00 2001 From: rbegam Date: Fri, 14 May 2021 15:03:51 -0700 Subject: [PATCH 09/21] modify the test. Signed-off-by: rbegam --- sycl/test/on-device/extensions/intel-ext-device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/on-device/extensions/intel-ext-device.cpp b/sycl/test/on-device/extensions/intel-ext-device.cpp index 2582fa957ad44..47f314ad753c9 100644 --- a/sycl/test/on-device/extensions/intel-ext-device.cpp +++ b/sycl/test/on-device/extensions/intel-ext-device.cpp @@ -109,7 +109,7 @@ int main(int argc, char **argv) { if (dev.has(aspect::ext_intel_device_info_uuid)) { auto uuid = dev.get_info(); - std::cout << "size = " << sizeof(uuid) << std::endl; + std::cout << "UUID size = " << sizeof(uuid) << std::endl; if (sizeof(uuid) != 16 * sizeof(std::byte)) { std::cout << "Error: Incorrect size of UUID." << std::endl; From 99248b0a274b5ba0f9860c7a8166bda9da4a1777 Mon Sep 17 00:00:00 2001 From: rbegam Date: Fri, 14 May 2021 15:14:18 -0700 Subject: [PATCH 10/21] minor modifications. Signed-off-by: rbegam --- sycl/include/CL/sycl/detail/pi.h | 1 - sycl/source/detail/device_impl.cpp | 2 -- sycl/test/on-device/extensions/intel-ext-device.cpp | 4 ++-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index ff99d93f09464..5d68a57f8ee81 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -65,7 +65,6 @@ using pi_uint64 = uint64_t; using pi_bool = pi_uint32; using pi_bitfield = pi_uint64; using pi_native_handle = uintptr_t; -using pi_uint8_ptr = uint8_t *; // // NOTE: prefer to map 1:1 to OpenCL so that no translation is needed diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 767916eb8dcd0..1ba11a4e78f62 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -308,8 +308,6 @@ bool device_impl::has(aspect Aspect) const { assert(return_size <= 16); std::byte uuid[16]; - //pi_uint8_ptr uuid = - // static_cast(malloc(return_size * sizeof(uint8_t))); return getPlugin().call_nocheck( MDevice, PI_DEVICE_INFO_UUID, 16 * sizeof(std::byte), uuid, nullptr) == PI_SUCCESS; diff --git a/sycl/test/on-device/extensions/intel-ext-device.cpp b/sycl/test/on-device/extensions/intel-ext-device.cpp index 47f314ad753c9..cf4e7da4d269b 100644 --- a/sycl/test/on-device/extensions/intel-ext-device.cpp +++ b/sycl/test/on-device/extensions/intel-ext-device.cpp @@ -18,9 +18,9 @@ #include -#include -#include #include +#include +#include using namespace cl::sycl; From 71b6a851f2530946c33fe2d4dca6df8bc41282f6 Mon Sep 17 00:00:00 2001 From: rbegam Date: Wed, 19 May 2021 14:30:36 -0700 Subject: [PATCH 11/21] moved uuid_type under sycl::detail. Signed-off-by: rbegam --- sycl/include/CL/sycl/detail/type_traits.hpp | 7 +++++++ sycl/include/CL/sycl/info/device_traits.def | 2 +- sycl/include/CL/sycl/info/info_desc.hpp | 5 ----- sycl/plugins/cuda/pi_cuda.cpp | 2 ++ sycl/plugins/level_zero/pi_level_zero.cpp | 3 +++ sycl/plugins/opencl/pi_opencl.cpp | 3 ++- sycl/source/detail/device_info.hpp | 2 +- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sycl/include/CL/sycl/detail/type_traits.hpp b/sycl/include/CL/sycl/detail/type_traits.hpp index 98989ab9fba2a..a8c11133a6b9c 100644 --- a/sycl/include/CL/sycl/detail/type_traits.hpp +++ b/sycl/include/CL/sycl/detail/type_traits.hpp @@ -15,6 +15,9 @@ #include +#include +#include + __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { template class group; @@ -51,6 +54,10 @@ __SYCL_INLINE_CONSTEXPR bool is_group_v = detail::is_group::value || detail::is_sub_group::value; namespace detail { +// Type for Intel device UUID extension. +// For details about this extension, see sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +using uuid_type = std::array; + template struct copy_cv_qualifiers; template diff --git a/sycl/include/CL/sycl/info/device_traits.def b/sycl/include/CL/sycl/info/device_traits.def index 4fe3f0ace377c..9d9e83ff4de7e 100644 --- a/sycl/include/CL/sycl/info/device_traits.def +++ b/sycl/include/CL/sycl/info/device_traits.def @@ -93,4 +93,4 @@ __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_gpu_subslices_per_slice, pi_uint32) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_gpu_eu_count_per_subslice, pi_uint32) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_max_mem_bandwidth, pi_uint64) __SYCL_PARAM_TRAITS_SPEC(device, ext_intel_mem_channel, bool) -__SYCL_PARAM_TRAITS_SPEC(device, ext_intel_device_info_uuid, info::array_type) +__SYCL_PARAM_TRAITS_SPEC(device, ext_intel_device_info_uuid, detail::uuid_type) diff --git a/sycl/include/CL/sycl/info/info_desc.hpp b/sycl/include/CL/sycl/info/info_desc.hpp index c1ca776fd637e..05690db553317 100644 --- a/sycl/include/CL/sycl/info/info_desc.hpp +++ b/sycl/include/CL/sycl/info/info_desc.hpp @@ -12,9 +12,6 @@ #include #include -#include -#include - __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { @@ -25,8 +22,6 @@ class platform; // TODO: stop using OpenCL directly, use PI. namespace info { -using array_type = std::array; - // Information descriptors // A.1 Platform information descriptors enum class platform { diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index f719c9c86fa1f..fe8adfdefaf38 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -1518,6 +1518,8 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, case PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: + // TODO: Check if Intel device UUID extension is utilized for CUDA. + // For details about this extension, see sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md case PI_DEVICE_INFO_UUID: return PI_INVALID_VALUE; diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index ba4a091083e7b..d4c465e6c1f63 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -1657,6 +1657,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, case PI_DEVICE_INFO_VENDOR_ID: return ReturnValue(pi_uint32{Device->ZeDeviceProperties.vendorId}); case PI_DEVICE_INFO_UUID: + // Intel extension for device UUID. This returns the UUID as + // std::array. For details about this extension, + // see sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md. return ReturnValue(Device->ZeDeviceProperties.uuid.id); case PI_DEVICE_INFO_EXTENSIONS: { // Convention adopted from OpenCL: diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 762bca1f94e10..41d0bf7950150 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -178,7 +178,8 @@ pi_result piDeviceGetInfo(pi_device device, pi_device_info paramName, case PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: - // Intel UUID extension. + // TODO: Check if device UUID extension is enabled in OpenCL. + // For details about Intel UUID extension, see sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md case PI_DEVICE_INFO_UUID: return PI_INVALID_VALUE; diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 956b91fbc8941..4b2cbf6e63865 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1085,7 +1085,7 @@ get_device_info_host() { } template <> -inline info::array_type +inline detail::uuid_type get_device_info_host() { throw runtime_error( "Obtaining the device uuid is not supported on HOST device", From 4ad63613f6414652cf0fc58f17bd140bfa4af152 Mon Sep 17 00:00:00 2001 From: rbegam Date: Wed, 19 May 2021 14:40:50 -0700 Subject: [PATCH 12/21] clang formatted. Signed-off-by: rbegam --- sycl/include/CL/sycl/detail/type_traits.hpp | 3 ++- sycl/plugins/cuda/pi_cuda.cpp | 3 ++- sycl/plugins/opencl/pi_opencl.cpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sycl/include/CL/sycl/detail/type_traits.hpp b/sycl/include/CL/sycl/detail/type_traits.hpp index a8c11133a6b9c..d2b5485041931 100644 --- a/sycl/include/CL/sycl/detail/type_traits.hpp +++ b/sycl/include/CL/sycl/detail/type_traits.hpp @@ -55,7 +55,8 @@ __SYCL_INLINE_CONSTEXPR bool is_group_v = namespace detail { // Type for Intel device UUID extension. -// For details about this extension, see sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +// For details about this extension, see +// sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md using uuid_type = std::array; template struct copy_cv_qualifiers; diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index fe8adfdefaf38..c9ef33907b33c 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -1519,7 +1519,8 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: // TODO: Check if Intel device UUID extension is utilized for CUDA. - // For details about this extension, see sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md + // For details about this extension, see + // sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md case PI_DEVICE_INFO_UUID: return PI_INVALID_VALUE; diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 41d0bf7950150..06dd2e9ca4d01 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -179,7 +179,8 @@ pi_result piDeviceGetInfo(pi_device device, pi_device_info paramName, case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: // TODO: Check if device UUID extension is enabled in OpenCL. - // For details about Intel UUID extension, see sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md + // For details about Intel UUID extension, see + // sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md case PI_DEVICE_INFO_UUID: return PI_INVALID_VALUE; From 1468a293e33469410d7532db6a781efa43382602 Mon Sep 17 00:00:00 2001 From: rbegam Date: Thu, 20 May 2021 11:35:09 -0700 Subject: [PATCH 13/21] fix has aspect. Signed-off-by: rbegam --- sycl/source/detail/device_impl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 1ba11a4e78f62..e486ea2624a40 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -299,8 +299,7 @@ bool device_impl::has(aspect Aspect) const { &return_size) == PI_SUCCESS; case aspect::ext_intel_device_info_uuid: { auto Result = getPlugin().call_nocheck( - MDevice, PI_DEVICE_INFO_UUID, sizeof(pi_device_type), &device_type, - &return_size); + MDevice, PI_DEVICE_INFO_UUID, 0, nullptr, &return_size); if (Result != PI_SUCCESS) { return false; } From 7256444dd9874ba1bd063092e3ce284dae21ba18 Mon Sep 17 00:00:00 2001 From: rbegam Date: Wed, 2 Jun 2021 14:11:52 -0700 Subject: [PATCH 14/21] add guard with C++17 check. Signed-off-by: rbegam --- sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md | 2 +- sycl/include/CL/sycl/detail/type_traits.hpp | 2 ++ sycl/source/detail/device_impl.cpp | 4 ++-- .../test/on-device/extensions/intel-ext-device.cpp | 14 -------------- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md index 1ecf02fc31447..6a5ae422a9847 100644 --- a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +++ b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md @@ -21,7 +21,7 @@ The Feature Test Macro SYCL\_EXT\_INTEL\_DEVICE\_INFO will be defined as one of A new device descriptor will be added which will provide the device Universal Unique ID (UUID). -This new device descriptor is currently only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior would be to expose the UUIDs of all supported GPU devices which enables detection of total number of unique devices. +This new device descriptor is currently only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior would be to expose the UUIDs of all supported devices which enables detection of total number of unique devices. ## Version ## diff --git a/sycl/include/CL/sycl/detail/type_traits.hpp b/sycl/include/CL/sycl/detail/type_traits.hpp index d2b5485041931..40a22d66b973a 100644 --- a/sycl/include/CL/sycl/detail/type_traits.hpp +++ b/sycl/include/CL/sycl/detail/type_traits.hpp @@ -57,7 +57,9 @@ namespace detail { // Type for Intel device UUID extension. // For details about this extension, see // sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +#if __cplusplus >= 201703L using uuid_type = std::array; +#endif template struct copy_cv_qualifiers; diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index e486ea2624a40..d194ca0eea613 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -305,10 +305,10 @@ bool device_impl::has(aspect Aspect) const { } assert(return_size <= 16); - std::byte uuid[16]; + std::byte UUID[16]; return getPlugin().call_nocheck( - MDevice, PI_DEVICE_INFO_UUID, 16 * sizeof(std::byte), uuid, + MDevice, PI_DEVICE_INFO_UUID, 16 * sizeof(std::byte), UUID, nullptr) == PI_SUCCESS; } case aspect::ext_intel_max_mem_bandwidth: diff --git a/sycl/test/on-device/extensions/intel-ext-device.cpp b/sycl/test/on-device/extensions/intel-ext-device.cpp index cf4e7da4d269b..7ab06e015723a 100644 --- a/sycl/test/on-device/extensions/intel-ext-device.cpp +++ b/sycl/test/on-device/extensions/intel-ext-device.cpp @@ -103,20 +103,6 @@ int main(int argc, char **argv) { std::cout << "Failed!" << std::endl; return 1; } - } - - if (SYCL_EXT_INTEL_DEVICE_INFO >= 2) { - if (dev.has(aspect::ext_intel_device_info_uuid)) { - auto uuid = dev.get_info(); - - std::cout << "UUID size = " << sizeof(uuid) << std::endl; - - if (sizeof(uuid) != 16 * sizeof(std::byte)) { - std::cout << "Error: Incorrect size of UUID." << std::endl; - std::cout << "Failed!" << std::endl; - return 1; - } - } } // SYCL_EXT_INTEL_DEVICE_INFO } std::cout << std::endl; From a7de8de5cf65ffe61514f030e0de816fb620598b Mon Sep 17 00:00:00 2001 From: rbegam Date: Wed, 2 Jun 2021 14:16:33 -0700 Subject: [PATCH 15/21] remove unnecessary code from the test. Signed-off-by: rbegam --- sycl/test/on-device/extensions/intel-ext-device.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/sycl/test/on-device/extensions/intel-ext-device.cpp b/sycl/test/on-device/extensions/intel-ext-device.cpp index 7ab06e015723a..55e08749fd774 100644 --- a/sycl/test/on-device/extensions/intel-ext-device.cpp +++ b/sycl/test/on-device/extensions/intel-ext-device.cpp @@ -18,8 +18,6 @@ #include -#include -#include #include using namespace cl::sycl; From 416027287a13d87c52db369cc912e13c71d7466b Mon Sep 17 00:00:00 2001 From: rbegam Date: Fri, 11 Jun 2021 14:43:27 -0700 Subject: [PATCH 16/21] changes uuid type and adds a unittest. Signed-off-by: rbegam --- .../extensions/IntelGPU/IntelGPUDeviceInfo.md | 2 +- sycl/include/CL/sycl/detail/type_traits.hpp | 4 +- sycl/source/detail/device_impl.cpp | 4 +- .../kernel-and-program/CMakeLists.txt | 1 + .../kernel-and-program/DeviceInfo.cpp | 78 +++++++++++++++++++ 5 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 sycl/unittests/kernel-and-program/DeviceInfo.cpp diff --git a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md index 6a5ae422a9847..06be3c70fbad8 100644 --- a/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md +++ b/sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md @@ -33,7 +33,7 @@ The extension supports this query in version 2 and later. | Device Descriptors | Return Type | Description | | ------------------ | ----------- | ----------- | -| info\:\:device\:\:ext\_intel\_device\_info\_uuid | std\:\:array\ | Returns the device UUID| +| info\:\:device\:\:ext\_intel\_device\_info\_uuid | unsigned char | Returns the device UUID| ## Aspects ## diff --git a/sycl/include/CL/sycl/detail/type_traits.hpp b/sycl/include/CL/sycl/detail/type_traits.hpp index 40a22d66b973a..6125d766c917e 100644 --- a/sycl/include/CL/sycl/detail/type_traits.hpp +++ b/sycl/include/CL/sycl/detail/type_traits.hpp @@ -57,9 +57,7 @@ namespace detail { // Type for Intel device UUID extension. // For details about this extension, see // sycl/doc/extensions/IntelGPU/IntelGPUDeviceInfo.md -#if __cplusplus >= 201703L -using uuid_type = std::array; -#endif +using uuid_type = std::array; template struct copy_cv_qualifiers; diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index d194ca0eea613..ce7d37dad5aca 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -305,10 +305,10 @@ bool device_impl::has(aspect Aspect) const { } assert(return_size <= 16); - std::byte UUID[16]; + unsigned char UUID[16]; return getPlugin().call_nocheck( - MDevice, PI_DEVICE_INFO_UUID, 16 * sizeof(std::byte), UUID, + MDevice, PI_DEVICE_INFO_UUID, 16 * sizeof(unsigned char), UUID, nullptr) == PI_SUCCESS; } case aspect::ext_intel_max_mem_bandwidth: diff --git a/sycl/unittests/kernel-and-program/CMakeLists.txt b/sycl/unittests/kernel-and-program/CMakeLists.txt index b6e5d3edbcd3f..ff102c5aaffb9 100644 --- a/sycl/unittests/kernel-and-program/CMakeLists.txt +++ b/sycl/unittests/kernel-and-program/CMakeLists.txt @@ -1,6 +1,7 @@ add_sycl_unittest(KernelAndProgramTests OBJECT KernelRelease.cpp KernelInfo.cpp + DeviceInfo.cpp PersistentDeviceCodeCache.cpp ) add_subdirectory(device) diff --git a/sycl/unittests/kernel-and-program/DeviceInfo.cpp b/sycl/unittests/kernel-and-program/DeviceInfo.cpp new file mode 100644 index 0000000000000..a6ef923cb26c6 --- /dev/null +++ b/sycl/unittests/kernel-and-program/DeviceInfo.cpp @@ -0,0 +1,78 @@ +//==-------------- KernelInfo.cpp --- kernel info unit test ----------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#define SYCL2020_DISABLE_DEPRECATION_WARNINGS + +#include +#include +#include +#include + +using namespace sycl; + +namespace { +struct TestCtx { + TestCtx(context &Ctx) : Ctx{Ctx} {}; + + context &Ctx; +}; +} // namespace + +static std::unique_ptr TestContext; + +static pi_result redefinedDeviceGetInfo(pi_device device, pi_device_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + return PI_SUCCESS; +} + +class DeviceInfoTest : public ::testing::Test { +public: + DeviceInfoTest() : Plt{default_selector()} {} + +protected: + void SetUp() override { + if (Plt.is_host()) { + std::clog << "This test is only supported on non-host platforms.\n"; + std::clog << "Current platform is " + << Plt.get_info() << "\n"; + return; + } + + Mock = std::make_unique(Plt); + + Mock->redefine( + redefinedDeviceGetInfo); + } + +protected: + platform Plt; + std::unique_ptr Mock; +}; + +TEST_F(DeviceInfoTest, GetDeviceUUID) { + if (Plt.is_host()) { + return; + } + + context Ctx{Plt}; + TestContext.reset(new TestCtx(Ctx)); + + device Dev = Ctx.get_devices()[0]; + + if (!Dev.has(aspect::ext_intel_device_info_uuid)) { + std::clog << "This test is only for the devices with UUID extension support.\n"; + return; + } + + auto UUID = Dev.get_info(); + + EXPECT_EQ(sizeof(UUID), 16 * sizeof(unsigned char)) + << "Expect piDeviceGetInfo to be " + << "called with PI_DEVICE_INFO_UUID"; +} From 2d1d711cce0a7480be6d247936ddb64ffe098e98 Mon Sep 17 00:00:00 2001 From: rbegam Date: Fri, 11 Jun 2021 14:51:04 -0700 Subject: [PATCH 17/21] clang formatted. Signed-off-by: rbegam --- sycl/unittests/kernel-and-program/DeviceInfo.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sycl/unittests/kernel-and-program/DeviceInfo.cpp b/sycl/unittests/kernel-and-program/DeviceInfo.cpp index a6ef923cb26c6..5a48a06cded5c 100644 --- a/sycl/unittests/kernel-and-program/DeviceInfo.cpp +++ b/sycl/unittests/kernel-and-program/DeviceInfo.cpp @@ -1,4 +1,4 @@ -//==-------------- KernelInfo.cpp --- kernel info unit test ----------------==// +//==-------------- DeviceInfo.cpp --- device info unit test ----------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -25,8 +25,10 @@ struct TestCtx { static std::unique_ptr TestContext; -static pi_result redefinedDeviceGetInfo(pi_device device, pi_device_info param_name, - size_t param_value_size, void *param_value, +static pi_result redefinedDeviceGetInfo(pi_device device, + pi_device_info param_name, + size_t param_value_size, + void *param_value, size_t *param_value_size_ret) { return PI_SUCCESS; } @@ -46,8 +48,7 @@ class DeviceInfoTest : public ::testing::Test { Mock = std::make_unique(Plt); - Mock->redefine( - redefinedDeviceGetInfo); + Mock->redefine(redefinedDeviceGetInfo); } protected: @@ -66,7 +67,8 @@ TEST_F(DeviceInfoTest, GetDeviceUUID) { device Dev = Ctx.get_devices()[0]; if (!Dev.has(aspect::ext_intel_device_info_uuid)) { - std::clog << "This test is only for the devices with UUID extension support.\n"; + std::clog + << "This test is only for the devices with UUID extension support.\n"; return; } From 244a082966fe5e1f4b354fd1f7a9dce1bccdae8e Mon Sep 17 00:00:00 2001 From: rbegam Date: Fri, 11 Jun 2021 14:56:55 -0700 Subject: [PATCH 18/21] remove old code. Signed-off-by: rbegam --- sycl/include/CL/sycl/detail/type_traits.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/sycl/include/CL/sycl/detail/type_traits.hpp b/sycl/include/CL/sycl/detail/type_traits.hpp index 6125d766c917e..aa29e6e96891f 100644 --- a/sycl/include/CL/sycl/detail/type_traits.hpp +++ b/sycl/include/CL/sycl/detail/type_traits.hpp @@ -16,7 +16,6 @@ #include #include -#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { From b344f6ded692b6355fd1b30c3b6845c1fd4f5350 Mon Sep 17 00:00:00 2001 From: rbegam Date: Mon, 14 Jun 2021 10:01:24 -0700 Subject: [PATCH 19/21] modified the unittest. Signed-off-by: rbegam --- sycl/unittests/kernel-and-program/DeviceInfo.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sycl/unittests/kernel-and-program/DeviceInfo.cpp b/sycl/unittests/kernel-and-program/DeviceInfo.cpp index 5a48a06cded5c..12e654b589420 100644 --- a/sycl/unittests/kernel-and-program/DeviceInfo.cpp +++ b/sycl/unittests/kernel-and-program/DeviceInfo.cpp @@ -20,6 +20,7 @@ struct TestCtx { TestCtx(context &Ctx) : Ctx{Ctx} {}; context &Ctx; + bool UUIDInfoCalled = false; }; } // namespace @@ -30,6 +31,10 @@ static pi_result redefinedDeviceGetInfo(pi_device device, size_t param_value_size, void *param_value, size_t *param_value_size_ret) { + if (param_name == PI_DEVICE_INFO_UUID) { + TestContext->UUIDInfoCalled = true; + } + return PI_SUCCESS; } @@ -74,7 +79,11 @@ TEST_F(DeviceInfoTest, GetDeviceUUID) { auto UUID = Dev.get_info(); - EXPECT_EQ(sizeof(UUID), 16 * sizeof(unsigned char)) + EXPECT_EQ(TestContext->UUIDInfoCalled, true) << "Expect piDeviceGetInfo to be " << "called with PI_DEVICE_INFO_UUID"; + + EXPECT_EQ(sizeof(UUID), 16 * sizeof(unsigned char)) + << "Expect device UUID to be " + << "of 16 bytes"; } From bddc7bc1ebe1eda25f8ac5d4d506ccd5af4e0851 Mon Sep 17 00:00:00 2001 From: rehana begam Date: Mon, 28 Jun 2021 13:34:33 -0700 Subject: [PATCH 20/21] minor corrections. Signed-off-by: rehana begam --- sycl/include/CL/sycl/detail/type_traits.hpp | 3 +-- sycl/unittests/kernel-and-program/DeviceInfo.cpp | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/sycl/include/CL/sycl/detail/type_traits.hpp b/sycl/include/CL/sycl/detail/type_traits.hpp index aa29e6e96891f..d1f45601c500f 100644 --- a/sycl/include/CL/sycl/detail/type_traits.hpp +++ b/sycl/include/CL/sycl/detail/type_traits.hpp @@ -13,9 +13,8 @@ #include #include -#include - #include +#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { diff --git a/sycl/unittests/kernel-and-program/DeviceInfo.cpp b/sycl/unittests/kernel-and-program/DeviceInfo.cpp index 12e654b589420..57139b368cb41 100644 --- a/sycl/unittests/kernel-and-program/DeviceInfo.cpp +++ b/sycl/unittests/kernel-and-program/DeviceInfo.cpp @@ -6,8 +6,6 @@ // //===----------------------------------------------------------------------===// -#define SYCL2020_DISABLE_DEPRECATION_WARNINGS - #include #include #include @@ -17,7 +15,7 @@ using namespace sycl; namespace { struct TestCtx { - TestCtx(context &Ctx) : Ctx{Ctx} {}; + TestCtx(context &Ctx) : Ctx{Ctx} {} context &Ctx; bool UUIDInfoCalled = false; From 22fa8f6b037fd860369283abab926351f38b2089 Mon Sep 17 00:00:00 2001 From: rehana begam Date: Wed, 30 Jun 2021 15:19:46 -0700 Subject: [PATCH 21/21] rearranged ext. Signed-off-by: rehana begam --- sycl/include/CL/sycl/info/info_desc.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sycl/include/CL/sycl/info/info_desc.hpp b/sycl/include/CL/sycl/info/info_desc.hpp index 05690db553317..d04695bf4da44 100644 --- a/sycl/include/CL/sycl/info/info_desc.hpp +++ b/sycl/include/CL/sycl/info/info_desc.hpp @@ -131,8 +131,6 @@ enum class device : cl_device_info { usm_shared_allocations = PI_USM_SINGLE_SHARED_SUPPORT, usm_restricted_shared_allocations = PI_USM_CROSS_SHARED_SUPPORT, usm_system_allocator = PI_USM_SYSTEM_SHARED_SUPPORT, - // uuid extension - ext_intel_device_info_uuid = PI_DEVICE_INFO_UUID, // intel extensions ext_intel_pci_address = PI_DEVICE_INFO_PCI_ADDRESS, ext_intel_gpu_eu_count = PI_DEVICE_INFO_GPU_EU_COUNT, @@ -142,7 +140,8 @@ enum class device : cl_device_info { ext_intel_gpu_eu_count_per_subslice = PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, ext_intel_max_mem_bandwidth = PI_DEVICE_INFO_MAX_MEM_BANDWIDTH, - ext_intel_mem_channel = PI_MEM_PROPERTIES_CHANNEL + ext_intel_mem_channel = PI_MEM_PROPERTIES_CHANNEL, + ext_intel_device_info_uuid = PI_DEVICE_INFO_UUID }; enum class device_type : pi_uint64 {