From 8ce98a21fb0abcb451616bea9b003ba2aa7a7db3 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 15 Mar 2024 04:26:06 -0700 Subject: [PATCH] [SYCL][PI] Add PI_ERROR_UNSUPPORTED_FEATURE error code This commit adds a new error code to PI as a mapping from UR_RESULT_ERROR_FEATURE_UNSUPPORTED. This relates to https://github.com/oneapi-src/unified-runtime/pull/1448. Signed-off-by: Larsen, Steffen --- sycl/include/sycl/detail/pi.h | 3 ++- sycl/include/sycl/detail/pi_error.def | 3 +++ sycl/plugins/native_cpu/pi_native_cpu.cpp | 4 ++-- sycl/plugins/unified_runtime/pi2ur.hpp | 3 ++- sycl/source/detail/memory_manager.cpp | 10 +++++----- sycl/source/detail/sampler_impl.cpp | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 56fdeb7a1051b..d2b2ae82f3625 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -154,9 +154,10 @@ // 15.44 Add coarse-grain memory advice flag for HIP. // 15.45 Added piextKernelSuggestMaxCooperativeGroupCount and // piextEnqueueCooperativeKernelLaunch. +// 15.46 Added PI_ERROR_FEATURE_UNSUPPORTED. #define _PI_H_VERSION_MAJOR 15 -#define _PI_H_VERSION_MINOR 45 +#define _PI_H_VERSION_MINOR 46 #define _PI_STRING_HELPER(a) #a #define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b) diff --git a/sycl/include/sycl/detail/pi_error.def b/sycl/include/sycl/detail/pi_error.def index d6651b53fccf1..e58cd52032b60 100644 --- a/sycl/include/sycl/detail/pi_error.def +++ b/sycl/include/sycl/detail/pi_error.def @@ -101,6 +101,9 @@ _PI_ERRC(PI_ERROR_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL, -1101) _PI_ERRC(PI_ERROR_UNINITIALIZED, -1102) // PI specific error codes +// PI_ERROR_UNSUPPORTED_FEATURE indicates that the backend or the corresponding +// device does not support the feature. +_PI_ERRC_WITH_MSG(PI_ERROR_UNSUPPORTED_FEATURE, -995, "The plugin or device does not support the called function") // PI_ERROR_PLUGIN_SPECIFIC_ERROR indicates that an backend spcific error or // warning has been emitted by the plugin. _PI_ERRC_WITH_MSG(PI_ERROR_PLUGIN_SPECIFIC_ERROR, -996, "The plugin has emitted a backend specific error") diff --git a/sycl/plugins/native_cpu/pi_native_cpu.cpp b/sycl/plugins/native_cpu/pi_native_cpu.cpp index 2aef845590663..194f307ae4e71 100644 --- a/sycl/plugins/native_cpu/pi_native_cpu.cpp +++ b/sycl/plugins/native_cpu/pi_native_cpu.cpp @@ -1257,13 +1257,13 @@ pi_result piextEnqueueCooperativeKernelLaunch( const size_t *, const size_t *, const size_t *, pi_uint32 , const pi_event *, pi_event *) { - return PI_ERROR_INVALID_OPERATION; + return PI_ERROR_UNSUPPORTED_FEATURE; } pi_result piextKernelSuggestMaxCooperativeGroupCount( pi_kernel , size_t , size_t , pi_uint32 *) { - return PI_ERROR_INVALID_OPERATION; + return PI_ERROR_UNSUPPORTED_FEATURE; } // Initialize function table with stubs. diff --git a/sycl/plugins/unified_runtime/pi2ur.hpp b/sycl/plugins/unified_runtime/pi2ur.hpp index 87ee60f41e2da..56f35b24b1cdc 100644 --- a/sycl/plugins/unified_runtime/pi2ur.hpp +++ b/sycl/plugins/unified_runtime/pi2ur.hpp @@ -100,8 +100,9 @@ static pi_result ur2piResult(ur_result_t urResult) { case UR_RESULT_ERROR_PROGRAM_LINK_FAILURE: return PI_ERROR_LINK_PROGRAM_FAILURE; case UR_RESULT_ERROR_UNSUPPORTED_VERSION: - case UR_RESULT_ERROR_UNSUPPORTED_FEATURE: return PI_ERROR_INVALID_OPERATION; + case UR_RESULT_ERROR_UNSUPPORTED_FEATURE: + return PI_ERROR_UNSUPPORTED_FEATURE; case UR_RESULT_ERROR_INVALID_ARGUMENT: case UR_RESULT_ERROR_INVALID_NULL_HANDLE: case UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE: diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 527297aa32371..c0af141935bd5 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -1533,7 +1533,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, Deps.size(), Deps.data(), OutSyncPoint); - if (Result == PI_ERROR_INVALID_OPERATION) { + if (Result == PI_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), "Device-to-host buffer copy command not supported by graph backend"); @@ -1563,7 +1563,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( &BufferOffset, &HostOffset, &RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, DstMem, Deps.size(), Deps.data(), OutSyncPoint); - if (Result == PI_ERROR_INVALID_OPERATION) { + if (Result == PI_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), "Device-to-host buffer copy command not supported by graph backend"); @@ -1610,7 +1610,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, Deps.size(), Deps.data(), OutSyncPoint); - if (Result == PI_ERROR_INVALID_OPERATION) { + if (Result == PI_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), "Host-to-device buffer copy command not supported by graph backend"); @@ -1641,7 +1641,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( BufferSlicePitch, HostRowPitch, HostSlicePitch, SrcMem, Deps.size(), Deps.data(), OutSyncPoint); - if (Result == PI_ERROR_INVALID_OPERATION) { + if (Result == PI_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), "Host-to-device buffer copy command not supported by graph backend"); @@ -1665,7 +1665,7 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer( Plugin->call_nocheck( CommandBuffer, DstMem, SrcMem, Len, Deps.size(), Deps.data(), OutSyncPoint); - if (Result == PI_ERROR_INVALID_OPERATION) { + if (Result == PI_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), "USM copy command not supported by graph backend"); diff --git a/sycl/source/detail/sampler_impl.cpp b/sycl/source/detail/sampler_impl.cpp index 78473d87b3689..c2af7884a164c 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -73,7 +73,7 @@ sampler_impl::getOrCreateSampler(const context &Context) { errcode_ret = Plugin->call_nocheck( getSyclObjImpl(Context)->getHandleRef(), sprops, &resultSampler); - if (errcode_ret == PI_ERROR_INVALID_OPERATION) + if (errcode_ret == PI_ERROR_UNSUPPORTED_FEATURE) throw sycl::exception(sycl::errc::feature_not_supported, "Images are not supported by this device.");