diff --git a/sycl/include/sycl/detail/pi.def b/sycl/include/sycl/detail/pi.def index c6b962b8b0f48..46a200e001231 100644 --- a/sycl/include/sycl/detail/pi.def +++ b/sycl/include/sycl/detail/pi.def @@ -31,6 +31,7 @@ _PI_API(piDeviceRetain) _PI_API(piDeviceRelease) _PI_API(piextDeviceSelectBinary) _PI_API(piextGetDeviceFunctionPointer) +_PI_API(piextGetGlobalVariablePointer) _PI_API(piextDeviceGetNativeHandle) _PI_API(piextDeviceCreateWithNativeHandle) // Context diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 56fdeb7a1051b..ee724af947e39 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -1287,6 +1287,10 @@ __SYCL_EXPORT pi_result piextGetDeviceFunctionPointer( pi_device device, pi_program program, const char *function_name, pi_uint64 *function_pointer_ret); +__SYCL_EXPORT pi_result piextGetGlobalVariablePointer( + pi_device Device, pi_program Program, const char *GlobalVariableName, + size_t *GlobalVariableSize, void **GlobalVariablePointerRet); + // // Context // diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 02fe3af901cb8..e6d395e758568 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -848,6 +848,15 @@ pi_result piextGetDeviceFunctionPointer(pi_device Device, pi_program Program, FunctionPointerRet); } +pi_result piextGetGlobalVariablePointer(pi_device Device, pi_program Program, + const char *GlobalVariableName, + size_t *GlobalVariableSize, + void **GlobalVariablePointerRet) { + return pi2ur::piextGetGlobalVariablePointer( + Device, Program, GlobalVariableName, GlobalVariableSize, + GlobalVariablePointerRet); +} + pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context, pi_device Device, pi_usm_mem_properties *Properties, size_t Size, diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index b895727c9d0fa..2fbde10b77123 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -851,6 +851,15 @@ pi_result piextGetDeviceFunctionPointer(pi_device Device, pi_program Program, FunctionPointerRet); } +pi_result piextGetGlobalVariablePointer(pi_device Device, pi_program Program, + const char *GlobalVariableName, + size_t *GlobalVariableSize, + void **GlobalVariablePointerRet) { + return pi2ur::piextGetGlobalVariablePointer( + Device, Program, GlobalVariableName, GlobalVariableSize, + GlobalVariablePointerRet); +} + pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context, pi_device Device, pi_usm_mem_properties *Properties, size_t Size, diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index c923c802f1d3f..26a1b104b3335 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -875,6 +875,15 @@ pi_result piextGetDeviceFunctionPointer(pi_device Device, pi_program Program, FunctionPointerRet); } +pi_result piextGetGlobalVariablePointer(pi_device Device, pi_program Program, + const char *GlobalVariableName, + size_t *GlobalVariableSize, + void **GlobalVariablePointerRet) { + return pi2ur::piextGetGlobalVariablePointer( + Device, Program, GlobalVariableName, GlobalVariableSize, + GlobalVariablePointerRet); +} + pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context, pi_device Device, pi_usm_mem_properties *Properties, size_t Size, diff --git a/sycl/plugins/native_cpu/pi_native_cpu.cpp b/sycl/plugins/native_cpu/pi_native_cpu.cpp index 2aef845590663..01b6dee1bb0f2 100644 --- a/sycl/plugins/native_cpu/pi_native_cpu.cpp +++ b/sycl/plugins/native_cpu/pi_native_cpu.cpp @@ -852,6 +852,15 @@ pi_result piextGetDeviceFunctionPointer(pi_device Device, pi_program Program, FunctionPointerRet); } +pi_result piextGetGlobalVariablePointer(pi_device Device, pi_program Program, + const char *GlobalVariableName, + size_t *GlobalVariableSize, + void **GlobalVariablePointerRet) { + return pi2ur::piextGetGlobalVariablePointer( + Device, Program, GlobalVariableName, GlobalVariableSize, + GlobalVariablePointerRet); +} + pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context, pi_device Device, pi_usm_mem_properties *Properties, size_t Size, diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 45fb66575ec42..e8a168b60445e 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -813,6 +813,15 @@ pi_result piextGetDeviceFunctionPointer(pi_device Device, pi_program Program, FunctionPointerRet); } +pi_result piextGetGlobalVariablePointer(pi_device Device, pi_program Program, + const char *GlobalVariableName, + size_t *GlobalVariableSize, + void **GlobalVariablePointerRet) { + return pi2ur::piextGetGlobalVariablePointer( + Device, Program, GlobalVariableName, GlobalVariableSize, + GlobalVariablePointerRet); +} + pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context, pi_device Device, pi_usm_mem_properties *Properties, size_t Size, diff --git a/sycl/plugins/unified_runtime/CMakeLists.txt b/sycl/plugins/unified_runtime/CMakeLists.txt index ab8cddeff8bb1..321acf522742b 100644 --- a/sycl/plugins/unified_runtime/CMakeLists.txt +++ b/sycl/plugins/unified_runtime/CMakeLists.txt @@ -56,14 +56,14 @@ endif() if(SYCL_PI_UR_USE_FETCH_CONTENT) include(FetchContent) - set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") - # commit e2ee9a4720414e0a59fa9c911e9575ab564ac57c - # Merge: 7a5150cd be622e7c + set(UNIFIED_RUNTIME_REPO "https://github.com/fabiomestre/unified-runtime.git") + # commit 588615e90bfd2b889834120dfff172236c6b8aa8 + # Merge: 4e69cc60 47084751 # Author: Kenneth Benzie (Benie) - # Date: Sun Mar 10 18:02:50 2024 +0000 - # Merge pull request #1340 from Bensuo/ewan/coverity_cuda_update - # [HIP][CUDA][Command-Buffer] Fix Coverity issues in HIP/CUDA command-buffer code - set(UNIFIED_RUNTIME_TAG e2ee9a4720414e0a59fa9c911e9575ab564ac57c) + # Date: Thu Feb 22 16:10:13 2024 +0000 + # Merge pull request #1371 from pbalcer/l0-query-status-sync-deadlock + # [L0] fix a deadlock in queue sync and event status query + set(UNIFIED_RUNTIME_TAG 1bc658a97c53c093b63ee1950147813401c8fd21) if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO) set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}") diff --git a/sycl/plugins/unified_runtime/pi2ur.hpp b/sycl/plugins/unified_runtime/pi2ur.hpp index 87ee60f41e2da..f1eb777046a90 100644 --- a/sycl/plugins/unified_runtime/pi2ur.hpp +++ b/sycl/plugins/unified_runtime/pi2ur.hpp @@ -2162,6 +2162,22 @@ inline pi_result piextGetDeviceFunctionPointer(pi_device Device, return PI_SUCCESS; } +inline pi_result piextGetGlobalVariablePointer( + pi_device Device, pi_program Program, const char *GlobalVariableName, + size_t *GlobalVariableSize, void **GlobalVariablePointerRet) { + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); + + auto UrDevice = reinterpret_cast(Device); + + ur_program_handle_t UrProgram = + reinterpret_cast(Program); + + HANDLE_ERRORS(urProgramGetGlobalVariablePointer( + UrDevice, UrProgram, GlobalVariableName, GlobalVariableSize, + GlobalVariablePointerRet)); + return PI_SUCCESS; +} + // Special version of piKernelSetArg to accept pi_mem. inline pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex, diff --git a/sycl/plugins/unified_runtime/pi_unified_runtime.cpp b/sycl/plugins/unified_runtime/pi_unified_runtime.cpp index 51d7041d03e48..6b491215c36af 100644 --- a/sycl/plugins/unified_runtime/pi_unified_runtime.cpp +++ b/sycl/plugins/unified_runtime/pi_unified_runtime.cpp @@ -763,6 +763,15 @@ __SYCL_EXPORT pi_result piextGetDeviceFunctionPointer( FunctionPointerRet); } +__SYCL_EXPORT pi_result piextGetGlobalVariablePointer( + pi_device Device, pi_program Program, const char *GlobalVariableName, + size_t *GlobalVariableSize, void **GlobalVariablePointerRet) { + + return pi2ur::piextGetGlobalVariablePointer( + Device, Program, GlobalVariableName, GlobalVariableSize, + GlobalVariablePointerRet); +} + /// Hint to migrate memory to the device /// /// @param Queue is the queue to submit to @@ -1424,6 +1433,7 @@ __SYCL_EXPORT pi_result piPluginInit(pi_plugin *PluginInit) { _PI_API(piProgramCompile) _PI_API(piProgramGetBuildInfo) _PI_API(piextGetDeviceFunctionPointer) + _PI_API(piextGetGlobalVariablePointer) _PI_API(piMemBufferCreate) _PI_API(piMemGetInfo) diff --git a/sycl/test/abi/pi_cuda_symbol_check.dump b/sycl/test/abi/pi_cuda_symbol_check.dump index 13b555bec8880..ec83769469dcd 100644 --- a/sycl/test/abi/pi_cuda_symbol_check.dump +++ b/sycl/test/abi/pi_cuda_symbol_check.dump @@ -115,6 +115,7 @@ piextEnqueueWriteHostPipe piextEventCreateWithNativeHandle piextEventGetNativeHandle piextGetDeviceFunctionPointer +piextGetGlobalVariablePointer piextImportExternalSemaphoreOpaqueFD piextKernelCreateWithNativeHandle piextKernelGetNativeHandle diff --git a/sycl/test/abi/pi_hip_symbol_check.dump b/sycl/test/abi/pi_hip_symbol_check.dump index 4c091716caedb..975e3315c0197 100644 --- a/sycl/test/abi/pi_hip_symbol_check.dump +++ b/sycl/test/abi/pi_hip_symbol_check.dump @@ -115,6 +115,7 @@ piextEnqueueWriteHostPipe piextEventCreateWithNativeHandle piextEventGetNativeHandle piextGetDeviceFunctionPointer +piextGetGlobalVariablePointer piextImportExternalSemaphoreOpaqueFD piextKernelCreateWithNativeHandle piextKernelGetNativeHandle diff --git a/sycl/test/abi/pi_level_zero_symbol_check.dump b/sycl/test/abi/pi_level_zero_symbol_check.dump index 7a90e461a30f6..336e1cd3cdd8e 100644 --- a/sycl/test/abi/pi_level_zero_symbol_check.dump +++ b/sycl/test/abi/pi_level_zero_symbol_check.dump @@ -114,6 +114,7 @@ piextEnqueueWriteHostPipe piextEventCreateWithNativeHandle piextEventGetNativeHandle piextGetDeviceFunctionPointer +piextGetGlobalVariablePointer piextImportExternalSemaphoreOpaqueFD piextKernelCreateWithNativeHandle piextKernelGetNativeHandle diff --git a/sycl/test/abi/pi_nativecpu_symbol_check.dump b/sycl/test/abi/pi_nativecpu_symbol_check.dump index 1929f3871cfe0..1294e7ae831cf 100644 --- a/sycl/test/abi/pi_nativecpu_symbol_check.dump +++ b/sycl/test/abi/pi_nativecpu_symbol_check.dump @@ -115,6 +115,7 @@ piextEnqueueWriteHostPipe piextEventCreateWithNativeHandle piextEventGetNativeHandle piextGetDeviceFunctionPointer +piextGetGlobalVariablePointer piextImportExternalSemaphoreOpaqueFD piextKernelCreateWithNativeHandle piextKernelGetNativeHandle diff --git a/sycl/test/abi/pi_opencl_symbol_check.dump b/sycl/test/abi/pi_opencl_symbol_check.dump index 159e427835651..fa7c7a2dc0525 100644 --- a/sycl/test/abi/pi_opencl_symbol_check.dump +++ b/sycl/test/abi/pi_opencl_symbol_check.dump @@ -114,6 +114,7 @@ piextEnqueueWriteHostPipe piextEventCreateWithNativeHandle piextEventGetNativeHandle piextGetDeviceFunctionPointer +piextGetGlobalVariablePointer piextImportExternalSemaphoreOpaqueFD piextKernelCreateWithNativeHandle piextKernelGetNativeHandle diff --git a/sycl/unittests/helpers/PiMockPlugin.hpp b/sycl/unittests/helpers/PiMockPlugin.hpp index 5ab408d2eed01..be777f23df239 100644 --- a/sycl/unittests/helpers/PiMockPlugin.hpp +++ b/sycl/unittests/helpers/PiMockPlugin.hpp @@ -280,6 +280,12 @@ mock_piextGetDeviceFunctionPointer(pi_device device, pi_program program, return PI_SUCCESS; } +inline pi_result mock_piextGetGlobalVariablePointer( + pi_device device, pi_program program, const char *global_variable_name, + size_t *global_variable_size, void **global_variable_size_ret) { + return PI_SUCCESS; +} + // // Context //