From e370466f3fd3f137006012041e95f5e3557e0871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Mestre?= Date: Fri, 23 Feb 2024 14:01:27 +0000 Subject: [PATCH 1/5] [UR] Add Global Variable Pointer entrypoint --- sycl/include/sycl/detail/pi.def | 1 + sycl/include/sycl/detail/pi.h | 4 ++++ sycl/plugins/cuda/pi_cuda.cpp | 9 +++++++++ sycl/plugins/hip/pi_hip.cpp | 9 +++++++++ sycl/plugins/level_zero/pi_level_zero.cpp | 9 +++++++++ sycl/plugins/native_cpu/pi_native_cpu.cpp | 9 +++++++++ sycl/plugins/opencl/pi_opencl.cpp | 9 +++++++++ sycl/plugins/unified_runtime/CMakeLists.txt | 14 +++++++------- sycl/plugins/unified_runtime/pi2ur.hpp | 16 ++++++++++++++++ .../unified_runtime/pi_unified_runtime.cpp | 10 ++++++++++ sycl/test/abi/pi_cuda_symbol_check.dump | 1 + sycl/test/abi/pi_hip_symbol_check.dump | 1 + sycl/test/abi/pi_level_zero_symbol_check.dump | 1 + sycl/test/abi/pi_nativecpu_symbol_check.dump | 1 + sycl/test/abi/pi_opencl_symbol_check.dump | 1 + sycl/unittests/helpers/PiMockPlugin.hpp | 6 ++++++ 16 files changed, 94 insertions(+), 7 deletions(-) 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 // From 45892f11de5d420d5def535e258a8f2aa0b20cda Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 14 Mar 2024 22:04:11 +0000 Subject: [PATCH 2/5] [UR] Bump tag to 6297b7fa --- sycl/plugins/unified_runtime/CMakeLists.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sycl/plugins/unified_runtime/CMakeLists.txt b/sycl/plugins/unified_runtime/CMakeLists.txt index 321acf522742b..7e2dbbe5af05f 100644 --- a/sycl/plugins/unified_runtime/CMakeLists.txt +++ b/sycl/plugins/unified_runtime/CMakeLists.txt @@ -57,13 +57,7 @@ if(SYCL_PI_UR_USE_FETCH_CONTENT) include(FetchContent) set(UNIFIED_RUNTIME_REPO "https://github.com/fabiomestre/unified-runtime.git") - # commit 588615e90bfd2b889834120dfff172236c6b8aa8 - # Merge: 4e69cc60 47084751 - # Author: Kenneth Benzie (Benie) - # 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) + set(UNIFIED_RUNTIME_TAG 6297b7fa772d93bfb4844836fe8b3e1036dd29a1) if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO) set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}") From 94060923002e6f82ec124f2bf04772e61ce873a9 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 18 Mar 2024 20:09:37 +0000 Subject: [PATCH 3/5] [UR] Bump tag to ca3da5aa --- sycl/plugins/unified_runtime/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/plugins/unified_runtime/CMakeLists.txt b/sycl/plugins/unified_runtime/CMakeLists.txt index ff6d8c68762cc..d3aa785c6981d 100644 --- a/sycl/plugins/unified_runtime/CMakeLists.txt +++ b/sycl/plugins/unified_runtime/CMakeLists.txt @@ -82,7 +82,7 @@ if(SYCL_PI_UR_USE_FETCH_CONTENT) endfunction() set(UNIFIED_RUNTIME_REPO "https://github.com/fabiomestre/unified-runtime.git") - set(UNIFIED_RUNTIME_TAG 6297b7fa772d93bfb4844836fe8b3e1036dd29a1) + set(UNIFIED_RUNTIME_TAG ca3da5aacc98e42ac9993a37a2cfae4bbb63063a) if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO) set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}") From bae7a5f1d2b68b1f96d3f74ee962a3072e352284 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 18 Mar 2024 23:57:30 +0000 Subject: [PATCH 4/5] [UR] Bump tag to 4d0183a8 --- sycl/plugins/unified_runtime/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sycl/plugins/unified_runtime/CMakeLists.txt b/sycl/plugins/unified_runtime/CMakeLists.txt index d3aa785c6981d..81543db0332ac 100644 --- a/sycl/plugins/unified_runtime/CMakeLists.txt +++ b/sycl/plugins/unified_runtime/CMakeLists.txt @@ -81,8 +81,14 @@ if(SYCL_PI_UR_USE_FETCH_CONTENT) CACHE PATH "Path to external '${name}' adapter source dir" FORCE) endfunction() - set(UNIFIED_RUNTIME_REPO "https://github.com/fabiomestre/unified-runtime.git") - set(UNIFIED_RUNTIME_TAG ca3da5aacc98e42ac9993a37a2cfae4bbb63063a) + set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") + # commit 4d0183a8e3152f7c5b7a814d5001c90cb2412051 + # Merge: 29ee45c4 ca3da5aa + # Author: Kenneth Benzie (Benie) + # Date: Mon Mar 18 23:56:24 2024 +0000 + # Merge pull request #1255 from fabiomestre/fabio/add_global_variable_pointer + # [SPEC] Add urProgramGetGlobalVariablePointer entrypoint + set(UNIFIED_RUNTIME_TAG 4d0183a8e3152f7c5b7a814d5001c90cb2412051) if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO) set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}") From d46bd540b24201b902ebfa34714c695cd82ecbf4 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 19 Mar 2024 13:20:19 +0000 Subject: [PATCH 5/5] [PI] Bump minor version --- sycl/include/sycl/detail/pi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index ee724af947e39..f6ee364c17a23 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 Add piextGetGlobalVariablePointer #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)