From eb38e8c0c338c5f9d0796996c589a53f4a35031e Mon Sep 17 00:00:00 2001 From: Brandon Yates Date: Tue, 25 Apr 2023 10:44:55 -0400 Subject: [PATCH 1/2] Fix failing device CTS Signed-off-by: Brandon Yates --- .../level_zero/ur_level_zero_device.cpp | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index d32eb5bd03308..a1d9bb3ce76d6 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -89,7 +89,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet( UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( ur_device_handle_t Device, ///< [in] handle of the device instance ur_device_info_t ParamName, ///< [in] type of the info to retrieve - size_t propSize, ///< [in] the number of bytes pointed to by pDeviceInfo. + size_t propSize, ///< [in] the number of bytes pointed to by ParamValue. void *ParamValue, ///< [out][optional] array of bytes holding the info. ///< If propSize is not equal to or greater than the real ///< number of bytes needed to return the info then the @@ -130,8 +130,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( return ReturnValue(UUID, sizeof(UUID)); } case UR_DEVICE_INFO_ATOMIC_64: - return ReturnValue(uint32_t{Device->ZeDeviceModuleProperties->flags & - ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS}); + return ReturnValue(static_cast(Device->ZeDeviceModuleProperties->flags & + ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS)); case UR_DEVICE_INFO_EXTENSIONS: { // Convention adopted from OpenCL: // "Returns a space separated list of extension names (the extension @@ -195,9 +195,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_EXT_DEVICE_INFO_BUILD_ON_SUBDEVICE: return ReturnValue(uint32_t{0}); case UR_DEVICE_INFO_COMPILER_AVAILABLE: - return ReturnValue(uint32_t{1}); + return ReturnValue(static_cast(true)); case UR_DEVICE_INFO_LINKER_AVAILABLE: - return ReturnValue(uint32_t{1}); + return ReturnValue(static_cast(true)); case UR_DEVICE_INFO_MAX_COMPUTE_UNITS: { uint32_t MaxComputeUnits = Device->ZeDeviceProperties->numEUsPerSubslice * @@ -255,12 +255,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( uint64_t{Device->ZeDeviceComputeProperties->maxSharedLocalMemory}); case UR_DEVICE_INFO_IMAGE_SUPPORTED: return ReturnValue( - uint32_t{Device->ZeDeviceImageProperties->maxImageDims1D > 0}); + static_cast(Device->ZeDeviceImageProperties->maxImageDims1D > 0)); case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY: - return ReturnValue(uint32_t{(Device->ZeDeviceProperties->flags & - ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) != 0}); + return ReturnValue(static_cast((Device->ZeDeviceProperties->flags & + ZE_DEVICE_PROPERTY_FLAG_INTEGRATED) != 0)); case UR_DEVICE_INFO_AVAILABLE: - return ReturnValue(uint32_t{ZeDevice ? true : false}); + return ReturnValue(static_cast(ZeDevice ? true : false)); case UR_DEVICE_INFO_VENDOR: // TODO: Level-Zero does not return vendor's name at the moment // only the ID. @@ -346,7 +346,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_EXT_DEVICE_INFO_OPENCL_C_VERSION: return ReturnValue(""); case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: - return ReturnValue(uint32_t{true}); + return ReturnValue(static_cast(true)); case UR_DEVICE_INFO_PRINTF_BUFFER_SIZE: return ReturnValue( size_t{Device->ZeDeviceModuleProperties->printfBufferSize}); @@ -363,12 +363,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( return ReturnValue(ur_device_exec_capability_flag_t{ UR_DEVICE_EXEC_CAPABILITY_FLAG_NATIVE_KERNEL}); case UR_DEVICE_INFO_ENDIAN_LITTLE: - return ReturnValue(uint32_t{true}); + return ReturnValue(static_cast(true)); case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT: - return ReturnValue(uint32_t{Device->ZeDeviceProperties->flags & - ZE_DEVICE_PROPERTY_FLAG_ECC}); + return ReturnValue(static_cast(Device->ZeDeviceProperties->flags & + ZE_DEVICE_PROPERTY_FLAG_ECC)); case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION: - return ReturnValue(size_t{Device->ZeDeviceProperties->timerResolution}); + return ReturnValue(static_cast(Device->ZeDeviceProperties->timerResolution)); case UR_DEVICE_INFO_LOCAL_MEM_TYPE: return ReturnValue(UR_DEVICE_LOCAL_MEM_TYPE_LOCAL); case UR_DEVICE_INFO_MAX_CONSTANT_ARGS: @@ -402,7 +402,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( return ReturnValue( uint32_t{Device->ZeDeviceImageProperties->maxWriteImageArgs}); case UR_DEVICE_INFO_SINGLE_FP_CONFIG: { - uint64_t SingleFPValue = 0; + ur_device_fp_capability_flags_t SingleFPValue = 0; ze_device_fp_flags_t ZeSingleFPCapabilities = Device->ZeDeviceModuleProperties->fp32flags; if (ZE_DEVICE_FP_FLAG_DENORM & ZeSingleFPCapabilities) { @@ -427,10 +427,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( SingleFPValue |= UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT; } - return ReturnValue(uint64_t{SingleFPValue}); + return ReturnValue(SingleFPValue); } case UR_DEVICE_INFO_HALF_FP_CONFIG: { - uint64_t HalfFPValue = 0; + ur_device_fp_capability_flags_t HalfFPValue = 0; ze_device_fp_flags_t ZeHalfFPCapabilities = Device->ZeDeviceModuleProperties->fp16flags; if (ZE_DEVICE_FP_FLAG_DENORM & ZeHalfFPCapabilities) { @@ -454,10 +454,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( if (ZE_DEVICE_FP_FLAG_ROUNDED_DIVIDE_SQRT & ZeHalfFPCapabilities) { HalfFPValue |= UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT; } - return ReturnValue(uint64_t{HalfFPValue}); + return ReturnValue(HalfFPValue); } case UR_DEVICE_INFO_DOUBLE_FP_CONFIG: { - uint64_t DoubleFPValue = 0; + ur_device_fp_capability_flags_t DoubleFPValue = 0; ze_device_fp_flags_t ZeDoubleFPCapabilities = Device->ZeDeviceModuleProperties->fp64flags; if (ZE_DEVICE_FP_FLAG_DENORM & ZeDoubleFPCapabilities) { @@ -482,7 +482,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( DoubleFPValue |= UR_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT; } - return ReturnValue(uint64_t{DoubleFPValue}); + return ReturnValue(DoubleFPValue); } case UR_DEVICE_INFO_IMAGE2D_MAX_WIDTH: return ReturnValue(size_t{Device->ZeDeviceImageProperties->maxImageDims2D}); @@ -537,7 +537,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( } case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: { // TODO: Not supported yet. Needs to be updated after support is added. - return ReturnValue(uint32_t{false}); + return ReturnValue(static_cast(false)); } case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: { // ze_device_compute_properties.subGroupSizes is in uint32_t whereas the @@ -569,6 +569,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT: case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: { auto MapCaps = [](const ze_memory_access_cap_flags_t &ZeCapabilities) { +#ifdef UR_SUPPORTS_USM_MEM_CAPS // #280 uint64_t Capabilities = 0; if (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_RW) Capabilities |= UR_EXT_USM_CAPS_ACCESS; @@ -579,6 +580,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( if (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC) Capabilities |= UR_EXT_USM_CAPS_CONCURRENT_ATOMIC_ACCESS; return Capabilities; +#else + ur_bool_t Capabilities = (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_RW); + return Capabilities; +#endif }; auto &Props = Device->ZeDeviceMemoryAccessProperties; switch (ParamName) { @@ -698,6 +703,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( Device->ZeDeviceProperties->numSlices; return ReturnValue(uint32_t{count}); } + case UR_DEVICE_INFO_GPU_EU_SLICES: { + return ReturnValue(uint32_t{Device->ZeDeviceProperties->numSlices}); + } case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH: return ReturnValue( uint32_t{Device->ZeDeviceProperties->physicalEUSimdWidth}); @@ -766,9 +774,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { - return ReturnValue(0); + ur_queue_flags_t queue_flags = 0; + return ReturnValue(queue_flags); + } + case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS: { + return ReturnValue(static_cast(0)); //__read_write attribute currently undefinde in opencl } + default: urPrint("Unsupported ParamName in urGetDeviceInfo\n"); urPrint("ParamName=%d(0x%x)\n", ParamName, ParamName); From 3c8c609ec1f0fb345f5e68e9d929d5aa79262317 Mon Sep 17 00:00:00 2001 From: Brandon Yates Date: Tue, 25 Apr 2023 14:49:39 -0400 Subject: [PATCH 2/2] Fixes Signed-off-by: Brandon Yates --- sycl/plugins/unified_runtime/pi2ur.hpp | 6 +++--- .../ur/adapters/level_zero/ur_level_zero_device.cpp | 12 +++--------- sycl/plugins/unified_runtime/ur/ur.hpp | 3 --- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/sycl/plugins/unified_runtime/pi2ur.hpp b/sycl/plugins/unified_runtime/pi2ur.hpp index 4aa8087b65779..d1da6eeb0cfe4 100644 --- a/sycl/plugins/unified_runtime/pi2ur.hpp +++ b/sycl/plugins/unified_runtime/pi2ur.hpp @@ -858,7 +858,7 @@ inline pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, InfoType = (ur_device_info_t)UR_DEVICE_INFO_DEVICE_ID; break; case PI_EXT_INTEL_DEVICE_INFO_FREE_MEMORY: - InfoType = (ur_device_info_t)UR_EXT_DEVICE_INFO_FREE_MEMORY; + InfoType = (ur_device_info_t)UR_DEVICE_INFO_GLOBAL_MEM_FREE; break; case PI_EXT_INTEL_DEVICE_INFO_MEMORY_CLOCK_RATE: InfoType = (ur_device_info_t)UR_DEVICE_INFO_MEMORY_CLOCK_RATE; @@ -870,7 +870,7 @@ inline pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, InfoType = (ur_device_info_t)UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES; break; case PI_DEVICE_INFO_GPU_SLICES: - InfoType = (ur_device_info_t)UR_EXT_DEVICE_INFO_GPU_SLICES; + InfoType = (ur_device_info_t)UR_DEVICE_INFO_GPU_EU_SLICES; break; case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: InfoType = (ur_device_info_t)UR_EXT_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE; @@ -879,7 +879,7 @@ inline pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, InfoType = (ur_device_info_t)UR_EXT_DEVICE_INFO_GPU_HW_THREADS_PER_EU; break; case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: - InfoType = (ur_device_info_t)UR_EXT_DEVICE_INFO_MAX_MEM_BANDWIDTH; + InfoType = (ur_device_info_t)UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH; break; case PI_EXT_ONEAPI_DEVICE_INFO_BFLOAT16_MATH_FUNCTIONS: InfoType = (ur_device_info_t)UR_DEVICE_INFO_BFLOAT16; diff --git a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp index a1d9bb3ce76d6..02c3232176177 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp @@ -266,6 +266,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( // only the ID. return ReturnValue("Intel(R) Corporation"); case UR_DEVICE_INFO_DRIVER_VERSION: + case UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION: return ReturnValue(Device->Platform->ZeDriverVersion.c_str()); case UR_DEVICE_INFO_VERSION: return ReturnValue(Device->Platform->ZeDriverApiVersion.c_str()); @@ -569,7 +570,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT: case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: { auto MapCaps = [](const ze_memory_access_cap_flags_t &ZeCapabilities) { -#ifdef UR_SUPPORTS_USM_MEM_CAPS // #280 uint64_t Capabilities = 0; if (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_RW) Capabilities |= UR_EXT_USM_CAPS_ACCESS; @@ -580,10 +580,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( if (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC) Capabilities |= UR_EXT_USM_CAPS_CONCURRENT_ATOMIC_ACCESS; return Capabilities; -#else - ur_bool_t Capabilities = (ZeCapabilities & ZE_MEMORY_ACCESS_CAP_FLAG_RW); - return Capabilities; -#endif }; auto &Props = Device->ZeDeviceMemoryAccessProperties; switch (ParamName) { @@ -622,7 +618,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( return ReturnValue(AddressBuffer); } - case UR_EXT_DEVICE_INFO_FREE_MEMORY: { + case UR_DEVICE_INFO_GLOBAL_MEM_FREE: { if (getenv("ZES_ENABLE_SYSMAN") == nullptr) { setErrorMessage("Set ZES_ENABLE_SYSMAN=1 to obtain free memory", UR_RESULT_SUCCESS); @@ -709,8 +705,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH: return ReturnValue( uint32_t{Device->ZeDeviceProperties->physicalEUSimdWidth}); - case UR_EXT_DEVICE_INFO_GPU_SLICES: - return ReturnValue(uint32_t{Device->ZeDeviceProperties->numSlices}); case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: return ReturnValue( uint32_t{Device->ZeDeviceProperties->numSubslicesPerSlice}); @@ -718,7 +712,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( return ReturnValue(uint32_t{Device->ZeDeviceProperties->numEUsPerSubslice}); case UR_EXT_DEVICE_INFO_GPU_HW_THREADS_PER_EU: return ReturnValue(uint32_t{Device->ZeDeviceProperties->numThreadsPerEU}); - case UR_EXT_DEVICE_INFO_MAX_MEM_BANDWIDTH: + case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: // currently not supported in level zero runtime return UR_RESULT_ERROR_INVALID_VALUE; case UR_DEVICE_INFO_BFLOAT16: { diff --git a/sycl/plugins/unified_runtime/ur/ur.hpp b/sycl/plugins/unified_runtime/ur/ur.hpp index 2399e50104f17..58b37fd366c5d 100644 --- a/sycl/plugins/unified_runtime/ur/ur.hpp +++ b/sycl/plugins/unified_runtime/ur/ur.hpp @@ -29,17 +29,14 @@ const int UR_EXT_DEVICE_INFO_MAX_WORK_GROUPS_3D = UR_EXT_DEVICE_INFO_END - 2; // UR_EXT_DEVICE_INFO_END - 3; // const int ZER_EXT_DEVICE_INFO_BFLOAT16_MATH_FUNCTIONS = // UR_EXT_DEVICE_INFO_END - 4; -const int UR_EXT_DEVICE_INFO_MAX_MEM_BANDWIDTH = UR_EXT_DEVICE_INFO_END - 6; const int UR_EXT_DEVICE_INFO_GPU_HW_THREADS_PER_EU = UR_EXT_DEVICE_INFO_END - 7; const int UR_EXT_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = UR_EXT_DEVICE_INFO_END - 8; -const int UR_EXT_DEVICE_INFO_GPU_SLICES = UR_EXT_DEVICE_INFO_END - 9; // const int UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES = // UR_EXT_DEVICE_INFO_END - 10; const int UR_EXT_DEVICE_INFO_MEMORY_BUS_WIDTH = UR_EXT_DEVICE_INFO_END - 11; // const int ZER_EXT_DEVICE_INFO_MEMORY_CLOCK_RATE = UR_EXT_DEVICE_INFO_END - // 12; -const int UR_EXT_DEVICE_INFO_FREE_MEMORY = UR_EXT_DEVICE_INFO_END - 13; // const int ZER_EXT_DEVICE_INFO_DEVICE_ID = UR_EXT_DEVICE_INFO_END - 14; // const int ZER_EXT_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE = // UR_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE;