From 9180bdc02f66a8c3cf2e869fa700397585ae420e Mon Sep 17 00:00:00 2001 From: Fare Date: Tue, 3 Sep 2024 10:41:32 +0100 Subject: [PATCH 01/21] WIP: Use Windows proxy loader for UR --- sycl/cmake/modules/FetchUnifiedRuntime.cmake | 7 +- sycl/include/sycl/detail/ur.hpp | 24 ++- sycl/source/CMakeLists.txt | 4 +- sycl/source/backend.cpp | 39 +++-- sycl/source/backend/level_zero.cpp | 2 +- sycl/source/backend/opencl.cpp | 8 +- sycl/source/context.cpp | 2 +- sycl/source/detail/allowlist.cpp | 2 +- sycl/source/detail/bindless_images.cpp | 53 +++---- sycl/source/detail/buffer_impl.cpp | 8 +- sycl/source/detail/context_impl.cpp | 26 ++-- sycl/source/detail/context_info.hpp | 2 +- .../source/detail/device_global_map_entry.cpp | 4 +- sycl/source/detail/device_image_impl.hpp | 6 +- sycl/source/detail/device_impl.cpp | 139 +++++++----------- sycl/source/detail/device_info.hpp | 103 +++++-------- .../detail/error_handling/error_handling.cpp | 20 +-- sycl/source/detail/event_impl.cpp | 16 +- sycl/source/detail/event_info.hpp | 4 +- sycl/source/detail/global_handler.cpp | 5 +- sycl/source/detail/graph_impl.cpp | 20 ++- sycl/source/detail/image_impl.cpp | 4 +- sycl/source/detail/kernel_bundle_impl.hpp | 16 +- sycl/source/detail/kernel_impl.cpp | 6 +- sycl/source/detail/kernel_impl.hpp | 10 +- sycl/source/detail/kernel_info.hpp | 14 +- sycl/source/detail/kernel_program_cache.hpp | 4 +- sycl/source/detail/memory_manager.cpp | 104 ++++++------- .../detail/persistent_device_code_cache.cpp | 6 +- sycl/source/detail/physical_mem_impl.hpp | 7 +- sycl/source/detail/platform_impl.cpp | 14 +- sycl/source/detail/platform_impl.hpp | 7 +- sycl/source/detail/platform_info.hpp | 4 +- sycl/source/detail/plugin.hpp | 60 ++++++-- .../program_manager/program_manager.cpp | 95 ++++++------ sycl/source/detail/queue_impl.cpp | 10 +- sycl/source/detail/queue_impl.hpp | 16 +- sycl/source/detail/sampler_impl.cpp | 12 +- sycl/source/detail/scheduler/commands.cpp | 79 +++++----- sycl/source/detail/sycl_mem_obj_t.cpp | 18 +-- sycl/source/detail/ur.cpp | 43 ++++-- sycl/source/detail/ur_utils.hpp | 4 +- sycl/source/detail/usm/usm_impl.cpp | 17 +-- sycl/source/detail/windows_ur.cpp | 5 + sycl/source/device.cpp | 24 +-- sycl/source/event.cpp | 2 +- sycl/source/handler.cpp | 5 +- sycl/source/interop_handle.cpp | 4 +- sycl/source/kernel.cpp | 4 +- sycl/source/platform.cpp | 2 +- sycl/source/virtual_mem.cpp | 16 +- 51 files changed, 551 insertions(+), 555 deletions(-) diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/FetchUnifiedRuntime.cmake index d3da2e00062b2..8f033a8c78bf9 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/FetchUnifiedRuntime.cmake @@ -23,8 +23,7 @@ option(SYCL_UR_USE_FETCH_CONTENT set(SYCL_UR_SOURCE_DIR "" CACHE PATH "Path to root of Unified Runtime repository") -option(SYCL_UMF_DISABLE_HWLOC - "Disable hwloc support in UMF" ON) + set(SYCL_UMF_DISABLE_HWLOC ON CACHE BOOL "Disable hwloc support in UMF") # Here we override the defaults to disable building tests from unified-runtime set(UR_BUILD_EXAMPLES OFF CACHE BOOL "Build example applications." FORCE) @@ -116,14 +115,14 @@ if(SYCL_UR_USE_FETCH_CONTENT) CACHE PATH "Path to external '${name}' adapter source dir" FORCE) endfunction() - set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") + set(UNIFIED_RUNTIME_REPO "https://github.com/callumfare/unified-runtime.git") # commit b766009add8dc41ad03e2a63be9f6ed40eea4c55 (HEAD, origin/main, origin/HEAD) # Merge: 608e9184 c3c57284 # Author: Omar Ahmed # Date: Tue Aug 27 16:30:04 2024 +0100 # Merge pull request #2011 from nrspruit/fix_opencl_usm_align_check # [OpenCL] Fix USM alignment error check to occur always and return nulllptr - set(UNIFIED_RUNTIME_TAG b766009add8dc41ad03e2a63be9f6ed40eea4c55) + set(UNIFIED_RUNTIME_TAG callum/ur_api_def) set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") # Due to the use of dependentloadflag and no installer for UMF and hwloc we need diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index 9f306ad479299..18f1059eddd77 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -17,7 +17,8 @@ #include #include #include -# +#define NOMINMAX +#include #include #include @@ -48,6 +49,25 @@ class context; namespace detail { +enum class UrApiKind { +#define _UR_API(api) api, +#include +#undef _UR_API +}; + +template struct UrFuncInfo {}; + +#define _UR_API(api) \ + template <> struct UrFuncInfo { \ + using FuncPtrT = decltype(&::api); \ + inline const char *getFuncName() { return #api; } \ + inline FuncPtrT getFuncPtr(void *module) { \ + return (FuncPtrT)GetProcAddress((HMODULE)module, #api); \ + } \ + }; +#include +#undef _UR_API + namespace pi { // This function is deprecated and it should be removed in the next release // cycle (along with the definition for pi_context_extended_deleter). @@ -76,6 +96,8 @@ int unloadOsLibrary(void *Library); // library, implementation is OS dependent. void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName); +void* loadURLoaderLibrary(); + // Performs UR one-time initialization. std::vector & initializeUr(ur_loader_config_handle_t LoaderConfig = nullptr); diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 6b483615ce0b2..db705d39c5b63 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -166,7 +166,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # Link and include UR target_link_libraries(${LIB_OBJ_NAME} PRIVATE - UnifiedRuntimeLoader + # UnifiedRuntimeLoader UnifiedRuntime-Headers UnifiedRuntimeCommon ) @@ -181,7 +181,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) target_link_libraries(${LIB_NAME} PRIVATE - UnifiedRuntimeLoader + # UnifiedRuntimeLoader UnifiedRuntime-Headers UnifiedRuntimeCommon ) diff --git a/sycl/source/backend.cpp b/sycl/source/backend.cpp index 2ce8c4c348c88..fd04985d46d3e 100644 --- a/sycl/source/backend.cpp +++ b/sycl/source/backend.cpp @@ -72,7 +72,7 @@ platform make_platform(ur_native_handle_t NativeHandle, backend Backend) { // Create UR platform first. ur_platform_handle_t UrPlatform = nullptr; - Plugin->call(urPlatformCreateWithNativeHandle, NativeHandle, + Plugin->call( NativeHandle, Plugin->getUrAdapter(), nullptr, &UrPlatform); return detail::createSyclObjFromImpl( @@ -84,7 +84,7 @@ __SYCL_EXPORT device make_device(ur_native_handle_t NativeHandle, const auto &Plugin = getPlugin(Backend); ur_device_handle_t UrDevice = nullptr; - Plugin->call(urDeviceCreateWithNativeHandle, NativeHandle, + Plugin->call( NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice); // Construct the SYCL device from UR device. return detail::createSyclObjFromImpl( @@ -105,7 +105,7 @@ __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle, for (const auto &Dev : DeviceList) { DeviceHandles.push_back(detail::getSyclObjImpl(Dev)->getHandleRef()); } - Plugin->call(urContextCreateWithNativeHandle, NativeHandle, + Plugin->call( NativeHandle, Plugin->getUrAdapter(), DeviceHandles.size(), DeviceHandles.data(), &Properties, &UrContext); // Construct the SYCL context from UR context. @@ -150,7 +150,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, // Create UR queue first. ur_queue_handle_t UrQueue = nullptr; - Plugin->call(urQueueCreateWithNativeHandle, NativeHandle, + Plugin->call( NativeHandle, ContextImpl->getHandleRef(), UrDevice, &NativeProperties, &UrQueue); // Construct the SYCL queue from UR queue. @@ -174,13 +174,13 @@ __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle, Properties.stype = UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call(urEventCreateWithNativeHandle, NativeHandle, + Plugin->call( NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrEvent); event Event = detail::createSyclObjFromImpl( std::make_shared(UrEvent, Context)); if (Backend == backend::opencl) - Plugin->call(urEventRetain, UrEvent); + Plugin->call( UrEvent); return Event; } @@ -196,33 +196,33 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call(urProgramCreateWithNativeHandle, NativeHandle, + Plugin->call( NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrProgram); if (ContextImpl->getBackend() == backend::opencl) - Plugin->call(urProgramRetain, UrProgram); + Plugin->call( UrProgram); std::vector ProgramDevices; uint32_t NumDevices = 0; - Plugin->call(urProgramGetInfo, UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, + Plugin->call( UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, nullptr); ProgramDevices.resize(NumDevices); - Plugin->call(urProgramGetInfo, UrProgram, UR_PROGRAM_INFO_DEVICES, + Plugin->call( UrProgram, UR_PROGRAM_INFO_DEVICES, sizeof(ur_device_handle_t) * NumDevices, ProgramDevices.data(), nullptr); for (auto &Dev : ProgramDevices) { ur_program_binary_type_t BinaryType; - Plugin->call(urProgramGetBuildInfo, UrProgram, Dev, + Plugin->call( UrProgram, Dev, UR_PROGRAM_BUILD_INFO_BINARY_TYPE, sizeof(ur_program_binary_type_t), &BinaryType, nullptr); switch (BinaryType) { case (UR_PROGRAM_BINARY_TYPE_NONE): if (State == bundle_state::object) { - auto Res = Plugin->call_nocheck(urProgramCompileExp, UrProgram, 1, &Dev, + auto Res = Plugin->call_nocheck( UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck(urProgramCompile, + Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), UrProgram, nullptr); } @@ -230,11 +230,10 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, } else if (State == bundle_state::executable) { - auto Res = Plugin->call_nocheck(urProgramBuildExp, UrProgram, 1, &Dev, + auto Res = Plugin->call_nocheck( UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( - urProgramBuild, ContextImpl->getHandleRef(), UrProgram, nullptr); + Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), UrProgram, nullptr); } Plugin->checkUrResult(Res); } @@ -250,10 +249,10 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, if (State == bundle_state::executable) { ur_program_handle_t UrLinkedProgram = nullptr; auto Res = - Plugin->call_nocheck(urProgramLinkExp, ContextImpl->getHandleRef(), + Plugin->call_nocheck( ContextImpl->getHandleRef(), 1, &Dev, 1, &UrProgram, nullptr, &UrLinkedProgram); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck(urProgramLink, ContextImpl->getHandleRef(), + Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), 1, &UrProgram, nullptr, &UrLinkedProgram); } Plugin->checkUrResult(Res); @@ -340,11 +339,11 @@ kernel make_kernel(const context &TargetContext, ur_kernel_native_properties_t Properties{}; Properties.stype = UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call(urKernelCreateWithNativeHandle, NativeHandle, + Plugin->call( NativeHandle, ContextImpl->getHandleRef(), UrProgram, &Properties, &UrKernel); if (Backend == backend::opencl) - Plugin->call(urKernelRetain, UrKernel); + Plugin->call( UrKernel); // Construct the SYCL queue from UR queue. return detail::createSyclObjFromImpl( diff --git a/sycl/source/backend/level_zero.cpp b/sycl/source/backend/level_zero.cpp index 26218fed618e4..c81cce48ca73e 100644 --- a/sycl/source/backend/level_zero.cpp +++ b/sycl/source/backend/level_zero.cpp @@ -23,7 +23,7 @@ __SYCL_EXPORT device make_device(const platform &Platform, const auto &PlatformImpl = getSyclObjImpl(Platform); // Create UR device first. ur_device_handle_t UrDevice; - Plugin->call(urDeviceCreateWithNativeHandle, NativeHandle, + Plugin->call( NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice); return detail::createSyclObjFromImpl( diff --git a/sycl/source/backend/opencl.cpp b/sycl/source/backend/opencl.cpp index ba6c2576adac6..3fce26ee21445 100644 --- a/sycl/source/backend/opencl.cpp +++ b/sycl/source/backend/opencl.cpp @@ -38,14 +38,14 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, // Manual invocation of plugin API to avoid using deprecated // info::platform::extensions call. size_t ResultSize = 0; - Plugin->call(urPlatformGetInfo, PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, + Plugin->call( PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, /*propSize=*/0, /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) return false; std::unique_ptr Result(new char[ResultSize]); - Plugin->call(urPlatformGetInfo, PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, + Plugin->call( PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, ResultSize, Result.get(), nullptr); std::string_view ExtensionsString(Result.get()); @@ -68,14 +68,14 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, // Manual invocation of plugin API to avoid using deprecated // info::device::extensions call. size_t ResultSize = 0; - Plugin->call(urDeviceGetInfo, PluginDevice, UR_DEVICE_INFO_EXTENSIONS, + Plugin->call( PluginDevice, UR_DEVICE_INFO_EXTENSIONS, /*propSize=*/0, /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) return false; std::unique_ptr Result(new char[ResultSize]); - Plugin->call(urDeviceGetInfo, PluginDevice, UR_DEVICE_INFO_EXTENSIONS, + Plugin->call( PluginDevice, UR_DEVICE_INFO_EXTENSIONS, ResultSize, Result.get(), nullptr); std::string_view ExtensionsString(Result.get()); diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index 3e88e9d80cb44..4295b4badce4e 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -77,7 +77,7 @@ context::context(cl_context ClContext, async_handler AsyncHandler) { ur_context_handle_t hContext = nullptr; ur_native_handle_t nativeHandle = reinterpret_cast(ClContext); - Plugin->call(urContextCreateWithNativeHandle, nativeHandle, Plugin->getUrAdapter(), + Plugin->call( nativeHandle, Plugin->getUrAdapter(), 0, nullptr, nullptr, &hContext); diff --git a/sycl/source/detail/allowlist.cpp b/sycl/source/detail/allowlist.cpp index 2c487e49e4709..a4d1381a57a55 100644 --- a/sycl/source/detail/allowlist.cpp +++ b/sycl/source/detail/allowlist.cpp @@ -377,7 +377,7 @@ void applyAllowList(std::vector &UrDevices, auto DeviceImpl = PlatformImpl->getOrMakeDeviceImpl(Device, PlatformImpl); // get DeviceType value and put it to DeviceDesc ur_device_type_t UrDevType = UR_DEVICE_TYPE_ALL; - Plugin->call(urDeviceGetInfo, Device, UR_DEVICE_INFO_TYPE, + Plugin->call( Device, UR_DEVICE_INFO_TYPE, sizeof(UrDevType), &UrDevType, nullptr); // TODO need mechanism to do these casts, there's a bunch of this sort of // thing diff --git a/sycl/source/detail/bindless_images.cpp b/sycl/source/detail/bindless_images.cpp index 457411313381f..98005bfb59aed 100644 --- a/sycl/source/detail/bindless_images.cpp +++ b/sycl/source/detail/bindless_images.cpp @@ -119,8 +119,7 @@ __SYCL_EXPORT void destroy_image_handle(unsampled_image_handle &imageHandle, ur_device_handle_t Device = DevImpl->getHandleRef(); const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( - urBindlessImagesUnsampledImageHandleDestroyExp, C, Device, + Plugin->call( C, Device, imageHandle.raw_handle); } @@ -141,8 +140,7 @@ __SYCL_EXPORT void destroy_image_handle(sampled_image_handle &imageHandle, ur_device_handle_t Device = DevImpl->getHandleRef(); const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( - urBindlessImagesSampledImageHandleDestroyExp, C, Device, + Plugin->call( C, Device, imageHandle.raw_handle); } @@ -172,8 +170,7 @@ alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice, image_mem_handle retHandle; // Call impl. - Plugin->call( - urBindlessImagesImageAllocateExp, C, Device, &urFormat, &urDesc, + Plugin->call( C, Device, &urFormat, &urDesc, reinterpret_cast(&retHandle.raw_handle)); return retHandle; @@ -198,7 +195,7 @@ __SYCL_EXPORT image_mem_handle get_mip_level_mem_handle( // Call impl. image_mem_handle individual_image; - Plugin->call(urBindlessImagesMipmapGetLevelExp, C, + Plugin->call( C, Device, mipMem.raw_handle, level, &individual_image.raw_handle); @@ -226,13 +223,11 @@ __SYCL_EXPORT void free_image_mem(image_mem_handle memHandle, if (memHandle.raw_handle != 0) { if (imageType == image_type::mipmap) { - Plugin->call( - urBindlessImagesMipmapFreeExp, C, Device, memHandle.raw_handle); + Plugin->call( C, Device, memHandle.raw_handle); } else if (imageType == image_type::standard || imageType == image_type::array || imageType == image_type::cubemap) { - Plugin->call( - urBindlessImagesImageFreeExp, C, Device, memHandle.raw_handle); + Plugin->call( C, Device, memHandle.raw_handle); } else { throw sycl::exception(sycl::make_error_code(sycl::errc::invalid), "Invalid image type to free"); @@ -279,7 +274,7 @@ create_image(image_mem_handle memHandle, const image_descriptor &desc, // Call impl. ur_exp_image_mem_native_handle_t urImageHandle; - Plugin->call(urBindlessImagesUnsampledImageCreateExp, C, + Plugin->call( C, Device, memHandle.raw_handle, &urFormat, &urDesc, &urImageHandle); @@ -406,7 +401,7 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, UrAddrModes.pNext = &UrCubemapProps; ur_sampler_handle_t urSampler = nullptr; - Plugin->call(urSamplerCreate, C, &UrSamplerProps, + Plugin->call( C, &UrSamplerProps, &urSampler); ur_image_desc_t urDesc; @@ -415,8 +410,7 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, // Call impl. ur_exp_image_mem_native_handle_t urImageHandle; - Plugin->call( - urBindlessImagesSampledImageCreateExp, C, Device, + Plugin->call( C, Device, reinterpret_cast(devPtr), &urFormat, &urDesc, urSampler, &urImageHandle); @@ -453,7 +447,7 @@ __SYCL_EXPORT external_mem import_external_memory( // For `resource_fd` external memory type, the handle type is always // `OPAQUE_FD`. No need for a switch statement like we have for win32 // resources. - Plugin->call(urBindlessImagesImportExternalMemoryExp, C, + Plugin->call( C, Device, externalMemDesc.size_in_bytes, UR_EXP_EXTERNAL_MEM_TYPE_OPAQUE_FD, &urExternalMemDescriptor, &urExternalMem); @@ -503,7 +497,7 @@ __SYCL_EXPORT external_mem import_external_memory( "Invalid memory handle type"); } - Plugin->call(urBindlessImagesImportExternalMemoryExp, C, + Plugin->call( C, Device, externalMemDesc.size_in_bytes, urHandleType, &urExternalMemDescriptor, &urExternalMem); @@ -541,7 +535,7 @@ image_mem_handle map_external_image_memory(external_mem extMem, ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle}; image_mem_handle retHandle; - Plugin->call(urBindlessImagesMapExternalArrayExp, C, + Plugin->call( C, Device, &urFormat, &urDesc, urExternalMem, &retHandle.raw_handle); @@ -571,7 +565,7 @@ void *map_external_linear_memory(external_mem extMem, uint64_t offset, ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle}; void *retMemory; - Plugin->call(urBindlessImagesMapExternalLinearMemoryExp, + Plugin->call( C, Device, offset, size, urExternalMem, &retMemory); @@ -596,7 +590,7 @@ __SYCL_EXPORT void release_external_memory(external_mem extMem, ur_device_handle_t Device = DevImpl->getHandleRef(); const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(urBindlessImagesReleaseExternalMemoryExp, C, + Plugin->call( C, Device, extMem.raw_handle); } @@ -628,7 +622,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( // For this specialization of `import_external_semaphore` the handleType is // always `OPAQUE_FD`. - Plugin->call(urBindlessImagesImportExternalSemaphoreExp, + Plugin->call( C, Device, UR_EXP_EXTERNAL_SEMAPHORE_TYPE_OPAQUE_FD, &urExternalSemDesc, &urExternalSemaphore); @@ -679,7 +673,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( "Invalid semaphore handle type"); } - Plugin->call(urBindlessImagesImportExternalSemaphoreExp, + Plugin->call( C, Device, urHandleType, &urExternalSemDesc, &urExternalSemaphore); @@ -707,7 +701,7 @@ release_external_semaphore(external_semaphore externalSemaphore, sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - Plugin->call(urBindlessImagesReleaseExternalSemaphoreExp, + Plugin->call( C, Device, externalSemaphore.raw_handle); } @@ -728,17 +722,17 @@ __SYCL_EXPORT sycl::range<3> get_image_range(const image_mem_handle memHandle, size_t Width = 0, Height = 0, Depth = 0; - Plugin->call(urBindlessImagesImageGetInfoExp, + Plugin->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_WIDTH, &Width, nullptr); - Plugin->call(urBindlessImagesImageGetInfoExp, + Plugin->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_HEIGHT, &Height, nullptr); - Plugin->call(urBindlessImagesImageGetInfoExp, + Plugin->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_DEPTH, &Depth, nullptr); @@ -763,7 +757,7 @@ get_image_channel_type(const image_mem_handle memHandle, ur_image_format_t URFormat; - Plugin->call(urBindlessImagesImageGetInfoExp, CtxImpl->getHandleRef(), + Plugin->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, &URFormat, nullptr); @@ -799,8 +793,7 @@ __SYCL_EXPORT void *pitched_alloc_device(size_t *resultPitch, ur_device_handle_t UrDevice = sycl::detail::getSyclObjImpl(syclDevice)->getHandleRef(); - Plugin->call( - urUSMPitchedAllocExp, UrContext, UrDevice, nullptr, nullptr, widthInBytes, + Plugin->call( UrContext, UrDevice, nullptr, nullptr, widthInBytes, height, elementSizeBytes, &RetVal, resultPitch); return RetVal; @@ -847,7 +840,7 @@ get_image_num_channels(const image_mem_handle memHandle, const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); ur_image_format_t URFormat = {}; - Plugin->call(urBindlessImagesImageGetInfoExp, CtxImpl->getHandleRef(), + Plugin->call( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, &URFormat, nullptr); diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 1a7c7825a0417..f3fd9280a395d 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -52,9 +52,9 @@ void buffer_impl::addInteropObject( ur::cast(MInteropMemObject)) == Handles.end()) { const PluginPtr &Plugin = getPlugin(); - Plugin->call(urMemRetain, ur::cast(MInteropMemObject)); + Plugin->call( ur::cast(MInteropMemObject)); ur_native_handle_t NativeHandle = 0; - Plugin->call(urMemGetNativeHandle, MInteropMemObject, nullptr, + Plugin->call( MInteropMemObject, nullptr, &NativeHandle); Handles.push_back(NativeHandle); } @@ -85,14 +85,14 @@ buffer_impl::getNativeVector(backend BackendName) const { auto Plugin = Platform->getPlugin(); if (Platform->getBackend() == backend::opencl) { - Plugin->call(urMemRetain, NativeMem); + Plugin->call( NativeMem); } ur_native_handle_t Handle = 0; // When doing buffer interop we don't know what device the memory should be // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. - Plugin->call(urMemGetNativeHandle, NativeMem, /*Dev*/ nullptr, &Handle); + Plugin->call( NativeMem, /*Dev*/ nullptr, &Handle); Handles.push_back(Handle); } diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index d738053302e54..dfbb259990e73 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -59,7 +59,7 @@ context_impl::context_impl(const std::vector Devices, DeviceIds.push_back(getSyclObjImpl(D)->getHandleRef()); } - getPlugin()->call(urContextCreate, DeviceIds.size(), DeviceIds.data(), + getPlugin()->call( DeviceIds.size(), DeviceIds.data(), nullptr, &MContext); MKernelProgramCache.setContextPtr(this); @@ -78,11 +78,11 @@ context_impl::context_impl(ur_context_handle_t UrContext, std::vector DeviceIds; uint32_t DevicesNum = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urContextGetInfo, MContext, UR_CONTEXT_INFO_NUM_DEVICES, + Plugin->call( MContext, UR_CONTEXT_INFO_NUM_DEVICES, sizeof(DevicesNum), &DevicesNum, nullptr); DeviceIds.resize(DevicesNum); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urContextGetInfo, MContext, UR_CONTEXT_INFO_DEVICES, + Plugin->call( MContext, UR_CONTEXT_INFO_DEVICES, sizeof(ur_device_handle_t) * DevicesNum, &DeviceIds[0], nullptr); @@ -106,16 +106,16 @@ context_impl::context_impl(ur_context_handle_t UrContext, // TODO: Move this backend-specific retain of the context to SYCL-2020 style // make_context interop, when that is created. if (getBackend() == sycl::backend::opencl) { - getPlugin()->call(urContextRetain, MContext); + getPlugin()->call( MContext); } MKernelProgramCache.setContextPtr(this); } cl_context context_impl::get() const { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(urContextRetain, MContext); + getPlugin()->call( MContext); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(urContextGetNativeHandle, MContext, &nativeHandle); + getPlugin()->call( MContext, &nativeHandle); return ur::cast(nativeHandle); } @@ -133,10 +133,10 @@ context_impl::~context_impl() { } for (auto LibProg : MCachedLibPrograms) { assert(LibProg.second && "Null program must not be kept in the cache"); - getPlugin()->call(urProgramRelease, LibProg.second); + getPlugin()->call( LibProg.second); } // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call_nocheck(urContextRelease, MContext); + getPlugin()->call_nocheck( MContext); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~context_impl", e); } @@ -292,9 +292,9 @@ context_impl::findMatchingDeviceImpl(ur_device_handle_t &DeviceUR) const { ur_native_handle_t context_impl::getNative() const { const auto &Plugin = getPlugin(); if (getBackend() == backend::opencl) - Plugin->call(urContextRetain, getHandleRef()); + Plugin->call( getHandleRef()); ur_native_handle_t Handle; - Plugin->call(urContextGetNativeHandle, getHandleRef(), &Handle); + Plugin->call( getHandleRef(), &Handle); return Handle; } @@ -355,7 +355,7 @@ std::vector context_impl::initializeDeviceGlobals( }); // Release the removed events. for (auto EventIt = NewEnd; EventIt != InitEventsRef.end(); ++EventIt) - Plugin->call(urEventRelease, *EventIt); + Plugin->call( *EventIt); // Remove them from the collection. InitEventsRef.erase(NewEnd, InitEventsRef.end()); // If there are no more events, we can mark it as fully initialized. @@ -412,7 +412,7 @@ std::vector context_impl::initializeDeviceGlobals( // initialize events list. ur_event_handle_t InitEvent; void *const &USMPtr = DeviceGlobalUSM.getPtr(); - Plugin->call(urEnqueueDeviceGlobalVariableWrite, + Plugin->call( QueueImpl->getHandleRef(), NativePrg, DeviceGlobalEntry->MUniqueId.c_str(), false, sizeof(void *), 0, &USMPtr, 0, nullptr, &InitEvent); @@ -426,7 +426,7 @@ std::vector context_impl::initializeDeviceGlobals( void context_impl::DeviceGlobalInitializer::ClearEvents( const PluginPtr &Plugin) { for (const ur_event_handle_t &Event : MDeviceGlobalInitEvents) - Plugin->call(urEventRelease, Event); + Plugin->call( Event); MDeviceGlobalInitEvents.clear(); } diff --git a/sycl/source/detail/context_info.hpp b/sycl/source/detail/context_info.hpp index b4ba1f1ec775d..e0626331c4781 100644 --- a/sycl/source/detail/context_info.hpp +++ b/sycl/source/detail/context_info.hpp @@ -24,7 +24,7 @@ typename Param::return_type get_context_info(ur_context_handle_t Ctx, "Invalid context information descriptor"); typename Param::return_type Result = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urContextGetInfo, Ctx, UrInfoCode::value, sizeof(Result), + Plugin->call( Ctx, UrInfoCode::value, sizeof(Result), &Result, nullptr); return Result; } diff --git a/sycl/source/detail/device_global_map_entry.cpp b/sycl/source/detail/device_global_map_entry.cpp index d12c1de36d024..fa5283411f01b 100644 --- a/sycl/source/detail/device_global_map_entry.cpp +++ b/sycl/source/detail/device_global_map_entry.cpp @@ -31,7 +31,7 @@ OwnedUrEvent DeviceGlobalUSMMem::getInitEvent(const PluginPtr &Plugin) { if (MInitEvent.has_value()) { if (get_event_info( *MInitEvent, Plugin) == info::event_command_status::complete) { - Plugin->call(urEventRelease, *MInitEvent); + Plugin->call( *MInitEvent); MInitEvent = {}; return OwnedUrEvent(Plugin); } else { @@ -100,7 +100,7 @@ void DeviceGlobalMapEntry::removeAssociatedResources( DeviceGlobalUSMMem &USMMem = USMPtrIt->second; detail::usm::freeInternal(USMMem.MPtr, CtxImpl); if (USMMem.MInitEvent.has_value()) - CtxImpl->getPlugin()->call(urEventRelease, *USMMem.MInitEvent); + CtxImpl->getPlugin()->call( *USMMem.MInitEvent); #ifndef NDEBUG // For debugging we set the event and memory to some recognizable values // to allow us to check that this cleanup happens before erasure. diff --git a/sycl/source/detail/device_image_impl.hpp b/sycl/source/detail/device_image_impl.hpp index e54fc0b2976c0..17e144fa6908a 100644 --- a/sycl/source/detail/device_image_impl.hpp +++ b/sycl/source/detail/device_image_impl.hpp @@ -292,9 +292,9 @@ class device_image_impl { const PluginPtr &Plugin = ContextImplPtr->getPlugin(); if (ContextImplPtr->getBackend() == backend::opencl) - Plugin->call(urProgramRetain, MProgram); + Plugin->call( MProgram); ur_native_handle_t NativeProgram = 0; - Plugin->call(urProgramGetNativeHandle, MProgram, &NativeProgram); + Plugin->call( MProgram, &NativeProgram); return NativeProgram; } @@ -303,7 +303,7 @@ class device_image_impl { try { if (MProgram) { const PluginPtr &Plugin = getSyclObjImpl(MContext)->getPlugin(); - Plugin->call(urProgramRelease, MProgram); + Plugin->call( MProgram); } if (MSpecConstsBuffer) { std::lock_guard Lock{MSpecConstAccessMtx}; diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 37a65e0e2a261..c3b0804373a89 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -42,19 +42,19 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, // Get UR device from the raw device handle. // NOTE: this is for OpenCL interop only (and should go away). // With SYCL-2020 BE generalization "make" functions are used instead. - Plugin->call(urDeviceCreateWithNativeHandle, InteropDeviceHandle, + Plugin->call( InteropDeviceHandle, Plugin->getUrAdapter(), nullptr, &MDevice); InteroperabilityConstructor = true; } // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urDeviceGetInfo, MDevice, UR_DEVICE_INFO_TYPE, + Plugin->call( MDevice, UR_DEVICE_INFO_TYPE, sizeof(ur_device_type_t), &MType, nullptr); // No need to set MRootDevice when MAlwaysRootDevice is true if ((Platform == nullptr) || !Platform->MAlwaysRootDevice) { // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urDeviceGetInfo, MDevice, UR_DEVICE_INFO_PARENT_DEVICE, + Plugin->call( MDevice, UR_DEVICE_INFO_PARENT_DEVICE, sizeof(ur_device_handle_t), &MRootDevice, nullptr); } @@ -62,7 +62,7 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, // TODO catch an exception and put it to list of asynchronous exceptions // Interoperability Constructor already calls DeviceRetain in // urDeviceCreateWithNativeHandle. - Plugin->call(urDeviceRetain, MDevice); + Plugin->call( MDevice); } // set MPlatform @@ -79,7 +79,7 @@ device_impl::~device_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions const PluginPtr &Plugin = getPlugin(); - ur_result_t Err = Plugin->call_nocheck(urDeviceRelease, MDevice); + ur_result_t Err = Plugin->call_nocheck(MDevice); __SYCL_CHECK_OCL_CODE_NO_EXC(Err); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_impl", e); @@ -95,7 +95,7 @@ bool device_impl::is_affinity_supported( cl_device_id device_impl::get() const { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(urDeviceRetain, MDevice); + getPlugin()->call( MDevice); return ur::cast(getNative()); } @@ -182,7 +182,7 @@ std::vector device_impl::create_sub_devices( std::vector SubDevices(SubDevicesCount); uint32_t ReturnedSubDevices = 0; const PluginPtr &Plugin = getPlugin(); - Plugin->call(urDevicePartition, MDevice, Properties, + Plugin->call( MDevice, Properties, SubDevicesCount, SubDevices.data(), &ReturnedSubDevices); if (ReturnedSubDevices != SubDevicesCount) { @@ -303,7 +303,7 @@ std::vector device_impl::create_sub_devices( uint32_t SubDevicesCount = 0; const PluginPtr &Plugin = getPlugin(); - Plugin->call(urDevicePartition, MDevice, &Properties, 0, + Plugin->call( MDevice, &Properties, 0, nullptr, &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); @@ -328,7 +328,7 @@ std::vector device_impl::create_sub_devices() const { uint32_t SubDevicesCount = 0; const PluginPtr &Plugin = getPlugin(); - Plugin->call(urDevicePartition, MDevice, &Properties, 0, nullptr, + Plugin->call( MDevice, &Properties, 0, nullptr, &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); @@ -337,9 +337,9 @@ std::vector device_impl::create_sub_devices() const { ur_native_handle_t device_impl::getNative() const { auto Plugin = getPlugin(); if (getBackend() == backend::opencl) - Plugin->call(urDeviceRetain, getHandleRef()); + Plugin->call( getHandleRef()); ur_native_handle_t Handle; - Plugin->call(urDeviceGetNativeHandle, getHandleRef(), &Handle); + Plugin->call( getHandleRef(), &Handle); return Handle; } @@ -406,53 +406,48 @@ bool device_impl::has(aspect Aspect) const { case aspect::usm_system_allocations: return get_info(); case aspect::ext_intel_device_id: - return getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_DEVICE_ID, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_pci_address: - return getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_PCI_ADDRESS, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_count: - return getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_COUNT, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_simd_width: - return getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH, 0, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_slices: - return getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_SLICES, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_subslices_per_slice: - return getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_count_per_subslice: - return getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_hw_threads_per_eu: - return getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_free_memory: - return getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GLOBAL_MEM_FREE, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_memory_clock_rate: - return getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_MEMORY_CLOCK_RATE, 0, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_MEMORY_CLOCK_RATE, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_memory_bus_width: - return getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_MEMORY_BUS_WIDTH, 0, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_MEMORY_BUS_WIDTH, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_device_info_uuid: { auto Result = - getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, UR_DEVICE_INFO_UUID, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_UUID, 0, nullptr, &return_size); if (Result != UR_RESULT_SUCCESS) { return false; @@ -461,8 +456,7 @@ bool device_impl::has(aspect Aspect) const { assert(return_size <= 16); unsigned char UUID[16]; - return getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_UUID, + return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_UUID, 16 * sizeof(unsigned char), UUID, nullptr) == UR_RESULT_SUCCESS; } case aspect::ext_intel_max_mem_bandwidth: @@ -475,15 +469,14 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cuda_async_barrier: { int async_barrier_supported; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_ASYNC_BARRIER, sizeof(int), + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_ASYNC_BARRIER, sizeof(int), &async_barrier_supported, nullptr) == UR_RESULT_SUCCESS; return call_successful && async_barrier_supported; } case aspect::ext_intel_legacy_image: { ur_bool_t legacy_image_support = false; bool call_successful = - getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_IMAGE_SUPPORTED, sizeof(ur_bool_t), &legacy_image_support, nullptr) == UR_RESULT_SUCCESS; @@ -492,7 +485,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; @@ -501,8 +494,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_shared_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -510,8 +502,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -519,8 +510,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -528,8 +518,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_external_memory_import: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_EXTERNAL_MEMORY_IMPORT_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -537,8 +526,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_external_semaphore_import: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_EXTERNAL_SEMAPHORE_IMPORT_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -546,15 +534,14 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_mipmap: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_mipmap_anisotropy: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck(urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; @@ -563,8 +550,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_mipmap_level_reference: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -572,8 +558,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -581,8 +566,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_1d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -590,8 +574,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -599,8 +582,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_2d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -608,8 +590,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_3d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -617,16 +598,14 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cubemap: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_cubemap_seamless_filtering: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -634,16 +613,14 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_image_array: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_IMAGE_ARRAY_SUPPORT_EXP, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_IMAGE_ARRAY_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_unique_addressing_per_dim: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_UNIQUE_ADDRESSING_PER_DIM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -651,8 +628,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_sample_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -660,8 +636,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_sample_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -669,8 +644,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_intel_esimd: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_ESIMD_SUPPORT, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_ESIMD_SUPPORT, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } @@ -713,8 +687,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_is_component: { typename sycl_to_ur::type Result; bool CallSuccessful = - getPlugin()->call_nocheck( - urDeviceGetInfo, getHandleRef(), + getPlugin()->call_nocheck( getHandleRef(), UrInfoCode::value, sizeof(Result), &Result, nullptr) == UR_RESULT_SUCCESS; @@ -724,8 +697,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_graph: { bool SupportsCommandBufferUpdate = false; bool CallSuccessful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP, sizeof(SupportsCommandBufferUpdate), &SupportsCommandBufferUpdate, nullptr) == UR_RESULT_SUCCESS; @@ -738,8 +710,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_limited_graph: { bool SupportsCommandBuffers = false; bool CallSuccessful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP, sizeof(SupportsCommandBuffers), &SupportsCommandBuffers, nullptr) == UR_RESULT_SUCCESS; if (!CallSuccessful) { @@ -757,8 +728,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_queue_profiling_tag: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -766,8 +736,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_virtual_mem: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( - urDeviceGetInfo, MDevice, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, + getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } @@ -825,7 +794,7 @@ uint64_t device_impl::getCurrentDeviceTime() { // If getCurrentDeviceTime is called for the first time or we have to refresh. if (!MDeviceHostBaseTime.second || Diff > TimeTillRefresh) { const auto &Plugin = getPlugin(); - auto Result = Plugin->call_nocheck(urDeviceGetGlobalTimestamps, MDevice, + auto Result = Plugin->call_nocheck( MDevice, &MDeviceHostBaseTime.first, &MDeviceHostBaseTime.second); // We have to remember base host timestamp right after UR call and it is @@ -864,7 +833,7 @@ uint64_t device_impl::getCurrentDeviceTime() { bool device_impl::isGetDeviceAndHostTimerSupported() { const auto &Plugin = getPlugin(); uint64_t DeviceTime = 0, HostTime = 0; - auto Result = Plugin->call_nocheck(urDeviceGetGlobalTimestamps, MDevice, + auto Result = Plugin->call_nocheck( MDevice, &DeviceTime, &HostTime); return Result != UR_RESULT_ERROR_INVALID_OPERATION; } diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 55ec8c9a484b8..2f68ecb8cbf43 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -142,7 +142,7 @@ template <> struct check_fp_support { template struct get_device_info_impl { static ReturnT get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return ReturnT(result); @@ -153,7 +153,7 @@ template struct get_device_info_impl { template struct get_device_info_impl { static platform get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); // TODO: Change UrDevice to device_impl. @@ -169,13 +169,13 @@ template struct get_device_info_impl { inline std::string device_impl::get_device_info_string(ur_device_info_t InfoCode) const { size_t resultSize = 0; - getPlugin()->call(urDeviceGetInfo, getHandleRef(), InfoCode, 0, nullptr, + getPlugin()->call( getHandleRef(), InfoCode, 0, nullptr, &resultSize); if (resultSize == 0) { return std::string(); } std::unique_ptr result(new char[resultSize]); - getPlugin()->call(urDeviceGetInfo, getHandleRef(), InfoCode, resultSize, + getPlugin()->call( getHandleRef(), InfoCode, resultSize, result.get(), nullptr); return std::string(result.get()); @@ -205,7 +205,7 @@ struct get_device_info_impl, Param> { return {}; } ur_device_fp_capability_flags_t result; - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_fp_bitfield(result); @@ -226,7 +226,7 @@ struct get_device_info_impl, info::device::single_fp_config> { static std::vector get(const DeviceImplPtr &Dev) { ur_device_fp_capability_flags_t result; - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_fp_bitfield(result); @@ -239,7 +239,7 @@ struct get_device_info_impl, template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_queue_flags_t Properties; - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(Properties), &Properties, nullptr); return Properties & UR_QUEUE_FLAG_PROFILING_ENABLE; @@ -252,8 +252,7 @@ struct get_device_info_impl, info::device::atomic_memory_order_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_memory_order_capability_flag_t result; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryOrderBitfield(result); @@ -266,8 +265,7 @@ struct get_device_info_impl, info::device::atomic_fence_order_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_memory_order_capability_flag_t result; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryOrderBitfield(result); @@ -280,8 +278,7 @@ struct get_device_info_impl, info::device::atomic_memory_scope_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { size_t result; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryScopeBitfield(result); @@ -294,8 +291,7 @@ struct get_device_info_impl, info::device::atomic_fence_scope_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { size_t result; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryScopeBitfield(result); @@ -308,8 +304,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { bool result = false; if (Dev->getBackend() == backend::ext_oneapi_cuda) { - auto Err = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + auto Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); if (Err != UR_RESULT_SUCCESS) { @@ -326,8 +321,7 @@ struct get_device_info_impl, info::device::execution_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_device_exec_capability_flag_t result; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_execution_bitfield(result); @@ -395,7 +389,7 @@ struct get_device_info_impl, const auto &Plugin = Dev->getPlugin(); size_t resultSize; - Plugin->call(urDeviceGetInfo, Dev->getHandleRef(), info_partition, 0, + Plugin->call( Dev->getHandleRef(), info_partition, 0, nullptr, &resultSize); size_t arrayLength = resultSize / sizeof(ur_device_partition_t); @@ -404,7 +398,7 @@ struct get_device_info_impl, } std::unique_ptr arrayResult( new ur_device_partition_t[arrayLength]); - Plugin->call(urDeviceGetInfo, Dev->getHandleRef(), info_partition, + Plugin->call( Dev->getHandleRef(), info_partition, resultSize, arrayResult.get(), nullptr); std::vector result; @@ -427,8 +421,7 @@ struct get_device_info_impl, static std::vector get(const DeviceImplPtr &Dev) { ur_device_affinity_domain_flags_t result; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_domain_bitfield(result); @@ -443,8 +436,7 @@ struct get_device_info_impl PartitionProperties; size_t PropertiesSize = 0; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &PropertiesSize); if (PropertiesSize == 0) @@ -453,8 +445,7 @@ struct get_device_info_implgetPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); @@ -475,8 +466,7 @@ struct get_device_info_impl PartitionProperties; size_t PropertiesSize = 0; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &PropertiesSize); if (PropertiesSize == 0) @@ -485,8 +475,7 @@ struct get_device_info_implgetPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); // The old UR implementation also just checked the first element, is that @@ -501,12 +490,12 @@ struct get_device_info_impl, info::device::sub_group_sizes> { static std::vector get(const DeviceImplPtr &Dev) { size_t resultSize = 0; - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &resultSize); std::vector result32(resultSize / sizeof(uint32_t)); - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, resultSize, result32.data(), nullptr); @@ -562,8 +551,7 @@ struct get_device_info_impl, info::device::max_work_item_sizes> { static range get(const DeviceImplPtr &Dev) { size_t result[3]; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode>::value, sizeof(result), &result, nullptr); return construct_range(result); @@ -691,8 +679,7 @@ struct get_device_info_impl< auto LookupIPVersion = [&](auto &ArchList) -> std::optional { uint32_t DeviceIp; - ur_result_t Err = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::architecture>::value, sizeof(DeviceIp), &DeviceIp, nullptr); @@ -723,11 +710,11 @@ struct get_device_info_impl< return ext::oneapi::experimental::architecture::unknown; }; size_t ResultSize = 0; - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &ResultSize); std::unique_ptr DeviceArch(new char[ResultSize]); - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, ResultSize, DeviceArch.get(), nullptr); std::string DeviceArchCopy(DeviceArch.get()); @@ -970,8 +957,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, sizeof(result), &result, nullptr); @@ -987,8 +973,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, sizeof(result), &result, nullptr); @@ -1004,8 +989,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, sizeof(result), &result, nullptr); @@ -1066,7 +1050,7 @@ struct get_device_info_impl, template <> struct get_device_info_impl { static device get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call(urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); if (result == nullptr) @@ -1095,8 +1079,7 @@ template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1112,8 +1095,7 @@ template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1128,8 +1110,7 @@ template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); return (Err != UR_RESULT_SUCCESS) @@ -1144,8 +1125,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); // Check that we don't support any cross device sharing @@ -1162,8 +1142,7 @@ template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); return (Err != UR_RESULT_SUCCESS) @@ -1208,8 +1187,7 @@ struct get_device_info_impl< ext::codeplay::experimental::info::device::max_registers_per_work_group> { static uint32_t get(const DeviceImplPtr &Dev) { uint32_t maxRegsPerWG; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(maxRegsPerWG), &maxRegsPerWG, nullptr); @@ -1225,8 +1203,7 @@ struct get_device_info_impl< static std::vector get(const DeviceImplPtr &Dev) { size_t ResultSize = 0; // First call to get DevCount. - ur_result_t Err = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::component_devices>::value, 0, nullptr, &ResultSize); @@ -1245,8 +1222,7 @@ struct get_device_info_impl< // Second call to get the list. std::vector Devs(DevCount); - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::component_devices>::value, ResultSize, Devs.data(), nullptr); @@ -1270,8 +1246,7 @@ struct get_device_info_impl< "can call this function."); typename sycl_to_ur::type Result; - Dev->getPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::composite_device>::value, sizeof(Result), &Result, nullptr); diff --git a/sycl/source/detail/error_handling/error_handling.cpp b/sycl/source/detail/error_handling/error_handling.cpp index 3780b526b5fc3..d48d90f9b2359 100644 --- a/sycl/source/detail/error_handling/error_handling.cpp +++ b/sycl/source/detail/error_handling/error_handling.cpp @@ -38,7 +38,7 @@ void handleOutOfResources(const device_impl &DeviceImpl, const PluginPtr &Plugin = DeviceImpl.getPlugin(); uint32_t NumRegisters = 0; - Plugin->call(urKernelGetInfo, Kernel, UR_KERNEL_INFO_NUM_REGS, + Plugin->call( Kernel, UR_KERNEL_INFO_NUM_REGS, sizeof(NumRegisters), &NumRegisters, nullptr); uint32_t MaxRegistersPerBlock = @@ -99,12 +99,12 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t CompileWGSize[3] = {0}; - Plugin->call(urKernelGetGroupInfo, Kernel, Device, + Plugin->call( Kernel, Device, UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(size_t) * 3, CompileWGSize, nullptr); size_t MaxWGSize = 0; - Plugin->call(urDeviceGetInfo, Device, UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, + Plugin->call( Device, UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t), &MaxWGSize, nullptr); const bool HasLocalSize = (NDRDesc.LocalSize[0] != 0); @@ -147,7 +147,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, if (HasLocalSize) { size_t MaxThreadsPerBlock[3] = {}; - Plugin->call(urDeviceGetInfo, Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, + Plugin->call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxThreadsPerBlock), MaxThreadsPerBlock, nullptr); for (size_t I = 0; I < 3; ++I) { @@ -185,7 +185,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // than the value specified by UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE in // table 5.21. size_t KernelWGSize = 0; - Plugin->call(urKernelGetGroupInfo, Kernel, Device, + Plugin->call( Kernel, Device, UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t), &KernelWGSize, nullptr); const size_t TotalNumberOfWIs = @@ -239,13 +239,13 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // work-group given by local_work_size ur_program_handle_t Program = nullptr; - Plugin->call(urKernelGetInfo, Kernel, UR_KERNEL_INFO_PROGRAM, + Plugin->call( Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); size_t OptsSize = 0; - Plugin->call(urProgramGetBuildInfo, Program, Device, + Plugin->call( Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, 0, nullptr, &OptsSize); std::string Opts(OptsSize, '\0'); - Plugin->call(urProgramGetBuildInfo, Program, Device, + Plugin->call( Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, OptsSize, &Opts.front(), nullptr); const bool HasStd20 = Opts.find("-cl-std=CL2.0") != std::string::npos; @@ -309,7 +309,7 @@ void handleInvalidWorkItemSize(const device_impl &DeviceImpl, size_t MaxWISize[] = {0, 0, 0}; - Plugin->call(urDeviceGetInfo, Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, + Plugin->call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxWISize), &MaxWISize, nullptr); for (unsigned I = 0; I < NDRDesc.Dims; I++) { if (NDRDesc.LocalSize[I] > MaxWISize[I]) @@ -327,7 +327,7 @@ void handleInvalidValue(const device_impl &DeviceImpl, ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t MaxNWGs[] = {0, 0, 0}; - Plugin->call(urDeviceGetInfo, Device, UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, + Plugin->call( Device, UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, sizeof(MaxNWGs), &MaxNWGs, nullptr); for (unsigned int I = 0; I < NDRDesc.Dims; I++) { size_t NWgs = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 27ddafdde10f2..8fe97aac25457 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -46,7 +46,7 @@ event_impl::~event_impl() { try { auto Handle = this->getHandle(); if (Handle) - getPlugin()->call(urEventRelease, Handle); + getPlugin()->call( Handle); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~event_impl", e); } @@ -56,7 +56,7 @@ void event_impl::waitInternal(bool *Success) { auto Handle = this->getHandle(); if (!MIsHostEvent && Handle) { // Wait for the native event - ur_result_t Err = getPlugin()->call_nocheck(urEventWait, 1, &Handle); + ur_result_t Err = getPlugin()->call_nocheck( 1, &Handle); // TODO drop the UR_RESULT_ERROR_UKNOWN from here (this was waiting for // https://github.com/oneapi-src/unified-runtime/issues/1459 which is now // closed). @@ -146,7 +146,7 @@ event_impl::event_impl(ur_event_handle_t Event, const context &SyclContext) MIsFlushed(true), MState(HES_Complete) { ur_context_handle_t TempContext; - getPlugin()->call(urEventGetInfo, this->getHandle(), UR_EVENT_INFO_CONTEXT, + getPlugin()->call( this->getHandle(), UR_EVENT_INFO_CONTEXT, sizeof(ur_context_handle_t), &TempContext, nullptr); if (MContext->getHandleRef() != TempContext) { @@ -487,15 +487,15 @@ ur_native_handle_t event_impl::getNative() { auto TempContext = MContext.get()->getHandleRef(); ur_event_native_properties_t NativeProperties{}; ur_event_handle_t UREvent = nullptr; - Plugin->call(urEventCreateWithNativeHandle, 0, TempContext, + Plugin->call( 0, TempContext, &NativeProperties, &UREvent); this->setHandle(UREvent); Handle = UREvent; } if (MContext->getBackend() == backend::opencl) - Plugin->call(urEventRetain, Handle); + Plugin->call( Handle); ur_native_handle_t OutHandle; - Plugin->call(urEventGetNativeHandle, Handle, &OutHandle); + Plugin->call( Handle, &OutHandle); return OutHandle; } @@ -536,11 +536,11 @@ void event_impl::flushIfNeeded(const QueueImplPtr &UserQueue) { // Check if the task for this event has already been submitted. ur_event_status_t Status = UR_EVENT_STATUS_QUEUED; - getPlugin()->call(urEventGetInfo, Handle, + getPlugin()->call( Handle, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, sizeof(ur_event_status_t), &Status, nullptr); if (Status == UR_EVENT_STATUS_QUEUED) { - getPlugin()->call(urQueueFlush, Queue->getHandleRef()); + getPlugin()->call( Queue->getHandleRef()); } MIsFlushed = true; } diff --git a/sycl/source/detail/event_info.hpp b/sycl/source/detail/event_info.hpp index ba8cf469d5c26..210e158caf2d3 100644 --- a/sycl/source/detail/event_info.hpp +++ b/sycl/source/detail/event_info.hpp @@ -25,7 +25,7 @@ typename Param::return_type get_event_profiling_info(ur_event_handle_t Event, "Unexpected event profiling info descriptor"); typename Param::return_type Result{0}; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urEventGetProfilingInfo, Event, UrInfoCode::value, + Plugin->call( Event, UrInfoCode::value, sizeof(Result), &Result, nullptr); return Result; } @@ -37,7 +37,7 @@ typename Param::return_type get_event_info(ur_event_handle_t Event, "Unexpected event info descriptor"); typename Param::return_type Result{0}; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urEventGetInfo, Event, UrInfoCode::value, sizeof(Result), + Plugin->call( Event, UrInfoCode::value, sizeof(Result), &Result, nullptr); // If the status is UR_EVENT_STATUS_QUEUED We need to change it since QUEUE is diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 93979c33feb42..1049ca10d98a7 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -273,7 +273,10 @@ void GlobalHandler::unloadPlugins() { } } - urLoaderTearDown(); + UrFuncInfo loaderTearDownInfo; + auto loaderTearDown = loaderTearDownInfo.getFuncPtr(ur::loadURLoaderLibrary()); + loaderTearDown(); + // urLoaderTearDown(); // Clear after unload to avoid uses after unload. getPlugins().clear(); diff --git a/sycl/source/detail/graph_impl.cpp b/sycl/source/detail/graph_impl.cpp index c876942c2ce3b..ce7819c95a49a 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -720,8 +720,7 @@ void exec_graph_impl::createCommandBuffers( auto ContextImpl = sycl::detail::getSyclObjImpl(MContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); auto DeviceImpl = sycl::detail::getSyclObjImpl(Device); - ur_result_t Res = Plugin->call_nocheck( - urCommandBufferCreateExp, ContextImpl->getHandleRef(), + ur_result_t Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), &Desc, &OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { throw sycl::exception(errc::invalid, "Failed to create UR command-buffer"); @@ -762,7 +761,7 @@ void exec_graph_impl::createCommandBuffers( Node->MCommandGroup->getAccStorage().end()); } - Res = Plugin->call_nocheck(urCommandBufferFinalizeExp, OutCommandBuffer); + Res = Plugin->call_nocheck( OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { throw sycl::exception(errc::invalid, "Failed to finalize UR command-buffer"); @@ -809,7 +808,7 @@ exec_graph_impl::~exec_graph_impl() { for (const auto &Iter : Partition->MCommandBuffers) { if (auto CmdBuf = Iter.second; CmdBuf) { ur_result_t Res = - Plugin->call_nocheck(urCommandBufferReleaseExp, CmdBuf); + Plugin->call_nocheck( CmdBuf); (void)Res; assert(Res == UR_RESULT_SUCCESS); } @@ -819,7 +818,7 @@ exec_graph_impl::~exec_graph_impl() { for (auto &Iter : MCommandMap) { if (auto Command = Iter.second; Command) { ur_result_t Res = - Plugin->call_nocheck(urCommandBufferReleaseCommandExp, Command); + Plugin->call_nocheck( Command); (void)Res; assert(Res == UR_RESULT_SUCCESS); } @@ -921,8 +920,7 @@ exec_graph_impl::enqueue(const std::shared_ptr &Queue, NewEvent->setSubmissionTime(); NewEvent->setHostEnqueueTime(); } - ur_result_t Res = Queue->getPlugin()->call_nocheck( - urCommandBufferEnqueueExp, CommandBuffer, Queue->getHandleRef(), 0, + ur_result_t Res = Queue->getPlugin()->call_nocheck( CommandBuffer, Queue->getHandleRef(), 0, nullptr, &UREvent); NewEvent->setHandle(UREvent); if (Res == UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES) { @@ -1394,7 +1392,7 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { if (NDRDesc.LocalSize[0] != 0) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call(urKernelGetGroupInfo, UrKernel, DeviceImpl->getHandleRef(), + Plugin->call( UrKernel, DeviceImpl->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, /* param_value_size_ret = */ nullptr); @@ -1494,13 +1492,13 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { ur_exp_command_buffer_command_handle_t Command = MCommandMap[ExecNode->second]; - ur_result_t Res = Plugin->call_nocheck(urCommandBufferUpdateKernelLaunchExp, + ur_result_t Res = Plugin->call_nocheck( Command, &UpdateDesc); if (UrProgram) { // We retained these objects by calling getOrCreateKernel() - Plugin->call(urKernelRelease, UrKernel); - Plugin->call(urProgramRelease, UrProgram); + Plugin->call( UrKernel); + Plugin->call( UrProgram); } if (Res != UR_RESULT_SUCCESS) { diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index c93b3d59ce751..8c38d292b649f 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -262,7 +262,7 @@ template static void getImageInfo(const ContextImplPtr Context, ur_image_info_t Info, T &Dest, ur_mem_handle_t InteropMemObject) { const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(urMemImageGetInfo, InteropMemObject, Info, sizeof(T), &Dest, + Plugin->call( InteropMemObject, Info, sizeof(T), &Dest, nullptr); } @@ -276,7 +276,7 @@ image_impl::image_impl(cl_mem MemObject, const context &SyclContext, ur_mem_handle_t Mem = ur::cast(BaseT::MInteropMemObject); const ContextImplPtr Context = getSyclObjImpl(SyclContext); const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(urMemGetInfo, Mem, UR_MEM_INFO_SIZE, sizeof(size_t), + Plugin->call( Mem, UR_MEM_INFO_SIZE, sizeof(size_t), &(BaseT::MSizeInBytes), nullptr); ur_image_format_t Format; diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 480bb1934e00d..d4ff34b1f907e 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -424,7 +424,7 @@ class kernel_bundle_impl { std::transform(DeviceVec.begin(), DeviceVec.end(), IPVersionVec.begin(), [&](ur_device_handle_t d) { uint32_t ipVersion = 0; - Plugin->call(urDeviceGetInfo, d, + Plugin->call( d, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); return ipVersion; @@ -452,33 +452,33 @@ class kernel_bundle_impl { }(); ur_program_handle_t UrProgram = nullptr; - Plugin->call(urProgramCreateWithIL, ContextImpl->getHandleRef(), + Plugin->call( ContextImpl->getHandleRef(), spirv.data(), spirv.size(), nullptr, &UrProgram); // program created by urProgramCreateWithIL is implicitly retained. std::string XsFlags = extractXsFlags(BuildOptions); auto Res = - Plugin->call_nocheck(urProgramBuildExp, UrProgram, DeviceVec.size(), + Plugin->call_nocheck( UrProgram, DeviceVec.size(), DeviceVec.data(), XsFlags.c_str()); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck(urProgramBuild, ContextImpl->getHandleRef(), + Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), UrProgram, XsFlags.c_str()); } Plugin->checkUrResult(Res); // Get the number of kernels in the program. size_t NumKernels; - Plugin->call(urProgramGetInfo, UrProgram, UR_PROGRAM_INFO_NUM_KERNELS, + Plugin->call( UrProgram, UR_PROGRAM_INFO_NUM_KERNELS, sizeof(size_t), &NumKernels, nullptr); // Get the kernel names. size_t KernelNamesSize; - Plugin->call(urProgramGetInfo, UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, 0, + Plugin->call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, 0, nullptr, &KernelNamesSize); // semi-colon delimited list of kernel names. std::string KernelNamesStr(KernelNamesSize, ' '); - Plugin->call(urProgramGetInfo, UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, + Plugin->call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, KernelNamesStr.size(), &KernelNamesStr[0], nullptr); std::vector KernelNames = detail::split_string(KernelNamesStr, ';'); @@ -531,7 +531,7 @@ class kernel_bundle_impl { ContextImplPtr ContextImpl = getSyclObjImpl(MContext); const PluginPtr &Plugin = ContextImpl->getPlugin(); ur_kernel_handle_t UrKernel = nullptr; - Plugin->call(urKernelCreate, UrProgram, AdjustedName.c_str(), &UrKernel); + Plugin->call( UrProgram, AdjustedName.c_str(), &UrKernel); // Kernel created by urKernelCreate is implicitly retained. std::shared_ptr KernelImpl = std::make_shared( diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index c458e6b3d47f9..2204e007239f2 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -26,7 +26,7 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr Context, MIsInterop(true), MKernelArgMaskPtr{ArgMask} { ur_context_handle_t UrContext = nullptr; // Using the plugin from the passed ContextImpl - getPlugin()->call(urKernelGetInfo, MKernel, UR_KERNEL_INFO_CONTEXT, + getPlugin()->call( MKernel, UR_KERNEL_INFO_CONTEXT, sizeof(UrContext), &UrContext, nullptr); if (Context->getHandleRef() != UrContext) throw sycl::exception( @@ -38,7 +38,7 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr Context, // For others, UR will turn this into a NOP. if (Context->getPlatformImpl()->supports_usm()) { bool EnableAccess = true; - getPlugin()->call(urKernelSetExecInfo, MKernel, + getPlugin()->call( MKernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &EnableAccess); } @@ -59,7 +59,7 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr ContextImpl, kernel_impl::~kernel_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(urKernelRelease, MKernel); + getPlugin()->call( MKernel); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~kernel_impl", e); } diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index e69ddaa2e3f48..400326f26f05a 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -74,9 +74,9 @@ class kernel_impl { /// /// \return a valid cl_kernel instance cl_kernel get() const { - getPlugin()->call(urKernelRetain, MKernel); + getPlugin()->call( MKernel); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(urKernelGetNativeHandle, MKernel, &nativeHandle); + getPlugin()->call( MKernel, &nativeHandle); return ur::cast(nativeHandle); } @@ -134,10 +134,10 @@ class kernel_impl { const PluginPtr &Plugin = MContext->getPlugin(); if (MContext->getBackend() == backend::opencl) - Plugin->call(urKernelRetain, MKernel); + Plugin->call( MKernel); ur_native_handle_t NativeKernel = 0; - Plugin->call(urKernelGetNativeHandle, MKernel, &NativeKernel); + Plugin->call( MKernel, &NativeKernel); return NativeKernel; } @@ -227,7 +227,7 @@ inline typename ext::oneapi::experimental::info::kernel_queue_specific:: const auto MaxWorkGroupSize = Queue.get_device().get_info(); uint32_t GroupCount = 0; - Plugin->call(urKernelSuggestMaxCooperativeGroupCountExp, Handle, + Plugin->call( Handle, MaxWorkGroupSize, /* DynamicSharedMemorySize */ 0, &GroupCount); return GroupCount; } diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index 397aa44f36e53..c10ef68770922 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -31,14 +31,14 @@ get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { size_t ResultSize = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urKernelGetInfo, Kernel, UrInfoCode::value, 0, nullptr, + Plugin->call( Kernel, UrInfoCode::value, 0, nullptr, &ResultSize); if (ResultSize == 0) { return ""; } std::vector Result(ResultSize); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urKernelGetInfo, Kernel, UrInfoCode::value, ResultSize, + Plugin->call( Kernel, UrInfoCode::value, ResultSize, Result.data(), nullptr); return std::string(Result.data()); } @@ -50,7 +50,7 @@ get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { ur_result_t Result = UR_RESULT_SUCCESS; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urKernelGetInfo, Kernel, UrInfoCode::value, + Plugin->call( Kernel, UrInfoCode::value, sizeof(uint32_t), &Result, nullptr); return Result; } @@ -62,7 +62,7 @@ get_kernel_device_specific_info_helper(ur_kernel_handle_t Kernel, ur_device_handle_t Device, const PluginPtr &Plugin, void *Result, size_t Size) { - Plugin->call(urKernelGetSubGroupInfo, Kernel, Device, + Plugin->call( Kernel, Device, UrInfoCode::value, Size, Result, nullptr); } @@ -71,7 +71,7 @@ typename std::enable_if::value>::type get_kernel_device_specific_info_helper( ur_kernel_handle_t Kernel, [[maybe_unused]] ur_device_handle_t Device, const PluginPtr &Plugin, void *Result, size_t Size) { - Plugin->call(urKernelGetInfo, Kernel, UrInfoCode::value, Size, Result, + Plugin->call( Kernel, UrInfoCode::value, Size, Result, nullptr); } @@ -83,7 +83,7 @@ get_kernel_device_specific_info_helper(ur_kernel_handle_t Kernel, const PluginPtr &Plugin, void *Result, size_t Size) { ur_result_t Error = - Plugin->call_nocheck(urKernelGetGroupInfo, Kernel, Device, + Plugin->call_nocheck( Kernel, Device, UrInfoCode::value, Size, Result, nullptr); if (Error != UR_RESULT_SUCCESS) kernel_get_group_info::handleErrorOrWarning(Error, UrInfoCode::value, @@ -140,7 +140,7 @@ uint32_t get_kernel_device_specific_info_with_input(ur_kernel_handle_t Kernel, uint32_t Result = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urKernelGetSubGroupInfo, Kernel, Device, + Plugin->call( Kernel, Device, UrInfoCode::value, sizeof(uint32_t), &Result, nullptr); return Result; diff --git a/sycl/source/detail/kernel_program_cache.hpp b/sycl/source/detail/kernel_program_cache.hpp index 5cc626b449aaa..6dcce7804cd85 100644 --- a/sycl/source/detail/kernel_program_cache.hpp +++ b/sycl/source/detail/kernel_program_cache.hpp @@ -102,7 +102,7 @@ class KernelProgramCache { ~ProgramBuildResult() { try { if (Val) { - ur_result_t Err = Plugin->call_nocheck(urProgramRelease, Val); + ur_result_t Err = Plugin->call_nocheck( Val); __SYCL_CHECK_OCL_CODE_NO_EXC(Err); } } catch (std::exception &e) { @@ -140,7 +140,7 @@ class KernelProgramCache { ~KernelBuildResult() { try { if (Val.first) { - ur_result_t Err = Plugin->call_nocheck(urKernelRelease, Val.first); + ur_result_t Err = Plugin->call_nocheck( Val.first); __SYCL_CHECK_OCL_CODE_NO_EXC(Err); } } catch (std::exception &e) { diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 437db6c877e2a..f9ea65c4144c8 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -128,7 +128,7 @@ static void waitForEvents(const std::vector &Events) { Events.begin(), Events.end(), UrEvents.begin(), [](const EventImplPtr &EventImpl) { return EventImpl->getHandle(); }); if (!UrEvents.empty() && UrEvents[0]) { - Plugin->call(urEventWait, UrEvents.size(), &UrEvents[0]); + Plugin->call( UrEvents.size(), &UrEvents[0]); } } } @@ -155,14 +155,14 @@ void memBufferCreateHelper(const PluginPtr &Plugin, ur_context_handle_t Ctx, // When doing buffer interop we don't know what device the memory should // be resident on, so pass nullptr for Device param. Buffer interop may // not be supported by all backends. - Plugin->call_nocheck(urMemGetNativeHandle, *RetMem, /*Dev*/ nullptr, + Plugin->call_nocheck( *RetMem, /*Dev*/ nullptr, &Ptr); emitMemAllocEndTrace(MemObjID, (uintptr_t)(Ptr), Size, 0 /* guard zone */, CorrID); }}; #endif if (Size) - Plugin->call(urMemBufferCreate, Ctx, Flags, Size, Props, RetMem); + Plugin->call( Ctx, Flags, Size, Props, RetMem); } } @@ -181,7 +181,7 @@ void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { // When doing buffer interop we don't know what device the memory should be // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. - Plugin->call_nocheck(urMemGetNativeHandle, Mem, /*Dev*/ nullptr, + Plugin->call_nocheck( Mem, /*Dev*/ nullptr, &PtrHandle); Ptr = (uintptr_t)(PtrHandle); } @@ -193,7 +193,7 @@ void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { xpti::utils::finally _{ [&] { emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call(urMemRelease, Mem); + Plugin->call( Mem); } } @@ -215,7 +215,7 @@ void memBufferMapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, 0 /* guard zone */, CorrID); }}; #endif - Plugin->call(urEnqueueMemBufferMap, Queue, Buffer, Blocking, Flags, Offset, + Plugin->call( Queue, Buffer, Blocking, Flags, Offset, Size, NumEvents, WaitList, Event, RetMap); } @@ -239,11 +239,11 @@ void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, // Always use call_nocheck here, because call may throw an exception, // and this lambda will be called from destructor, which in combination // rewards us with UB. - Plugin->call_nocheck(urEventWait, 1, Event); + Plugin->call_nocheck( 1, Event); emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call(urEnqueueMemUnmap, Queue, Mem, MappedPtr, NumEvents, WaitList, + Plugin->call( Queue, Mem, MappedPtr, NumEvents, WaitList, Event); } } @@ -317,7 +317,7 @@ void *MemoryManager::allocateInteropMemObject( // destruction if (nullptr != OutEventToWait) { const PluginPtr &Plugin = InteropEvent->getPlugin(); - Plugin->call(urEventRetain, OutEventToWait); + Plugin->call( OutEventToWait); } return UserPtr; } @@ -342,7 +342,7 @@ void *MemoryManager::allocateImageObject(ContextImplPtr TargetContext, ur_mem_handle_t NewMem = nullptr; const PluginPtr &Plugin = TargetContext->getPlugin(); - Plugin->call(urMemImageCreate, TargetContext->getHandleRef(), CreationFlags, + Plugin->call( TargetContext->getHandleRef(), CreationFlags, &Format, &Desc, UserPtr, &NewMem); return NewMem; } @@ -446,8 +446,7 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, SizeInBytes}; ur_mem_handle_t NewMem; const PluginPtr &Plugin = TargetContext->getPlugin(); - Error = Plugin->call_nocheck( - urMemBufferPartition, ur::cast(ParentMemObj), + Error = Plugin->call_nocheck( ur::cast(ParentMemObj), UR_MEM_FLAG_READ_WRITE, UR_BUFFER_CREATE_TYPE_REGION, &Region, &NewMem); if (Error == UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET) throw detail::set_ur_error( @@ -522,7 +521,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferWrite, Queue, DstMem, + Plugin->call( Queue, DstMem, /*blocking_write=*/false, DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -543,7 +542,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferWriteRect, Queue, DstMem, + Plugin->call( Queue, DstMem, /*blocking_write=*/false, BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, SrcMem, DepEvents.size(), DepEvents.data(), @@ -561,7 +560,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemImageWrite, Queue, DstMem, + Plugin->call( Queue, DstMem, /*blocking_write=*/false, Origin, Region, InputRowPitch, InputSlicePitch, SrcMem, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -605,7 +604,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferRead, Queue, SrcMem, + Plugin->call( Queue, SrcMem, /*blocking_read=*/false, SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -626,7 +625,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferReadRect, Queue, SrcMem, + Plugin->call( Queue, SrcMem, /*blocking_read=*/false, BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, DstMem, DepEvents.size(), DepEvents.data(), @@ -644,7 +643,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemImageRead, Queue, SrcMem, false, Offset, Region, + Plugin->call( Queue, SrcMem, false, Offset, Region, RowPitch, SlicePitch, DstMem, DepEvents.size(), DepEvents.data(), &OutEvent); } @@ -681,7 +680,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferCopy, Queue, SrcMem, DstMem, SrcXOffBytes, + Plugin->call( Queue, SrcMem, DstMem, SrcXOffBytes, DstXOffBytes, SrcAccessRangeWidthBytes, DepEvents.size(), DepEvents.data(), &OutEvent); } else { @@ -706,7 +705,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferCopyRect, Queue, SrcMem, DstMem, SrcOrigin, + Plugin->call( Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, DstSlicePitch, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -721,7 +720,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemImageCopy, Queue, SrcMem, DstMem, SrcOrigin, + Plugin->call( Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, DepEvents.size(), DepEvents.data(), &OutEvent); } @@ -818,7 +817,7 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, size_t RangeMultiplier = AccRange[0] * AccRange[1] * AccRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call(urEnqueueMemBufferFill, Queue->getHandleRef(), + Plugin->call( Queue->getHandleRef(), ur::cast(Mem), Pattern, PatternSize, Offset[0] * ElementSize, RangeMultiplier * ElementSize, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -913,7 +912,7 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - SrcQueue->getPlugin()->call(urEnqueueEventsWait, SrcQueue->getHandleRef(), + SrcQueue->getPlugin()->call( SrcQueue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -926,7 +925,7 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, const PluginPtr &Plugin = SrcQueue->getPlugin(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueUSMMemcpy, SrcQueue->getHandleRef(), + Plugin->call( SrcQueue->getHandleRef(), /* blocking */ false, DstMem, SrcMem, Len, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -941,7 +940,7 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call(urEnqueueEventsWait, Queue->getHandleRef(), + Queue->getPlugin()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -953,7 +952,7 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call(urEnqueueUSMFill, Queue->getHandleRef(), Mem, Pattern.size(), + Plugin->call( Queue->getHandleRef(), Mem, Pattern.size(), Pattern.data(), Length, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -966,7 +965,7 @@ void MemoryManager::prefetch_usm(void *Mem, QueueImplPtr Queue, size_t Length, const PluginPtr &Plugin = Queue->getPlugin(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueUSMPrefetch, Queue->getHandleRef(), Mem, Length, 0, + Plugin->call( Queue->getHandleRef(), Mem, Length, 0, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -979,7 +978,7 @@ void MemoryManager::advise_usm(const void *Mem, QueueImplPtr Queue, const PluginPtr &Plugin = Queue->getPlugin(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueUSMAdvise, Queue->getHandleRef(), Mem, Length, Advice, + Plugin->call( Queue->getHandleRef(), Mem, Length, Advice, OutEvent); } @@ -995,7 +994,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call(urEnqueueEventsWait, Queue->getHandleRef(), + Queue->getPlugin()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1008,7 +1007,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, const PluginPtr &Plugin = Queue->getPlugin(); bool SupportsUSMMemcpy2D = false; - Plugin->call(urContextGetInfo, Queue->getContextImplPtr()->getHandleRef(), + Plugin->call( Queue->getContextImplPtr()->getHandleRef(), UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, sizeof(bool), &SupportsUSMMemcpy2D, nullptr); @@ -1016,7 +1015,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); // Direct memcpy2D is supported so we use this function. - Plugin->call(urEnqueueUSMMemcpy2D, Queue->getHandleRef(), + Plugin->call(Queue->getHandleRef(), /*blocking=*/false, DstMem, DstPitch, SrcMem, SrcPitch, Width, Height, DepEvents.size(), DepEvents.data(), OutEvent); return; @@ -1046,7 +1045,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, for (size_t I = 0; I < Height; ++I) { char *DstItBegin = static_cast(DstMem) + I * DstPitch; const char *SrcItBegin = static_cast(SrcMem) + I * SrcPitch; - Plugin->call(urEnqueueUSMMemcpy, Queue->getHandleRef(), + Plugin->call( Queue->getHandleRef(), /* blocking */ false, DstItBegin, SrcItBegin, Width, DepEvents.size(), DepEvents.data(), CopyEvents.data() + I); CopyEventsManaged.emplace_back(CopyEvents[I], Plugin, @@ -1055,7 +1054,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); // Then insert a wait to coalesce the copy events. - Queue->getPlugin()->call(urEnqueueEventsWait, Queue->getHandleRef(), + Queue->getPlugin()->call( Queue->getHandleRef(), CopyEvents.size(), CopyEvents.data(), OutEvent); } @@ -1071,7 +1070,7 @@ void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call(urEnqueueEventsWait, Queue->getHandleRef(), + Queue->getPlugin()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1083,7 +1082,7 @@ void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call(urEnqueueUSMFill2D, Queue->getHandleRef(), DstMem, Pitch, + Plugin->call(Queue->getHandleRef(), DstMem, Pitch, Pattern.size(), Pattern.data(), Width, Height, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -1100,7 +1099,7 @@ void MemoryManager::memset_2d_usm(void *DstMem, QueueImplPtr Queue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call(urEnqueueEventsWait, Queue->getHandleRef(), + Queue->getPlugin()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1233,7 +1232,7 @@ memcpyToDeviceGlobalDirect(QueueImplPtr Queue, ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call(urEnqueueDeviceGlobalVariableWrite, Queue->getHandleRef(), + Plugin->call( Queue->getHandleRef(), Program, DeviceGlobalEntry->MUniqueId.c_str(), false, NumBytes, Offset, Src, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -1249,7 +1248,7 @@ memcpyFromDeviceGlobalDirect(QueueImplPtr Queue, ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call(urEnqueueDeviceGlobalVariableRead, Queue->getHandleRef(), + Plugin->call( Queue->getHandleRef(), Program, DeviceGlobalEntry->MUniqueId.c_str(), false, NumBytes, Offset, Dest, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -1331,7 +1330,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - Plugin->call(urCommandBufferAppendMemBufferCopyExp, CommandBuffer, + Plugin->call( CommandBuffer, sycl::detail::ur::cast(SrcMem), sycl::detail::ur::cast(DstMem), SrcXOffBytes, DstXOffBytes, SrcAccessRangeWidthBytes, Deps.size(), @@ -1357,7 +1356,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - Plugin->call(urCommandBufferAppendMemBufferCopyRectExp, CommandBuffer, + Plugin->call( CommandBuffer, sycl::detail::ur::cast(SrcMem), sycl::detail::ur::cast(DstMem), SrcOrigin, DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, @@ -1395,8 +1394,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendMemBufferReadExp, CommandBuffer, + ur_result_t Result = Plugin->call_nocheck( CommandBuffer, sycl::detail::ur::cast(SrcMem), SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, Deps.size(), Deps.data(), OutSyncPoint); @@ -1424,8 +1422,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendMemBufferReadRectExp, CommandBuffer, + ur_result_t Result = Plugin->call_nocheck( CommandBuffer, sycl::detail::ur::cast(SrcMem), BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, DstMem, Deps.size(), Deps.data(), OutSyncPoint); @@ -1469,8 +1466,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendMemBufferWriteExp, CommandBuffer, + ur_result_t Result = Plugin->call_nocheck( CommandBuffer, sycl::detail::ur::cast(DstMem), DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, Deps.size(), Deps.data(), OutSyncPoint); @@ -1498,8 +1494,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( DstAccessRange[DstPos.YTerm], DstAccessRange[DstPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendMemBufferWriteRectExp, CommandBuffer, + ur_result_t Result = Plugin->call_nocheck( CommandBuffer, sycl::detail::ur::cast(DstMem), BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, SrcMem, Deps.size(), Deps.data(), OutSyncPoint); @@ -1524,8 +1519,7 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer( "NULL pointer argument in memory copy operation."); const PluginPtr &Plugin = Context->getPlugin(); - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendUSMMemcpyExp, CommandBuffer, DstMem, SrcMem, Len, + ur_result_t Result = Plugin->call_nocheck( CommandBuffer, DstMem, SrcMem, Len, Deps.size(), Deps.data(), OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( @@ -1548,7 +1542,7 @@ void MemoryManager::ext_oneapi_fill_usm_cmd_buffer( "NULL pointer argument in memory fill operation."); const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(urCommandBufferAppendUSMFillExp, CommandBuffer, DstMem, + Plugin->call( CommandBuffer, DstMem, Pattern.data(), Pattern.size(), Len, Deps.size(), Deps.data(), OutSyncPoint); } @@ -1578,7 +1572,7 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( size_t RangeMultiplier = AccessRange[0] * AccessRange[1] * AccessRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call(urCommandBufferAppendMemBufferFillExp, CommandBuffer, + Plugin->call( CommandBuffer, ur::cast(Mem), Pattern, PatternSize, AccessOffset[0] * ElementSize, RangeMultiplier * ElementSize, Deps.size(), Deps.data(), OutSyncPoint); @@ -1596,7 +1590,7 @@ void MemoryManager::ext_oneapi_prefetch_usm_cmd_buffer( std::vector Deps, ur_exp_command_buffer_sync_point_t *OutSyncPoint) { const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(urCommandBufferAppendUSMPrefetchExp, CommandBuffer, Mem, Length, + Plugin->call( CommandBuffer, Mem, Length, ur_usm_migration_flags_t(0), Deps.size(), Deps.data(), OutSyncPoint); } @@ -1608,7 +1602,7 @@ void MemoryManager::ext_oneapi_advise_usm_cmd_buffer( std::vector Deps, ur_exp_command_buffer_sync_point_t *OutSyncPoint) { const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(urCommandBufferAppendUSMAdviseExp, CommandBuffer, Mem, Length, + Plugin->call( CommandBuffer, Mem, Length, Advice, Deps.size(), Deps.data(), OutSyncPoint); } @@ -1639,7 +1633,7 @@ void MemoryManager::copy_image_bindless( CopyRegion.srcOffset = SrcOffset; CopyRegion.dstOffset = DstOffset; - Plugin->call(urBindlessImagesImageCopyExp, Queue->getHandleRef(), Src, Dst, + Plugin->call( Queue->getHandleRef(), Src, Dst, &SrcDesc, &DstDesc, &SrcFormat, &DstFormat, &CopyRegion, Flags, DepEvents.size(), DepEvents.data(), OutEvent); } diff --git a/sycl/source/detail/persistent_device_code_cache.cpp b/sycl/source/detail/persistent_device_code_cache.cpp index f41912ddd11b0..7600e16b2376c 100644 --- a/sycl/source/detail/persistent_device_code_cache.cpp +++ b/sycl/source/detail/persistent_device_code_cache.cpp @@ -131,11 +131,11 @@ void PersistentDeviceCodeCache::putItemToDisc( unsigned int DeviceNum = 0; - Plugin->call(urProgramGetInfo, NativePrg, UR_PROGRAM_INFO_NUM_DEVICES, + Plugin->call( NativePrg, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(DeviceNum), &DeviceNum, nullptr); std::vector BinarySizes(DeviceNum); - Plugin->call(urProgramGetInfo, NativePrg, UR_PROGRAM_INFO_BINARY_SIZES, + Plugin->call( NativePrg, UR_PROGRAM_INFO_BINARY_SIZES, sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), nullptr); @@ -146,7 +146,7 @@ void PersistentDeviceCodeCache::putItemToDisc( Pointers.push_back(Result[I].data()); } - Plugin->call(urProgramGetInfo, NativePrg, UR_PROGRAM_INFO_BINARIES, + Plugin->call( NativePrg, UR_PROGRAM_INFO_BINARIES, sizeof(char *) * Pointers.size(), Pointers.data(), nullptr); size_t i = 0; std::string FileName; diff --git a/sycl/source/detail/physical_mem_impl.hpp b/sycl/source/detail/physical_mem_impl.hpp index 9e1d07372077b..d623ddfd18230 100644 --- a/sycl/source/detail/physical_mem_impl.hpp +++ b/sycl/source/detail/physical_mem_impl.hpp @@ -43,8 +43,7 @@ class physical_mem_impl { MContext(getSyclObjImpl(SyclContext)), MNumBytes(NumBytes) { const PluginPtr &Plugin = MContext->getPlugin(); - auto Err = Plugin->call_nocheck( - urPhysicalMemCreate, MContext->getHandleRef(), MDevice->getHandleRef(), + auto Err = Plugin->call_nocheck( MContext->getHandleRef(), MDevice->getHandleRef(), MNumBytes, nullptr, &MPhysicalMem); if (Err == UR_RESULT_ERROR_OUT_OF_RESOURCES || @@ -56,7 +55,7 @@ class physical_mem_impl { ~physical_mem_impl() noexcept(false) { const PluginPtr &Plugin = MContext->getPlugin(); - Plugin->call(urPhysicalMemRelease, MPhysicalMem); + Plugin->call( MPhysicalMem); } void *map(uintptr_t Ptr, size_t NumBytes, @@ -65,7 +64,7 @@ class physical_mem_impl { auto AccessFlags = AccessModeToVirtualAccessFlags(Mode); const PluginPtr &Plugin = MContext->getPlugin(); void *ResultPtr = reinterpret_cast(Ptr); - Plugin->call(urVirtualMemMap, MContext->getHandleRef(), ResultPtr, NumBytes, + Plugin->call( MContext->getHandleRef(), ResultPtr, NumBytes, MPhysicalMem, Offset, AccessFlags); return ResultPtr; } diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index b3214ed27b698..3336afe6285fa 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -64,7 +64,7 @@ platform_impl::getPlatformFromUrDevice(ur_device_handle_t UrDevice, ur_platform_handle_t Plt = nullptr; // TODO catch an exception and put it to list // of asynchronous exceptions - Plugin->call(urDeviceGetInfo, UrDevice, UR_DEVICE_INFO_PLATFORM, sizeof(Plt), + Plugin->call( UrDevice, UR_DEVICE_INFO_PLATFORM, sizeof(Plt), &Plt, nullptr); return getOrMakePlatformImpl(Plt, Plugin); } @@ -198,7 +198,7 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, // Find out backend of the platform ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN; - MPlugin->call(urPlatformGetInfo, MPlatform, UR_PLATFORM_INFO_BACKEND, + MPlugin->call( MPlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), &UrBackend, nullptr); backend Backend = convertUrBackend(UrBackend); @@ -209,7 +209,7 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, int DeviceNum = MPlugin->getStartingDeviceId(MPlatform); for (ur_device_handle_t Device : UrDevices) { ur_device_type_t UrDevType = UR_DEVICE_TYPE_ALL; - MPlugin->call(urDeviceGetInfo, Device, UR_DEVICE_INFO_TYPE, + MPlugin->call( Device, UR_DEVICE_INFO_TYPE, sizeof(ur_device_type_t), &UrDevType, nullptr); // Assumption here is that there is 1-to-1 mapping between UrDevType and // Sycl device type for GPU, CPU, and ACC. @@ -460,7 +460,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { } uint32_t NumDevices = 0; - MPlugin->call(urDeviceGet, MPlatform, UrDeviceType, + MPlugin->call(MPlatform, UrDeviceType, 0, // CP info::device_type::all nullptr, &NumDevices); const backend Backend = getBackend(); @@ -486,7 +486,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { std::vector UrDevices(NumDevices); // TODO catch an exception and put it to list of asynchronous exceptions - MPlugin->call(urDeviceGet, MPlatform, + MPlugin->call(MPlatform, UrDeviceType, // CP info::device_type::all NumDevices, UrDevices.data(), nullptr); @@ -520,7 +520,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { // The reference counter for handles, that we used to create sycl objects, is // incremented, so we need to call release here. for (ur_device_handle_t &UrDev : UrDevicesToCleanUp) - MPlugin->call(urDeviceRelease, UrDev); + MPlugin->call( UrDev); // If we aren't using ONEAPI_DEVICE_SELECTOR, then we are done. // and if there are no devices so far, there won't be any need to replace them @@ -549,7 +549,7 @@ bool platform_impl::supports_usm() const { ur_native_handle_t platform_impl::getNative() const { const auto &Plugin = getPlugin(); ur_native_handle_t Handle = 0; - Plugin->call(urPlatformGetNativeHandle, getHandleRef(), &Handle); + Plugin->call( getHandleRef(), &Handle); return Handle; } diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index a2d926834bf05..0edf5d5e74867 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -42,7 +42,7 @@ class platform_impl { : MPlatform(APlatform), MPlugin(APlugin) { // Find out backend of the platform ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN; - APlugin->call_nocheck(urPlatformGetInfo, APlatform, + APlugin->call_nocheck( APlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), &UrBackend, nullptr); MBackend = convertUrBackend(UrBackend); @@ -92,15 +92,14 @@ class platform_impl { void getBackendOption(const char *frontend_option, const char **backend_option) const { const auto &Plugin = getPlugin(); - ur_result_t Err = Plugin->call_nocheck( - urPlatformGetBackendOption, MPlatform, frontend_option, backend_option); + ur_result_t Err = Plugin->call_nocheck( MPlatform, frontend_option, backend_option); Plugin->checkUrResult(Err); } /// \return an instance of OpenCL cl_platform_id. cl_platform_id get() const { ur_native_handle_t nativeHandle = 0; - getPlugin()->call(urPlatformGetNativeHandle, MPlatform, &nativeHandle); + getPlugin()->call( MPlatform, &nativeHandle); return ur::cast(nativeHandle); } diff --git a/sycl/source/detail/platform_info.hpp b/sycl/source/detail/platform_info.hpp index 20e698eaf2390..d2f79116ef638 100644 --- a/sycl/source/detail/platform_info.hpp +++ b/sycl/source/detail/platform_info.hpp @@ -24,13 +24,13 @@ inline std::string get_platform_info_string_impl(ur_platform_handle_t Plt, ur_platform_info_t UrCode) { size_t ResultSize = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urPlatformGetInfo, Plt, UrCode, 0, nullptr, &ResultSize); + Plugin->call( Plt, UrCode, 0, nullptr, &ResultSize); if (ResultSize == 0) { return ""; } std::unique_ptr Result(new char[ResultSize]); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urPlatformGetInfo, Plt, UrCode, ResultSize, Result.get(), + Plugin->call( Plt, UrCode, ResultSize, Result.get(), nullptr); return Result.get(); } diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/plugin.hpp index 6cf40da421ff3..9dd0b9a8e72ae 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -15,6 +15,8 @@ #include #include +#include "ur_win_proxy_loader.hpp" + #include #ifdef XPTI_ENABLE_INSTRUMENTATION @@ -50,7 +52,12 @@ class plugin { plugin(ur_adapter_handle_t adapter, backend UseBackend) : MAdapter(adapter), MBackend(UseBackend), TracingMutex(std::make_shared()), - MPluginMutex(std::make_shared()) {} + MPluginMutex(std::make_shared()) { + +#ifdef _WIN32 + UrLoaderHandle = ur::loadURLoaderLibrary(); +#endif + } // Disallow accidental copies of plugins plugin &operator=(const plugin &) = delete; @@ -66,7 +73,7 @@ class plugin { const char *message = nullptr; if (ur_result == UR_RESULT_ERROR_ADAPTER_SPECIFIC) { int32_t adapter_error = 0; - ur_result = call_nocheck(urAdapterGetLastError, MAdapter, &message, &adapter_error); + ur_result = call_nocheck(MAdapter, &message, &adapter_error); // If the warning level is greater then 2 emit the message if (detail::SYCLConfig::get() >= 2) { @@ -92,9 +99,9 @@ class plugin { std::vector &getUrPlatforms() { std::call_once(PlatformsPopulated, [&]() { uint32_t platformCount = 0; - call(urPlatformGet, &MAdapter, 1, 0, nullptr, &platformCount); + call(&MAdapter, 1, 0, nullptr, &platformCount); UrPlatforms.resize(platformCount); - call(urPlatformGet, &MAdapter, 1, platformCount, UrPlatforms.data(), + call(&MAdapter, 1, platformCount, UrPlatforms.data(), nullptr); // We need one entry in this per platform LastDeviceIds.resize(platformCount); @@ -114,10 +121,22 @@ class plugin { /// \endcode /// /// \sa plugin::checkUrResult - template - ur_result_t call_nocheck(UrFunc F, ArgsT... Args) const { + // template + // ur_result_t call_nocheck(UrFunc F, ArgsT... Args) const { + // ur_result_t R = UR_RESULT_SUCCESS; + // if (!adapterReleased) { + // R = F(Args...); + // } + // return R; + // } + + template + ur_result_t call_nocheck(ArgsT... Args) const { ur_result_t R = UR_RESULT_SUCCESS; + // fprintf(stderr, "CALL_NOCHECK2\n"); if (!adapterReleased) { + detail::UrFuncInfo UrApiInfo; + auto F = UrApiInfo.getFuncPtr(UrLoaderHandle); R = F(Args...); } return R; @@ -126,16 +145,28 @@ class plugin { /// Calls the API, traces the call, checks the result /// /// \throw sycl::runtime_exception if the call was not successful. - template - void call(UrFunc F, ArgsT... Args) const { - auto Err = call_nocheck(F, Args...); + // template + // void call(UrFunc F, ArgsT... Args) const { + // auto Err = call_nocheck(F, Args...); + // checkUrResult(Err); + // } + + template + void call(ArgsT... Args) const { + auto Err = call_nocheck(Args...); checkUrResult(Err); } /// \throw sycl::exceptions(errc) if the call was not successful. - template - void call(UrFunc F, ArgsT... Args) const { - auto Err = call_nocheck(F, Args...); + // template + // void call(UrFunc F, ArgsT... Args) const { + // auto Err = call_nocheck(F, Args...); + // checkUrResult(Err); + // } + + template + void call(ArgsT... Args) const { + auto Err = call_nocheck(Args...); checkUrResult(Err); } @@ -145,7 +176,7 @@ class plugin { bool hasBackend(backend Backend) const { return Backend == MBackend; } void release() { - call(urAdapterRelease, MAdapter); + call(MAdapter); this->adapterReleased = true; } @@ -213,6 +244,9 @@ class plugin { // represents the unique ids of the last device of each platform // index of this vector corresponds to the index in UrPlatforms vector. std::vector LastDeviceIds; +#ifdef _WIN32 + void* UrLoaderHandle = nullptr; +#endif }; // class plugin using PluginPtr = std::shared_ptr; diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 5b22f0cf7f89e..fc8aa70efaf2e 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -63,7 +63,7 @@ static void enableITTAnnotationsIfNeeded(const ur_program_handle_t &Prog, constexpr char SpecValue = 1; ur_specialization_constant_info_t SpecConstInfo = { ITTSpecConstId, sizeof(char), &SpecValue}; - Plugin->call(urProgramSetSpecializationConstants, Prog, 1, &SpecConstInfo); + Plugin->call( Prog, 1, &SpecConstInfo); } } @@ -78,7 +78,7 @@ createBinaryProgram(const ContextImplPtr Context, const device &Device, const PluginPtr &Plugin = Context->getPlugin(); #ifndef _NDEBUG uint32_t NumDevices = 0; - Plugin->call(urContextGetInfo, Context->getHandleRef(), + Plugin->call( Context->getHandleRef(), UR_CONTEXT_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, /*param_value_size_ret=*/nullptr); assert(NumDevices > 0 && @@ -93,7 +93,7 @@ createBinaryProgram(const ContextImplPtr Context, const device &Device, Properties.pNext = nullptr; Properties.count = Metadata.size(); Properties.pMetadatas = Metadata.data(); - Plugin->call(urProgramCreateWithBinary, Context->getHandleRef(), UrDevice, + Plugin->call( Context->getHandleRef(), UrDevice, DataLen, Data, &Properties, &Program); if (BinaryStatus != UR_RESULT_SUCCESS) { @@ -111,7 +111,7 @@ static ur_program_handle_t createSpirvProgram(const ContextImplPtr Context, size_t DataLen) { ur_program_handle_t Program = nullptr; const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(urProgramCreateWithIL, Context->getHandleRef(), Data, DataLen, + Plugin->call( Context->getHandleRef(), Data, DataLen, nullptr, &Program); return Program; } @@ -568,7 +568,7 @@ static bool compatibleWithDevice(RTDeviceBinaryImage *BinImage, UrBinary.pDeviceTargetSpec = getUrDeviceTarget(DevBin->DeviceTargetSpec); ur_result_t Error = - Plugin->call_nocheck(urDeviceSelectBinary, URDeviceHandle, &UrBinary, + Plugin->call_nocheck( URDeviceHandle, &UrBinary, /*num bin images = */ (uint32_t)1, &SuitableImageID); if (Error != UR_RESULT_SUCCESS && Error != UR_RESULT_ERROR_INVALID_BINARY) throw detail::set_ur_error(exception(make_error_code(errc::runtime), @@ -722,7 +722,7 @@ setSpecializationConstants(const std::shared_ptr &InputImpl, ur_specialization_constant_info_t SpecConstInfo = { SpecIDDesc.ID, SpecIDDesc.Size, SpecConsts.data() + SpecIDDesc.BlobOffset}; - Plugin->call(urProgramSetSpecializationConstants, Prog, 1, + Plugin->call( Prog, 1, &SpecConstInfo); } } @@ -757,7 +757,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( } ur_bool_t MustBuildOnSubdevice = true; - ContextImpl->getPlugin()->call(urDeviceGetInfo, RootDevImpl->getHandleRef(), + ContextImpl->getPlugin()->call( RootDevImpl->getHandleRef(), UR_DEVICE_INFO_BUILD_ON_SUBDEVICE, sizeof(ur_bool_t), &MustBuildOnSubdevice, nullptr); @@ -802,7 +802,9 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( enableITTAnnotationsIfNeeded(NativePrg, Plugin); } - ProgramPtr ProgramManaged(NativePrg, urProgramRelease); + UrFuncInfo programReleaseInfo;; + auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + ProgramPtr ProgramManaged(NativePrg, programRelease); // Link a fallback implementation of device libraries if they are not // supported by a device compiler. @@ -845,7 +847,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( SYCL_DEVICE_BINARY_TYPE_SPIRV); // Those extra programs won't be used anymore, just the final linked result for (ur_program_handle_t Prg : ProgramsToLink) - Plugin->call(urProgramRelease, Prg); + Plugin->call( Prg); emitBuiltProgramInfo(BuiltProgram.get(), ContextImpl); @@ -896,7 +898,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( bool DidInsert = Cache.insertBuiltProgram(CacheKey, ResProgram); if (DidInsert) { // For every cached copy of the program, we need to increment its refcount - Plugin->call(urProgramRetain, ResProgram); + Plugin->call( ResProgram); } } @@ -904,7 +906,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // program. - ContextImpl->getPlugin()->call(urProgramRetain, ResProgram); + ContextImpl->getPlugin()->call( ResProgram); return ResProgram; } @@ -942,9 +944,9 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, if (std::get(ret_tuple)) { // Pulling a copy of a kernel and program from the cache, // so we need to retain those resources. - ContextImpl->getPlugin()->call(urKernelRetain, + ContextImpl->getPlugin()->call( std::get(ret_tuple)); - ContextImpl->getPlugin()->call(urProgramRetain, + ContextImpl->getPlugin()->call( std::get(ret_tuple)); return ret_tuple; } @@ -957,15 +959,15 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, ur_kernel_handle_t Kernel = nullptr; const PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call(urKernelCreate, Program, - KernelName.c_str(), &Kernel); + Plugin->call( + Program, KernelName.c_str(), &Kernel); // Only set UR_USM_INDIRECT_ACCESS if the platform can handle it. if (ContextImpl->getPlatformImpl()->supports_usm()) { // Some UR Plugins (like OpenCL) require this call to enable USM // For others, UR will turn this into a NOP. const ur_bool_t UrTrue = true; - Plugin->call(urKernelSetExecInfo, Kernel, + Plugin->call( Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &UrTrue); } @@ -999,7 +1001,7 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // kernel. - ContextImpl->getPlugin()->call(urKernelRetain, KernelArgMaskPair.first); + ContextImpl->getPlugin()->call( KernelArgMaskPair.first); Cache.saveKernel(key, ret_val); return ret_val; } @@ -1009,7 +1011,7 @@ ProgramManager::getUrProgramFromUrKernel(ur_kernel_handle_t Kernel, const ContextImplPtr Context) { ur_program_handle_t Program; const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(urKernelGetInfo, Kernel, UR_KERNEL_INFO_PROGRAM, + Plugin->call( Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); return Program; } @@ -1019,23 +1021,23 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, const ContextImplPtr Context) { size_t URDevicesSize = 0; const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(urProgramGetInfo, Program, UR_PROGRAM_INFO_DEVICES, 0, nullptr, + Plugin->call( Program, UR_PROGRAM_INFO_DEVICES, 0, nullptr, &URDevicesSize); std::vector URDevices(URDevicesSize / sizeof(ur_device_handle_t)); - Plugin->call(urProgramGetInfo, Program, UR_PROGRAM_INFO_DEVICES, + Plugin->call( Program, UR_PROGRAM_INFO_DEVICES, URDevicesSize, URDevices.data(), nullptr); std::string Log = "The program was built for " + std::to_string(URDevices.size()) + " devices"; for (ur_device_handle_t &Device : URDevices) { std::string DeviceBuildInfoString; size_t DeviceBuildInfoStrSize = 0; - Plugin->call(urProgramGetBuildInfo, Program, Device, + Plugin->call( Program, Device, UR_PROGRAM_BUILD_INFO_LOG, 0, nullptr, &DeviceBuildInfoStrSize); if (DeviceBuildInfoStrSize > 0) { std::vector DeviceBuildInfo(DeviceBuildInfoStrSize); - Plugin->call(urProgramGetBuildInfo, Program, Device, + Plugin->call( Program, Device, UR_PROGRAM_BUILD_INFO_LOG, DeviceBuildInfoStrSize, DeviceBuildInfo.data(), nullptr); DeviceBuildInfoString = std::string(DeviceBuildInfo.data()); @@ -1043,11 +1045,11 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, std::string DeviceNameString; size_t DeviceNameStrSize = 0; - Plugin->call(urDeviceGetInfo, Device, UR_DEVICE_INFO_NAME, 0, nullptr, + Plugin->call( Device, UR_DEVICE_INFO_NAME, 0, nullptr, &DeviceNameStrSize); if (DeviceNameStrSize > 0) { std::vector DeviceName(DeviceNameStrSize); - Plugin->call(urDeviceGetInfo, Device, UR_DEVICE_INFO_NAME, + Plugin->call( Device, UR_DEVICE_INFO_NAME, DeviceNameStrSize, DeviceName.data(), nullptr); DeviceNameString = std::string(DeviceName.data()); } @@ -1150,9 +1152,9 @@ static ur_result_t doCompile(const PluginPtr &Plugin, // Try to compile with given devices, fall back to compiling with the program // context if unsupported by the adapter auto Result = - Plugin->call_nocheck(urProgramCompileExp, Program, NumDevs, Devs, Opts); + Plugin->call_nocheck( Program, NumDevs, Devs, Opts); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - return Plugin->call_nocheck(urProgramCompile, Ctx, Program, Opts); + return Plugin->call_nocheck( Ctx, Program, Opts); } return Result; } @@ -1332,8 +1334,7 @@ RTDeviceBinaryImage *getBinImageFromMultiMap( uint32_t ImgInd = 0; // Ask the native runtime under the given context to choose the device image // it prefers. - getSyclObjImpl(Context)->getPlugin()->call( - urDeviceSelectBinary, getSyclObjImpl(Device)->getHandleRef(), + getSyclObjImpl(Context)->getPlugin()->call( getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), UrBinaries.size(), &ImgInd); return DeviceFilteredImgs[ImgInd]; } @@ -1417,8 +1418,7 @@ RTDeviceBinaryImage &ProgramManager::getDeviceImage( getUrDeviceTarget(RawImgs[BinaryCount]->DeviceTargetSpec); } - getSyclObjImpl(Context)->getPlugin()->call( - urDeviceSelectBinary, getSyclObjImpl(Device)->getHandleRef(), + getSyclObjImpl(Context)->getPlugin()->call( getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), UrBinaries.size(), &ImgInd); ImageIterator = ImageSet.begin(); @@ -1548,10 +1548,10 @@ ProgramManager::ProgramPtr ProgramManager::build( ? CompileOptions : (CompileOptions + " " + LinkOptions); ur_result_t Error = - Plugin->call_nocheck(urProgramBuildExp, Program.get(), + Plugin->call_nocheck( Program.get(), /*num devices =*/1, &Device, Options.c_str()); if (Error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Error = Plugin->call_nocheck(urProgramBuild, Context->getHandleRef(), + Error = Plugin->call_nocheck( Context->getHandleRef(), Program.get(), Options.c_str()); } @@ -1583,12 +1583,12 @@ ProgramManager::ProgramPtr ProgramManager::build( ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck(urProgramLinkExp, Context->getHandleRef(), + auto Res = Plugin->call_nocheck( Context->getHandleRef(), /*num devices =*/1, &Device, LinkPrograms.size(), LinkPrograms.data(), LinkOptions.c_str(), &LinkedProg); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck(urProgramLink, Context->getHandleRef(), + Res = Plugin->call_nocheck( Context->getHandleRef(), LinkPrograms.size(), LinkPrograms.data(), LinkOptions.c_str(), &LinkedProg); } @@ -2405,12 +2405,11 @@ ProgramManager::link(const device_image_plain &DeviceImage, ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck( - urProgramLinkExp, ContextImpl->getHandleRef(), URDevices.size(), + auto Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), URDevices.size(), URDevices.data(), URPrograms.size(), URPrograms.data(), LinkOptionsStr.c_str(), &LinkedProg); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck(urProgramLink, ContextImpl->getHandleRef(), + Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), URPrograms.size(), URPrograms.data(), LinkOptionsStr.c_str(), &LinkedProg); } @@ -2544,7 +2543,9 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, InputImpl->get_bin_image_ref()->supportsSpecConstants()) setSpecializationConstants(InputImpl, NativePrg, Plugin); - ProgramPtr ProgramManaged(NativePrg, urProgramRelease); + UrFuncInfo programReleaseInfo;; + auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + ProgramPtr ProgramManaged(NativePrg, programRelease); // Link a fallback implementation of device libraries if they are not // supported by a device compiler. @@ -2614,7 +2615,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // other devices. const PluginPtr &Plugin = ContextImpl->getPlugin(); auto CacheOtherDevices = [ResProgram, &Plugin]() { - Plugin->call(urProgramRetain, ResProgram); + Plugin->call( ResProgram); return ResProgram; }; @@ -2634,7 +2635,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // devive_image_impl shares ownership of PIProgram with, at least, program // cache. The ref counter will be descremented in the destructor of // device_image_impl - Plugin->call(urProgramRetain, ResProgram); + Plugin->call( ResProgram); DeviceImageImplPtr ExecImpl = std::make_shared( InputImpl->get_bin_image_ref(), Context, Devs, bundle_state::executable, @@ -2663,12 +2664,12 @@ ProgramManager::getOrCreateKernel(const context &Context, ur_kernel_handle_t Kernel = nullptr; const PluginPtr &Plugin = Ctx->getPlugin(); - Plugin->call(urKernelCreate, Program, KernelName.c_str(), &Kernel); + Plugin->call( Program, KernelName.c_str(), &Kernel); // Only set UR_USM_INDIRECT_ACCESS if the platform can handle it. if (Ctx->getPlatformImpl()->supports_usm()) { bool EnableAccess = true; - Plugin->call(urKernelSetExecInfo, Kernel, + Plugin->call( Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &EnableAccess); } @@ -2700,7 +2701,7 @@ ProgramManager::getOrCreateKernel(const context &Context, // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // kernel. - Ctx->getPlugin()->call(urKernelRetain, BuildResult->Val.first); + Ctx->getPlugin()->call( BuildResult->Val.first); return std::make_tuple(BuildResult->Val.first, &(BuildResult->MBuildResultMutex), BuildResult->Val.second); @@ -2754,7 +2755,9 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( auto Program = createURProgram(Img, Context, Device); auto DeviceImpl = detail::getSyclObjImpl(Device); auto &Plugin = DeviceImpl->getPlugin(); - ProgramPtr ProgramManaged(Program, urProgramRelease); + UrFuncInfo programReleaseInfo;; + auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + ProgramPtr ProgramManaged(Program, programRelease); std::string CompileOpts; std::string LinkOpts; @@ -2767,8 +2770,8 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( /*For non SPIR-V devices DeviceLibReqdMask is always 0*/ 0, ExtraProgramsToLink); ur_kernel_handle_t UrKernel{nullptr}; - Plugin->call(urKernelCreate, BuildProgram.get(), - KernelName.c_str(), &UrKernel); + Plugin->call( + BuildProgram.get(), KernelName.c_str(), &UrKernel); { std::lock_guard KernelIDsGuard(m_KernelIDsMutex); m_MaterializedKernels[KernelName][SpecializationConsts] = UrKernel; diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 8b4e51f340aed..0ebd7d7f7ffe1 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -59,7 +59,7 @@ getUrEvents(const std::vector &DepEvents) { template <> uint32_t queue_impl::get_info() const { ur_result_t result = UR_RESULT_SUCCESS; - getPlugin()->call(urQueueGetInfo, MQueues[0], UR_QUEUE_INFO_REFERENCE_COUNT, + getPlugin()->call( MQueues[0], UR_QUEUE_INFO_REFERENCE_COUNT, sizeof(result), &result, nullptr); return result; } @@ -613,7 +613,7 @@ void queue_impl::wait(const detail::code_location &CodeLoc) { } if (SupportsPiFinish) { const PluginPtr &Plugin = getPlugin(); - Plugin->call(urQueueFinish, getHandleRef()); + Plugin->call( getHandleRef()); assert(SharedEvents.empty() && "Queues that support calling piQueueFinish " "shouldn't have shared events"); } else { @@ -695,13 +695,13 @@ void queue_impl::destructorNotification() { ur_native_handle_t queue_impl::getNative(int32_t &NativeHandleDesc) const { const PluginPtr &Plugin = getPlugin(); if (getContextImplPtr()->getBackend() == backend::opencl) - Plugin->call(urQueueRetain, MQueues[0]); + Plugin->call( MQueues[0]); ur_native_handle_t Handle{}; ur_queue_native_desc_t UrNativeDesc{UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC, nullptr, nullptr}; UrNativeDesc.pNativeData = &NativeHandleDesc; - Plugin->call(urQueueGetNativeHandle, MQueues[0], &UrNativeDesc, &Handle); + Plugin->call( MQueues[0], &UrNativeDesc, &Handle); return Handle; } @@ -731,7 +731,7 @@ bool queue_impl::ext_oneapi_empty() const { // Check the status of the backend queue if this is not a host queue. ur_bool_t IsReady = false; - getPlugin()->call(urQueueGetInfo, MQueues[0], UR_QUEUE_INFO_EMPTY, + getPlugin()->call( MQueues[0], UR_QUEUE_INFO_EMPTY, sizeof(IsReady), &IsReady, nullptr); if (!IsReady) return false; diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index c5777c368145d..0727b6910af44 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -196,7 +196,7 @@ class queue_impl { ur_device_handle_t DeviceUr{}; const PluginPtr &Plugin = getPlugin(); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(urQueueGetInfo, MQueues[0], UR_QUEUE_INFO_DEVICE, + Plugin->call( MQueues[0], UR_QUEUE_INFO_DEVICE, sizeof(DeviceUr), &DeviceUr, nullptr); MDevice = MContext->findMatchingDeviceImpl(DeviceUr); if (MDevice == nullptr) { @@ -262,7 +262,7 @@ class queue_impl { #endif throw_asynchronous(); cleanup_fusion_cmd(); - getPlugin()->call(urQueueRelease, MQueues[0]); + getPlugin()->call( MQueues[0]); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~queue_impl", e); } @@ -271,9 +271,9 @@ class queue_impl { /// \return an OpenCL interoperability queue handle. cl_command_queue get() { - getPlugin()->call(urQueueRetain, MQueues[0]); + getPlugin()->call( MQueues[0]); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(urQueueGetNativeHandle, MQueues[0], nullptr, + getPlugin()->call( MQueues[0], nullptr, &nativeHandle); return ur::cast(nativeHandle); } @@ -321,7 +321,7 @@ class queue_impl { "recording to a command graph."); } for (const auto &queue : MQueues) { - getPlugin()->call(urQueueFlush, queue); + getPlugin()->call( queue); } } @@ -513,7 +513,7 @@ class queue_impl { .get_index(); Properties.pNext = &IndexProperties; } - ur_result_t Error = Plugin->call_nocheck(urQueueCreate, Context, Device, + ur_result_t Error = Plugin->call_nocheck( Context, Device, &Properties, &Queue); // If creating out-of-order queue failed and this property is not @@ -556,7 +556,7 @@ class queue_impl { if (!ReuseQueue) *PIQ = createQueue(QueueOrder::Ordered); else - getPlugin()->call(urQueueFinish, *PIQ); + getPlugin()->call( *PIQ); return *PIQ; } @@ -738,7 +738,7 @@ class queue_impl { EventImplPtr insertHelperBarrier(const HandlerType &Handler) { auto ResEvent = std::make_shared(Handler.MQueue); ur_event_handle_t UREvent = nullptr; - getPlugin()->call(urEnqueueEventsWaitWithBarrier, + getPlugin()->call( Handler.MQueue->getHandleRef(), 0, nullptr, &UREvent); ResEvent->setHandle(UREvent); return ResEvent; diff --git a/sycl/source/detail/sampler_impl.cpp b/sycl/source/detail/sampler_impl.cpp index dd117814fba2c..779d207031dbf 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -24,21 +24,21 @@ sampler_impl::sampler_impl(coordinate_normalization_mode normalizationMode, sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { const PluginPtr &Plugin = getSyclObjImpl(syclContext)->getPlugin(); ur_sampler_handle_t Sampler{}; - Plugin->call(urSamplerCreateWithNativeHandle, + Plugin->call( reinterpret_cast(clSampler), getSyclObjImpl(syclContext)->getHandleRef(), nullptr, &Sampler); MContextToSampler[syclContext] = Sampler; bool NormalizedCoords; - Plugin->call(urSamplerGetInfo, Sampler, UR_SAMPLER_INFO_NORMALIZED_COORDS, + Plugin->call( Sampler, UR_SAMPLER_INFO_NORMALIZED_COORDS, sizeof(ur_bool_t), &NormalizedCoords, nullptr); MCoordNormMode = NormalizedCoords ? coordinate_normalization_mode::normalized : coordinate_normalization_mode::unnormalized; ur_sampler_addressing_mode_t AddrMode; - Plugin->call(urSamplerGetInfo, Sampler, UR_SAMPLER_INFO_ADDRESSING_MODE, + Plugin->call( Sampler, UR_SAMPLER_INFO_ADDRESSING_MODE, sizeof(ur_sampler_addressing_mode_t), &AddrMode, nullptr); switch (AddrMode) { case UR_SAMPLER_ADDRESSING_MODE_CLAMP: @@ -60,7 +60,7 @@ sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { } ur_sampler_filter_mode_t FiltMode; - Plugin->call(urSamplerGetInfo, Sampler, UR_SAMPLER_INFO_FILTER_MODE, + Plugin->call( Sampler, UR_SAMPLER_INFO_FILTER_MODE, sizeof(ur_sampler_filter_mode_t), &FiltMode, nullptr); switch (FiltMode) { case UR_SAMPLER_FILTER_MODE_LINEAR: @@ -80,7 +80,7 @@ sampler_impl::~sampler_impl() { // TODO catch an exception and add it to the list of asynchronous // exceptions const PluginPtr &Plugin = getSyclObjImpl(Iter.first)->getPlugin(); - Plugin->call(urSamplerRelease, Iter.second); + Plugin->call( Iter.second); } } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~sample_impl", e); @@ -129,7 +129,7 @@ ur_sampler_handle_t sampler_impl::getOrCreateSampler(const context &Context) { ur_sampler_handle_t resultSampler = nullptr; const PluginPtr &Plugin = getSyclObjImpl(Context)->getPlugin(); - errcode_ret = Plugin->call_nocheck(urSamplerCreate, + errcode_ret = Plugin->call_nocheck( getSyclObjImpl(Context)->getHandleRef(), &desc, &resultSampler); diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 09f745c5fc4d8..e9e7a6eb4809d 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -354,7 +354,7 @@ class DispatchHostTask { if (RawEvents.size() == 0) continue; try { - PluginWithEvents.first->call(urEventWait, RawEvents.size(), + PluginWithEvents.first->call( RawEvents.size(), RawEvents.data()); } catch (const sycl::exception &) { MThisCmd->MEvent->getSubmittedQueue()->reportAsyncException( @@ -424,8 +424,7 @@ class DispatchHostTask { // for host task? auto &Queue = HostTask.MQueue; bool NativeCommandSupport = false; - Queue->getPlugin()->call( - urDeviceGetInfo, + Queue->getPlugin()->call( detail::getSyclObjImpl(Queue->get_device())->getHandleRef(), UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP, sizeof(NativeCommandSupport), &NativeCommandSupport, nullptr); @@ -440,8 +439,7 @@ class DispatchHostTask { // // This entry point is needed in order to migrate memory across // devices in the same context for CUDA and HIP backends - Queue->getPlugin()->call( - urEnqueueNativeCommandExp, HostTask.MQueue->getHandleRef(), + Queue->getPlugin()->call( HostTask.MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData, MReqUrMem.size(), MReqUrMem.data(), nullptr, 0, nullptr, nullptr); } else { @@ -535,7 +533,7 @@ void Command::waitForEvents(QueueImplPtr Queue, std::vector RawEvents = getUrEvents(CtxWithEvents.second); if (!RawEvents.empty()) { - CtxWithEvents.first->getPlugin()->call(urEventWait, RawEvents.size(), + CtxWithEvents.first->getPlugin()->call( RawEvents.size(), RawEvents.data()); } } @@ -546,7 +544,7 @@ void Command::waitForEvents(QueueImplPtr Queue, if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call(urEnqueueEventsWait, Queue->getHandleRef(), RawEvents.size(), + Plugin->call( Queue->getHandleRef(), RawEvents.size(), &RawEvents[0], &Event); } } @@ -2286,16 +2284,16 @@ void SetArgBasedOnType( ur_kernel_arg_mem_obj_properties_t MemObjData{}; MemObjData.stype = UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES; MemObjData.memoryAccess = AccessModeToUr(Req->MAccessMode); - Plugin->call(urKernelSetArgMemObj, Kernel, NextTrueIndex, &MemObjData, + Plugin->call( Kernel, NextTrueIndex, &MemObjData, MemArg); break; } case kernel_param_kind_t::kind_std_layout: { if (Arg.MPtr) { - Plugin->call(urKernelSetArgValue, Kernel, NextTrueIndex, Arg.MSize, + Plugin->call( Kernel, NextTrueIndex, Arg.MSize, nullptr, Arg.MPtr); } else { - Plugin->call(urKernelSetArgLocal, Kernel, NextTrueIndex, Arg.MSize, + Plugin->call( Kernel, NextTrueIndex, Arg.MSize, nullptr); } @@ -2306,7 +2304,7 @@ void SetArgBasedOnType( ur_sampler_handle_t Sampler = (ur_sampler_handle_t)detail::getSyclObjImpl(*SamplerPtr) ->getOrCreateSampler(Context); - Plugin->call(urKernelSetArgSampler, Kernel, NextTrueIndex, nullptr, + Plugin->call( Kernel, NextTrueIndex, nullptr, Sampler); break; } @@ -2314,7 +2312,7 @@ void SetArgBasedOnType( // We need to de-rerence this to get the actual USM allocation - that's the // pointer UR is expecting. const void *Ptr = *static_cast(Arg.MPtr); - Plugin->call(urKernelSetArgPointer, Kernel, NextTrueIndex, nullptr, Ptr); + Plugin->call( Kernel, NextTrueIndex, nullptr, Ptr); break; } case kernel_param_kind_t::kind_specialization_constants_buffer: { @@ -2326,7 +2324,7 @@ void SetArgBasedOnType( MemObjProps.pNext = nullptr; MemObjProps.stype = UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES; MemObjProps.memoryAccess = UR_MEM_FLAG_READ_ONLY; - Plugin->call(urKernelSetArgMemObj, Kernel, NextTrueIndex, &MemObjProps, + Plugin->call( Kernel, NextTrueIndex, &MemObjProps, SpecConstsBuffer); break; } @@ -2380,7 +2378,7 @@ static ur_result_t SetKernelParamsAndLaunch( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call(urKernelGetGroupInfo, Kernel, + Plugin->call( Kernel, Queue->getDeviceImplPtr()->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -2416,8 +2414,7 @@ static ur_result_t SetKernelParamsAndLaunch( } ur_event_handle_t UREvent = nullptr; - ur_result_t Error = Plugin->call_nocheck( - urEnqueueKernelLaunchCustomExp, Queue->getHandleRef(), Kernel, + ur_result_t Error = Plugin->call_nocheck( Queue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalSize[0], LocalSize, property_list.size(), property_list.data(), RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], @@ -2431,10 +2428,10 @@ static ur_result_t SetKernelParamsAndLaunch( ur_result_t Error = [&](auto... Args) { if (IsCooperative) { - return Plugin->call_nocheck(urEnqueueCooperativeKernelLaunchExp, + return Plugin->call_nocheck( Args...); } - return Plugin->call_nocheck(urEnqueueKernelLaunch, Args...); + return Plugin->call_nocheck( Args...); }(Queue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], @@ -2516,7 +2513,7 @@ ur_result_t enqueueImpCommandBufferKernel( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call(urKernelGetGroupInfo, UrKernel, DeviceImpl->getHandleRef(), + Plugin->call( UrKernel, DeviceImpl->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, /* pPropSizeRet = */ nullptr); @@ -2528,15 +2525,14 @@ ur_result_t enqueueImpCommandBufferKernel( LocalSize = RequiredWGSize; } - ur_result_t Res = Plugin->call_nocheck( - urCommandBufferAppendKernelLaunchExp, CommandBuffer, UrKernel, + ur_result_t Res = Plugin->call_nocheck( CommandBuffer, UrKernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, SyncPoints.size(), SyncPoints.size() ? SyncPoints.data() : nullptr, OutSyncPoint, OutCommand); if (!SyclKernelImpl && !Kernel) { - Plugin->call(urKernelRelease, UrKernel); - Plugin->call(urProgramRelease, UrProgram); + Plugin->call( UrKernel); + Plugin->call( UrProgram); } if (Res != UR_RESULT_SUCCESS) { @@ -2640,8 +2636,7 @@ void enqueueImpKernel( if (KernelCacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_SLM || KernelCacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_DATA) { const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( - urKernelSetExecInfo, Kernel, UR_KERNEL_EXEC_INFO_CACHE_CONFIG, + Plugin->call( Kernel, UR_KERNEL_EXEC_INFO_CACHE_CONFIG, sizeof(ur_kernel_cache_config_t), nullptr, &KernelCacheConfig); } @@ -2652,8 +2647,8 @@ void enqueueImpKernel( const PluginPtr &Plugin = Queue->getPlugin(); if (!SyclKernelImpl && !MSyclKernel) { - Plugin->call(urKernelRelease, Kernel); - Plugin->call(urProgramRelease, Program); + Plugin->call( Kernel); + Plugin->call( Program); } } if (UR_RESULT_SUCCESS != Error) { @@ -2705,13 +2700,11 @@ ur_result_t enqueueReadWriteHostPipe(const QueueImplPtr &Queue, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); if (read) { - Error = Plugin->call_nocheck( - urEnqueueReadHostPipe, ur_q, Program, PipeName.c_str(), blocking, ptr, + Error = Plugin->call_nocheck( ur_q, Program, PipeName.c_str(), blocking, ptr, size, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], OutEvent); } else { - Error = Plugin->call_nocheck( - urEnqueueWriteHostPipe, ur_q, Program, PipeName.c_str(), blocking, ptr, + Error = Plugin->call_nocheck( ur_q, Program, PipeName.c_str(), blocking, ptr, size, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], OutEvent); } @@ -2733,7 +2726,7 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() { flushCrossQueueDeps(EventImpls, MWorkerQueue); std::vector RawEvents = getUrEvents(EventImpls); if (!RawEvents.empty()) { - MQueue->getPlugin()->call(urEventWait, RawEvents.size(), &RawEvents[0]); + MQueue->getPlugin()->call( RawEvents.size(), &RawEvents[0]); } ur_exp_command_buffer_sync_point_t OutSyncPoint; @@ -3186,14 +3179,13 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { HostTask->MHostTask->MInteropTask}; ur_bool_t NativeCommandSupport = false; - MQueue->getPlugin()->call( - urDeviceGetInfo, + MQueue->getPlugin()->call( detail::getSyclObjImpl(MQueue->get_device())->getHandleRef(), UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP, sizeof(NativeCommandSupport), &NativeCommandSupport, nullptr); assert(NativeCommandSupport && "ext_codeplay_enqueue_native_command is not " "supported on this device"); - MQueue->getPlugin()->call(urEnqueueNativeCommandExp, MQueue->getHandleRef(), + MQueue->getPlugin()->call( MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData, ReqMems.size(), ReqMems.data(), nullptr, RawEvents.size(), RawEvents.data(), Event); @@ -3206,7 +3198,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const PluginPtr &Plugin = MQueue->getPlugin(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call(urEnqueueEventsWaitWithBarrier, MQueue->getHandleRef(), 0, + Plugin->call( MQueue->getHandleRef(), 0, nullptr, Event); if (Event) MEvent->setHandle(*Event); @@ -3224,7 +3216,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const PluginPtr &Plugin = MQueue->getPlugin(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call(urEnqueueEventsWaitWithBarrier, MQueue->getHandleRef(), + Plugin->call( MQueue->getHandleRef(), UrEvents.size(), &UrEvents[0], Event); if (Event) MEvent->setHandle(*Event); @@ -3241,13 +3233,13 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { // not pass an output event to the UR call. Once that is fixed, // this immediately-deleted event can be removed. ur_event_handle_t PreTimestampBarrierEvent{}; - Plugin->call(urEnqueueEventsWaitWithBarrier, MQueue->getHandleRef(), + Plugin->call( MQueue->getHandleRef(), /*num_events_in_wait_list=*/0, /*event_wait_list=*/nullptr, &PreTimestampBarrierEvent); - Plugin->call(urEventRelease, PreTimestampBarrierEvent); + Plugin->call( PreTimestampBarrierEvent); } - Plugin->call(urEnqueueTimestampRecordingExp, MQueue->getHandleRef(), + Plugin->call( MQueue->getHandleRef(), /*blocking=*/false, /*num_events_in_wait_list=*/0, /*event_wait_list=*/nullptr, Event); @@ -3298,8 +3290,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { static_cast(MCommandGroup.get()); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - ur_result_t Err = MQueue->getPlugin()->call_nocheck( - urCommandBufferEnqueueExp, CmdBufferCG->MCommandBuffer, + ur_result_t Err = MQueue->getPlugin()->call_nocheck( CmdBufferCG->MCommandBuffer, MQueue->getHandleRef(), RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], Event); if (Event) @@ -3327,7 +3318,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const detail::PluginPtr &Plugin = MQueue->getPlugin(); auto OptWaitValue = SemWait->getWaitValue(); uint64_t WaitValue = OptWaitValue.has_value() ? OptWaitValue.value() : 0; - Plugin->call(urBindlessImagesWaitExternalSemaphoreExp, + Plugin->call( MQueue->getHandleRef(), SemWait->getExternalSemaphore(), OptWaitValue.has_value(), WaitValue, 0, nullptr, nullptr); @@ -3341,7 +3332,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { auto OptSignalValue = SemSignal->getSignalValue(); uint64_t SignalValue = OptSignalValue.has_value() ? OptSignalValue.value() : 0; - Plugin->call(urBindlessImagesSignalExternalSemaphoreExp, + Plugin->call( MQueue->getHandleRef(), SemSignal->getExternalSemaphore(), OptSignalValue.has_value(), SignalValue, 0, nullptr, nullptr); diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 457c1c6faada5..b3603fec07ce7 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -40,15 +40,15 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, ur_mem_native_properties_t MemProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Plugin->call(urMemBufferCreateWithNativeHandle, MemObject, + Plugin->call( MemObject, MInteropContext->getHandleRef(), &MemProperties, &MInteropMemObject); // Get the size of the buffer in bytes - Plugin->call(urMemGetInfo, MInteropMemObject, UR_MEM_INFO_SIZE, + Plugin->call( MInteropMemObject, UR_MEM_INFO_SIZE, sizeof(size_t), &MSizeInBytes, nullptr); - Plugin->call(urMemGetInfo, MInteropMemObject, UR_MEM_INFO_CONTEXT, + Plugin->call( MInteropMemObject, UR_MEM_INFO_CONTEXT, sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) @@ -57,7 +57,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, "Input context must be the same as the context of cl_mem"); if (MInteropContext->getBackend() == backend::opencl) - Plugin->call(urMemRetain, MInteropMemObject); + Plugin->call( MInteropMemObject); } ur_mem_type_t getImageType(int Dimensions) { @@ -99,11 +99,11 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, ur_mem_native_properties_t NativeProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Plugin->call(urMemImageCreateWithNativeHandle, MemObject, + Plugin->call( MemObject, MInteropContext->getHandleRef(), &Format, &Desc, &NativeProperties, &MInteropMemObject); - Plugin->call(urMemGetInfo, MInteropMemObject, UR_MEM_INFO_CONTEXT, + Plugin->call( MInteropMemObject, UR_MEM_INFO_CONTEXT, sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) @@ -112,7 +112,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, "Input context must be the same as the context of cl_mem"); if (MInteropContext->getBackend() == backend::opencl) - Plugin->call(urMemRetain, MInteropMemObject); + Plugin->call( MInteropMemObject); } void SYCLMemObjT::releaseMem(ContextImplPtr Context, void *MemAllocation) { @@ -155,7 +155,7 @@ void SYCLMemObjT::updateHostMemory() { if (MOpenCLInterop) { const PluginPtr &Plugin = getPlugin(); - Plugin->call(urMemRelease, MInteropMemObject); + Plugin->call( MInteropMemObject); } } const PluginPtr &SYCLMemObjT::getPlugin() const { @@ -169,7 +169,7 @@ size_t SYCLMemObjT::getBufSizeForContext(const ContextImplPtr &Context, size_t BufSize = 0; const PluginPtr &Plugin = Context->getPlugin(); // TODO is there something required to support non-OpenCL backends? - Plugin->call(urMemGetInfo, detail::ur::cast(MemObject), + Plugin->call( detail::ur::cast(MemObject), UR_MEM_INFO_SIZE, sizeof(size_t), &BufSize, nullptr); return BufSize; } diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index f9847e0b23447..83d239d5a2541 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -49,7 +49,7 @@ void contextSetExtendedDeleter(const sycl::context &context, void *user_data) { auto impl = getSyclObjImpl(context); const auto &Plugin = impl->getPlugin(); - Plugin->call(urContextSetExtendedDeleter, impl->getHandleRef(), + Plugin->call( impl->getHandleRef(), reinterpret_cast(func), user_data); } @@ -108,10 +108,25 @@ static void initializePlugins(std::vector &Plugins, #define CHECK_UR_SUCCESS(Call) \ __SYCL_CHECK_OCL_CODE_NO_EXC(Call) + UrFuncInfo loaderConfigCreateInfo; + auto loaderConfigCreate = loaderConfigCreateInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo loaderConfigEnableLayerInfo; + auto loaderConfigEnableLayer = loaderConfigEnableLayerInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo loaderConfigReleaseInfo; + auto loaderConfigRelease = loaderConfigReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo loaderConfigSetCodeLocationCallbackInfo; + auto loaderConfigSetCodeLocationCallback = loaderConfigSetCodeLocationCallbackInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo loaderInitInfo; + auto loaderInit = loaderInitInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo adapterGet_Info; + auto adapterGet = adapterGet_Info.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo adapterGetInfoInfo; + auto adapterGetInfo = adapterGetInfoInfo.getFuncPtr(ur::loadURLoaderLibrary()); + bool OwnLoaderConfig = false; // If we weren't provided with a custom config handle create our own. if(!LoaderConfig) { - CHECK_UR_SUCCESS(urLoaderConfigCreate(&LoaderConfig)) + CHECK_UR_SUCCESS(loaderConfigCreate(&LoaderConfig)) OwnLoaderConfig = true; } @@ -123,7 +138,7 @@ static void initializePlugins(std::vector &Plugins, setenv("UR_LOG_TRACING", LogOptions, 1); #endif CHECK_UR_SUCCESS( - urLoaderConfigEnableLayer(LoaderConfig, "UR_LAYER_TRACING")); + loaderConfigEnableLayer(LoaderConfig, "UR_LAYER_TRACING")); } if (trace(TraceLevel::TRACE_BASIC)) { @@ -134,39 +149,39 @@ static void initializePlugins(std::vector &Plugins, #endif } - CHECK_UR_SUCCESS(urLoaderConfigSetCodeLocationCallback( + CHECK_UR_SUCCESS(loaderConfigSetCodeLocationCallback( LoaderConfig, codeLocationCallback, nullptr)); if (ProgramManager::getInstance().kernelUsesAsan()) { - if (urLoaderConfigEnableLayer(LoaderConfig, "UR_LAYER_ASAN")) { - urLoaderConfigRelease(LoaderConfig); + if (loaderConfigEnableLayer(LoaderConfig, "UR_LAYER_ASAN")) { + loaderConfigRelease(LoaderConfig); std::cerr << "Failed to enable ASAN layer\n"; return; } } - urLoaderConfigSetCodeLocationCallback(LoaderConfig, codeLocationCallback, + loaderConfigSetCodeLocationCallback(LoaderConfig, codeLocationCallback, nullptr); if (ProgramManager::getInstance().kernelUsesAsan()) { - if (urLoaderConfigEnableLayer(LoaderConfig, "UR_LAYER_ASAN")) { - urLoaderConfigRelease(LoaderConfig); + if (loaderConfigEnableLayer(LoaderConfig, "UR_LAYER_ASAN")) { + loaderConfigRelease(LoaderConfig); std::cerr << "Failed to enable ASAN layer\n"; return; } } ur_device_init_flags_t device_flags = 0; - CHECK_UR_SUCCESS(urLoaderInit(device_flags, LoaderConfig)); + CHECK_UR_SUCCESS(loaderInit(device_flags, LoaderConfig)); if (OwnLoaderConfig) { - CHECK_UR_SUCCESS(urLoaderConfigRelease(LoaderConfig)); + CHECK_UR_SUCCESS(loaderConfigRelease(LoaderConfig)); } uint32_t adapterCount = 0; - CHECK_UR_SUCCESS(urAdapterGet(0, nullptr, &adapterCount)); + CHECK_UR_SUCCESS(adapterGet(0, nullptr, &adapterCount)); std::vector adapters(adapterCount); - CHECK_UR_SUCCESS(urAdapterGet(adapterCount, adapters.data(), nullptr)); + CHECK_UR_SUCCESS(adapterGet(adapterCount, adapters.data(), nullptr)); auto UrToSyclBackend = [](ur_adapter_backend_t backend) -> sycl::backend { switch (backend) { @@ -189,7 +204,7 @@ static void initializePlugins(std::vector &Plugins, for (const auto &adapter : adapters) { ur_adapter_backend_t adapterBackend = UR_ADAPTER_BACKEND_UNKNOWN; - CHECK_UR_SUCCESS(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, + CHECK_UR_SUCCESS(adapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, sizeof(adapterBackend), &adapterBackend, nullptr)); auto syclBackend = UrToSyclBackend(adapterBackend); diff --git a/sycl/source/detail/ur_utils.hpp b/sycl/source/detail/ur_utils.hpp index 335d6ecd11baa..191d4a3443bee 100644 --- a/sycl/source/detail/ur_utils.hpp +++ b/sycl/source/detail/ur_utils.hpp @@ -29,13 +29,13 @@ struct OwnedUrEvent { // If it is not instructed to take ownership, retain the event to share // ownership of it. if (!TakeOwnership) - MPlugin->call(urEventRetain, *MEvent); + MPlugin->call( *MEvent); } ~OwnedUrEvent() { try { // Release the event if the ownership was not transferred. if (MEvent.has_value()) - MPlugin->call(urEventRelease, *MEvent); + MPlugin->call( *MEvent); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~OwnedUrEvent", e); diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 3270907ee9a0d..6386a0d9de07a 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -86,7 +86,7 @@ void *alignedAllocHost(size_t Alignment, size_t Size, const sycl::context &Ctxt, UsmDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck(urUSMHostAlloc, C, &UsmDesc, + Error = Plugin->call_nocheck( C, &UsmDesc, /* pool= */ nullptr, Size, &RetVal); // Error is for debugging purposes. @@ -157,7 +157,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck(urUSMDeviceAlloc, C, Dev, &UsmDesc, + Error = Plugin->call_nocheck( C, Dev, &UsmDesc, /*pool=*/nullptr, Size, &RetVal); break; @@ -193,7 +193,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDeviceDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck(urUSMSharedAlloc, C, Dev, &UsmDesc, + Error = Plugin->call_nocheck( C, Dev, &UsmDesc, /*pool=*/nullptr, Size, &RetVal); break; @@ -250,7 +250,7 @@ void freeInternal(void *Ptr, const context_impl *CtxImpl) { return; ur_context_handle_t C = CtxImpl->getHandleRef(); const PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(urUSMFree, C, Ptr); + Plugin->call( C, Ptr); } void free(void *Ptr, const context &Ctxt, @@ -529,8 +529,7 @@ alloc get_pointer_type(const void *Ptr, const context &Ctxt) { // query type using UR function const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - ur_result_t Err = Plugin->call_nocheck( - urUSMGetMemAllocInfo, URCtx, Ptr, UR_USM_ALLOC_INFO_TYPE, + ur_result_t Err = Plugin->call_nocheck( URCtx, Ptr, UR_USM_ALLOC_INFO_TYPE, sizeof(ur_usm_type_t), &AllocTy, nullptr); // UR_RESULT_ERROR_INVALID_VALUE means USM doesn't know about this ptr @@ -590,7 +589,7 @@ device get_pointer_device(const void *Ptr, const context &Ctxt) { // query device using UR function const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(urUSMGetMemAllocInfo, URCtx, Ptr, UR_USM_ALLOC_INFO_DEVICE, + Plugin->call( URCtx, Ptr, UR_USM_ALLOC_INFO_DEVICE, sizeof(ur_device_handle_t), &DeviceId, nullptr); // The device is not necessarily a member of the context, it could be a @@ -612,7 +611,7 @@ static void prepare_for_usm_device_copy(const void *Ptr, size_t Size, ur_context_handle_t URCtx = CtxImpl->getHandleRef(); // Call the UR function const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(urUSMImportExp, URCtx, const_cast(Ptr), Size); + Plugin->call( URCtx, const_cast(Ptr), Size); } static void release_from_usm_device_copy(const void *Ptr, const context &Ctxt) { @@ -620,7 +619,7 @@ static void release_from_usm_device_copy(const void *Ptr, const context &Ctxt) { ur_context_handle_t URCtx = CtxImpl->getHandleRef(); // Call the UR function const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(urUSMReleaseExp, URCtx, const_cast(Ptr)); + Plugin->call( URCtx, const_cast(Ptr)); } namespace ext::oneapi::experimental { diff --git a/sycl/source/detail/windows_ur.cpp b/sycl/source/detail/windows_ur.cpp index f730b087a67af..7ea45defe7d9f 100644 --- a/sycl/source/detail/windows_ur.cpp +++ b/sycl/source/detail/windows_ur.cpp @@ -70,6 +70,11 @@ static std::filesystem::path getCurrentDSODirPath() { return std::filesystem::path(Path); } +void* loadURLoaderLibrary() { + const std::filesystem::path LibSYCLDir = getCurrentDSODirPath(); + return getPreloadedPlugin(LibSYCLDir / std::string("ur_loader.dll")); +} + } // namespace ur } // namespace detail } // namespace _V1 diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index b7872d3e54654..fbcc3a112d899 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -37,13 +37,13 @@ device::device(cl_device_id DeviceId) { // The implementation constructor takes ownership of the native handle so we // must retain it in order to adhere to SYCL 1.2.1 spec (Rev6, section 4.3.1.) ur_device_handle_t Device; - Plugin->call(urDeviceCreateWithNativeHandle, + Plugin->call( detail::ur::cast(DeviceId), Plugin->getUrAdapter(), nullptr, &Device); auto Platform = detail::platform_impl::getPlatformFromUrDevice(Device, Plugin); impl = Platform->getOrMakeDeviceImpl(Device, Platform); - Plugin->call(urDeviceRetain, impl->getHandleRef()); + Plugin->call( impl->getHandleRef()); } device::device(const device_selector &deviceSelector) { @@ -211,7 +211,7 @@ void device::ext_oneapi_enable_peer_access(const device &peer) { ur_device_handle_t Peer = peer.impl->getHandleRef(); if (Device != Peer) { auto Plugin = impl->getPlugin(); - Plugin->call(urUsmP2PEnablePeerAccessExp, Device, Peer); + Plugin->call(Device, Peer); } } @@ -220,7 +220,7 @@ void device::ext_oneapi_disable_peer_access(const device &peer) { ur_device_handle_t Peer = peer.impl->getHandleRef(); if (Device != Peer) { auto Plugin = impl->getPlugin(); - Plugin->call(urUsmP2PDisablePeerAccessExp, Device, Peer); + Plugin->call(Device, Peer); } } @@ -247,11 +247,11 @@ bool device::ext_oneapi_can_access_peer(const device &peer, "Unrecognized peer access attribute."); }(); auto Plugin = impl->getPlugin(); - Plugin->call(urUsmP2PPeerAccessGetInfoExp, Device, Peer, UrAttr, 0, nullptr, - &returnSize); + Plugin->call( + Device, Peer, UrAttr, 0, nullptr, &returnSize); - Plugin->call(urUsmP2PPeerAccessGetInfoExp, Device, Peer, UrAttr, returnSize, - &value, nullptr); + Plugin->call( + Device, Peer, UrAttr, returnSize, &value, nullptr); return value == 1; } @@ -277,7 +277,7 @@ bool device::ext_oneapi_supports_cl_c_feature(detail::string_view Feature) { auto Plugin = impl->getPlugin(); uint32_t ipVersion = 0; auto res = - Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION, + Plugin->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -292,7 +292,7 @@ bool device::ext_oneapi_supports_cl_c_version( auto Plugin = impl->getPlugin(); uint32_t ipVersion = 0; auto res = - Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION, + Plugin->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -308,7 +308,7 @@ bool device::ext_oneapi_supports_cl_extension( auto Plugin = impl->getPlugin(); uint32_t ipVersion = 0; auto res = - Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION, + Plugin->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -322,7 +322,7 @@ detail::string device::ext_oneapi_cl_profile_impl() const { auto Plugin = impl->getPlugin(); uint32_t ipVersion = 0; auto res = - Plugin->call_nocheck(urDeviceGetInfo, Device, UR_DEVICE_INFO_IP_VERSION, + Plugin->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return detail::string{""}; diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index 3f9048284abac..e73885a20d532 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -30,7 +30,7 @@ event::event(cl_event ClEvent, const context &SyclContext) // This is a special interop constructor for OpenCL, so the event must be // retained. // TODO(pi2ur): Don't just cast from cl_event above - impl->getPlugin()->call(urEventRetain, + impl->getPlugin()->call( detail::ur::cast(ClEvent)); } diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index dffea5915241e..31ba3ce642865 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -1610,7 +1610,7 @@ checkContextSupports(const std::shared_ptr &ContextImpl, ur_context_info_t InfoQuery) { auto &Plugin = ContextImpl->getPlugin(); ur_bool_t SupportsOp = false; - Plugin->call(urContextGetInfo, ContextImpl->getHandleRef(), InfoQuery, + Plugin->call( ContextImpl->getHandleRef(), InfoQuery, sizeof(ur_bool_t), &SupportsOp, nullptr); return SupportsOp; } @@ -1845,8 +1845,7 @@ void handler::setUserFacingNodeType(ext::oneapi::experimental::node_type Type) { std::optional> handler::getMaxWorkGroups() { auto Dev = detail::getSyclObjImpl(detail::getDeviceFromHandler(*this)); std::array UrResult = {}; - auto Ret = Dev->getPlugin()->call_nocheck( - urDeviceGetInfo, Dev->getHandleRef(), + auto Ret = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, sizeof(UrResult), &UrResult, nullptr); diff --git a/sycl/source/interop_handle.cpp b/sycl/source/interop_handle.cpp index 0d70f12de3d2b..fa5f5910a2e6a 100644 --- a/sycl/source/interop_handle.cpp +++ b/sycl/source/interop_handle.cpp @@ -35,8 +35,8 @@ interop_handle::getNativeMem(detail::Requirement *Req) const { auto Plugin = MQueue->getPlugin(); ur_native_handle_t Handle; - Plugin->call(urMemGetNativeHandle, Iter->second, MDevice->getHandleRef(), - &Handle); + Plugin->call( + Iter->second, MDevice->getHandleRef(), &Handle); return Handle; } diff --git a/sycl/source/kernel.cpp b/sycl/source/kernel.cpp index 83b6f2b346450..43c26c654e539 100644 --- a/sycl/source/kernel.cpp +++ b/sycl/source/kernel.cpp @@ -22,7 +22,7 @@ kernel::kernel(cl_kernel ClKernel, const context &SyclContext) { ur_kernel_handle_t hKernel = nullptr; ur_native_handle_t nativeHandle = reinterpret_cast(ClKernel); - Plugin->call(urKernelCreateWithNativeHandle, nativeHandle, + Plugin->call( nativeHandle, detail::getSyclObjImpl(SyclContext)->getHandleRef(), nullptr, nullptr, &hKernel); impl = std::make_shared( @@ -30,7 +30,7 @@ kernel::kernel(cl_kernel ClKernel, const context &SyclContext) { // This is a special interop constructor for OpenCL, so the kernel must be // retained. if (get_backend() == backend::opencl) { - impl->getPlugin()->call(urKernelRetain, hKernel); + impl->getPlugin()->call( hKernel); } } diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index 4bc02c9b983a4..4c08c2fa659e3 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -25,7 +25,7 @@ platform::platform() : platform(default_selector_v) {} platform::platform(cl_platform_id PlatformId) { auto Plugin = sycl::detail::ur::getPlugin(); ur_platform_handle_t UrPlatform = nullptr; - Plugin->call(urPlatformCreateWithNativeHandle, + Plugin->call( detail::ur::cast(PlatformId), Plugin->getUrAdapter(), /* pProperties = */ nullptr, &UrPlatform); impl = detail::platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin); diff --git a/sycl/source/virtual_mem.cpp b/sycl/source/virtual_mem.cpp index e9fe20b51f00a..b8cd7c2f15bf3 100644 --- a/sycl/source/virtual_mem.cpp +++ b/sycl/source/virtual_mem.cpp @@ -48,14 +48,14 @@ __SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice, const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); #ifndef NDEBUG size_t InfoOutputSize; - Plugin->call(urVirtualMemGranularityGetInfo, ContextImpl->getHandleRef(), + Plugin->call( ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery, 0, nullptr, &InfoOutputSize); assert(InfoOutputSize == sizeof(size_t) && "Unexpected output size of granularity info query."); #endif // NDEBUG size_t Granularity = 0; - Plugin->call(urVirtualMemGranularityGetInfo, ContextImpl->getHandleRef(), + Plugin->call( ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery, sizeof(size_t), &Granularity, nullptr); return Granularity; @@ -115,7 +115,7 @@ __SYCL_EXPORT uintptr_t reserve_virtual_mem(uintptr_t Start, size_t NumBytes, sycl::detail::getSyclObjImpl(SyclContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); void *OutPtr = nullptr; - Plugin->call(urVirtualMemReserve, ContextImpl->getHandleRef(), + Plugin->call( ContextImpl->getHandleRef(), reinterpret_cast(Start), NumBytes, &OutPtr); return reinterpret_cast(OutPtr); } @@ -125,7 +125,7 @@ __SYCL_EXPORT void free_virtual_mem(uintptr_t Ptr, size_t NumBytes, std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call(urVirtualMemFree, ContextImpl->getHandleRef(), + Plugin->call( ContextImpl->getHandleRef(), reinterpret_cast(Ptr), NumBytes); } @@ -136,7 +136,7 @@ __SYCL_EXPORT void set_access_mode(const void *Ptr, size_t NumBytes, std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call(urVirtualMemSetAccess, ContextImpl->getHandleRef(), Ptr, + Plugin->call( ContextImpl->getHandleRef(), Ptr, NumBytes, AccessFlags); } @@ -148,13 +148,13 @@ __SYCL_EXPORT address_access_mode get_access_mode(const void *Ptr, const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); #ifndef NDEBUG size_t InfoOutputSize = 0; - Plugin->call(urVirtualMemGetInfo, ContextImpl->getHandleRef(), Ptr, NumBytes, + Plugin->call( ContextImpl->getHandleRef(), Ptr, NumBytes, UR_VIRTUAL_MEM_INFO_ACCESS_MODE, 0, nullptr, &InfoOutputSize); assert(InfoOutputSize == sizeof(ur_virtual_mem_access_flags_t) && "Unexpected output size of access mode info query."); #endif // NDEBUG ur_virtual_mem_access_flags_t AccessFlags; - Plugin->call(urVirtualMemGetInfo, ContextImpl->getHandleRef(), Ptr, NumBytes, + Plugin->call( ContextImpl->getHandleRef(), Ptr, NumBytes, UR_VIRTUAL_MEM_INFO_ACCESS_MODE, sizeof(ur_virtual_mem_access_flags_t), &AccessFlags, nullptr); @@ -170,7 +170,7 @@ __SYCL_EXPORT void unmap(const void *Ptr, size_t NumBytes, std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call(urVirtualMemUnmap, ContextImpl->getHandleRef(), Ptr, NumBytes); + Plugin->call( ContextImpl->getHandleRef(), Ptr, NumBytes); } } // Namespace ext::oneapi::experimental From e51c3b46b30a148291081606901283b462f37a82 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 10:52:26 +0100 Subject: [PATCH 02/21] Fix formatting --- sycl/include/sycl/detail/ur.hpp | 4 +- sycl/source/backend.cpp | 81 ++--- sycl/source/backend/level_zero.cpp | 4 +- sycl/source/backend/opencl.cpp | 24 +- sycl/source/context.cpp | 7 +- sycl/source/detail/allowlist.cpp | 4 +- sycl/source/detail/bindless_images.cpp | 155 +++++---- sycl/source/detail/buffer_impl.cpp | 12 +- sycl/source/detail/context_impl.cpp | 40 +-- sycl/source/detail/context_info.hpp | 4 +- .../source/detail/device_global_map_entry.cpp | 5 +- sycl/source/detail/device_image_impl.hpp | 6 +- sycl/source/detail/device_impl.cpp | 243 +++++++------- sycl/source/detail/device_info.hpp | 191 ++++++----- .../detail/error_handling/error_handling.cpp | 53 +-- sycl/source/detail/event_impl.cpp | 26 +- sycl/source/detail/event_info.hpp | 8 +- sycl/source/detail/global_handler.cpp | 3 +- sycl/source/detail/graph_impl.cpp | 43 ++- sycl/source/detail/image_impl.cpp | 8 +- sycl/source/detail/kernel_bundle_impl.hpp | 37 ++- sycl/source/detail/kernel_impl.cpp | 12 +- sycl/source/detail/kernel_impl.hpp | 13 +- sycl/source/detail/kernel_info.hpp | 30 +- sycl/source/detail/kernel_program_cache.hpp | 6 +- sycl/source/detail/memory_manager.cpp | 301 ++++++++++-------- .../detail/persistent_device_code_cache.cpp | 16 +- sycl/source/detail/physical_mem_impl.hpp | 12 +- sycl/source/detail/platform_impl.cpp | 29 +- sycl/source/detail/platform_impl.hpp | 13 +- sycl/source/detail/platform_info.hpp | 7 +- sycl/source/detail/plugin.hpp | 9 +- .../program_manager/program_manager.cpp | 176 +++++----- sycl/source/detail/queue_impl.cpp | 16 +- sycl/source/detail/queue_impl.hpp | 22 +- sycl/source/detail/sampler_impl.cpp | 24 +- sycl/source/detail/scheduler/commands.cpp | 162 +++++----- sycl/source/detail/sycl_mem_obj_t.cpp | 35 +- sycl/source/detail/ur.cpp | 34 +- sycl/source/detail/ur_utils.hpp | 4 +- sycl/source/detail/usm/usm_impl.cpp | 44 +-- sycl/source/detail/windows_ur.cpp | 2 +- sycl/source/device.cpp | 26 +- sycl/source/event.cpp | 2 +- sycl/source/handler.cpp | 8 +- sycl/source/kernel.cpp | 8 +- sycl/source/platform.cpp | 4 +- sycl/source/virtual_mem.cpp | 40 +-- 48 files changed, 1100 insertions(+), 913 deletions(-) diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index 18f1059eddd77..de309eed70331 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -18,8 +18,8 @@ #include #include #define NOMINMAX -#include #include +#include #include #include @@ -96,7 +96,7 @@ int unloadOsLibrary(void *Library); // library, implementation is OS dependent. void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName); -void* loadURLoaderLibrary(); +void *loadURLoaderLibrary(); // Performs UR one-time initialization. std::vector & diff --git a/sycl/source/backend.cpp b/sycl/source/backend.cpp index fd04985d46d3e..1658268297271 100644 --- a/sycl/source/backend.cpp +++ b/sycl/source/backend.cpp @@ -72,8 +72,8 @@ platform make_platform(ur_native_handle_t NativeHandle, backend Backend) { // Create UR platform first. ur_platform_handle_t UrPlatform = nullptr; - Plugin->call( NativeHandle, - Plugin->getUrAdapter(), nullptr, &UrPlatform); + Plugin->call( + NativeHandle, Plugin->getUrAdapter(), nullptr, &UrPlatform); return detail::createSyclObjFromImpl( platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin)); @@ -84,8 +84,8 @@ __SYCL_EXPORT device make_device(ur_native_handle_t NativeHandle, const auto &Plugin = getPlugin(Backend); ur_device_handle_t UrDevice = nullptr; - Plugin->call( NativeHandle, - Plugin->getUrAdapter(), nullptr, &UrDevice); + Plugin->call( + NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice); // Construct the SYCL device from UR device. return detail::createSyclObjFromImpl( std::make_shared(UrDevice, Plugin)); @@ -105,9 +105,9 @@ __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle, for (const auto &Dev : DeviceList) { DeviceHandles.push_back(detail::getSyclObjImpl(Dev)->getHandleRef()); } - Plugin->call( NativeHandle, - Plugin->getUrAdapter(), DeviceHandles.size(), - DeviceHandles.data(), &Properties, &UrContext); + Plugin->call( + NativeHandle, Plugin->getUrAdapter(), DeviceHandles.size(), + DeviceHandles.data(), &Properties, &UrContext); // Construct the SYCL context from UR context. return detail::createSyclObjFromImpl(std::make_shared( UrContext, Handler, Plugin, DeviceList, !KeepOwnership)); @@ -150,9 +150,9 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, // Create UR queue first. ur_queue_handle_t UrQueue = nullptr; - Plugin->call( NativeHandle, - ContextImpl->getHandleRef(), UrDevice, &NativeProperties, - &UrQueue); + Plugin->call( + NativeHandle, ContextImpl->getHandleRef(), UrDevice, &NativeProperties, + &UrQueue); // Construct the SYCL queue from UR queue. return detail::createSyclObjFromImpl( std::make_shared(UrQueue, ContextImpl, Handler, PropList)); @@ -174,13 +174,13 @@ __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle, Properties.stype = UR_STRUCTURE_TYPE_EVENT_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call( NativeHandle, - ContextImpl->getHandleRef(), &Properties, &UrEvent); + Plugin->call( + NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrEvent); event Event = detail::createSyclObjFromImpl( std::make_shared(UrEvent, Context)); if (Backend == backend::opencl) - Plugin->call( UrEvent); + Plugin->call(UrEvent); return Event; } @@ -196,44 +196,45 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call( NativeHandle, - ContextImpl->getHandleRef(), &Properties, &UrProgram); + Plugin->call( + NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrProgram); if (ContextImpl->getBackend() == backend::opencl) - Plugin->call( UrProgram); + Plugin->call(UrProgram); std::vector ProgramDevices; uint32_t NumDevices = 0; - Plugin->call( UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, - sizeof(NumDevices), &NumDevices, nullptr); + Plugin->call( + UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, + nullptr); ProgramDevices.resize(NumDevices); - Plugin->call( UrProgram, UR_PROGRAM_INFO_DEVICES, - sizeof(ur_device_handle_t) * NumDevices, ProgramDevices.data(), - nullptr); + Plugin->call( + UrProgram, UR_PROGRAM_INFO_DEVICES, + sizeof(ur_device_handle_t) * NumDevices, ProgramDevices.data(), nullptr); for (auto &Dev : ProgramDevices) { ur_program_binary_type_t BinaryType; - Plugin->call( UrProgram, Dev, - UR_PROGRAM_BUILD_INFO_BINARY_TYPE, - sizeof(ur_program_binary_type_t), &BinaryType, nullptr); + Plugin->call( + UrProgram, Dev, UR_PROGRAM_BUILD_INFO_BINARY_TYPE, + sizeof(ur_program_binary_type_t), &BinaryType, nullptr); switch (BinaryType) { case (UR_PROGRAM_BINARY_TYPE_NONE): if (State == bundle_state::object) { - auto Res = Plugin->call_nocheck( UrProgram, 1, &Dev, - nullptr); + auto Res = Plugin->call_nocheck( + UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { Res = Plugin->call_nocheck( - ContextImpl->getHandleRef(), UrProgram, - nullptr); + ContextImpl->getHandleRef(), UrProgram, nullptr); } Plugin->checkUrResult(Res); } else if (State == bundle_state::executable) { - auto Res = Plugin->call_nocheck( UrProgram, 1, &Dev, - nullptr); + auto Res = Plugin->call_nocheck( + UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), UrProgram, nullptr); + Res = Plugin->call_nocheck( + ContextImpl->getHandleRef(), UrProgram, nullptr); } Plugin->checkUrResult(Res); } @@ -248,12 +249,13 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, detail::codeToString(UR_RESULT_ERROR_INVALID_VALUE)); if (State == bundle_state::executable) { ur_program_handle_t UrLinkedProgram = nullptr; - auto Res = - Plugin->call_nocheck( ContextImpl->getHandleRef(), - 1, &Dev, 1, &UrProgram, nullptr, &UrLinkedProgram); + auto Res = Plugin->call_nocheck( + ContextImpl->getHandleRef(), 1, &Dev, 1, &UrProgram, nullptr, + &UrLinkedProgram); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), - 1, &UrProgram, nullptr, &UrLinkedProgram); + Res = Plugin->call_nocheck( + ContextImpl->getHandleRef(), 1, &UrProgram, nullptr, + &UrLinkedProgram); } Plugin->checkUrResult(Res); if (UrLinkedProgram != nullptr) { @@ -339,11 +341,12 @@ kernel make_kernel(const context &TargetContext, ur_kernel_native_properties_t Properties{}; Properties.stype = UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call( NativeHandle, - ContextImpl->getHandleRef(), UrProgram, &Properties, &UrKernel); + Plugin->call( + NativeHandle, ContextImpl->getHandleRef(), UrProgram, &Properties, + &UrKernel); if (Backend == backend::opencl) - Plugin->call( UrKernel); + Plugin->call(UrKernel); // Construct the SYCL queue from UR queue. return detail::createSyclObjFromImpl( diff --git a/sycl/source/backend/level_zero.cpp b/sycl/source/backend/level_zero.cpp index c81cce48ca73e..74c860b136028 100644 --- a/sycl/source/backend/level_zero.cpp +++ b/sycl/source/backend/level_zero.cpp @@ -23,8 +23,8 @@ __SYCL_EXPORT device make_device(const platform &Platform, const auto &PlatformImpl = getSyclObjImpl(Platform); // Create UR device first. ur_device_handle_t UrDevice; - Plugin->call( NativeHandle, - Plugin->getUrAdapter(), nullptr, &UrDevice); + Plugin->call( + NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice); return detail::createSyclObjFromImpl( PlatformImpl->getOrMakeDeviceImpl(UrDevice, PlatformImpl)); diff --git a/sycl/source/backend/opencl.cpp b/sycl/source/backend/opencl.cpp index 3fce26ee21445..491a167656f58 100644 --- a/sycl/source/backend/opencl.cpp +++ b/sycl/source/backend/opencl.cpp @@ -38,15 +38,17 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, // Manual invocation of plugin API to avoid using deprecated // info::platform::extensions call. size_t ResultSize = 0; - Plugin->call( PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, - /*propSize=*/0, - /*pPropValue=*/nullptr, &ResultSize); + Plugin->call( + PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, + /*propSize=*/0, + /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) return false; std::unique_ptr Result(new char[ResultSize]); - Plugin->call( PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, - ResultSize, Result.get(), nullptr); + Plugin->call(PluginPlatform, + UR_PLATFORM_INFO_EXTENSIONS, + ResultSize, Result.get(), nullptr); std::string_view ExtensionsString(Result.get()); return ExtensionsString.find(Extension) != std::string::npos; @@ -68,15 +70,17 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, // Manual invocation of plugin API to avoid using deprecated // info::device::extensions call. size_t ResultSize = 0; - Plugin->call( PluginDevice, UR_DEVICE_INFO_EXTENSIONS, - /*propSize=*/0, - /*pPropValue=*/nullptr, &ResultSize); + Plugin->call(PluginDevice, + UR_DEVICE_INFO_EXTENSIONS, + /*propSize=*/0, + /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) return false; std::unique_ptr Result(new char[ResultSize]); - Plugin->call( PluginDevice, UR_DEVICE_INFO_EXTENSIONS, - ResultSize, Result.get(), nullptr); + Plugin->call(PluginDevice, + UR_DEVICE_INFO_EXTENSIONS, + ResultSize, Result.get(), nullptr); std::string_view ExtensionsString(Result.get()); return ExtensionsString.find(Extension) != std::string::npos; diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index 4295b4badce4e..a60be1251bcba 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -77,10 +77,9 @@ context::context(cl_context ClContext, async_handler AsyncHandler) { ur_context_handle_t hContext = nullptr; ur_native_handle_t nativeHandle = reinterpret_cast(ClContext); - Plugin->call( nativeHandle, Plugin->getUrAdapter(), - 0, nullptr, nullptr, - &hContext); - + Plugin->call( + nativeHandle, Plugin->getUrAdapter(), 0, nullptr, nullptr, &hContext); + impl = std::make_shared( hContext, AsyncHandler, Plugin); } diff --git a/sycl/source/detail/allowlist.cpp b/sycl/source/detail/allowlist.cpp index a4d1381a57a55..2aee3418f536a 100644 --- a/sycl/source/detail/allowlist.cpp +++ b/sycl/source/detail/allowlist.cpp @@ -377,8 +377,8 @@ void applyAllowList(std::vector &UrDevices, auto DeviceImpl = PlatformImpl->getOrMakeDeviceImpl(Device, PlatformImpl); // get DeviceType value and put it to DeviceDesc ur_device_type_t UrDevType = UR_DEVICE_TYPE_ALL; - Plugin->call( Device, UR_DEVICE_INFO_TYPE, - sizeof(UrDevType), &UrDevType, nullptr); + Plugin->call( + Device, UR_DEVICE_INFO_TYPE, sizeof(UrDevType), &UrDevType, nullptr); // TODO need mechanism to do these casts, there's a bunch of this sort of // thing sycl::info::device_type DeviceType = info::device_type::all; diff --git a/sycl/source/detail/bindless_images.cpp b/sycl/source/detail/bindless_images.cpp index 98005bfb59aed..78e1235df74df 100644 --- a/sycl/source/detail/bindless_images.cpp +++ b/sycl/source/detail/bindless_images.cpp @@ -119,8 +119,10 @@ __SYCL_EXPORT void destroy_image_handle(unsampled_image_handle &imageHandle, ur_device_handle_t Device = DevImpl->getHandleRef(); const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( C, Device, - imageHandle.raw_handle); + Plugin->call< + sycl::errc::runtime, + sycl::detail::UrApiKind::urBindlessImagesUnsampledImageHandleDestroyExp>( + C, Device, imageHandle.raw_handle); } __SYCL_EXPORT void destroy_image_handle(unsampled_image_handle &imageHandle, @@ -140,8 +142,10 @@ __SYCL_EXPORT void destroy_image_handle(sampled_image_handle &imageHandle, ur_device_handle_t Device = DevImpl->getHandleRef(); const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( C, Device, - imageHandle.raw_handle); + Plugin->call< + sycl::errc::runtime, + sycl::detail::UrApiKind::urBindlessImagesSampledImageHandleDestroyExp>( + C, Device, imageHandle.raw_handle); } __SYCL_EXPORT void destroy_image_handle(sampled_image_handle &imageHandle, @@ -170,8 +174,11 @@ alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice, image_mem_handle retHandle; // Call impl. - Plugin->call( C, Device, &urFormat, &urDesc, - reinterpret_cast(&retHandle.raw_handle)); + Plugin->call( + C, Device, &urFormat, &urDesc, + reinterpret_cast( + &retHandle.raw_handle)); return retHandle; } @@ -195,9 +202,9 @@ __SYCL_EXPORT image_mem_handle get_mip_level_mem_handle( // Call impl. image_mem_handle individual_image; - Plugin->call( C, - Device, mipMem.raw_handle, level, - &individual_image.raw_handle); + Plugin->call( + C, Device, mipMem.raw_handle, level, &individual_image.raw_handle); return individual_image; } @@ -223,11 +230,15 @@ __SYCL_EXPORT void free_image_mem(image_mem_handle memHandle, if (memHandle.raw_handle != 0) { if (imageType == image_type::mipmap) { - Plugin->call( C, Device, memHandle.raw_handle); + Plugin->call( + C, Device, memHandle.raw_handle); } else if (imageType == image_type::standard || imageType == image_type::array || imageType == image_type::cubemap) { - Plugin->call( C, Device, memHandle.raw_handle); + Plugin->call( + C, Device, memHandle.raw_handle); } else { throw sycl::exception(sycl::make_error_code(sycl::errc::invalid), "Invalid image type to free"); @@ -274,9 +285,10 @@ create_image(image_mem_handle memHandle, const image_descriptor &desc, // Call impl. ur_exp_image_mem_native_handle_t urImageHandle; - Plugin->call( C, - Device, memHandle.raw_handle, &urFormat, - &urDesc, &urImageHandle); + Plugin + ->call( + C, Device, memHandle.raw_handle, &urFormat, &urDesc, &urImageHandle); return unsampled_image_handle{urImageHandle}; } @@ -401,8 +413,8 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, UrAddrModes.pNext = &UrCubemapProps; ur_sampler_handle_t urSampler = nullptr; - Plugin->call( C, &UrSamplerProps, - &urSampler); + Plugin->call( + C, &UrSamplerProps, &urSampler); ur_image_desc_t urDesc; ur_image_format_t urFormat; @@ -410,9 +422,10 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, // Call impl. ur_exp_image_mem_native_handle_t urImageHandle; - Plugin->call( C, Device, - reinterpret_cast(devPtr), &urFormat, &urDesc, - urSampler, &urImageHandle); + Plugin->call( + C, Device, reinterpret_cast(devPtr), + &urFormat, &urDesc, urSampler, &urImageHandle); return sampled_image_handle{urImageHandle}; } @@ -447,10 +460,12 @@ __SYCL_EXPORT external_mem import_external_memory( // For `resource_fd` external memory type, the handle type is always // `OPAQUE_FD`. No need for a switch statement like we have for win32 // resources. - Plugin->call( C, - Device, externalMemDesc.size_in_bytes, - UR_EXP_EXTERNAL_MEM_TYPE_OPAQUE_FD, - &urExternalMemDescriptor, &urExternalMem); + Plugin + ->call( + C, Device, externalMemDesc.size_in_bytes, + UR_EXP_EXTERNAL_MEM_TYPE_OPAQUE_FD, &urExternalMemDescriptor, + &urExternalMem); return external_mem{urExternalMem}; } @@ -497,10 +512,11 @@ __SYCL_EXPORT external_mem import_external_memory( "Invalid memory handle type"); } - Plugin->call( C, - Device, externalMemDesc.size_in_bytes, - urHandleType, &urExternalMemDescriptor, - &urExternalMem); + Plugin + ->call( + C, Device, externalMemDesc.size_in_bytes, urHandleType, + &urExternalMemDescriptor, &urExternalMem); return external_mem{urExternalMem}; } @@ -535,9 +551,9 @@ image_mem_handle map_external_image_memory(external_mem extMem, ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle}; image_mem_handle retHandle; - Plugin->call( C, - Device, &urFormat, &urDesc, urExternalMem, - &retHandle.raw_handle); + Plugin->call( + C, Device, &urFormat, &urDesc, urExternalMem, &retHandle.raw_handle); return image_mem_handle{retHandle}; } @@ -565,9 +581,10 @@ void *map_external_linear_memory(external_mem extMem, uint64_t offset, ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle}; void *retMemory; - Plugin->call( - C, Device, offset, size, urExternalMem, - &retMemory); + Plugin->call< + sycl::errc::invalid, + sycl::detail::UrApiKind::urBindlessImagesMapExternalLinearMemoryExp>( + C, Device, offset, size, urExternalMem, &retMemory); return retMemory; } @@ -590,8 +607,10 @@ __SYCL_EXPORT void release_external_memory(external_mem extMem, ur_device_handle_t Device = DevImpl->getHandleRef(); const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( C, - Device, extMem.raw_handle); + Plugin + ->call( + C, Device, extMem.raw_handle); } __SYCL_EXPORT void release_external_memory(external_mem extMem, @@ -622,10 +641,11 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( // For this specialization of `import_external_semaphore` the handleType is // always `OPAQUE_FD`. - Plugin->call( - C, Device, - UR_EXP_EXTERNAL_SEMAPHORE_TYPE_OPAQUE_FD, - &urExternalSemDesc, &urExternalSemaphore); + Plugin->call< + sycl::errc::invalid, + sycl::detail::UrApiKind::urBindlessImagesImportExternalSemaphoreExp>( + C, Device, UR_EXP_EXTERNAL_SEMAPHORE_TYPE_OPAQUE_FD, &urExternalSemDesc, + &urExternalSemaphore); return external_semaphore{urExternalSemaphore, external_semaphore_handle_type::opaque_fd}; @@ -673,9 +693,10 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( "Invalid semaphore handle type"); } - Plugin->call( - C, Device, urHandleType, &urExternalSemDesc, - &urExternalSemaphore); + Plugin->call< + sycl::errc::invalid, + sycl::detail::UrApiKind::urBindlessImagesImportExternalSemaphoreExp>( + C, Device, urHandleType, &urExternalSemDesc, &urExternalSemaphore); return external_semaphore{urExternalSemaphore, externalSemaphoreDesc.handle_type}; @@ -701,8 +722,10 @@ release_external_semaphore(external_semaphore externalSemaphore, sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - Plugin->call( - C, Device, externalSemaphore.raw_handle); + Plugin->call< + sycl::errc::invalid, + sycl::detail::UrApiKind::urBindlessImagesReleaseExternalSemaphoreExp>( + C, Device, externalSemaphore.raw_handle); } __SYCL_EXPORT void @@ -722,20 +745,20 @@ __SYCL_EXPORT sycl::range<3> get_image_range(const image_mem_handle memHandle, size_t Width = 0, Height = 0, Depth = 0; - Plugin->call( - CtxImpl->getHandleRef(), - memHandle.raw_handle, UR_IMAGE_INFO_WIDTH, - &Width, nullptr); + Plugin->call( + CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_WIDTH, + &Width, nullptr); - Plugin->call( - CtxImpl->getHandleRef(), - memHandle.raw_handle, UR_IMAGE_INFO_HEIGHT, - &Height, nullptr); + Plugin->call( + CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_HEIGHT, + &Height, nullptr); - Plugin->call( - CtxImpl->getHandleRef(), - memHandle.raw_handle, UR_IMAGE_INFO_DEPTH, - &Depth, nullptr); + Plugin->call( + CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_DEPTH, + &Depth, nullptr); return {Width, Height, Depth}; } @@ -757,9 +780,10 @@ get_image_channel_type(const image_mem_handle memHandle, ur_image_format_t URFormat; - Plugin->call( CtxImpl->getHandleRef(), - memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, - &URFormat, nullptr); + Plugin->call( + CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, + &URFormat, nullptr); image_channel_type ChannelType = sycl::detail::convertChannelType(URFormat.channelType); @@ -793,8 +817,10 @@ __SYCL_EXPORT void *pitched_alloc_device(size_t *resultPitch, ur_device_handle_t UrDevice = sycl::detail::getSyclObjImpl(syclDevice)->getHandleRef(); - Plugin->call( UrContext, UrDevice, nullptr, nullptr, widthInBytes, - height, elementSizeBytes, &RetVal, resultPitch); + Plugin->call( + UrContext, UrDevice, nullptr, nullptr, widthInBytes, height, + elementSizeBytes, &RetVal, resultPitch); return RetVal; } @@ -840,9 +866,10 @@ get_image_num_channels(const image_mem_handle memHandle, const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); ur_image_format_t URFormat = {}; - Plugin->call( CtxImpl->getHandleRef(), - memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, - &URFormat, nullptr); + Plugin->call( + CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, + &URFormat, nullptr); image_channel_order Order = sycl::detail::convertChannelOrder(URFormat.channelOrder); diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index f3fd9280a395d..3aa0e06ee7ced 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -52,10 +52,11 @@ void buffer_impl::addInteropObject( ur::cast(MInteropMemObject)) == Handles.end()) { const PluginPtr &Plugin = getPlugin(); - Plugin->call( ur::cast(MInteropMemObject)); + Plugin->call( + ur::cast(MInteropMemObject)); ur_native_handle_t NativeHandle = 0; - Plugin->call( MInteropMemObject, nullptr, - &NativeHandle); + Plugin->call(MInteropMemObject, nullptr, + &NativeHandle); Handles.push_back(NativeHandle); } } @@ -85,14 +86,15 @@ buffer_impl::getNativeVector(backend BackendName) const { auto Plugin = Platform->getPlugin(); if (Platform->getBackend() == backend::opencl) { - Plugin->call( NativeMem); + Plugin->call(NativeMem); } ur_native_handle_t Handle = 0; // When doing buffer interop we don't know what device the memory should be // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. - Plugin->call( NativeMem, /*Dev*/ nullptr, &Handle); + Plugin->call(NativeMem, /*Dev*/ nullptr, + &Handle); Handles.push_back(Handle); } diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index dfbb259990e73..36d7b1b6b8904 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -59,8 +59,8 @@ context_impl::context_impl(const std::vector Devices, DeviceIds.push_back(getSyclObjImpl(D)->getHandleRef()); } - getPlugin()->call( DeviceIds.size(), DeviceIds.data(), - nullptr, &MContext); + getPlugin()->call( + DeviceIds.size(), DeviceIds.data(), nullptr, &MContext); MKernelProgramCache.setContextPtr(this); } @@ -78,13 +78,14 @@ context_impl::context_impl(ur_context_handle_t UrContext, std::vector DeviceIds; uint32_t DevicesNum = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( MContext, UR_CONTEXT_INFO_NUM_DEVICES, - sizeof(DevicesNum), &DevicesNum, nullptr); + Plugin->call( + MContext, UR_CONTEXT_INFO_NUM_DEVICES, sizeof(DevicesNum), &DevicesNum, + nullptr); DeviceIds.resize(DevicesNum); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( MContext, UR_CONTEXT_INFO_DEVICES, - sizeof(ur_device_handle_t) * DevicesNum, &DeviceIds[0], - nullptr); + Plugin->call( + MContext, UR_CONTEXT_INFO_DEVICES, + sizeof(ur_device_handle_t) * DevicesNum, &DeviceIds[0], nullptr); if (DeviceIds.empty()) throw exception( @@ -106,16 +107,17 @@ context_impl::context_impl(ur_context_handle_t UrContext, // TODO: Move this backend-specific retain of the context to SYCL-2020 style // make_context interop, when that is created. if (getBackend() == sycl::backend::opencl) { - getPlugin()->call( MContext); + getPlugin()->call(MContext); } MKernelProgramCache.setContextPtr(this); } cl_context context_impl::get() const { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call( MContext); + getPlugin()->call(MContext); ur_native_handle_t nativeHandle = 0; - getPlugin()->call( MContext, &nativeHandle); + getPlugin()->call(MContext, + &nativeHandle); return ur::cast(nativeHandle); } @@ -133,10 +135,10 @@ context_impl::~context_impl() { } for (auto LibProg : MCachedLibPrograms) { assert(LibProg.second && "Null program must not be kept in the cache"); - getPlugin()->call( LibProg.second); + getPlugin()->call(LibProg.second); } // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call_nocheck( MContext); + getPlugin()->call_nocheck(MContext); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~context_impl", e); } @@ -292,9 +294,9 @@ context_impl::findMatchingDeviceImpl(ur_device_handle_t &DeviceUR) const { ur_native_handle_t context_impl::getNative() const { const auto &Plugin = getPlugin(); if (getBackend() == backend::opencl) - Plugin->call( getHandleRef()); + Plugin->call(getHandleRef()); ur_native_handle_t Handle; - Plugin->call( getHandleRef(), &Handle); + Plugin->call(getHandleRef(), &Handle); return Handle; } @@ -355,7 +357,7 @@ std::vector context_impl::initializeDeviceGlobals( }); // Release the removed events. for (auto EventIt = NewEnd; EventIt != InitEventsRef.end(); ++EventIt) - Plugin->call( *EventIt); + Plugin->call(*EventIt); // Remove them from the collection. InitEventsRef.erase(NewEnd, InitEventsRef.end()); // If there are no more events, we can mark it as fully initialized. @@ -413,9 +415,9 @@ std::vector context_impl::initializeDeviceGlobals( ur_event_handle_t InitEvent; void *const &USMPtr = DeviceGlobalUSM.getPtr(); Plugin->call( - QueueImpl->getHandleRef(), NativePrg, - DeviceGlobalEntry->MUniqueId.c_str(), false, sizeof(void *), - 0, &USMPtr, 0, nullptr, &InitEvent); + QueueImpl->getHandleRef(), NativePrg, + DeviceGlobalEntry->MUniqueId.c_str(), false, sizeof(void *), 0, + &USMPtr, 0, nullptr, &InitEvent); InitEventsRef.push_back(InitEvent); } @@ -426,7 +428,7 @@ std::vector context_impl::initializeDeviceGlobals( void context_impl::DeviceGlobalInitializer::ClearEvents( const PluginPtr &Plugin) { for (const ur_event_handle_t &Event : MDeviceGlobalInitEvents) - Plugin->call( Event); + Plugin->call(Event); MDeviceGlobalInitEvents.clear(); } diff --git a/sycl/source/detail/context_info.hpp b/sycl/source/detail/context_info.hpp index e0626331c4781..75e1b64580e83 100644 --- a/sycl/source/detail/context_info.hpp +++ b/sycl/source/detail/context_info.hpp @@ -24,8 +24,8 @@ typename Param::return_type get_context_info(ur_context_handle_t Ctx, "Invalid context information descriptor"); typename Param::return_type Result = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Ctx, UrInfoCode::value, sizeof(Result), - &Result, nullptr); + Plugin->call(Ctx, UrInfoCode::value, + sizeof(Result), &Result, nullptr); return Result; } diff --git a/sycl/source/detail/device_global_map_entry.cpp b/sycl/source/detail/device_global_map_entry.cpp index fa5283411f01b..aceb1437660a4 100644 --- a/sycl/source/detail/device_global_map_entry.cpp +++ b/sycl/source/detail/device_global_map_entry.cpp @@ -31,7 +31,7 @@ OwnedUrEvent DeviceGlobalUSMMem::getInitEvent(const PluginPtr &Plugin) { if (MInitEvent.has_value()) { if (get_event_info( *MInitEvent, Plugin) == info::event_command_status::complete) { - Plugin->call( *MInitEvent); + Plugin->call(*MInitEvent); MInitEvent = {}; return OwnedUrEvent(Plugin); } else { @@ -100,7 +100,8 @@ void DeviceGlobalMapEntry::removeAssociatedResources( DeviceGlobalUSMMem &USMMem = USMPtrIt->second; detail::usm::freeInternal(USMMem.MPtr, CtxImpl); if (USMMem.MInitEvent.has_value()) - CtxImpl->getPlugin()->call( *USMMem.MInitEvent); + CtxImpl->getPlugin()->call( + *USMMem.MInitEvent); #ifndef NDEBUG // For debugging we set the event and memory to some recognizable values // to allow us to check that this cleanup happens before erasure. diff --git a/sycl/source/detail/device_image_impl.hpp b/sycl/source/detail/device_image_impl.hpp index 17e144fa6908a..b8f1b3094285c 100644 --- a/sycl/source/detail/device_image_impl.hpp +++ b/sycl/source/detail/device_image_impl.hpp @@ -292,9 +292,9 @@ class device_image_impl { const PluginPtr &Plugin = ContextImplPtr->getPlugin(); if (ContextImplPtr->getBackend() == backend::opencl) - Plugin->call( MProgram); + Plugin->call(MProgram); ur_native_handle_t NativeProgram = 0; - Plugin->call( MProgram, &NativeProgram); + Plugin->call(MProgram, &NativeProgram); return NativeProgram; } @@ -303,7 +303,7 @@ class device_image_impl { try { if (MProgram) { const PluginPtr &Plugin = getSyclObjImpl(MContext)->getPlugin(); - Plugin->call( MProgram); + Plugin->call(MProgram); } if (MSpecConstsBuffer) { std::lock_guard Lock{MSpecConstAccessMtx}; diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index c3b0804373a89..546bb8a5831c4 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -42,27 +42,28 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, // Get UR device from the raw device handle. // NOTE: this is for OpenCL interop only (and should go away). // With SYCL-2020 BE generalization "make" functions are used instead. - Plugin->call( InteropDeviceHandle, - Plugin->getUrAdapter(), nullptr, &MDevice); + Plugin->call( + InteropDeviceHandle, Plugin->getUrAdapter(), nullptr, &MDevice); InteroperabilityConstructor = true; } // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( MDevice, UR_DEVICE_INFO_TYPE, - sizeof(ur_device_type_t), &MType, nullptr); + Plugin->call( + MDevice, UR_DEVICE_INFO_TYPE, sizeof(ur_device_type_t), &MType, nullptr); // No need to set MRootDevice when MAlwaysRootDevice is true if ((Platform == nullptr) || !Platform->MAlwaysRootDevice) { // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( MDevice, UR_DEVICE_INFO_PARENT_DEVICE, - sizeof(ur_device_handle_t), &MRootDevice, nullptr); + Plugin->call( + MDevice, UR_DEVICE_INFO_PARENT_DEVICE, sizeof(ur_device_handle_t), + &MRootDevice, nullptr); } if (!InteroperabilityConstructor) { // TODO catch an exception and put it to list of asynchronous exceptions // Interoperability Constructor already calls DeviceRetain in // urDeviceCreateWithNativeHandle. - Plugin->call( MDevice); + Plugin->call(MDevice); } // set MPlatform @@ -95,7 +96,7 @@ bool device_impl::is_affinity_supported( cl_device_id device_impl::get() const { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call( MDevice); + getPlugin()->call(MDevice); return ur::cast(getNative()); } @@ -182,9 +183,9 @@ std::vector device_impl::create_sub_devices( std::vector SubDevices(SubDevicesCount); uint32_t ReturnedSubDevices = 0; const PluginPtr &Plugin = getPlugin(); - Plugin->call( MDevice, Properties, - SubDevicesCount, SubDevices.data(), - &ReturnedSubDevices); + Plugin->call( + MDevice, Properties, SubDevicesCount, SubDevices.data(), + &ReturnedSubDevices); if (ReturnedSubDevices != SubDevicesCount) { throw sycl::exception( errc::invalid, @@ -303,8 +304,8 @@ std::vector device_impl::create_sub_devices( uint32_t SubDevicesCount = 0; const PluginPtr &Plugin = getPlugin(); - Plugin->call( MDevice, &Properties, 0, - nullptr, &SubDevicesCount); + Plugin->call( + MDevice, &Properties, 0, nullptr, &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); } @@ -328,8 +329,8 @@ std::vector device_impl::create_sub_devices() const { uint32_t SubDevicesCount = 0; const PluginPtr &Plugin = getPlugin(); - Plugin->call( MDevice, &Properties, 0, nullptr, - &SubDevicesCount); + Plugin->call(MDevice, &Properties, 0, nullptr, + &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); } @@ -337,9 +338,9 @@ std::vector device_impl::create_sub_devices() const { ur_native_handle_t device_impl::getNative() const { auto Plugin = getPlugin(); if (getBackend() == backend::opencl) - Plugin->call( getHandleRef()); + Plugin->call(getHandleRef()); ur_native_handle_t Handle; - Plugin->call( getHandleRef(), &Handle); + Plugin->call(getHandleRef(), &Handle); return Handle; } @@ -406,49 +407,52 @@ bool device_impl::has(aspect Aspect) const { case aspect::usm_system_allocations: return get_info(); case aspect::ext_intel_device_id: - return getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_DEVICE_ID, 0, nullptr, - &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_DEVICE_ID, 0, nullptr, &return_size) == + UR_RESULT_SUCCESS; case aspect::ext_intel_pci_address: - return getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_PCI_ADDRESS, 0, nullptr, - &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_PCI_ADDRESS, 0, nullptr, &return_size) == + UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_count: - return getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_GPU_EU_COUNT, 0, nullptr, - &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_GPU_EU_COUNT, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_simd_width: - return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH, 0, - nullptr, &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_slices: - return getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_GPU_EU_SLICES, 0, nullptr, - &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_GPU_EU_SLICES, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_subslices_per_slice: - return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, - 0, nullptr, &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_eu_count_per_subslice: - return getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, - 0, nullptr, - &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_gpu_hw_threads_per_eu: - return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU, - 0, nullptr, &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_free_memory: - return getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_GLOBAL_MEM_FREE, 0, nullptr, - &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_GLOBAL_MEM_FREE, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_memory_clock_rate: - return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_MEMORY_CLOCK_RATE, 0, - nullptr, &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_MEMORY_CLOCK_RATE, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_memory_bus_width: - return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_MEMORY_BUS_WIDTH, 0, - nullptr, &return_size) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_MEMORY_BUS_WIDTH, 0, nullptr, + &return_size) == UR_RESULT_SUCCESS; case aspect::ext_intel_device_info_uuid: { - auto Result = - getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_UUID, - 0, nullptr, &return_size); + auto Result = getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_UUID, 0, nullptr, &return_size); if (Result != UR_RESULT_SUCCESS) { return false; } @@ -456,8 +460,9 @@ bool device_impl::has(aspect Aspect) const { assert(return_size <= 16); unsigned char UUID[16]; - return getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_UUID, - 16 * sizeof(unsigned char), UUID, nullptr) == UR_RESULT_SUCCESS; + return getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_UUID, 16 * sizeof(unsigned char), UUID, + nullptr) == UR_RESULT_SUCCESS; } case aspect::ext_intel_max_mem_bandwidth: // currently not supported @@ -469,183 +474,185 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cuda_async_barrier: { int async_barrier_supported; bool call_successful = - getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_ASYNC_BARRIER, sizeof(int), + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_ASYNC_BARRIER, sizeof(int), &async_barrier_supported, nullptr) == UR_RESULT_SUCCESS; return call_successful && async_barrier_supported; } case aspect::ext_intel_legacy_image: { ur_bool_t legacy_image_support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_IMAGE_SUPPORTED, - sizeof(ur_bool_t), &legacy_image_support, - nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_IMAGE_SUPPORTED, sizeof(ur_bool_t), + &legacy_image_support, nullptr) == UR_RESULT_SUCCESS; return call_successful && legacy_image_support; } case aspect::ext_oneapi_bindless_images: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP, - sizeof(ur_bool_t), &support, - nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP, + sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_images_shared_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_images_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_images_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_external_memory_import: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_EXTERNAL_MEMORY_IMPORT_SUPPORT_EXP, sizeof(ur_bool_t), - &support, nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_EXTERNAL_MEMORY_IMPORT_SUPPORT_EXP, + sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_external_semaphore_import: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_EXTERNAL_SEMAPHORE_IMPORT_SUPPORT_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_EXTERNAL_SEMAPHORE_IMPORT_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_mipmap: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP, - sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP, sizeof(ur_bool_t), + &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_mipmap_anisotropy: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP, - sizeof(ur_bool_t), &support, - nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP, + sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_mipmap_level_reference: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_sampled_image_fetch_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_sampled_image_fetch_1d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_sampled_image_fetch_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_sampled_image_fetch_2d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_sampled_image_fetch_3d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_cubemap: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP, - sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP, sizeof(ur_bool_t), + &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_cubemap_seamless_filtering: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_image_array: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_IMAGE_ARRAY_SUPPORT_EXP, - sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_IMAGE_ARRAY_SUPPORT_EXP, sizeof(ur_bool_t), + &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_unique_addressing_per_dim: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_UNIQUE_ADDRESSING_PER_DIM_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_UNIQUE_ADDRESSING_PER_DIM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_images_sample_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_bindless_images_sample_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_intel_esimd: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_ESIMD_SUPPORT, - sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_ESIMD_SUPPORT, sizeof(ur_bool_t), &support, + nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_ballot_group: @@ -687,7 +694,8 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_is_component: { typename sycl_to_ur::type Result; bool CallSuccessful = - getPlugin()->call_nocheck( getHandleRef(), + getPlugin()->call_nocheck( + getHandleRef(), UrInfoCode::value, sizeof(Result), &Result, nullptr) == UR_RESULT_SUCCESS; @@ -697,8 +705,8 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_graph: { bool SupportsCommandBufferUpdate = false; bool CallSuccessful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP, sizeof(SupportsCommandBufferUpdate), &SupportsCommandBufferUpdate, nullptr) == UR_RESULT_SUCCESS; if (!CallSuccessful) { @@ -710,7 +718,8 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_limited_graph: { bool SupportsCommandBuffers = false; bool CallSuccessful = - getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP, + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP, sizeof(SupportsCommandBuffers), &SupportsCommandBuffers, nullptr) == UR_RESULT_SUCCESS; if (!CallSuccessful) { @@ -728,16 +737,17 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_queue_profiling_tag: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, - UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP, sizeof(ur_bool_t), - &support, nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP, + sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_oneapi_virtual_mem: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( MDevice, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, - sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; + getPlugin()->call_nocheck( + MDevice, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t), + &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; } case aspect::ext_intel_fpga_task_sequence: { @@ -794,9 +804,8 @@ uint64_t device_impl::getCurrentDeviceTime() { // If getCurrentDeviceTime is called for the first time or we have to refresh. if (!MDeviceHostBaseTime.second || Diff > TimeTillRefresh) { const auto &Plugin = getPlugin(); - auto Result = Plugin->call_nocheck( MDevice, - &MDeviceHostBaseTime.first, - &MDeviceHostBaseTime.second); + auto Result = Plugin->call_nocheck( + MDevice, &MDeviceHostBaseTime.first, &MDeviceHostBaseTime.second); // We have to remember base host timestamp right after UR call and it is // going to be used for calculation of the device timestamp at the next // getCurrentDeviceTime() call. We need to do it here because getPlugin() @@ -833,8 +842,8 @@ uint64_t device_impl::getCurrentDeviceTime() { bool device_impl::isGetDeviceAndHostTimerSupported() { const auto &Plugin = getPlugin(); uint64_t DeviceTime = 0, HostTime = 0; - auto Result = Plugin->call_nocheck( MDevice, - &DeviceTime, &HostTime); + auto Result = Plugin->call_nocheck( + MDevice, &DeviceTime, &HostTime); return Result != UR_RESULT_ERROR_INVALID_OPERATION; } diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 2f68ecb8cbf43..8f3fd44586889 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -142,9 +142,9 @@ template <> struct check_fp_support { template struct get_device_info_impl { static ReturnT get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, sizeof(result), &result, - nullptr); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, + nullptr); return ReturnT(result); } }; @@ -153,9 +153,9 @@ template struct get_device_info_impl { template struct get_device_info_impl { static platform get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, sizeof(result), &result, - nullptr); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, + nullptr); // TODO: Change UrDevice to device_impl. // Use the Plugin from the device_impl class after plugin details // are added to the class. @@ -169,14 +169,14 @@ template struct get_device_info_impl { inline std::string device_impl::get_device_info_string(ur_device_info_t InfoCode) const { size_t resultSize = 0; - getPlugin()->call( getHandleRef(), InfoCode, 0, nullptr, - &resultSize); + getPlugin()->call(getHandleRef(), InfoCode, 0, + nullptr, &resultSize); if (resultSize == 0) { return std::string(); } std::unique_ptr result(new char[resultSize]); - getPlugin()->call( getHandleRef(), InfoCode, resultSize, - result.get(), nullptr); + getPlugin()->call( + getHandleRef(), InfoCode, resultSize, result.get(), nullptr); return std::string(result.get()); } @@ -205,9 +205,9 @@ struct get_device_info_impl, Param> { return {}; } ur_device_fp_capability_flags_t result; - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, sizeof(result), &result, - nullptr); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, + nullptr); return read_fp_bitfield(result); } }; @@ -226,9 +226,9 @@ struct get_device_info_impl, info::device::single_fp_config> { static std::vector get(const DeviceImplPtr &Dev) { ur_device_fp_capability_flags_t result; - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, - sizeof(result), &result, nullptr); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, + sizeof(result), &result, nullptr); return read_fp_bitfield(result); } }; @@ -239,9 +239,9 @@ struct get_device_info_impl, template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_queue_flags_t Properties; - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, - sizeof(Properties), &Properties, nullptr); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, + sizeof(Properties), &Properties, nullptr); return Properties & UR_QUEUE_FLAG_PROFILING_ENABLE; } }; @@ -252,7 +252,8 @@ struct get_device_info_impl, info::device::atomic_memory_order_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_memory_order_capability_flag_t result; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryOrderBitfield(result); @@ -265,7 +266,8 @@ struct get_device_info_impl, info::device::atomic_fence_order_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_memory_order_capability_flag_t result; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryOrderBitfield(result); @@ -278,7 +280,8 @@ struct get_device_info_impl, info::device::atomic_memory_scope_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { size_t result; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryScopeBitfield(result); @@ -291,7 +294,8 @@ struct get_device_info_impl, info::device::atomic_fence_scope_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { size_t result; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryScopeBitfield(result); @@ -304,7 +308,8 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { bool result = false; if (Dev->getBackend() == backend::ext_oneapi_cuda) { - auto Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), + auto Err = Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); if (Err != UR_RESULT_SUCCESS) { @@ -321,7 +326,8 @@ struct get_device_info_impl, info::device::execution_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_device_exec_capability_flag_t result; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_execution_bitfield(result); @@ -389,8 +395,8 @@ struct get_device_info_impl, const auto &Plugin = Dev->getPlugin(); size_t resultSize; - Plugin->call( Dev->getHandleRef(), info_partition, 0, - nullptr, &resultSize); + Plugin->call( + Dev->getHandleRef(), info_partition, 0, nullptr, &resultSize); size_t arrayLength = resultSize / sizeof(ur_device_partition_t); if (arrayLength == 0) { @@ -398,8 +404,9 @@ struct get_device_info_impl, } std::unique_ptr arrayResult( new ur_device_partition_t[arrayLength]); - Plugin->call( Dev->getHandleRef(), info_partition, - resultSize, arrayResult.get(), nullptr); + Plugin->call(Dev->getHandleRef(), + info_partition, resultSize, + arrayResult.get(), nullptr); std::vector result; for (size_t i = 0; i < arrayLength; ++i) { @@ -421,7 +428,8 @@ struct get_device_info_impl, static std::vector get(const DeviceImplPtr &Dev) { ur_device_affinity_domain_flags_t result; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_domain_bitfield(result); @@ -436,7 +444,8 @@ struct get_device_info_impl PartitionProperties; size_t PropertiesSize = 0; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &PropertiesSize); if (PropertiesSize == 0) @@ -445,7 +454,8 @@ struct get_device_info_implgetPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); @@ -466,7 +476,8 @@ struct get_device_info_impl PartitionProperties; size_t PropertiesSize = 0; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &PropertiesSize); if (PropertiesSize == 0) @@ -475,7 +486,8 @@ struct get_device_info_implgetPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); // The old UR implementation also just checked the first element, is that @@ -490,14 +502,14 @@ struct get_device_info_impl, info::device::sub_group_sizes> { static std::vector get(const DeviceImplPtr &Dev) { size_t resultSize = 0; - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, 0, - nullptr, &resultSize); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, + 0, nullptr, &resultSize); std::vector result32(resultSize / sizeof(uint32_t)); - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, - resultSize, result32.data(), nullptr); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, + resultSize, result32.data(), nullptr); std::vector result; result.reserve(result32.size()); @@ -551,7 +563,8 @@ struct get_device_info_impl, info::device::max_work_item_sizes> { static range get(const DeviceImplPtr &Dev) { size_t result[3]; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode>::value, sizeof(result), &result, nullptr); return construct_range(result); @@ -679,10 +692,12 @@ struct get_device_info_impl< auto LookupIPVersion = [&](auto &ArchList) -> std::optional { uint32_t DeviceIp; - ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), - UrInfoCode< - ext::oneapi::experimental::info::device::architecture>::value, - sizeof(DeviceIp), &DeviceIp, nullptr); + ur_result_t Err = + Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), + UrInfoCode< + ext::oneapi::experimental::info::device::architecture>::value, + sizeof(DeviceIp), &DeviceIp, nullptr); if (Err == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { // Not all devices support this device info query return std::nullopt; @@ -710,13 +725,13 @@ struct get_device_info_impl< return ext::oneapi::experimental::architecture::unknown; }; size_t ResultSize = 0; - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, 0, - nullptr, &ResultSize); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, 0, + nullptr, &ResultSize); std::unique_ptr DeviceArch(new char[ResultSize]); - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, - ResultSize, DeviceArch.get(), nullptr); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, + ResultSize, DeviceArch.get(), nullptr); std::string DeviceArchCopy(DeviceArch.get()); std::string DeviceArchSubstr = DeviceArchCopy.substr(0, DeviceArchCopy.find(":")); @@ -957,7 +972,8 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, sizeof(result), &result, nullptr); @@ -973,7 +989,8 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, sizeof(result), &result, nullptr); @@ -989,7 +1006,8 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, sizeof(result), &result, nullptr); @@ -1050,9 +1068,9 @@ struct get_device_info_impl, template <> struct get_device_info_impl { static device get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( Dev->getHandleRef(), - UrInfoCode::value, - sizeof(result), &result, nullptr); + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, + sizeof(result), &result, nullptr); if (result == nullptr) throw exception(make_error_code(errc::invalid), "No parent for device because it is not a subdevice"); @@ -1079,9 +1097,11 @@ template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), - UrInfoCode::value, - sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); + ur_result_t Err = + Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), + UrInfoCode::value, + sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); return (Err != UR_RESULT_SUCCESS) ? false @@ -1095,9 +1115,11 @@ template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), - UrInfoCode::value, - sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); + ur_result_t Err = + Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), + UrInfoCode::value, + sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); return (Err != UR_RESULT_SUCCESS) ? false @@ -1110,9 +1132,11 @@ template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), - UrInfoCode::value, - sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); + ur_result_t Err = + Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), + UrInfoCode::value, + sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); return (Err != UR_RESULT_SUCCESS) ? false : (caps & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS); @@ -1125,9 +1149,11 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), - UrInfoCode::value, - sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); + ur_result_t Err = + Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), + UrInfoCode::value, + sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); // Check that we don't support any cross device sharing return (Err != UR_RESULT_SUCCESS) ? false @@ -1142,9 +1168,11 @@ template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; - ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), - UrInfoCode::value, - sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); + ur_result_t Err = + Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), + UrInfoCode::value, + sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); return (Err != UR_RESULT_SUCCESS) ? false : (caps & UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS); @@ -1187,7 +1215,8 @@ struct get_device_info_impl< ext::codeplay::experimental::info::device::max_registers_per_work_group> { static uint32_t get(const DeviceImplPtr &Dev) { uint32_t maxRegsPerWG; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(maxRegsPerWG), &maxRegsPerWG, nullptr); @@ -1203,10 +1232,12 @@ struct get_device_info_impl< static std::vector get(const DeviceImplPtr &Dev) { size_t ResultSize = 0; // First call to get DevCount. - ur_result_t Err = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), - UrInfoCode< - ext::oneapi::experimental::info::device::component_devices>::value, - 0, nullptr, &ResultSize); + ur_result_t Err = + Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), + UrInfoCode::value, + 0, nullptr, &ResultSize); // If the feature is unsupported or if the result was empty, return an empty // list of devices. @@ -1222,7 +1253,8 @@ struct get_device_info_impl< // Second call to get the list. std::vector Devs(DevCount); - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::component_devices>::value, ResultSize, Devs.data(), nullptr); @@ -1246,7 +1278,8 @@ struct get_device_info_impl< "can call this function."); typename sycl_to_ur::type Result; - Dev->getPlugin()->call( Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::composite_device>::value, sizeof(Result), &Result, nullptr); diff --git a/sycl/source/detail/error_handling/error_handling.cpp b/sycl/source/detail/error_handling/error_handling.cpp index d48d90f9b2359..7c609adcfcd82 100644 --- a/sycl/source/detail/error_handling/error_handling.cpp +++ b/sycl/source/detail/error_handling/error_handling.cpp @@ -38,8 +38,9 @@ void handleOutOfResources(const device_impl &DeviceImpl, const PluginPtr &Plugin = DeviceImpl.getPlugin(); uint32_t NumRegisters = 0; - Plugin->call( Kernel, UR_KERNEL_INFO_NUM_REGS, - sizeof(NumRegisters), &NumRegisters, nullptr); + Plugin->call(Kernel, UR_KERNEL_INFO_NUM_REGS, + sizeof(NumRegisters), + &NumRegisters, nullptr); uint32_t MaxRegistersPerBlock = DeviceImpl.get_infocall( Kernel, Device, - UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(size_t) * 3, - CompileWGSize, nullptr); + Plugin->call( + Kernel, Device, UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, + sizeof(size_t) * 3, CompileWGSize, nullptr); size_t MaxWGSize = 0; - Plugin->call( Device, UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, - sizeof(size_t), &MaxWGSize, nullptr); + Plugin->call(Device, + UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, + sizeof(size_t), &MaxWGSize, nullptr); const bool HasLocalSize = (NDRDesc.LocalSize[0] != 0); @@ -147,8 +149,9 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, if (HasLocalSize) { size_t MaxThreadsPerBlock[3] = {}; - Plugin->call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, - sizeof(MaxThreadsPerBlock), MaxThreadsPerBlock, nullptr); + Plugin->call( + Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxThreadsPerBlock), + MaxThreadsPerBlock, nullptr); for (size_t I = 0; I < 3; ++I) { if (MaxThreadsPerBlock[I] < NDRDesc.LocalSize[I]) { @@ -185,9 +188,9 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // than the value specified by UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE in // table 5.21. size_t KernelWGSize = 0; - Plugin->call( Kernel, Device, - UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t), - &KernelWGSize, nullptr); + Plugin->call( + Kernel, Device, UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t), + &KernelWGSize, nullptr); const size_t TotalNumberOfWIs = NDRDesc.LocalSize[0] * NDRDesc.LocalSize[1] * NDRDesc.LocalSize[2]; if (TotalNumberOfWIs > KernelWGSize) @@ -239,15 +242,17 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // work-group given by local_work_size ur_program_handle_t Program = nullptr; - Plugin->call( Kernel, UR_KERNEL_INFO_PROGRAM, - sizeof(ur_program_handle_t), &Program, nullptr); + Plugin->call( + Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), + &Program, nullptr); size_t OptsSize = 0; - Plugin->call( Program, Device, - UR_PROGRAM_BUILD_INFO_OPTIONS, 0, nullptr, &OptsSize); + Plugin->call( + Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, 0, nullptr, + &OptsSize); std::string Opts(OptsSize, '\0'); - Plugin->call( Program, Device, - UR_PROGRAM_BUILD_INFO_OPTIONS, OptsSize, &Opts.front(), - nullptr); + Plugin->call( + Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, OptsSize, + &Opts.front(), nullptr); const bool HasStd20 = Opts.find("-cl-std=CL2.0") != std::string::npos; const bool RequiresUniformWGSize = Opts.find("-cl-uniform-work-group-size") != std::string::npos; @@ -309,8 +314,9 @@ void handleInvalidWorkItemSize(const device_impl &DeviceImpl, size_t MaxWISize[] = {0, 0, 0}; - Plugin->call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, - sizeof(MaxWISize), &MaxWISize, nullptr); + Plugin->call( + Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxWISize), &MaxWISize, + nullptr); for (unsigned I = 0; I < NDRDesc.Dims; I++) { if (NDRDesc.LocalSize[I] > MaxWISize[I]) throw sycl::exception( @@ -327,8 +333,9 @@ void handleInvalidValue(const device_impl &DeviceImpl, ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t MaxNWGs[] = {0, 0, 0}; - Plugin->call( Device, UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, - sizeof(MaxNWGs), &MaxNWGs, nullptr); + Plugin->call(Device, + UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, + sizeof(MaxNWGs), &MaxNWGs, nullptr); for (unsigned int I = 0; I < NDRDesc.Dims; I++) { size_t NWgs = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; if (NWgs > MaxNWGs[I]) diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 8fe97aac25457..7ca70acc6ae4b 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -46,7 +46,7 @@ event_impl::~event_impl() { try { auto Handle = this->getHandle(); if (Handle) - getPlugin()->call( Handle); + getPlugin()->call(Handle); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~event_impl", e); } @@ -56,7 +56,8 @@ void event_impl::waitInternal(bool *Success) { auto Handle = this->getHandle(); if (!MIsHostEvent && Handle) { // Wait for the native event - ur_result_t Err = getPlugin()->call_nocheck( 1, &Handle); + ur_result_t Err = + getPlugin()->call_nocheck(1, &Handle); // TODO drop the UR_RESULT_ERROR_UKNOWN from here (this was waiting for // https://github.com/oneapi-src/unified-runtime/issues/1459 which is now // closed). @@ -146,8 +147,9 @@ event_impl::event_impl(ur_event_handle_t Event, const context &SyclContext) MIsFlushed(true), MState(HES_Complete) { ur_context_handle_t TempContext; - getPlugin()->call( this->getHandle(), UR_EVENT_INFO_CONTEXT, - sizeof(ur_context_handle_t), &TempContext, nullptr); + getPlugin()->call( + this->getHandle(), UR_EVENT_INFO_CONTEXT, sizeof(ur_context_handle_t), + &TempContext, nullptr); if (MContext->getHandleRef() != TempContext) { throw sycl::exception(sycl::make_error_code(sycl::errc::invalid), @@ -487,15 +489,15 @@ ur_native_handle_t event_impl::getNative() { auto TempContext = MContext.get()->getHandleRef(); ur_event_native_properties_t NativeProperties{}; ur_event_handle_t UREvent = nullptr; - Plugin->call( 0, TempContext, - &NativeProperties, &UREvent); + Plugin->call( + 0, TempContext, &NativeProperties, &UREvent); this->setHandle(UREvent); Handle = UREvent; } if (MContext->getBackend() == backend::opencl) - Plugin->call( Handle); + Plugin->call(Handle); ur_native_handle_t OutHandle; - Plugin->call( Handle, &OutHandle); + Plugin->call(Handle, &OutHandle); return OutHandle; } @@ -536,11 +538,11 @@ void event_impl::flushIfNeeded(const QueueImplPtr &UserQueue) { // Check if the task for this event has already been submitted. ur_event_status_t Status = UR_EVENT_STATUS_QUEUED; - getPlugin()->call( Handle, - UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, - sizeof(ur_event_status_t), &Status, nullptr); + getPlugin()->call( + Handle, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, sizeof(ur_event_status_t), + &Status, nullptr); if (Status == UR_EVENT_STATUS_QUEUED) { - getPlugin()->call( Queue->getHandleRef()); + getPlugin()->call(Queue->getHandleRef()); } MIsFlushed = true; } diff --git a/sycl/source/detail/event_info.hpp b/sycl/source/detail/event_info.hpp index 210e158caf2d3..119862e08941e 100644 --- a/sycl/source/detail/event_info.hpp +++ b/sycl/source/detail/event_info.hpp @@ -25,8 +25,8 @@ typename Param::return_type get_event_profiling_info(ur_event_handle_t Event, "Unexpected event profiling info descriptor"); typename Param::return_type Result{0}; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Event, UrInfoCode::value, - sizeof(Result), &Result, nullptr); + Plugin->call( + Event, UrInfoCode::value, sizeof(Result), &Result, nullptr); return Result; } @@ -37,8 +37,8 @@ typename Param::return_type get_event_info(ur_event_handle_t Event, "Unexpected event info descriptor"); typename Param::return_type Result{0}; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Event, UrInfoCode::value, sizeof(Result), - &Result, nullptr); + Plugin->call(Event, UrInfoCode::value, + sizeof(Result), &Result, nullptr); // If the status is UR_EVENT_STATUS_QUEUED We need to change it since QUEUE is // not a valid status in sycl. diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 1049ca10d98a7..2e1c4216249bd 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -274,7 +274,8 @@ void GlobalHandler::unloadPlugins() { } UrFuncInfo loaderTearDownInfo; - auto loaderTearDown = loaderTearDownInfo.getFuncPtr(ur::loadURLoaderLibrary()); + auto loaderTearDown = + loaderTearDownInfo.getFuncPtr(ur::loadURLoaderLibrary()); loaderTearDown(); // urLoaderTearDown(); diff --git a/sycl/source/detail/graph_impl.cpp b/sycl/source/detail/graph_impl.cpp index ce7819c95a49a..fb4dc6b4f4e7a 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -720,8 +720,10 @@ void exec_graph_impl::createCommandBuffers( auto ContextImpl = sycl::detail::getSyclObjImpl(MContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); auto DeviceImpl = sycl::detail::getSyclObjImpl(Device); - ur_result_t Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), - DeviceImpl->getHandleRef(), &Desc, &OutCommandBuffer); + ur_result_t Res = + Plugin->call_nocheck( + ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), &Desc, + &OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { throw sycl::exception(errc::invalid, "Failed to create UR command-buffer"); } @@ -761,7 +763,9 @@ void exec_graph_impl::createCommandBuffers( Node->MCommandGroup->getAccStorage().end()); } - Res = Plugin->call_nocheck( OutCommandBuffer); + Res = + Plugin->call_nocheck( + OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { throw sycl::exception(errc::invalid, "Failed to finalize UR command-buffer"); @@ -807,8 +811,8 @@ exec_graph_impl::~exec_graph_impl() { Partition->MSchedule.clear(); for (const auto &Iter : Partition->MCommandBuffers) { if (auto CmdBuf = Iter.second; CmdBuf) { - ur_result_t Res = - Plugin->call_nocheck( CmdBuf); + ur_result_t Res = Plugin->call_nocheck< + sycl::detail::UrApiKind::urCommandBufferReleaseExp>(CmdBuf); (void)Res; assert(Res == UR_RESULT_SUCCESS); } @@ -817,8 +821,8 @@ exec_graph_impl::~exec_graph_impl() { for (auto &Iter : MCommandMap) { if (auto Command = Iter.second; Command) { - ur_result_t Res = - Plugin->call_nocheck( Command); + ur_result_t Res = Plugin->call_nocheck< + sycl::detail::UrApiKind::urCommandBufferReleaseCommandExp>(Command); (void)Res; assert(Res == UR_RESULT_SUCCESS); } @@ -920,8 +924,11 @@ exec_graph_impl::enqueue(const std::shared_ptr &Queue, NewEvent->setSubmissionTime(); NewEvent->setHostEnqueueTime(); } - ur_result_t Res = Queue->getPlugin()->call_nocheck( CommandBuffer, Queue->getHandleRef(), 0, - nullptr, &UREvent); + ur_result_t Res = + Queue->getPlugin() + ->call_nocheck< + sycl::detail::UrApiKind::urCommandBufferEnqueueExp>( + CommandBuffer, Queue->getHandleRef(), 0, nullptr, &UREvent); NewEvent->setHandle(UREvent); if (Res == UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES) { throw sycl::exception( @@ -1392,10 +1399,11 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { if (NDRDesc.LocalSize[0] != 0) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( UrKernel, DeviceImpl->getHandleRef(), - UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, - sizeof(RequiredWGSize), RequiredWGSize, - /* param_value_size_ret = */ nullptr); + Plugin->call( + UrKernel, DeviceImpl->getHandleRef(), + UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), + RequiredWGSize, + /* param_value_size_ret = */ nullptr); const bool EnforcedLocalSize = (RequiredWGSize[0] != 0 || RequiredWGSize[1] != 0 || @@ -1492,13 +1500,14 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { ur_exp_command_buffer_command_handle_t Command = MCommandMap[ExecNode->second]; - ur_result_t Res = Plugin->call_nocheck( - Command, &UpdateDesc); + ur_result_t Res = Plugin->call_nocheck< + sycl::detail::UrApiKind::urCommandBufferUpdateKernelLaunchExp>( + Command, &UpdateDesc); if (UrProgram) { // We retained these objects by calling getOrCreateKernel() - Plugin->call( UrKernel); - Plugin->call( UrProgram); + Plugin->call(UrKernel); + Plugin->call(UrProgram); } if (Res != UR_RESULT_SUCCESS) { diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index 8c38d292b649f..f02c7f594a057 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -262,8 +262,8 @@ template static void getImageInfo(const ContextImplPtr Context, ur_image_info_t Info, T &Dest, ur_mem_handle_t InteropMemObject) { const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( InteropMemObject, Info, sizeof(T), &Dest, - nullptr); + Plugin->call(InteropMemObject, Info, sizeof(T), + &Dest, nullptr); } image_impl::image_impl(cl_mem MemObject, const context &SyclContext, @@ -276,8 +276,8 @@ image_impl::image_impl(cl_mem MemObject, const context &SyclContext, ur_mem_handle_t Mem = ur::cast(BaseT::MInteropMemObject); const ContextImplPtr Context = getSyclObjImpl(SyclContext); const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( Mem, UR_MEM_INFO_SIZE, sizeof(size_t), - &(BaseT::MSizeInBytes), nullptr); + Plugin->call(Mem, UR_MEM_INFO_SIZE, sizeof(size_t), + &(BaseT::MSizeInBytes), nullptr); ur_image_format_t Format; getImageInfo(Context, UR_IMAGE_INFO_FORMAT, Format, Mem); diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index d4ff34b1f907e..ce200bd7a2846 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -424,9 +424,9 @@ class kernel_bundle_impl { std::transform(DeviceVec.begin(), DeviceVec.end(), IPVersionVec.begin(), [&](ur_device_handle_t d) { uint32_t ipVersion = 0; - Plugin->call( d, - UR_DEVICE_INFO_IP_VERSION, - sizeof(uint32_t), &ipVersion, nullptr); + Plugin->call( + d, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), + &ipVersion, nullptr); return ipVersion; }); return syclex::detail::OpenCLC_to_SPIRV(SourceStr, IPVersionVec, @@ -452,34 +452,36 @@ class kernel_bundle_impl { }(); ur_program_handle_t UrProgram = nullptr; - Plugin->call( ContextImpl->getHandleRef(), - spirv.data(), spirv.size(), nullptr, &UrProgram); + Plugin->call(ContextImpl->getHandleRef(), + spirv.data(), spirv.size(), + nullptr, &UrProgram); // program created by urProgramCreateWithIL is implicitly retained. std::string XsFlags = extractXsFlags(BuildOptions); - auto Res = - Plugin->call_nocheck( UrProgram, DeviceVec.size(), - DeviceVec.data(), XsFlags.c_str()); + auto Res = Plugin->call_nocheck( + UrProgram, DeviceVec.size(), DeviceVec.data(), XsFlags.c_str()); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), - UrProgram, XsFlags.c_str()); + Res = Plugin->call_nocheck( + ContextImpl->getHandleRef(), UrProgram, XsFlags.c_str()); } Plugin->checkUrResult(Res); // Get the number of kernels in the program. size_t NumKernels; - Plugin->call( UrProgram, UR_PROGRAM_INFO_NUM_KERNELS, - sizeof(size_t), &NumKernels, nullptr); + Plugin->call( + UrProgram, UR_PROGRAM_INFO_NUM_KERNELS, sizeof(size_t), &NumKernels, + nullptr); // Get the kernel names. size_t KernelNamesSize; - Plugin->call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, 0, - nullptr, &KernelNamesSize); + Plugin->call( + UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, 0, nullptr, &KernelNamesSize); // semi-colon delimited list of kernel names. std::string KernelNamesStr(KernelNamesSize, ' '); - Plugin->call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, - KernelNamesStr.size(), &KernelNamesStr[0], nullptr); + Plugin->call( + UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, KernelNamesStr.size(), + &KernelNamesStr[0], nullptr); std::vector KernelNames = detail::split_string(KernelNamesStr, ';'); @@ -531,7 +533,8 @@ class kernel_bundle_impl { ContextImplPtr ContextImpl = getSyclObjImpl(MContext); const PluginPtr &Plugin = ContextImpl->getPlugin(); ur_kernel_handle_t UrKernel = nullptr; - Plugin->call( UrProgram, AdjustedName.c_str(), &UrKernel); + Plugin->call(UrProgram, AdjustedName.c_str(), + &UrKernel); // Kernel created by urKernelCreate is implicitly retained. std::shared_ptr KernelImpl = std::make_shared( diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index 2204e007239f2..faf3695c04e94 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -26,8 +26,8 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr Context, MIsInterop(true), MKernelArgMaskPtr{ArgMask} { ur_context_handle_t UrContext = nullptr; // Using the plugin from the passed ContextImpl - getPlugin()->call( MKernel, UR_KERNEL_INFO_CONTEXT, - sizeof(UrContext), &UrContext, nullptr); + getPlugin()->call( + MKernel, UR_KERNEL_INFO_CONTEXT, sizeof(UrContext), &UrContext, nullptr); if (Context->getHandleRef() != UrContext) throw sycl::exception( make_error_code(errc::invalid), @@ -38,9 +38,9 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr Context, // For others, UR will turn this into a NOP. if (Context->getPlatformImpl()->supports_usm()) { bool EnableAccess = true; - getPlugin()->call( MKernel, - UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, - sizeof(ur_bool_t), nullptr, &EnableAccess); + getPlugin()->call( + MKernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), + nullptr, &EnableAccess); } } @@ -59,7 +59,7 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr ContextImpl, kernel_impl::~kernel_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call( MKernel); + getPlugin()->call(MKernel); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~kernel_impl", e); } diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 400326f26f05a..ab2950e26a856 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -74,9 +74,10 @@ class kernel_impl { /// /// \return a valid cl_kernel instance cl_kernel get() const { - getPlugin()->call( MKernel); + getPlugin()->call(MKernel); ur_native_handle_t nativeHandle = 0; - getPlugin()->call( MKernel, &nativeHandle); + getPlugin()->call(MKernel, + &nativeHandle); return ur::cast(nativeHandle); } @@ -134,10 +135,10 @@ class kernel_impl { const PluginPtr &Plugin = MContext->getPlugin(); if (MContext->getBackend() == backend::opencl) - Plugin->call( MKernel); + Plugin->call(MKernel); ur_native_handle_t NativeKernel = 0; - Plugin->call( MKernel, &NativeKernel); + Plugin->call(MKernel, &NativeKernel); return NativeKernel; } @@ -227,8 +228,8 @@ inline typename ext::oneapi::experimental::info::kernel_queue_specific:: const auto MaxWorkGroupSize = Queue.get_device().get_info(); uint32_t GroupCount = 0; - Plugin->call( Handle, - MaxWorkGroupSize, /* DynamicSharedMemorySize */ 0, &GroupCount); + Plugin->call( + Handle, MaxWorkGroupSize, /* DynamicSharedMemorySize */ 0, &GroupCount); return GroupCount; } diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index c10ef68770922..809a9dd25510e 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -31,15 +31,15 @@ get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { size_t ResultSize = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Kernel, UrInfoCode::value, 0, nullptr, - &ResultSize); + Plugin->call(Kernel, UrInfoCode::value, 0, + nullptr, &ResultSize); if (ResultSize == 0) { return ""; } std::vector Result(ResultSize); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Kernel, UrInfoCode::value, ResultSize, - Result.data(), nullptr); + Plugin->call(Kernel, UrInfoCode::value, + ResultSize, Result.data(), nullptr); return std::string(Result.data()); } @@ -50,8 +50,8 @@ get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { ur_result_t Result = UR_RESULT_SUCCESS; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Kernel, UrInfoCode::value, - sizeof(uint32_t), &Result, nullptr); + Plugin->call(Kernel, UrInfoCode::value, + sizeof(uint32_t), &Result, nullptr); return Result; } @@ -62,8 +62,8 @@ get_kernel_device_specific_info_helper(ur_kernel_handle_t Kernel, ur_device_handle_t Device, const PluginPtr &Plugin, void *Result, size_t Size) { - Plugin->call( Kernel, Device, - UrInfoCode::value, Size, Result, nullptr); + Plugin->call( + Kernel, Device, UrInfoCode::value, Size, Result, nullptr); } template @@ -71,8 +71,8 @@ typename std::enable_if::value>::type get_kernel_device_specific_info_helper( ur_kernel_handle_t Kernel, [[maybe_unused]] ur_device_handle_t Device, const PluginPtr &Plugin, void *Result, size_t Size) { - Plugin->call( Kernel, UrInfoCode::value, Size, Result, - nullptr); + Plugin->call(Kernel, UrInfoCode::value, + Size, Result, nullptr); } template @@ -82,9 +82,8 @@ get_kernel_device_specific_info_helper(ur_kernel_handle_t Kernel, ur_device_handle_t Device, const PluginPtr &Plugin, void *Result, size_t Size) { - ur_result_t Error = - Plugin->call_nocheck( Kernel, Device, - UrInfoCode::value, Size, Result, nullptr); + ur_result_t Error = Plugin->call_nocheck( + Kernel, Device, UrInfoCode::value, Size, Result, nullptr); if (Error != UR_RESULT_SUCCESS) kernel_get_group_info::handleErrorOrWarning(Error, UrInfoCode::value, Plugin); @@ -140,8 +139,9 @@ uint32_t get_kernel_device_specific_info_with_input(ur_kernel_handle_t Kernel, uint32_t Result = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Kernel, Device, - UrInfoCode::value, sizeof(uint32_t), &Result, nullptr); + Plugin->call( + Kernel, Device, UrInfoCode::value, sizeof(uint32_t), &Result, + nullptr); return Result; } diff --git a/sycl/source/detail/kernel_program_cache.hpp b/sycl/source/detail/kernel_program_cache.hpp index 6dcce7804cd85..f6e6bfc2cd250 100644 --- a/sycl/source/detail/kernel_program_cache.hpp +++ b/sycl/source/detail/kernel_program_cache.hpp @@ -102,7 +102,8 @@ class KernelProgramCache { ~ProgramBuildResult() { try { if (Val) { - ur_result_t Err = Plugin->call_nocheck( Val); + ur_result_t Err = + Plugin->call_nocheck(Val); __SYCL_CHECK_OCL_CODE_NO_EXC(Err); } } catch (std::exception &e) { @@ -140,7 +141,8 @@ class KernelProgramCache { ~KernelBuildResult() { try { if (Val.first) { - ur_result_t Err = Plugin->call_nocheck( Val.first); + ur_result_t Err = + Plugin->call_nocheck(Val.first); __SYCL_CHECK_OCL_CODE_NO_EXC(Err); } } catch (std::exception &e) { diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index f9ea65c4144c8..c4281e8df0013 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -128,7 +128,7 @@ static void waitForEvents(const std::vector &Events) { Events.begin(), Events.end(), UrEvents.begin(), [](const EventImplPtr &EventImpl) { return EventImpl->getHandle(); }); if (!UrEvents.empty() && UrEvents[0]) { - Plugin->call( UrEvents.size(), &UrEvents[0]); + Plugin->call(UrEvents.size(), &UrEvents[0]); } } } @@ -155,14 +155,15 @@ void memBufferCreateHelper(const PluginPtr &Plugin, ur_context_handle_t Ctx, // When doing buffer interop we don't know what device the memory should // be resident on, so pass nullptr for Device param. Buffer interop may // not be supported by all backends. - Plugin->call_nocheck( *RetMem, /*Dev*/ nullptr, - &Ptr); + Plugin->call_nocheck( + *RetMem, /*Dev*/ nullptr, &Ptr); emitMemAllocEndTrace(MemObjID, (uintptr_t)(Ptr), Size, 0 /* guard zone */, CorrID); }}; #endif if (Size) - Plugin->call( Ctx, Flags, Size, Props, RetMem); + Plugin->call(Ctx, Flags, Size, Props, + RetMem); } } @@ -181,8 +182,8 @@ void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { // When doing buffer interop we don't know what device the memory should be // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. - Plugin->call_nocheck( Mem, /*Dev*/ nullptr, - &PtrHandle); + Plugin->call_nocheck(Mem, /*Dev*/ nullptr, + &PtrHandle); Ptr = (uintptr_t)(PtrHandle); } #endif @@ -193,7 +194,7 @@ void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { xpti::utils::finally _{ [&] { emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call( Mem); + Plugin->call(Mem); } } @@ -215,8 +216,9 @@ void memBufferMapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, 0 /* guard zone */, CorrID); }}; #endif - Plugin->call( Queue, Buffer, Blocking, Flags, Offset, - Size, NumEvents, WaitList, Event, RetMap); + Plugin->call(Queue, Buffer, Blocking, Flags, + Offset, Size, NumEvents, + WaitList, Event, RetMap); } void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, @@ -239,12 +241,12 @@ void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, // Always use call_nocheck here, because call may throw an exception, // and this lambda will be called from destructor, which in combination // rewards us with UB. - Plugin->call_nocheck( 1, Event); + Plugin->call_nocheck(1, Event); emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call( Queue, Mem, MappedPtr, NumEvents, WaitList, - Event); + Plugin->call(Queue, Mem, MappedPtr, NumEvents, + WaitList, Event); } } @@ -317,7 +319,7 @@ void *MemoryManager::allocateInteropMemObject( // destruction if (nullptr != OutEventToWait) { const PluginPtr &Plugin = InteropEvent->getPlugin(); - Plugin->call( OutEventToWait); + Plugin->call(OutEventToWait); } return UserPtr; } @@ -342,8 +344,9 @@ void *MemoryManager::allocateImageObject(ContextImplPtr TargetContext, ur_mem_handle_t NewMem = nullptr; const PluginPtr &Plugin = TargetContext->getPlugin(); - Plugin->call( TargetContext->getHandleRef(), CreationFlags, - &Format, &Desc, UserPtr, &NewMem); + Plugin->call(TargetContext->getHandleRef(), + CreationFlags, &Format, &Desc, + UserPtr, &NewMem); return NewMem; } @@ -446,8 +449,9 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, SizeInBytes}; ur_mem_handle_t NewMem; const PluginPtr &Plugin = TargetContext->getPlugin(); - Error = Plugin->call_nocheck( ur::cast(ParentMemObj), - UR_MEM_FLAG_READ_WRITE, UR_BUFFER_CREATE_TYPE_REGION, &Region, &NewMem); + Error = Plugin->call_nocheck( + ur::cast(ParentMemObj), UR_MEM_FLAG_READ_WRITE, + UR_BUFFER_CREATE_TYPE_REGION, &Region, &NewMem); if (Error == UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET) throw detail::set_ur_error( exception(make_error_code(errc::invalid), @@ -521,10 +525,10 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, DstMem, - /*blocking_write=*/false, DstXOffBytes, - DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, - DepEvents.size(), DepEvents.data(), &OutEvent); + Plugin->call( + Queue, DstMem, + /*blocking_write=*/false, DstXOffBytes, DstAccessRangeWidthBytes, + SrcMem + SrcXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent); } else { size_t BufferRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes; size_t BufferSlicePitch = @@ -542,11 +546,11 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, DstMem, - /*blocking_write=*/false, BufferOffset, HostOffset, - RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, - HostSlicePitch, SrcMem, DepEvents.size(), DepEvents.data(), - &OutEvent); + Plugin->call( + Queue, DstMem, + /*blocking_write=*/false, BufferOffset, HostOffset, RectRegion, + BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, + SrcMem, DepEvents.size(), DepEvents.data(), &OutEvent); } } else { size_t InputRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes; @@ -560,10 +564,10 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, DstMem, - /*blocking_write=*/false, Origin, Region, InputRowPitch, - InputSlicePitch, SrcMem, DepEvents.size(), DepEvents.data(), - &OutEvent); + Plugin->call( + Queue, DstMem, + /*blocking_write=*/false, Origin, Region, InputRowPitch, + InputSlicePitch, SrcMem, DepEvents.size(), DepEvents.data(), &OutEvent); } } @@ -604,10 +608,10 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, SrcMem, - /*blocking_read=*/false, SrcXOffBytes, - SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, - DepEvents.size(), DepEvents.data(), &OutEvent); + Plugin->call( + Queue, SrcMem, + /*blocking_read=*/false, SrcXOffBytes, SrcAccessRangeWidthBytes, + DstMem + DstXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent); } else { size_t BufferRowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes; size_t BufferSlicePitch = @@ -625,11 +629,11 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, SrcMem, - /*blocking_read=*/false, BufferOffset, HostOffset, - RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, - HostSlicePitch, DstMem, DepEvents.size(), DepEvents.data(), - &OutEvent); + Plugin->call( + Queue, SrcMem, + /*blocking_read=*/false, BufferOffset, HostOffset, RectRegion, + BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, + DstMem, DepEvents.size(), DepEvents.data(), &OutEvent); } } else { size_t RowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes; @@ -643,9 +647,9 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, SrcMem, false, Offset, Region, - RowPitch, SlicePitch, DstMem, DepEvents.size(), - DepEvents.data(), &OutEvent); + Plugin->call( + Queue, SrcMem, false, Offset, Region, RowPitch, SlicePitch, DstMem, + DepEvents.size(), DepEvents.data(), &OutEvent); } } @@ -680,9 +684,10 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, SrcMem, DstMem, SrcXOffBytes, - DstXOffBytes, SrcAccessRangeWidthBytes, DepEvents.size(), - DepEvents.data(), &OutEvent); + Plugin->call( + Queue, SrcMem, DstMem, SrcXOffBytes, DstXOffBytes, + SrcAccessRangeWidthBytes, DepEvents.size(), DepEvents.data(), + &OutEvent); } else { // passing 0 for pitches not allowed. Because clEnqueueCopyBufferRect will // calculate both src and dest pitch using region[0], which is not correct @@ -705,10 +710,10 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, SrcMem, DstMem, SrcOrigin, - DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, - DstSlicePitch, DepEvents.size(), DepEvents.data(), - &OutEvent); + Plugin->call( + Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, SrcRowPitch, + SrcSlicePitch, DstRowPitch, DstSlicePitch, DepEvents.size(), + DepEvents.data(), &OutEvent); } } else { ur_rect_offset_t SrcOrigin{SrcOffset[SrcPos.XTerm], SrcOffset[SrcPos.YTerm], @@ -720,9 +725,9 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue, SrcMem, DstMem, SrcOrigin, - DstOrigin, Region, DepEvents.size(), DepEvents.data(), - &OutEvent); + Plugin->call( + Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, DepEvents.size(), + DepEvents.data(), &OutEvent); } } @@ -817,10 +822,10 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, size_t RangeMultiplier = AccRange[0] * AccRange[1] * AccRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call( Queue->getHandleRef(), - ur::cast(Mem), Pattern, PatternSize, - Offset[0] * ElementSize, RangeMultiplier * ElementSize, - DepEvents.size(), DepEvents.data(), &OutEvent); + Plugin->call( + Queue->getHandleRef(), ur::cast(Mem), Pattern, + PatternSize, Offset[0] * ElementSize, RangeMultiplier * ElementSize, + DepEvents.size(), DepEvents.data(), &OutEvent); return; } // The sycl::handler uses a parallel_for kernel in the case of unusable @@ -912,8 +917,9 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - SrcQueue->getPlugin()->call( SrcQueue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + SrcQueue->getPlugin()->call( + SrcQueue->getHandleRef(), DepEvents.size(), DepEvents.data(), + OutEvent); } return; } @@ -925,9 +931,10 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, const PluginPtr &Plugin = SrcQueue->getPlugin(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( SrcQueue->getHandleRef(), - /* blocking */ false, DstMem, SrcMem, Len, DepEvents.size(), - DepEvents.data(), OutEvent); + Plugin->call(SrcQueue->getHandleRef(), + /* blocking */ false, DstMem, + SrcMem, Len, DepEvents.size(), + DepEvents.data(), OutEvent); } void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, @@ -940,8 +947,8 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( Queue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; } @@ -952,9 +959,9 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( Queue->getHandleRef(), Mem, Pattern.size(), - Pattern.data(), Length, DepEvents.size(), DepEvents.data(), - OutEvent); + Plugin->call( + Queue->getHandleRef(), Mem, Pattern.size(), Pattern.data(), Length, + DepEvents.size(), DepEvents.data(), OutEvent); } void MemoryManager::prefetch_usm(void *Mem, QueueImplPtr Queue, size_t Length, @@ -965,8 +972,9 @@ void MemoryManager::prefetch_usm(void *Mem, QueueImplPtr Queue, size_t Length, const PluginPtr &Plugin = Queue->getPlugin(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue->getHandleRef(), Mem, Length, 0, - DepEvents.size(), DepEvents.data(), OutEvent); + Plugin->call(Queue->getHandleRef(), Mem, + Length, 0, DepEvents.size(), + DepEvents.data(), OutEvent); } void MemoryManager::advise_usm(const void *Mem, QueueImplPtr Queue, @@ -978,8 +986,8 @@ void MemoryManager::advise_usm(const void *Mem, QueueImplPtr Queue, const PluginPtr &Plugin = Queue->getPlugin(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( Queue->getHandleRef(), Mem, Length, Advice, - OutEvent); + Plugin->call(Queue->getHandleRef(), Mem, + Length, Advice, OutEvent); } void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, @@ -994,8 +1002,8 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( Queue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; } @@ -1007,17 +1015,19 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, const PluginPtr &Plugin = Queue->getPlugin(); bool SupportsUSMMemcpy2D = false; - Plugin->call( Queue->getContextImplPtr()->getHandleRef(), - UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, sizeof(bool), - &SupportsUSMMemcpy2D, nullptr); + Plugin->call( + Queue->getContextImplPtr()->getHandleRef(), + UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, sizeof(bool), &SupportsUSMMemcpy2D, + nullptr); if (SupportsUSMMemcpy2D) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); // Direct memcpy2D is supported so we use this function. - Plugin->call(Queue->getHandleRef(), - /*blocking=*/false, DstMem, DstPitch, SrcMem, SrcPitch, Width, - Height, DepEvents.size(), DepEvents.data(), OutEvent); + Plugin->call( + Queue->getHandleRef(), + /*blocking=*/false, DstMem, DstPitch, SrcMem, SrcPitch, Width, Height, + DepEvents.size(), DepEvents.data(), OutEvent); return; } @@ -1045,17 +1055,18 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, for (size_t I = 0; I < Height; ++I) { char *DstItBegin = static_cast(DstMem) + I * DstPitch; const char *SrcItBegin = static_cast(SrcMem) + I * SrcPitch; - Plugin->call( Queue->getHandleRef(), - /* blocking */ false, DstItBegin, SrcItBegin, Width, - DepEvents.size(), DepEvents.data(), CopyEvents.data() + I); + Plugin->call( + Queue->getHandleRef(), + /* blocking */ false, DstItBegin, SrcItBegin, Width, DepEvents.size(), + DepEvents.data(), CopyEvents.data() + I); CopyEventsManaged.emplace_back(CopyEvents[I], Plugin, /*TakeOwnership=*/true); } if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); // Then insert a wait to coalesce the copy events. - Queue->getPlugin()->call( Queue->getHandleRef(), - CopyEvents.size(), CopyEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), CopyEvents.size(), CopyEvents.data(), OutEvent); } void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, @@ -1070,8 +1081,8 @@ void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( Queue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; } @@ -1082,9 +1093,9 @@ void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call(Queue->getHandleRef(), DstMem, Pitch, - Pattern.size(), Pattern.data(), Width, Height, DepEvents.size(), - DepEvents.data(), OutEvent); + Plugin->call( + Queue->getHandleRef(), DstMem, Pitch, Pattern.size(), Pattern.data(), + Width, Height, DepEvents.size(), DepEvents.data(), OutEvent); } void MemoryManager::memset_2d_usm(void *DstMem, QueueImplPtr Queue, @@ -1099,8 +1110,8 @@ void MemoryManager::memset_2d_usm(void *DstMem, QueueImplPtr Queue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( Queue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; } @@ -1232,9 +1243,10 @@ memcpyToDeviceGlobalDirect(QueueImplPtr Queue, ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( Queue->getHandleRef(), - Program, DeviceGlobalEntry->MUniqueId.c_str(), false, NumBytes, - Offset, Src, DepEvents.size(), DepEvents.data(), OutEvent); + Plugin->call( + Queue->getHandleRef(), Program, DeviceGlobalEntry->MUniqueId.c_str(), + false, NumBytes, Offset, Src, DepEvents.size(), DepEvents.data(), + OutEvent); } static void @@ -1248,9 +1260,10 @@ memcpyFromDeviceGlobalDirect(QueueImplPtr Queue, ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( Queue->getHandleRef(), - Program, DeviceGlobalEntry->MUniqueId.c_str(), false, NumBytes, - Offset, Dest, DepEvents.size(), DepEvents.data(), OutEvent); + Plugin->call( + Queue->getHandleRef(), Program, DeviceGlobalEntry->MUniqueId.c_str(), + false, NumBytes, Offset, Dest, DepEvents.size(), DepEvents.data(), + OutEvent); } void MemoryManager::copy_to_device_global( @@ -1330,11 +1343,11 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - Plugin->call( CommandBuffer, - sycl::detail::ur::cast(SrcMem), - sycl::detail::ur::cast(DstMem), SrcXOffBytes, - DstXOffBytes, SrcAccessRangeWidthBytes, Deps.size(), - Deps.data(), OutSyncPoint); + Plugin->call( + CommandBuffer, sycl::detail::ur::cast(SrcMem), + sycl::detail::ur::cast(DstMem), SrcXOffBytes, + DstXOffBytes, SrcAccessRangeWidthBytes, Deps.size(), Deps.data(), + OutSyncPoint); } else { // passing 0 for pitches not allowed. Because clEnqueueCopyBufferRect will // calculate both src and dest pitch using region[0], which is not correct @@ -1356,11 +1369,11 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - Plugin->call( CommandBuffer, - sycl::detail::ur::cast(SrcMem), - sycl::detail::ur::cast(DstMem), SrcOrigin, - DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, - DstSlicePitch, Deps.size(), Deps.data(), OutSyncPoint); + Plugin->call( + CommandBuffer, sycl::detail::ur::cast(SrcMem), + sycl::detail::ur::cast(DstMem), SrcOrigin, DstOrigin, + Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, DstSlicePitch, + Deps.size(), Deps.data(), OutSyncPoint); } } @@ -1394,10 +1407,11 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - ur_result_t Result = Plugin->call_nocheck( CommandBuffer, - sycl::detail::ur::cast(SrcMem), SrcXOffBytes, - SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, Deps.size(), - Deps.data(), OutSyncPoint); + ur_result_t Result = + Plugin->call_nocheck( + CommandBuffer, sycl::detail::ur::cast(SrcMem), + SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, + Deps.size(), Deps.data(), OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( @@ -1422,10 +1436,12 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck( CommandBuffer, - sycl::detail::ur::cast(SrcMem), BufferOffset, - HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, - HostSlicePitch, DstMem, Deps.size(), Deps.data(), OutSyncPoint); + ur_result_t Result = Plugin->call_nocheck< + UrApiKind::urCommandBufferAppendMemBufferReadRectExp>( + CommandBuffer, sycl::detail::ur::cast(SrcMem), + BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, + HostRowPitch, HostSlicePitch, DstMem, Deps.size(), Deps.data(), + OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), @@ -1466,10 +1482,11 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - ur_result_t Result = Plugin->call_nocheck( CommandBuffer, - sycl::detail::ur::cast(DstMem), DstXOffBytes, - DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, Deps.size(), - Deps.data(), OutSyncPoint); + ur_result_t Result = + Plugin->call_nocheck( + CommandBuffer, sycl::detail::ur::cast(DstMem), + DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, + Deps.size(), Deps.data(), OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( @@ -1494,10 +1511,12 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( DstAccessRange[DstPos.YTerm], DstAccessRange[DstPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck( CommandBuffer, - sycl::detail::ur::cast(DstMem), BufferOffset, - HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, - HostSlicePitch, SrcMem, Deps.size(), Deps.data(), OutSyncPoint); + ur_result_t Result = Plugin->call_nocheck< + UrApiKind::urCommandBufferAppendMemBufferWriteRectExp>( + CommandBuffer, sycl::detail::ur::cast(DstMem), + BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, + HostRowPitch, HostSlicePitch, SrcMem, Deps.size(), Deps.data(), + OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( @@ -1519,8 +1538,10 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer( "NULL pointer argument in memory copy operation."); const PluginPtr &Plugin = Context->getPlugin(); - ur_result_t Result = Plugin->call_nocheck( CommandBuffer, DstMem, SrcMem, Len, - Deps.size(), Deps.data(), OutSyncPoint); + ur_result_t Result = + Plugin->call_nocheck( + CommandBuffer, DstMem, SrcMem, Len, Deps.size(), Deps.data(), + OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), @@ -1542,9 +1563,9 @@ void MemoryManager::ext_oneapi_fill_usm_cmd_buffer( "NULL pointer argument in memory fill operation."); const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( CommandBuffer, DstMem, - Pattern.data(), Pattern.size(), Len, Deps.size(), Deps.data(), - OutSyncPoint); + Plugin->call( + CommandBuffer, DstMem, Pattern.data(), Pattern.size(), Len, Deps.size(), + Deps.data(), OutSyncPoint); } void MemoryManager::ext_oneapi_fill_cmd_buffer( @@ -1572,10 +1593,10 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( size_t RangeMultiplier = AccessRange[0] * AccessRange[1] * AccessRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call( CommandBuffer, - ur::cast(Mem), Pattern, PatternSize, - AccessOffset[0] * ElementSize, RangeMultiplier * ElementSize, - Deps.size(), Deps.data(), OutSyncPoint); + Plugin->call( + CommandBuffer, ur::cast(Mem), Pattern, PatternSize, + AccessOffset[0] * ElementSize, RangeMultiplier * ElementSize, + Deps.size(), Deps.data(), OutSyncPoint); return; } // The sycl::handler uses a parallel_for kernel in the case of unusable @@ -1590,9 +1611,9 @@ void MemoryManager::ext_oneapi_prefetch_usm_cmd_buffer( std::vector Deps, ur_exp_command_buffer_sync_point_t *OutSyncPoint) { const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( CommandBuffer, Mem, Length, - ur_usm_migration_flags_t(0), Deps.size(), Deps.data(), - OutSyncPoint); + Plugin->call( + CommandBuffer, Mem, Length, ur_usm_migration_flags_t(0), Deps.size(), + Deps.data(), OutSyncPoint); } void MemoryManager::ext_oneapi_advise_usm_cmd_buffer( @@ -1602,8 +1623,9 @@ void MemoryManager::ext_oneapi_advise_usm_cmd_buffer( std::vector Deps, ur_exp_command_buffer_sync_point_t *OutSyncPoint) { const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( CommandBuffer, Mem, Length, - Advice, Deps.size(), Deps.data(), OutSyncPoint); + Plugin->call( + CommandBuffer, Mem, Length, Advice, Deps.size(), Deps.data(), + OutSyncPoint); } void MemoryManager::copy_image_bindless( @@ -1633,9 +1655,10 @@ void MemoryManager::copy_image_bindless( CopyRegion.srcOffset = SrcOffset; CopyRegion.dstOffset = DstOffset; - Plugin->call( Queue->getHandleRef(), Src, Dst, - &SrcDesc, &DstDesc, &SrcFormat, &DstFormat, &CopyRegion, Flags, - DepEvents.size(), DepEvents.data(), OutEvent); + Plugin->call( + Queue->getHandleRef(), Src, Dst, &SrcDesc, &DstDesc, &SrcFormat, + &DstFormat, &CopyRegion, Flags, DepEvents.size(), DepEvents.data(), + OutEvent); } } // namespace detail diff --git a/sycl/source/detail/persistent_device_code_cache.cpp b/sycl/source/detail/persistent_device_code_cache.cpp index 7600e16b2376c..7484ed00150e2 100644 --- a/sycl/source/detail/persistent_device_code_cache.cpp +++ b/sycl/source/detail/persistent_device_code_cache.cpp @@ -131,13 +131,14 @@ void PersistentDeviceCodeCache::putItemToDisc( unsigned int DeviceNum = 0; - Plugin->call( NativePrg, UR_PROGRAM_INFO_NUM_DEVICES, - sizeof(DeviceNum), &DeviceNum, nullptr); + Plugin->call( + NativePrg, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(DeviceNum), &DeviceNum, + nullptr); std::vector BinarySizes(DeviceNum); - Plugin->call( NativePrg, UR_PROGRAM_INFO_BINARY_SIZES, - sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), - nullptr); + Plugin->call( + NativePrg, UR_PROGRAM_INFO_BINARY_SIZES, + sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), nullptr); std::vector> Result; std::vector Pointers; @@ -146,8 +147,9 @@ void PersistentDeviceCodeCache::putItemToDisc( Pointers.push_back(Result[I].data()); } - Plugin->call( NativePrg, UR_PROGRAM_INFO_BINARIES, - sizeof(char *) * Pointers.size(), Pointers.data(), nullptr); + Plugin->call(NativePrg, UR_PROGRAM_INFO_BINARIES, + sizeof(char *) * Pointers.size(), + Pointers.data(), nullptr); size_t i = 0; std::string FileName; do { diff --git a/sycl/source/detail/physical_mem_impl.hpp b/sycl/source/detail/physical_mem_impl.hpp index d623ddfd18230..e31b5c36bfab8 100644 --- a/sycl/source/detail/physical_mem_impl.hpp +++ b/sycl/source/detail/physical_mem_impl.hpp @@ -43,8 +43,9 @@ class physical_mem_impl { MContext(getSyclObjImpl(SyclContext)), MNumBytes(NumBytes) { const PluginPtr &Plugin = MContext->getPlugin(); - auto Err = Plugin->call_nocheck( MContext->getHandleRef(), MDevice->getHandleRef(), - MNumBytes, nullptr, &MPhysicalMem); + auto Err = Plugin->call_nocheck( + MContext->getHandleRef(), MDevice->getHandleRef(), MNumBytes, nullptr, + &MPhysicalMem); if (Err == UR_RESULT_ERROR_OUT_OF_RESOURCES || Err == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) @@ -55,7 +56,7 @@ class physical_mem_impl { ~physical_mem_impl() noexcept(false) { const PluginPtr &Plugin = MContext->getPlugin(); - Plugin->call( MPhysicalMem); + Plugin->call(MPhysicalMem); } void *map(uintptr_t Ptr, size_t NumBytes, @@ -64,8 +65,9 @@ class physical_mem_impl { auto AccessFlags = AccessModeToVirtualAccessFlags(Mode); const PluginPtr &Plugin = MContext->getPlugin(); void *ResultPtr = reinterpret_cast(Ptr); - Plugin->call( MContext->getHandleRef(), ResultPtr, NumBytes, - MPhysicalMem, Offset, AccessFlags); + Plugin->call(MContext->getHandleRef(), + ResultPtr, NumBytes, MPhysicalMem, + Offset, AccessFlags); return ResultPtr; } diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index 3336afe6285fa..8cc068dfba7fa 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -64,8 +64,8 @@ platform_impl::getPlatformFromUrDevice(ur_device_handle_t UrDevice, ur_platform_handle_t Plt = nullptr; // TODO catch an exception and put it to list // of asynchronous exceptions - Plugin->call( UrDevice, UR_DEVICE_INFO_PLATFORM, sizeof(Plt), - &Plt, nullptr); + Plugin->call(UrDevice, UR_DEVICE_INFO_PLATFORM, + sizeof(Plt), &Plt, nullptr); return getOrMakePlatformImpl(Plt, Plugin); } @@ -198,8 +198,9 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, // Find out backend of the platform ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN; - MPlugin->call( MPlatform, UR_PLATFORM_INFO_BACKEND, - sizeof(ur_platform_backend_t), &UrBackend, nullptr); + MPlugin->call( + MPlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), + &UrBackend, nullptr); backend Backend = convertUrBackend(UrBackend); int InsertIDx = 0; @@ -209,8 +210,9 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, int DeviceNum = MPlugin->getStartingDeviceId(MPlatform); for (ur_device_handle_t Device : UrDevices) { ur_device_type_t UrDevType = UR_DEVICE_TYPE_ALL; - MPlugin->call( Device, UR_DEVICE_INFO_TYPE, - sizeof(ur_device_type_t), &UrDevType, nullptr); + MPlugin->call(Device, UR_DEVICE_INFO_TYPE, + sizeof(ur_device_type_t), + &UrDevType, nullptr); // Assumption here is that there is 1-to-1 mapping between UrDevType and // Sycl device type for GPU, CPU, and ACC. info::device_type DeviceType = info::device_type::all; @@ -461,8 +463,8 @@ platform_impl::get_devices(info::device_type DeviceType) const { uint32_t NumDevices = 0; MPlugin->call(MPlatform, UrDeviceType, - 0, // CP info::device_type::all - nullptr, &NumDevices); + 0, // CP info::device_type::all + nullptr, &NumDevices); const backend Backend = getBackend(); if (NumDevices == 0) { @@ -486,9 +488,10 @@ platform_impl::get_devices(info::device_type DeviceType) const { std::vector UrDevices(NumDevices); // TODO catch an exception and put it to list of asynchronous exceptions - MPlugin->call(MPlatform, - UrDeviceType, // CP info::device_type::all - NumDevices, UrDevices.data(), nullptr); + MPlugin->call( + MPlatform, + UrDeviceType, // CP info::device_type::all + NumDevices, UrDevices.data(), nullptr); // Some elements of UrDevices vector might be filtered out, so make a copy of // handles to do a cleanup later @@ -520,7 +523,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { // The reference counter for handles, that we used to create sycl objects, is // incremented, so we need to call release here. for (ur_device_handle_t &UrDev : UrDevicesToCleanUp) - MPlugin->call( UrDev); + MPlugin->call(UrDev); // If we aren't using ONEAPI_DEVICE_SELECTOR, then we are done. // and if there are no devices so far, there won't be any need to replace them @@ -549,7 +552,7 @@ bool platform_impl::supports_usm() const { ur_native_handle_t platform_impl::getNative() const { const auto &Plugin = getPlugin(); ur_native_handle_t Handle = 0; - Plugin->call( getHandleRef(), &Handle); + Plugin->call(getHandleRef(), &Handle); return Handle; } diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index 0edf5d5e74867..55b211c592a9d 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -42,9 +42,9 @@ class platform_impl { : MPlatform(APlatform), MPlugin(APlugin) { // Find out backend of the platform ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN; - APlugin->call_nocheck( APlatform, - UR_PLATFORM_INFO_BACKEND, - sizeof(ur_platform_backend_t), &UrBackend, nullptr); + APlugin->call_nocheck( + APlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), + &UrBackend, nullptr); MBackend = convertUrBackend(UrBackend); } @@ -92,14 +92,17 @@ class platform_impl { void getBackendOption(const char *frontend_option, const char **backend_option) const { const auto &Plugin = getPlugin(); - ur_result_t Err = Plugin->call_nocheck( MPlatform, frontend_option, backend_option); + ur_result_t Err = + Plugin->call_nocheck( + MPlatform, frontend_option, backend_option); Plugin->checkUrResult(Err); } /// \return an instance of OpenCL cl_platform_id. cl_platform_id get() const { ur_native_handle_t nativeHandle = 0; - getPlugin()->call( MPlatform, &nativeHandle); + getPlugin()->call(MPlatform, + &nativeHandle); return ur::cast(nativeHandle); } diff --git a/sycl/source/detail/platform_info.hpp b/sycl/source/detail/platform_info.hpp index d2f79116ef638..11a7636c3f597 100644 --- a/sycl/source/detail/platform_info.hpp +++ b/sycl/source/detail/platform_info.hpp @@ -24,14 +24,15 @@ inline std::string get_platform_info_string_impl(ur_platform_handle_t Plt, ur_platform_info_t UrCode) { size_t ResultSize = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Plt, UrCode, 0, nullptr, &ResultSize); + Plugin->call(Plt, UrCode, 0, nullptr, + &ResultSize); if (ResultSize == 0) { return ""; } std::unique_ptr Result(new char[ResultSize]); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( Plt, UrCode, ResultSize, Result.get(), - nullptr); + Plugin->call(Plt, UrCode, ResultSize, + Result.get(), nullptr); return Result.get(); } // The platform information methods diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/plugin.hpp index 9dd0b9a8e72ae..01f07128cdcf2 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -73,7 +73,8 @@ class plugin { const char *message = nullptr; if (ur_result == UR_RESULT_ERROR_ADAPTER_SPECIFIC) { int32_t adapter_error = 0; - ur_result = call_nocheck(MAdapter, &message, &adapter_error); + ur_result = call_nocheck( + MAdapter, &message, &adapter_error); // If the warning level is greater then 2 emit the message if (detail::SYCLConfig::get() >= 2) { @@ -101,8 +102,8 @@ class plugin { uint32_t platformCount = 0; call(&MAdapter, 1, 0, nullptr, &platformCount); UrPlatforms.resize(platformCount); - call(&MAdapter, 1, platformCount, UrPlatforms.data(), - nullptr); + call(&MAdapter, 1, platformCount, + UrPlatforms.data(), nullptr); // We need one entry in this per platform LastDeviceIds.resize(platformCount); }); @@ -245,7 +246,7 @@ class plugin { // index of this vector corresponds to the index in UrPlatforms vector. std::vector LastDeviceIds; #ifdef _WIN32 - void* UrLoaderHandle = nullptr; + void *UrLoaderHandle = nullptr; #endif }; // class plugin diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index fc8aa70efaf2e..48ab81dcb1fbe 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -63,7 +63,8 @@ static void enableITTAnnotationsIfNeeded(const ur_program_handle_t &Prog, constexpr char SpecValue = 1; ur_specialization_constant_info_t SpecConstInfo = { ITTSpecConstId, sizeof(char), &SpecValue}; - Plugin->call( Prog, 1, &SpecConstInfo); + Plugin->call( + Prog, 1, &SpecConstInfo); } } @@ -78,9 +79,10 @@ createBinaryProgram(const ContextImplPtr Context, const device &Device, const PluginPtr &Plugin = Context->getPlugin(); #ifndef _NDEBUG uint32_t NumDevices = 0; - Plugin->call( Context->getHandleRef(), - UR_CONTEXT_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, - /*param_value_size_ret=*/nullptr); + Plugin->call(Context->getHandleRef(), + UR_CONTEXT_INFO_NUM_DEVICES, + sizeof(NumDevices), &NumDevices, + /*param_value_size_ret=*/nullptr); assert(NumDevices > 0 && "Only a single device is supported for AOT compilation"); #endif @@ -93,8 +95,8 @@ createBinaryProgram(const ContextImplPtr Context, const device &Device, Properties.pNext = nullptr; Properties.count = Metadata.size(); Properties.pMetadatas = Metadata.data(); - Plugin->call( Context->getHandleRef(), UrDevice, - DataLen, Data, &Properties, &Program); + Plugin->call( + Context->getHandleRef(), UrDevice, DataLen, Data, &Properties, &Program); if (BinaryStatus != UR_RESULT_SUCCESS) { throw detail::set_ur_error( @@ -111,8 +113,8 @@ static ur_program_handle_t createSpirvProgram(const ContextImplPtr Context, size_t DataLen) { ur_program_handle_t Program = nullptr; const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( Context->getHandleRef(), Data, DataLen, - nullptr, &Program); + Plugin->call(Context->getHandleRef(), Data, + DataLen, nullptr, &Program); return Program; } @@ -567,9 +569,9 @@ static bool compatibleWithDevice(RTDeviceBinaryImage *BinImage, ur_device_binary_t UrBinary{}; UrBinary.pDeviceTargetSpec = getUrDeviceTarget(DevBin->DeviceTargetSpec); - ur_result_t Error = - Plugin->call_nocheck( URDeviceHandle, &UrBinary, - /*num bin images = */ (uint32_t)1, &SuitableImageID); + ur_result_t Error = Plugin->call_nocheck( + URDeviceHandle, &UrBinary, + /*num bin images = */ (uint32_t)1, &SuitableImageID); if (Error != UR_RESULT_SUCCESS && Error != UR_RESULT_ERROR_INVALID_BINARY) throw detail::set_ur_error(exception(make_error_code(errc::runtime), "Invalid binary image or device"), @@ -722,8 +724,8 @@ setSpecializationConstants(const std::shared_ptr &InputImpl, ur_specialization_constant_info_t SpecConstInfo = { SpecIDDesc.ID, SpecIDDesc.Size, SpecConsts.data() + SpecIDDesc.BlobOffset}; - Plugin->call( Prog, 1, - &SpecConstInfo); + Plugin->call( + Prog, 1, &SpecConstInfo); } } } @@ -757,10 +759,9 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( } ur_bool_t MustBuildOnSubdevice = true; - ContextImpl->getPlugin()->call( RootDevImpl->getHandleRef(), - UR_DEVICE_INFO_BUILD_ON_SUBDEVICE, - sizeof(ur_bool_t), &MustBuildOnSubdevice, - nullptr); + ContextImpl->getPlugin()->call( + RootDevImpl->getHandleRef(), UR_DEVICE_INFO_BUILD_ON_SUBDEVICE, + sizeof(ur_bool_t), &MustBuildOnSubdevice, nullptr); DeviceImplPtr Dev = (MustBuildOnSubdevice == true) ? DeviceImpl : RootDevImpl; auto Context = createSyclObjFromImpl(ContextImpl); @@ -802,8 +803,10 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( enableITTAnnotationsIfNeeded(NativePrg, Plugin); } - UrFuncInfo programReleaseInfo;; - auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo programReleaseInfo; + ; + auto programRelease = + programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); ProgramPtr ProgramManaged(NativePrg, programRelease); // Link a fallback implementation of device libraries if they are not @@ -847,7 +850,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( SYCL_DEVICE_BINARY_TYPE_SPIRV); // Those extra programs won't be used anymore, just the final linked result for (ur_program_handle_t Prg : ProgramsToLink) - Plugin->call( Prg); + Plugin->call(Prg); emitBuiltProgramInfo(BuiltProgram.get(), ContextImpl); @@ -898,7 +901,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( bool DidInsert = Cache.insertBuiltProgram(CacheKey, ResProgram); if (DidInsert) { // For every cached copy of the program, we need to increment its refcount - Plugin->call( ResProgram); + Plugin->call(ResProgram); } } @@ -906,7 +909,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // program. - ContextImpl->getPlugin()->call( ResProgram); + ContextImpl->getPlugin()->call(ResProgram); return ResProgram; } @@ -945,9 +948,9 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, // Pulling a copy of a kernel and program from the cache, // so we need to retain those resources. ContextImpl->getPlugin()->call( - std::get(ret_tuple)); + std::get(ret_tuple)); ContextImpl->getPlugin()->call( - std::get(ret_tuple)); + std::get(ret_tuple)); return ret_tuple; } } @@ -967,9 +970,9 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, // Some UR Plugins (like OpenCL) require this call to enable USM // For others, UR will turn this into a NOP. const ur_bool_t UrTrue = true; - Plugin->call( Kernel, - UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), - nullptr, &UrTrue); + Plugin->call( + Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), + nullptr, &UrTrue); } const KernelArgMask *ArgMask = nullptr; @@ -1001,7 +1004,8 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // kernel. - ContextImpl->getPlugin()->call( KernelArgMaskPair.first); + ContextImpl->getPlugin()->call( + KernelArgMaskPair.first); Cache.saveKernel(key, ret_val); return ret_val; } @@ -1011,8 +1015,9 @@ ProgramManager::getUrProgramFromUrKernel(ur_kernel_handle_t Kernel, const ContextImplPtr Context) { ur_program_handle_t Program; const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( Kernel, UR_KERNEL_INFO_PROGRAM, - sizeof(ur_program_handle_t), &Program, nullptr); + Plugin->call(Kernel, UR_KERNEL_INFO_PROGRAM, + sizeof(ur_program_handle_t), + &Program, nullptr); return Program; } @@ -1021,36 +1026,38 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, const ContextImplPtr Context) { size_t URDevicesSize = 0; const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( Program, UR_PROGRAM_INFO_DEVICES, 0, nullptr, - &URDevicesSize); + Plugin->call(Program, UR_PROGRAM_INFO_DEVICES, 0, + nullptr, &URDevicesSize); std::vector URDevices(URDevicesSize / sizeof(ur_device_handle_t)); - Plugin->call( Program, UR_PROGRAM_INFO_DEVICES, - URDevicesSize, URDevices.data(), nullptr); + Plugin->call(Program, UR_PROGRAM_INFO_DEVICES, + URDevicesSize, URDevices.data(), + nullptr); std::string Log = "The program was built for " + std::to_string(URDevices.size()) + " devices"; for (ur_device_handle_t &Device : URDevices) { std::string DeviceBuildInfoString; size_t DeviceBuildInfoStrSize = 0; - Plugin->call( Program, Device, - UR_PROGRAM_BUILD_INFO_LOG, 0, nullptr, - &DeviceBuildInfoStrSize); + Plugin->call( + Program, Device, UR_PROGRAM_BUILD_INFO_LOG, 0, nullptr, + &DeviceBuildInfoStrSize); if (DeviceBuildInfoStrSize > 0) { std::vector DeviceBuildInfo(DeviceBuildInfoStrSize); - Plugin->call( Program, Device, - UR_PROGRAM_BUILD_INFO_LOG, DeviceBuildInfoStrSize, - DeviceBuildInfo.data(), nullptr); + Plugin->call( + Program, Device, UR_PROGRAM_BUILD_INFO_LOG, DeviceBuildInfoStrSize, + DeviceBuildInfo.data(), nullptr); DeviceBuildInfoString = std::string(DeviceBuildInfo.data()); } std::string DeviceNameString; size_t DeviceNameStrSize = 0; - Plugin->call( Device, UR_DEVICE_INFO_NAME, 0, nullptr, - &DeviceNameStrSize); + Plugin->call(Device, UR_DEVICE_INFO_NAME, 0, + nullptr, &DeviceNameStrSize); if (DeviceNameStrSize > 0) { std::vector DeviceName(DeviceNameStrSize); - Plugin->call( Device, UR_DEVICE_INFO_NAME, - DeviceNameStrSize, DeviceName.data(), nullptr); + Plugin->call(Device, UR_DEVICE_INFO_NAME, + DeviceNameStrSize, + DeviceName.data(), nullptr); DeviceNameString = std::string(DeviceName.data()); } Log += "\nBuild program log for '" + DeviceNameString + "':\n" + @@ -1151,10 +1158,11 @@ static ur_result_t doCompile(const PluginPtr &Plugin, const char *Opts) { // Try to compile with given devices, fall back to compiling with the program // context if unsupported by the adapter - auto Result = - Plugin->call_nocheck( Program, NumDevs, Devs, Opts); + auto Result = Plugin->call_nocheck( + Program, NumDevs, Devs, Opts); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - return Plugin->call_nocheck( Ctx, Program, Opts); + return Plugin->call_nocheck(Ctx, Program, + Opts); } return Result; } @@ -1334,8 +1342,9 @@ RTDeviceBinaryImage *getBinImageFromMultiMap( uint32_t ImgInd = 0; // Ask the native runtime under the given context to choose the device image // it prefers. - getSyclObjImpl(Context)->getPlugin()->call( getSyclObjImpl(Device)->getHandleRef(), - UrBinaries.data(), UrBinaries.size(), &ImgInd); + getSyclObjImpl(Context)->getPlugin()->call( + getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), + UrBinaries.size(), &ImgInd); return DeviceFilteredImgs[ImgInd]; } @@ -1418,8 +1427,9 @@ RTDeviceBinaryImage &ProgramManager::getDeviceImage( getUrDeviceTarget(RawImgs[BinaryCount]->DeviceTargetSpec); } - getSyclObjImpl(Context)->getPlugin()->call( getSyclObjImpl(Device)->getHandleRef(), - UrBinaries.data(), UrBinaries.size(), &ImgInd); + getSyclObjImpl(Context)->getPlugin()->call( + getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), + UrBinaries.size(), &ImgInd); ImageIterator = ImageSet.begin(); std::advance(ImageIterator, ImgInd); @@ -1547,12 +1557,12 @@ ProgramManager::ProgramPtr ProgramManager::build( const std::string &Options = LinkOptions.empty() ? CompileOptions : (CompileOptions + " " + LinkOptions); - ur_result_t Error = - Plugin->call_nocheck( Program.get(), - /*num devices =*/1, &Device, Options.c_str()); + ur_result_t Error = Plugin->call_nocheck( + Program.get(), + /*num devices =*/1, &Device, Options.c_str()); if (Error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Error = Plugin->call_nocheck( Context->getHandleRef(), - Program.get(), Options.c_str()); + Error = Plugin->call_nocheck( + Context->getHandleRef(), Program.get(), Options.c_str()); } if (Error != UR_RESULT_SUCCESS) @@ -1583,14 +1593,14 @@ ProgramManager::ProgramPtr ProgramManager::build( ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck( Context->getHandleRef(), - /*num devices =*/1, &Device, - LinkPrograms.size(), LinkPrograms.data(), - LinkOptions.c_str(), &LinkedProg); + auto Res = Plugin->call_nocheck( + Context->getHandleRef(), + /*num devices =*/1, &Device, LinkPrograms.size(), LinkPrograms.data(), + LinkOptions.c_str(), &LinkedProg); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( Context->getHandleRef(), - LinkPrograms.size(), LinkPrograms.data(), - LinkOptions.c_str(), &LinkedProg); + Res = Plugin->call_nocheck( + Context->getHandleRef(), LinkPrograms.size(), LinkPrograms.data(), + LinkOptions.c_str(), &LinkedProg); } return Res; }; @@ -2405,13 +2415,14 @@ ProgramManager::link(const device_image_plain &DeviceImage, ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), URDevices.size(), - URDevices.data(), URPrograms.size(), URPrograms.data(), - LinkOptionsStr.c_str(), &LinkedProg); + auto Res = Plugin->call_nocheck( + ContextImpl->getHandleRef(), URDevices.size(), URDevices.data(), + URPrograms.size(), URPrograms.data(), LinkOptionsStr.c_str(), + &LinkedProg); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( ContextImpl->getHandleRef(), - URPrograms.size(), URPrograms.data(), - LinkOptionsStr.c_str(), &LinkedProg); + Res = Plugin->call_nocheck( + ContextImpl->getHandleRef(), URPrograms.size(), URPrograms.data(), + LinkOptionsStr.c_str(), &LinkedProg); } return Res; }; @@ -2543,8 +2554,10 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, InputImpl->get_bin_image_ref()->supportsSpecConstants()) setSpecializationConstants(InputImpl, NativePrg, Plugin); - UrFuncInfo programReleaseInfo;; - auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo programReleaseInfo; + ; + auto programRelease = + programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); ProgramPtr ProgramManaged(NativePrg, programRelease); // Link a fallback implementation of device libraries if they are not @@ -2615,7 +2628,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // other devices. const PluginPtr &Plugin = ContextImpl->getPlugin(); auto CacheOtherDevices = [ResProgram, &Plugin]() { - Plugin->call( ResProgram); + Plugin->call(ResProgram); return ResProgram; }; @@ -2635,7 +2648,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // devive_image_impl shares ownership of PIProgram with, at least, program // cache. The ref counter will be descremented in the destructor of // device_image_impl - Plugin->call( ResProgram); + Plugin->call(ResProgram); DeviceImageImplPtr ExecImpl = std::make_shared( InputImpl->get_bin_image_ref(), Context, Devs, bundle_state::executable, @@ -2664,14 +2677,15 @@ ProgramManager::getOrCreateKernel(const context &Context, ur_kernel_handle_t Kernel = nullptr; const PluginPtr &Plugin = Ctx->getPlugin(); - Plugin->call( Program, KernelName.c_str(), &Kernel); + Plugin->call(Program, KernelName.c_str(), + &Kernel); // Only set UR_USM_INDIRECT_ACCESS if the platform can handle it. if (Ctx->getPlatformImpl()->supports_usm()) { bool EnableAccess = true; - Plugin->call( Kernel, - UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), - nullptr, &EnableAccess); + Plugin->call( + Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), + nullptr, &EnableAccess); } // Ignore possible m_UseSpvFile for now. @@ -2701,7 +2715,7 @@ ProgramManager::getOrCreateKernel(const context &Context, // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // kernel. - Ctx->getPlugin()->call( BuildResult->Val.first); + Ctx->getPlugin()->call(BuildResult->Val.first); return std::make_tuple(BuildResult->Val.first, &(BuildResult->MBuildResultMutex), BuildResult->Val.second); @@ -2755,8 +2769,10 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( auto Program = createURProgram(Img, Context, Device); auto DeviceImpl = detail::getSyclObjImpl(Device); auto &Plugin = DeviceImpl->getPlugin(); - UrFuncInfo programReleaseInfo;; - auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo programReleaseInfo; + ; + auto programRelease = + programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); ProgramPtr ProgramManaged(Program, programRelease); std::string CompileOpts; diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 0ebd7d7f7ffe1..686ebba4c67a7 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -59,8 +59,9 @@ getUrEvents(const std::vector &DepEvents) { template <> uint32_t queue_impl::get_info() const { ur_result_t result = UR_RESULT_SUCCESS; - getPlugin()->call( MQueues[0], UR_QUEUE_INFO_REFERENCE_COUNT, - sizeof(result), &result, nullptr); + getPlugin()->call( + MQueues[0], UR_QUEUE_INFO_REFERENCE_COUNT, sizeof(result), &result, + nullptr); return result; } @@ -613,7 +614,7 @@ void queue_impl::wait(const detail::code_location &CodeLoc) { } if (SupportsPiFinish) { const PluginPtr &Plugin = getPlugin(); - Plugin->call( getHandleRef()); + Plugin->call(getHandleRef()); assert(SharedEvents.empty() && "Queues that support calling piQueueFinish " "shouldn't have shared events"); } else { @@ -695,13 +696,14 @@ void queue_impl::destructorNotification() { ur_native_handle_t queue_impl::getNative(int32_t &NativeHandleDesc) const { const PluginPtr &Plugin = getPlugin(); if (getContextImplPtr()->getBackend() == backend::opencl) - Plugin->call( MQueues[0]); + Plugin->call(MQueues[0]); ur_native_handle_t Handle{}; ur_queue_native_desc_t UrNativeDesc{UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC, nullptr, nullptr}; UrNativeDesc.pNativeData = &NativeHandleDesc; - Plugin->call( MQueues[0], &UrNativeDesc, &Handle); + Plugin->call(MQueues[0], &UrNativeDesc, + &Handle); return Handle; } @@ -731,8 +733,8 @@ bool queue_impl::ext_oneapi_empty() const { // Check the status of the backend queue if this is not a host queue. ur_bool_t IsReady = false; - getPlugin()->call( MQueues[0], UR_QUEUE_INFO_EMPTY, - sizeof(IsReady), &IsReady, nullptr); + getPlugin()->call( + MQueues[0], UR_QUEUE_INFO_EMPTY, sizeof(IsReady), &IsReady, nullptr); if (!IsReady) return false; diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 0727b6910af44..cf21a66adb4e2 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -196,8 +196,8 @@ class queue_impl { ur_device_handle_t DeviceUr{}; const PluginPtr &Plugin = getPlugin(); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( MQueues[0], UR_QUEUE_INFO_DEVICE, - sizeof(DeviceUr), &DeviceUr, nullptr); + Plugin->call( + MQueues[0], UR_QUEUE_INFO_DEVICE, sizeof(DeviceUr), &DeviceUr, nullptr); MDevice = MContext->findMatchingDeviceImpl(DeviceUr); if (MDevice == nullptr) { throw sycl::exception( @@ -262,7 +262,7 @@ class queue_impl { #endif throw_asynchronous(); cleanup_fusion_cmd(); - getPlugin()->call( MQueues[0]); + getPlugin()->call(MQueues[0]); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~queue_impl", e); } @@ -271,10 +271,10 @@ class queue_impl { /// \return an OpenCL interoperability queue handle. cl_command_queue get() { - getPlugin()->call( MQueues[0]); + getPlugin()->call(MQueues[0]); ur_native_handle_t nativeHandle = 0; - getPlugin()->call( MQueues[0], nullptr, - &nativeHandle); + getPlugin()->call(MQueues[0], nullptr, + &nativeHandle); return ur::cast(nativeHandle); } @@ -321,7 +321,7 @@ class queue_impl { "recording to a command graph."); } for (const auto &queue : MQueues) { - getPlugin()->call( queue); + getPlugin()->call(queue); } } @@ -513,8 +513,8 @@ class queue_impl { .get_index(); Properties.pNext = &IndexProperties; } - ur_result_t Error = Plugin->call_nocheck( Context, Device, - &Properties, &Queue); + ur_result_t Error = Plugin->call_nocheck( + Context, Device, &Properties, &Queue); // If creating out-of-order queue failed and this property is not // supported (for example, on FPGA), it will return @@ -556,7 +556,7 @@ class queue_impl { if (!ReuseQueue) *PIQ = createQueue(QueueOrder::Ordered); else - getPlugin()->call( *PIQ); + getPlugin()->call(*PIQ); return *PIQ; } @@ -739,7 +739,7 @@ class queue_impl { auto ResEvent = std::make_shared(Handler.MQueue); ur_event_handle_t UREvent = nullptr; getPlugin()->call( - Handler.MQueue->getHandleRef(), 0, nullptr, &UREvent); + Handler.MQueue->getHandleRef(), 0, nullptr, &UREvent); ResEvent->setHandle(UREvent); return ResEvent; } diff --git a/sycl/source/detail/sampler_impl.cpp b/sycl/source/detail/sampler_impl.cpp index 779d207031dbf..cb3e69b6a9a1a 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -25,21 +25,23 @@ sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { const PluginPtr &Plugin = getSyclObjImpl(syclContext)->getPlugin(); ur_sampler_handle_t Sampler{}; Plugin->call( - reinterpret_cast(clSampler), - getSyclObjImpl(syclContext)->getHandleRef(), nullptr, &Sampler); + reinterpret_cast(clSampler), + getSyclObjImpl(syclContext)->getHandleRef(), nullptr, &Sampler); MContextToSampler[syclContext] = Sampler; bool NormalizedCoords; - Plugin->call( Sampler, UR_SAMPLER_INFO_NORMALIZED_COORDS, - sizeof(ur_bool_t), &NormalizedCoords, nullptr); + Plugin->call( + Sampler, UR_SAMPLER_INFO_NORMALIZED_COORDS, sizeof(ur_bool_t), + &NormalizedCoords, nullptr); MCoordNormMode = NormalizedCoords ? coordinate_normalization_mode::normalized : coordinate_normalization_mode::unnormalized; ur_sampler_addressing_mode_t AddrMode; - Plugin->call( Sampler, UR_SAMPLER_INFO_ADDRESSING_MODE, - sizeof(ur_sampler_addressing_mode_t), &AddrMode, nullptr); + Plugin->call( + Sampler, UR_SAMPLER_INFO_ADDRESSING_MODE, + sizeof(ur_sampler_addressing_mode_t), &AddrMode, nullptr); switch (AddrMode) { case UR_SAMPLER_ADDRESSING_MODE_CLAMP: MAddrMode = addressing_mode::clamp; @@ -60,8 +62,9 @@ sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { } ur_sampler_filter_mode_t FiltMode; - Plugin->call( Sampler, UR_SAMPLER_INFO_FILTER_MODE, - sizeof(ur_sampler_filter_mode_t), &FiltMode, nullptr); + Plugin->call( + Sampler, UR_SAMPLER_INFO_FILTER_MODE, sizeof(ur_sampler_filter_mode_t), + &FiltMode, nullptr); switch (FiltMode) { case UR_SAMPLER_FILTER_MODE_LINEAR: MFiltMode = filtering_mode::linear; @@ -80,7 +83,7 @@ sampler_impl::~sampler_impl() { // TODO catch an exception and add it to the list of asynchronous // exceptions const PluginPtr &Plugin = getSyclObjImpl(Iter.first)->getPlugin(); - Plugin->call( Iter.second); + Plugin->call(Iter.second); } } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~sample_impl", e); @@ -130,8 +133,7 @@ ur_sampler_handle_t sampler_impl::getOrCreateSampler(const context &Context) { const PluginPtr &Plugin = getSyclObjImpl(Context)->getPlugin(); errcode_ret = Plugin->call_nocheck( - getSyclObjImpl(Context)->getHandleRef(), - &desc, &resultSampler); + getSyclObjImpl(Context)->getHandleRef(), &desc, &resultSampler); if (errcode_ret == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) throw sycl::exception(sycl::errc::feature_not_supported, diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index e9e7a6eb4809d..dde2aa21af75d 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -354,8 +354,8 @@ class DispatchHostTask { if (RawEvents.size() == 0) continue; try { - PluginWithEvents.first->call( RawEvents.size(), - RawEvents.data()); + PluginWithEvents.first->call(RawEvents.size(), + RawEvents.data()); } catch (const sycl::exception &) { MThisCmd->MEvent->getSubmittedQueue()->reportAsyncException( std::current_exception()); @@ -439,9 +439,9 @@ class DispatchHostTask { // // This entry point is needed in order to migrate memory across // devices in the same context for CUDA and HIP backends - Queue->getPlugin()->call( HostTask.MQueue->getHandleRef(), - InteropFreeFunc, &CustomOpData, MReqUrMem.size(), - MReqUrMem.data(), nullptr, 0, nullptr, nullptr); + Queue->getPlugin()->call( + HostTask.MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData, + MReqUrMem.size(), MReqUrMem.data(), nullptr, 0, nullptr, nullptr); } else { HostTask.MHostTask->call(MThisCmd->MEvent->getHostProfilingInfo(), IH); @@ -533,8 +533,8 @@ void Command::waitForEvents(QueueImplPtr Queue, std::vector RawEvents = getUrEvents(CtxWithEvents.second); if (!RawEvents.empty()) { - CtxWithEvents.first->getPlugin()->call( RawEvents.size(), - RawEvents.data()); + CtxWithEvents.first->getPlugin()->call( + RawEvents.size(), RawEvents.data()); } } } else { @@ -544,8 +544,8 @@ void Command::waitForEvents(QueueImplPtr Queue, if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( Queue->getHandleRef(), RawEvents.size(), - &RawEvents[0], &Event); + Plugin->call( + Queue->getHandleRef(), RawEvents.size(), &RawEvents[0], &Event); } } } @@ -2284,17 +2284,17 @@ void SetArgBasedOnType( ur_kernel_arg_mem_obj_properties_t MemObjData{}; MemObjData.stype = UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES; MemObjData.memoryAccess = AccessModeToUr(Req->MAccessMode); - Plugin->call( Kernel, NextTrueIndex, &MemObjData, - MemArg); + Plugin->call(Kernel, NextTrueIndex, + &MemObjData, MemArg); break; } case kernel_param_kind_t::kind_std_layout: { if (Arg.MPtr) { - Plugin->call( Kernel, NextTrueIndex, Arg.MSize, - nullptr, Arg.MPtr); + Plugin->call( + Kernel, NextTrueIndex, Arg.MSize, nullptr, Arg.MPtr); } else { - Plugin->call( Kernel, NextTrueIndex, Arg.MSize, - nullptr); + Plugin->call(Kernel, NextTrueIndex, + Arg.MSize, nullptr); } break; @@ -2304,15 +2304,16 @@ void SetArgBasedOnType( ur_sampler_handle_t Sampler = (ur_sampler_handle_t)detail::getSyclObjImpl(*SamplerPtr) ->getOrCreateSampler(Context); - Plugin->call( Kernel, NextTrueIndex, nullptr, - Sampler); + Plugin->call(Kernel, NextTrueIndex, + nullptr, Sampler); break; } case kernel_param_kind_t::kind_pointer: { // We need to de-rerence this to get the actual USM allocation - that's the // pointer UR is expecting. const void *Ptr = *static_cast(Arg.MPtr); - Plugin->call( Kernel, NextTrueIndex, nullptr, Ptr); + Plugin->call(Kernel, NextTrueIndex, + nullptr, Ptr); break; } case kernel_param_kind_t::kind_specialization_constants_buffer: { @@ -2324,8 +2325,8 @@ void SetArgBasedOnType( MemObjProps.pNext = nullptr; MemObjProps.stype = UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES; MemObjProps.memoryAccess = UR_MEM_FLAG_READ_ONLY; - Plugin->call( Kernel, NextTrueIndex, &MemObjProps, - SpecConstsBuffer); + Plugin->call( + Kernel, NextTrueIndex, &MemObjProps, SpecConstsBuffer); break; } case kernel_param_kind_t::kind_invalid: @@ -2378,11 +2379,11 @@ static ur_result_t SetKernelParamsAndLaunch( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( Kernel, - Queue->getDeviceImplPtr()->getHandleRef(), - UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, - sizeof(RequiredWGSize), RequiredWGSize, - /* pPropSizeRet = */ nullptr); + Plugin->call( + Kernel, Queue->getDeviceImplPtr()->getHandleRef(), + UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), + RequiredWGSize, + /* pPropSizeRet = */ nullptr); const bool EnforcedLocalSize = (RequiredWGSize[0] != 0 || RequiredWGSize[1] != 0 || @@ -2414,11 +2415,12 @@ static ur_result_t SetKernelParamsAndLaunch( } ur_event_handle_t UREvent = nullptr; - ur_result_t Error = Plugin->call_nocheck( Queue->getHandleRef(), Kernel, - NDRDesc.Dims, &NDRDesc.GlobalSize[0], LocalSize, property_list.size(), - property_list.data(), RawEvents.size(), - RawEvents.empty() ? nullptr : &RawEvents[0], - OutEventImpl ? &UREvent : nullptr); + ur_result_t Error = + Plugin->call_nocheck( + Queue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalSize[0], + LocalSize, property_list.size(), property_list.data(), + RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], + OutEventImpl ? &UREvent : nullptr); if (OutEventImpl) { OutEventImpl->setHandle(UREvent); } @@ -2428,10 +2430,11 @@ static ur_result_t SetKernelParamsAndLaunch( ur_result_t Error = [&](auto... Args) { if (IsCooperative) { - return Plugin->call_nocheck( - Args...); + return Plugin + ->call_nocheck( + Args...); } - return Plugin->call_nocheck( Args...); + return Plugin->call_nocheck(Args...); }(Queue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], @@ -2513,10 +2516,11 @@ ur_result_t enqueueImpCommandBufferKernel( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( UrKernel, DeviceImpl->getHandleRef(), - UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, - sizeof(RequiredWGSize), RequiredWGSize, - /* pPropSizeRet = */ nullptr); + Plugin->call( + UrKernel, DeviceImpl->getHandleRef(), + UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), + RequiredWGSize, + /* pPropSizeRet = */ nullptr); const bool EnforcedLocalSize = (RequiredWGSize[0] != 0 || RequiredWGSize[1] != 0 || @@ -2525,14 +2529,16 @@ ur_result_t enqueueImpCommandBufferKernel( LocalSize = RequiredWGSize; } - ur_result_t Res = Plugin->call_nocheck( CommandBuffer, UrKernel, - NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, - SyncPoints.size(), SyncPoints.size() ? SyncPoints.data() : nullptr, - OutSyncPoint, OutCommand); + ur_result_t Res = + Plugin->call_nocheck( + CommandBuffer, UrKernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], + &NDRDesc.GlobalSize[0], LocalSize, SyncPoints.size(), + SyncPoints.size() ? SyncPoints.data() : nullptr, OutSyncPoint, + OutCommand); if (!SyclKernelImpl && !Kernel) { - Plugin->call( UrKernel); - Plugin->call( UrProgram); + Plugin->call(UrKernel); + Plugin->call(UrProgram); } if (Res != UR_RESULT_SUCCESS) { @@ -2636,7 +2642,8 @@ void enqueueImpKernel( if (KernelCacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_SLM || KernelCacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_DATA) { const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( Kernel, UR_KERNEL_EXEC_INFO_CACHE_CONFIG, + Plugin->call( + Kernel, UR_KERNEL_EXEC_INFO_CACHE_CONFIG, sizeof(ur_kernel_cache_config_t), nullptr, &KernelCacheConfig); } @@ -2647,8 +2654,8 @@ void enqueueImpKernel( const PluginPtr &Plugin = Queue->getPlugin(); if (!SyclKernelImpl && !MSyclKernel) { - Plugin->call( Kernel); - Plugin->call( Program); + Plugin->call(Kernel); + Plugin->call(Program); } } if (UR_RESULT_SUCCESS != Error) { @@ -2700,13 +2707,13 @@ ur_result_t enqueueReadWriteHostPipe(const QueueImplPtr &Queue, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); if (read) { - Error = Plugin->call_nocheck( ur_q, Program, PipeName.c_str(), blocking, ptr, - size, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], - OutEvent); + Error = Plugin->call_nocheck( + ur_q, Program, PipeName.c_str(), blocking, ptr, size, RawEvents.size(), + RawEvents.empty() ? nullptr : &RawEvents[0], OutEvent); } else { - Error = Plugin->call_nocheck( ur_q, Program, PipeName.c_str(), blocking, ptr, - size, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], - OutEvent); + Error = Plugin->call_nocheck( + ur_q, Program, PipeName.c_str(), blocking, ptr, size, RawEvents.size(), + RawEvents.empty() ? nullptr : &RawEvents[0], OutEvent); } if (Error == UR_RESULT_SUCCESS && OutEventImpl) { OutEventImpl->setHandle(UREvent); @@ -2726,7 +2733,8 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() { flushCrossQueueDeps(EventImpls, MWorkerQueue); std::vector RawEvents = getUrEvents(EventImpls); if (!RawEvents.empty()) { - MQueue->getPlugin()->call( RawEvents.size(), &RawEvents[0]); + MQueue->getPlugin()->call(RawEvents.size(), + &RawEvents[0]); } ur_exp_command_buffer_sync_point_t OutSyncPoint; @@ -3185,10 +3193,9 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { sizeof(NativeCommandSupport), &NativeCommandSupport, nullptr); assert(NativeCommandSupport && "ext_codeplay_enqueue_native_command is not " "supported on this device"); - MQueue->getPlugin()->call( MQueue->getHandleRef(), - InteropFreeFunc, &CustomOpData, ReqMems.size(), - ReqMems.data(), nullptr, RawEvents.size(), - RawEvents.data(), Event); + MQueue->getPlugin()->call( + MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData, ReqMems.size(), + ReqMems.data(), nullptr, RawEvents.size(), RawEvents.data(), Event); if (Event) MEvent->setHandle(*Event); return UR_RESULT_SUCCESS; @@ -3198,8 +3205,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const PluginPtr &Plugin = MQueue->getPlugin(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( MQueue->getHandleRef(), 0, - nullptr, Event); + Plugin->call( + MQueue->getHandleRef(), 0, nullptr, Event); if (Event) MEvent->setHandle(*Event); return UR_RESULT_SUCCESS; @@ -3216,8 +3223,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const PluginPtr &Plugin = MQueue->getPlugin(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( MQueue->getHandleRef(), - UrEvents.size(), &UrEvents[0], Event); + Plugin->call( + MQueue->getHandleRef(), UrEvents.size(), &UrEvents[0], Event); if (Event) MEvent->setHandle(*Event); return UR_RESULT_SUCCESS; @@ -3233,16 +3240,17 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { // not pass an output event to the UR call. Once that is fixed, // this immediately-deleted event can be removed. ur_event_handle_t PreTimestampBarrierEvent{}; - Plugin->call( MQueue->getHandleRef(), - /*num_events_in_wait_list=*/0, - /*event_wait_list=*/nullptr, &PreTimestampBarrierEvent); - Plugin->call( PreTimestampBarrierEvent); + Plugin->call( + MQueue->getHandleRef(), + /*num_events_in_wait_list=*/0, + /*event_wait_list=*/nullptr, &PreTimestampBarrierEvent); + Plugin->call(PreTimestampBarrierEvent); } - Plugin->call( MQueue->getHandleRef(), - /*blocking=*/false, - /*num_events_in_wait_list=*/0, /*event_wait_list=*/nullptr, - Event); + Plugin->call( + MQueue->getHandleRef(), + /*blocking=*/false, + /*num_events_in_wait_list=*/0, /*event_wait_list=*/nullptr, Event); if (Event) MEvent->setHandle(*Event); return UR_RESULT_SUCCESS; @@ -3290,9 +3298,11 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { static_cast(MCommandGroup.get()); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - ur_result_t Err = MQueue->getPlugin()->call_nocheck( CmdBufferCG->MCommandBuffer, - MQueue->getHandleRef(), RawEvents.size(), - RawEvents.empty() ? nullptr : &RawEvents[0], Event); + ur_result_t Err = + MQueue->getPlugin()->call_nocheck( + CmdBufferCG->MCommandBuffer, MQueue->getHandleRef(), + RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], + Event); if (Event) MEvent->setHandle(*Event); @@ -3319,8 +3329,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { auto OptWaitValue = SemWait->getWaitValue(); uint64_t WaitValue = OptWaitValue.has_value() ? OptWaitValue.value() : 0; Plugin->call( - MQueue->getHandleRef(), SemWait->getExternalSemaphore(), - OptWaitValue.has_value(), WaitValue, 0, nullptr, nullptr); + MQueue->getHandleRef(), SemWait->getExternalSemaphore(), + OptWaitValue.has_value(), WaitValue, 0, nullptr, nullptr); return UR_RESULT_SUCCESS; } @@ -3333,8 +3343,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { uint64_t SignalValue = OptSignalValue.has_value() ? OptSignalValue.value() : 0; Plugin->call( - MQueue->getHandleRef(), SemSignal->getExternalSemaphore(), - OptSignalValue.has_value(), SignalValue, 0, nullptr, nullptr); + MQueue->getHandleRef(), SemSignal->getExternalSemaphore(), + OptSignalValue.has_value(), SignalValue, 0, nullptr, nullptr); return UR_RESULT_SUCCESS; } diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index b3603fec07ce7..5f5e711752ac0 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -40,16 +40,16 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, ur_mem_native_properties_t MemProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Plugin->call( MemObject, - MInteropContext->getHandleRef(), &MemProperties, - &MInteropMemObject); + Plugin->call( + MemObject, MInteropContext->getHandleRef(), &MemProperties, + &MInteropMemObject); // Get the size of the buffer in bytes - Plugin->call( MInteropMemObject, UR_MEM_INFO_SIZE, - sizeof(size_t), &MSizeInBytes, nullptr); + Plugin->call(MInteropMemObject, UR_MEM_INFO_SIZE, + sizeof(size_t), &MSizeInBytes, nullptr); - Plugin->call( MInteropMemObject, UR_MEM_INFO_CONTEXT, - sizeof(Context), &Context, nullptr); + Plugin->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, + sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) throw sycl::exception( @@ -57,7 +57,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, "Input context must be the same as the context of cl_mem"); if (MInteropContext->getBackend() == backend::opencl) - Plugin->call( MInteropMemObject); + Plugin->call(MInteropMemObject); } ur_mem_type_t getImageType(int Dimensions) { @@ -99,12 +99,12 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, ur_mem_native_properties_t NativeProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Plugin->call( MemObject, - MInteropContext->getHandleRef(), &Format, &Desc, - &NativeProperties, &MInteropMemObject); + Plugin->call( + MemObject, MInteropContext->getHandleRef(), &Format, &Desc, + &NativeProperties, &MInteropMemObject); - Plugin->call( MInteropMemObject, UR_MEM_INFO_CONTEXT, - sizeof(Context), &Context, nullptr); + Plugin->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, + sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) throw sycl::exception( @@ -112,7 +112,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, "Input context must be the same as the context of cl_mem"); if (MInteropContext->getBackend() == backend::opencl) - Plugin->call( MInteropMemObject); + Plugin->call(MInteropMemObject); } void SYCLMemObjT::releaseMem(ContextImplPtr Context, void *MemAllocation) { @@ -155,7 +155,7 @@ void SYCLMemObjT::updateHostMemory() { if (MOpenCLInterop) { const PluginPtr &Plugin = getPlugin(); - Plugin->call( MInteropMemObject); + Plugin->call(MInteropMemObject); } } const PluginPtr &SYCLMemObjT::getPlugin() const { @@ -169,8 +169,9 @@ size_t SYCLMemObjT::getBufSizeForContext(const ContextImplPtr &Context, size_t BufSize = 0; const PluginPtr &Plugin = Context->getPlugin(); // TODO is there something required to support non-OpenCL backends? - Plugin->call( detail::ur::cast(MemObject), - UR_MEM_INFO_SIZE, sizeof(size_t), &BufSize, nullptr); + Plugin->call( + detail::ur::cast(MemObject), UR_MEM_INFO_SIZE, + sizeof(size_t), &BufSize, nullptr); return BufSize; } diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index 83d239d5a2541..7582d1fd1ce17 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -49,9 +49,9 @@ void contextSetExtendedDeleter(const sycl::context &context, void *user_data) { auto impl = getSyclObjImpl(context); const auto &Plugin = impl->getPlugin(); - Plugin->call( impl->getHandleRef(), - reinterpret_cast(func), - user_data); + Plugin->call( + impl->getHandleRef(), + reinterpret_cast(func), user_data); } } // namespace pi @@ -109,19 +109,26 @@ static void initializePlugins(std::vector &Plugins, __SYCL_CHECK_OCL_CODE_NO_EXC(Call) UrFuncInfo loaderConfigCreateInfo; - auto loaderConfigCreate = loaderConfigCreateInfo.getFuncPtr(ur::loadURLoaderLibrary()); + auto loaderConfigCreate = + loaderConfigCreateInfo.getFuncPtr(ur::loadURLoaderLibrary()); UrFuncInfo loaderConfigEnableLayerInfo; - auto loaderConfigEnableLayer = loaderConfigEnableLayerInfo.getFuncPtr(ur::loadURLoaderLibrary()); + auto loaderConfigEnableLayer = + loaderConfigEnableLayerInfo.getFuncPtr(ur::loadURLoaderLibrary()); UrFuncInfo loaderConfigReleaseInfo; - auto loaderConfigRelease = loaderConfigReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); - UrFuncInfo loaderConfigSetCodeLocationCallbackInfo; - auto loaderConfigSetCodeLocationCallback = loaderConfigSetCodeLocationCallbackInfo.getFuncPtr(ur::loadURLoaderLibrary()); + auto loaderConfigRelease = + loaderConfigReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + UrFuncInfo + loaderConfigSetCodeLocationCallbackInfo; + auto loaderConfigSetCodeLocationCallback = + loaderConfigSetCodeLocationCallbackInfo.getFuncPtr( + ur::loadURLoaderLibrary()); UrFuncInfo loaderInitInfo; auto loaderInit = loaderInitInfo.getFuncPtr(ur::loadURLoaderLibrary()); UrFuncInfo adapterGet_Info; auto adapterGet = adapterGet_Info.getFuncPtr(ur::loadURLoaderLibrary()); UrFuncInfo adapterGetInfoInfo; - auto adapterGetInfo = adapterGetInfoInfo.getFuncPtr(ur::loadURLoaderLibrary()); + auto adapterGetInfo = + adapterGetInfoInfo.getFuncPtr(ur::loadURLoaderLibrary()); bool OwnLoaderConfig = false; // If we weren't provided with a custom config handle create our own. @@ -137,8 +144,7 @@ static void initializePlugins(std::vector &Plugins, #else setenv("UR_LOG_TRACING", LogOptions, 1); #endif - CHECK_UR_SUCCESS( - loaderConfigEnableLayer(LoaderConfig, "UR_LAYER_TRACING")); + CHECK_UR_SUCCESS(loaderConfigEnableLayer(LoaderConfig, "UR_LAYER_TRACING")); } if (trace(TraceLevel::TRACE_BASIC)) { @@ -161,7 +167,7 @@ static void initializePlugins(std::vector &Plugins, } loaderConfigSetCodeLocationCallback(LoaderConfig, codeLocationCallback, - nullptr); + nullptr); if (ProgramManager::getInstance().kernelUsesAsan()) { if (loaderConfigEnableLayer(LoaderConfig, "UR_LAYER_ASAN")) { @@ -205,8 +211,8 @@ static void initializePlugins(std::vector &Plugins, for (const auto &adapter : adapters) { ur_adapter_backend_t adapterBackend = UR_ADAPTER_BACKEND_UNKNOWN; CHECK_UR_SUCCESS(adapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, - sizeof(adapterBackend), &adapterBackend, - nullptr)); + sizeof(adapterBackend), &adapterBackend, + nullptr)); auto syclBackend = UrToSyclBackend(adapterBackend); Plugins.emplace_back(std::make_shared(adapter, syclBackend)); } diff --git a/sycl/source/detail/ur_utils.hpp b/sycl/source/detail/ur_utils.hpp index 191d4a3443bee..e15e5c97a1472 100644 --- a/sycl/source/detail/ur_utils.hpp +++ b/sycl/source/detail/ur_utils.hpp @@ -29,13 +29,13 @@ struct OwnedUrEvent { // If it is not instructed to take ownership, retain the event to share // ownership of it. if (!TakeOwnership) - MPlugin->call( *MEvent); + MPlugin->call(*MEvent); } ~OwnedUrEvent() { try { // Release the event if the ownership was not transferred. if (MEvent.has_value()) - MPlugin->call( *MEvent); + MPlugin->call(*MEvent); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~OwnedUrEvent", e); diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 6386a0d9de07a..f9f4ebf7beb07 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -86,13 +86,14 @@ void *alignedAllocHost(size_t Alignment, size_t Size, const sycl::context &Ctxt, UsmDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( C, &UsmDesc, - /* pool= */ nullptr, Size, &RetVal); - - // Error is for debugging purposes. - // The spec wants a nullptr returned, not an exception. - if (Error != UR_RESULT_SUCCESS) - return nullptr; + Error = Plugin->call_nocheck( + C, &UsmDesc, + /* pool= */ nullptr, Size, &RetVal); + + // Error is for debugging purposes. + // The spec wants a nullptr returned, not an exception. + if (Error != UR_RESULT_SUCCESS) + return nullptr; #ifdef XPTI_ENABLE_INSTRUMENTATION xpti::addMetadata(PrepareNotify.traceEvent(), "memory_ptr", reinterpret_cast(RetVal)); @@ -157,8 +158,9 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( C, Dev, &UsmDesc, - /*pool=*/nullptr, Size, &RetVal); + Error = Plugin->call_nocheck( + C, Dev, &UsmDesc, + /*pool=*/nullptr, Size, &RetVal); break; } @@ -193,8 +195,9 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDeviceDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( C, Dev, &UsmDesc, - /*pool=*/nullptr, Size, &RetVal); + Error = Plugin->call_nocheck( + C, Dev, &UsmDesc, + /*pool=*/nullptr, Size, &RetVal); break; } @@ -250,7 +253,7 @@ void freeInternal(void *Ptr, const context_impl *CtxImpl) { return; ur_context_handle_t C = CtxImpl->getHandleRef(); const PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( C, Ptr); + Plugin->call(C, Ptr); } void free(void *Ptr, const context &Ctxt, @@ -529,8 +532,10 @@ alloc get_pointer_type(const void *Ptr, const context &Ctxt) { // query type using UR function const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - ur_result_t Err = Plugin->call_nocheck( URCtx, Ptr, UR_USM_ALLOC_INFO_TYPE, - sizeof(ur_usm_type_t), &AllocTy, nullptr); + ur_result_t Err = + Plugin->call_nocheck( + URCtx, Ptr, UR_USM_ALLOC_INFO_TYPE, sizeof(ur_usm_type_t), &AllocTy, + nullptr); // UR_RESULT_ERROR_INVALID_VALUE means USM doesn't know about this ptr if (Err == UR_RESULT_ERROR_INVALID_VALUE) @@ -589,8 +594,9 @@ device get_pointer_device(const void *Ptr, const context &Ctxt) { // query device using UR function const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( URCtx, Ptr, UR_USM_ALLOC_INFO_DEVICE, - sizeof(ur_device_handle_t), &DeviceId, nullptr); + Plugin->call( + URCtx, Ptr, UR_USM_ALLOC_INFO_DEVICE, sizeof(ur_device_handle_t), + &DeviceId, nullptr); // The device is not necessarily a member of the context, it could be a // member's descendant instead. Fetch the corresponding device from the cache. @@ -611,7 +617,8 @@ static void prepare_for_usm_device_copy(const void *Ptr, size_t Size, ur_context_handle_t URCtx = CtxImpl->getHandleRef(); // Call the UR function const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( URCtx, const_cast(Ptr), Size); + Plugin->call( + URCtx, const_cast(Ptr), Size); } static void release_from_usm_device_copy(const void *Ptr, const context &Ctxt) { @@ -619,7 +626,8 @@ static void release_from_usm_device_copy(const void *Ptr, const context &Ctxt) { ur_context_handle_t URCtx = CtxImpl->getHandleRef(); // Call the UR function const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( URCtx, const_cast(Ptr)); + Plugin->call(URCtx, + const_cast(Ptr)); } namespace ext::oneapi::experimental { diff --git a/sycl/source/detail/windows_ur.cpp b/sycl/source/detail/windows_ur.cpp index 7ea45defe7d9f..3f5cb2e914f21 100644 --- a/sycl/source/detail/windows_ur.cpp +++ b/sycl/source/detail/windows_ur.cpp @@ -70,7 +70,7 @@ static std::filesystem::path getCurrentDSODirPath() { return std::filesystem::path(Path); } -void* loadURLoaderLibrary() { +void *loadURLoaderLibrary() { const std::filesystem::path LibSYCLDir = getCurrentDSODirPath(); return getPreloadedPlugin(LibSYCLDir / std::string("ur_loader.dll")); } diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index fbcc3a112d899..1a4d1cb9c4a75 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -38,12 +38,12 @@ device::device(cl_device_id DeviceId) { // must retain it in order to adhere to SYCL 1.2.1 spec (Rev6, section 4.3.1.) ur_device_handle_t Device; Plugin->call( - detail::ur::cast(DeviceId), - Plugin->getUrAdapter(), nullptr, &Device); + detail::ur::cast(DeviceId), Plugin->getUrAdapter(), + nullptr, &Device); auto Platform = detail::platform_impl::getPlatformFromUrDevice(Device, Plugin); impl = Platform->getOrMakeDeviceImpl(Device, Platform); - Plugin->call( impl->getHandleRef()); + Plugin->call(impl->getHandleRef()); } device::device(const device_selector &deviceSelector) { @@ -276,9 +276,8 @@ bool device::ext_oneapi_supports_cl_c_feature(detail::string_view Feature) { ur_device_handle_t Device = impl->getHandleRef(); auto Plugin = impl->getPlugin(); uint32_t ipVersion = 0; - auto res = - Plugin->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, - sizeof(uint32_t), &ipVersion, nullptr); + auto res = Plugin->call_nocheck( + Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -291,9 +290,8 @@ bool device::ext_oneapi_supports_cl_c_version( ur_device_handle_t Device = impl->getHandleRef(); auto Plugin = impl->getPlugin(); uint32_t ipVersion = 0; - auto res = - Plugin->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, - sizeof(uint32_t), &ipVersion, nullptr); + auto res = Plugin->call_nocheck( + Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -307,9 +305,8 @@ bool device::ext_oneapi_supports_cl_extension( ur_device_handle_t Device = impl->getHandleRef(); auto Plugin = impl->getPlugin(); uint32_t ipVersion = 0; - auto res = - Plugin->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, - sizeof(uint32_t), &ipVersion, nullptr); + auto res = Plugin->call_nocheck( + Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -321,9 +318,8 @@ detail::string device::ext_oneapi_cl_profile_impl() const { ur_device_handle_t Device = impl->getHandleRef(); auto Plugin = impl->getPlugin(); uint32_t ipVersion = 0; - auto res = - Plugin->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, - sizeof(uint32_t), &ipVersion, nullptr); + auto res = Plugin->call_nocheck( + Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return detail::string{""}; diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index e73885a20d532..7d21233631bad 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -31,7 +31,7 @@ event::event(cl_event ClEvent, const context &SyclContext) // retained. // TODO(pi2ur): Don't just cast from cl_event above impl->getPlugin()->call( - detail::ur::cast(ClEvent)); + detail::ur::cast(ClEvent)); } bool event::operator==(const event &rhs) const { return rhs.impl == impl; } diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 31ba3ce642865..11ce6608b6a33 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -1610,8 +1610,9 @@ checkContextSupports(const std::shared_ptr &ContextImpl, ur_context_info_t InfoQuery) { auto &Plugin = ContextImpl->getPlugin(); ur_bool_t SupportsOp = false; - Plugin->call( ContextImpl->getHandleRef(), InfoQuery, - sizeof(ur_bool_t), &SupportsOp, nullptr); + Plugin->call(ContextImpl->getHandleRef(), + InfoQuery, sizeof(ur_bool_t), + &SupportsOp, nullptr); return SupportsOp; } @@ -1845,7 +1846,8 @@ void handler::setUserFacingNodeType(ext::oneapi::experimental::node_type Type) { std::optional> handler::getMaxWorkGroups() { auto Dev = detail::getSyclObjImpl(detail::getDeviceFromHandler(*this)); std::array UrResult = {}; - auto Ret = Dev->getPlugin()->call_nocheck( Dev->getHandleRef(), + auto Ret = Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, sizeof(UrResult), &UrResult, nullptr); diff --git a/sycl/source/kernel.cpp b/sycl/source/kernel.cpp index 43c26c654e539..f4ec76bcf9e7d 100644 --- a/sycl/source/kernel.cpp +++ b/sycl/source/kernel.cpp @@ -22,15 +22,15 @@ kernel::kernel(cl_kernel ClKernel, const context &SyclContext) { ur_kernel_handle_t hKernel = nullptr; ur_native_handle_t nativeHandle = reinterpret_cast(ClKernel); - Plugin->call( nativeHandle, - detail::getSyclObjImpl(SyclContext)->getHandleRef(), nullptr, - nullptr, &hKernel); + Plugin->call( + nativeHandle, detail::getSyclObjImpl(SyclContext)->getHandleRef(), + nullptr, nullptr, &hKernel); impl = std::make_shared( hKernel, detail::getSyclObjImpl(SyclContext), nullptr, nullptr); // This is a special interop constructor for OpenCL, so the kernel must be // retained. if (get_backend() == backend::opencl) { - impl->getPlugin()->call( hKernel); + impl->getPlugin()->call(hKernel); } } diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index 4c08c2fa659e3..0a1690961d075 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -26,8 +26,8 @@ platform::platform(cl_platform_id PlatformId) { auto Plugin = sycl::detail::ur::getPlugin(); ur_platform_handle_t UrPlatform = nullptr; Plugin->call( - detail::ur::cast(PlatformId), - Plugin->getUrAdapter(), /* pProperties = */ nullptr, &UrPlatform); + detail::ur::cast(PlatformId), Plugin->getUrAdapter(), + /* pProperties = */ nullptr, &UrPlatform); impl = detail::platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin); } diff --git a/sycl/source/virtual_mem.cpp b/sycl/source/virtual_mem.cpp index b8cd7c2f15bf3..7a0002acb18b1 100644 --- a/sycl/source/virtual_mem.cpp +++ b/sycl/source/virtual_mem.cpp @@ -48,16 +48,16 @@ __SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice, const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); #ifndef NDEBUG size_t InfoOutputSize; - Plugin->call( ContextImpl->getHandleRef(), - DeviceImpl->getHandleRef(), GranularityQuery, 0, nullptr, - &InfoOutputSize); + Plugin->call( + ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery, + 0, nullptr, &InfoOutputSize); assert(InfoOutputSize == sizeof(size_t) && "Unexpected output size of granularity info query."); #endif // NDEBUG size_t Granularity = 0; - Plugin->call( ContextImpl->getHandleRef(), - DeviceImpl->getHandleRef(), GranularityQuery, sizeof(size_t), - &Granularity, nullptr); + Plugin->call( + ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery, + sizeof(size_t), &Granularity, nullptr); return Granularity; } @@ -115,8 +115,9 @@ __SYCL_EXPORT uintptr_t reserve_virtual_mem(uintptr_t Start, size_t NumBytes, sycl::detail::getSyclObjImpl(SyclContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); void *OutPtr = nullptr; - Plugin->call( ContextImpl->getHandleRef(), - reinterpret_cast(Start), NumBytes, &OutPtr); + Plugin->call( + ContextImpl->getHandleRef(), reinterpret_cast(Start), NumBytes, + &OutPtr); return reinterpret_cast(OutPtr); } @@ -125,8 +126,8 @@ __SYCL_EXPORT void free_virtual_mem(uintptr_t Ptr, size_t NumBytes, std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( ContextImpl->getHandleRef(), - reinterpret_cast(Ptr), NumBytes); + Plugin->call( + ContextImpl->getHandleRef(), reinterpret_cast(Ptr), NumBytes); } __SYCL_EXPORT void set_access_mode(const void *Ptr, size_t NumBytes, @@ -136,8 +137,8 @@ __SYCL_EXPORT void set_access_mode(const void *Ptr, size_t NumBytes, std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( ContextImpl->getHandleRef(), Ptr, - NumBytes, AccessFlags); + Plugin->call( + ContextImpl->getHandleRef(), Ptr, NumBytes, AccessFlags); } __SYCL_EXPORT address_access_mode get_access_mode(const void *Ptr, @@ -148,15 +149,17 @@ __SYCL_EXPORT address_access_mode get_access_mode(const void *Ptr, const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); #ifndef NDEBUG size_t InfoOutputSize = 0; - Plugin->call( ContextImpl->getHandleRef(), Ptr, NumBytes, - UR_VIRTUAL_MEM_INFO_ACCESS_MODE, 0, nullptr, &InfoOutputSize); + Plugin->call( + ContextImpl->getHandleRef(), Ptr, NumBytes, + UR_VIRTUAL_MEM_INFO_ACCESS_MODE, 0, nullptr, &InfoOutputSize); assert(InfoOutputSize == sizeof(ur_virtual_mem_access_flags_t) && "Unexpected output size of access mode info query."); #endif // NDEBUG ur_virtual_mem_access_flags_t AccessFlags; - Plugin->call( ContextImpl->getHandleRef(), Ptr, NumBytes, - UR_VIRTUAL_MEM_INFO_ACCESS_MODE, - sizeof(ur_virtual_mem_access_flags_t), &AccessFlags, nullptr); + Plugin->call( + ContextImpl->getHandleRef(), Ptr, NumBytes, + UR_VIRTUAL_MEM_INFO_ACCESS_MODE, sizeof(ur_virtual_mem_access_flags_t), + &AccessFlags, nullptr); if (AccessFlags & UR_VIRTUAL_MEM_ACCESS_FLAG_READ_WRITE) return address_access_mode::read_write; @@ -170,7 +173,8 @@ __SYCL_EXPORT void unmap(const void *Ptr, size_t NumBytes, std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( ContextImpl->getHandleRef(), Ptr, NumBytes); + Plugin->call( + ContextImpl->getHandleRef(), Ptr, NumBytes); } } // Namespace ext::oneapi::experimental From 636d2554c4f63725b6474379fde70278fe10b8f7 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 11:54:56 +0100 Subject: [PATCH 03/21] Fix missing .def file and Linux build --- sycl/CMakeLists.txt | 3 ++ sycl/include/sycl/detail/ur.hpp | 15 +++++++++- sycl/source/CMakeLists.txt | 9 ++++-- sycl/source/detail/plugin.hpp | 28 ++----------------- sycl/source/detail/posix_ur.cpp | 2 ++ .../program_manager/program_manager.cpp | 3 -- 6 files changed, 29 insertions(+), 31 deletions(-) diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 4655a8756e0b9..3c529e7e5aeb2 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -251,6 +251,7 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/syclcompat ${SYCL_INCLUDE_BUILD_DIR}/syclcompat COMMAND ${CMAKE_COMMAND} -E copy ${sycl_inc_dir}/syclcompat.hpp ${SYCL_INCLUDE_BUILD_DIR}/syclcompat.hpp COMMAND ${CMAKE_COMMAND} -E copy ${UNIFIED_RUNTIME_INCLUDE_DIR}/ur_api.h ${SYCL_INCLUDE_BUILD_DIR}/sycl + COMMAND ${CMAKE_COMMAND} -E copy ${UNIFIED_RUNTIME_INCLUDE_DIR}/ur_api_funcs.def ${SYCL_INCLUDE_BUILD_DIR}/sycl COMMAND ${CMAKE_COMMAND} -E copy ${UNIFIED_RUNTIME_INCLUDE_DIR}/ur_print.hpp ${SYCL_INCLUDE_BUILD_DIR}/sycl COMMENT "Copying SYCL headers ...") @@ -263,6 +264,8 @@ install(DIRECTORY "${sycl_inc_dir}/syclcompat" DESTINATION ${SYCL_INCLUDE_DIR} C install(FILES "${sycl_inc_dir}/syclcompat.hpp" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers) install(FILES "${UNIFIED_RUNTIME_INCLUDE_DIR}/ur_api.h" DESTINATION ${SYCL_INCLUDE_DIR}/sycl COMPONENT sycl-headers) +install(FILES "${UNIFIED_RUNTIME_INCLUDE_DIR}/ur_api_funcs.def" DESTINATION ${SYCL_INCLUDE_DIR}/sycl + COMPONENT sycl-headers) install(FILES "${UNIFIED_RUNTIME_INCLUDE_DIR}/ur_print.hpp" DESTINATION ${SYCL_INCLUDE_DIR}/sycl COMPONENT sycl-headers) diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index de309eed70331..4937fef944ed3 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -17,9 +17,11 @@ #include #include #include -#define NOMINMAX #include +#ifdef _WIN32 +#define NOMINMAX #include +#endif #include #include @@ -57,6 +59,7 @@ enum class UrApiKind { template struct UrFuncInfo {}; +#ifdef _WIN32 #define _UR_API(api) \ template <> struct UrFuncInfo { \ using FuncPtrT = decltype(&::api); \ @@ -67,6 +70,16 @@ template struct UrFuncInfo {}; }; #include #undef _UR_API +#else +#define _UR_API(api) \ + template <> struct UrFuncInfo { \ + using FuncPtrT = decltype(&::api); \ + inline const char *getFuncName() { return #api; } \ + constexpr inline FuncPtrT getFuncPtr(void *) { return &api; } \ + }; +#include +#undef _UR_API +#endif namespace pi { // This function is deprecated and it should be removed in the next release diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index db705d39c5b63..17fc29900b3de 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -166,7 +166,6 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # Link and include UR target_link_libraries(${LIB_OBJ_NAME} PRIVATE - # UnifiedRuntimeLoader UnifiedRuntime-Headers UnifiedRuntimeCommon ) @@ -181,11 +180,17 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) target_link_libraries(${LIB_NAME} PRIVATE - # UnifiedRuntimeLoader UnifiedRuntime-Headers UnifiedRuntimeCommon ) + if (NOT WIN32) + target_link_libraries(${LIB_NAME} + PRIVATE + UnifiedRuntimeLoader + ) + endif() + target_include_directories(${LIB_NAME} PRIVATE "${UNIFIED_RUNTIME_SRC_INCLUDE_DIR}" diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/plugin.hpp index 01f07128cdcf2..715c8b034a48a 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -15,7 +15,9 @@ #include #include +#ifdef _WIN32 #include "ur_win_proxy_loader.hpp" +#endif #include @@ -116,25 +118,15 @@ class plugin { /// /// Usage: /// \code{cpp} - /// ur_result_t Err = Plugin->call(urEntryPoint, Args); + /// ur_result_t Err = Plugin->call(Args); /// Plugin->checkUrResult(Err); // Checks Result and throws a runtime_error /// // exception. /// \endcode /// /// \sa plugin::checkUrResult - // template - // ur_result_t call_nocheck(UrFunc F, ArgsT... Args) const { - // ur_result_t R = UR_RESULT_SUCCESS; - // if (!adapterReleased) { - // R = F(Args...); - // } - // return R; - // } - template ur_result_t call_nocheck(ArgsT... Args) const { ur_result_t R = UR_RESULT_SUCCESS; - // fprintf(stderr, "CALL_NOCHECK2\n"); if (!adapterReleased) { detail::UrFuncInfo UrApiInfo; auto F = UrApiInfo.getFuncPtr(UrLoaderHandle); @@ -146,12 +138,6 @@ class plugin { /// Calls the API, traces the call, checks the result /// /// \throw sycl::runtime_exception if the call was not successful. - // template - // void call(UrFunc F, ArgsT... Args) const { - // auto Err = call_nocheck(F, Args...); - // checkUrResult(Err); - // } - template void call(ArgsT... Args) const { auto Err = call_nocheck(Args...); @@ -159,12 +145,6 @@ class plugin { } /// \throw sycl::exceptions(errc) if the call was not successful. - // template - // void call(UrFunc F, ArgsT... Args) const { - // auto Err = call_nocheck(F, Args...); - // checkUrResult(Err); - // } - template void call(ArgsT... Args) const { auto Err = call_nocheck(Args...); @@ -245,9 +225,7 @@ class plugin { // represents the unique ids of the last device of each platform // index of this vector corresponds to the index in UrPlatforms vector. std::vector LastDeviceIds; -#ifdef _WIN32 void *UrLoaderHandle = nullptr; -#endif }; // class plugin using PluginPtr = std::shared_ptr; diff --git a/sycl/source/detail/posix_ur.cpp b/sycl/source/detail/posix_ur.cpp index 80618428c4ef7..cab046fa5b9e9 100644 --- a/sycl/source/detail/posix_ur.cpp +++ b/sycl/source/detail/posix_ur.cpp @@ -35,6 +35,8 @@ void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName) { return dlsym(Library, FunctionName.c_str()); } +void *loadURLoaderLibrary() { return nullptr; } + } // namespace detail::ur } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 48ab81dcb1fbe..7d29694e1757c 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -804,7 +804,6 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( } UrFuncInfo programReleaseInfo; - ; auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); ProgramPtr ProgramManaged(NativePrg, programRelease); @@ -2555,7 +2554,6 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, setSpecializationConstants(InputImpl, NativePrg, Plugin); UrFuncInfo programReleaseInfo; - ; auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); ProgramPtr ProgramManaged(NativePrg, programRelease); @@ -2770,7 +2768,6 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( auto DeviceImpl = detail::getSyclObjImpl(Device); auto &Plugin = DeviceImpl->getPlugin(); UrFuncInfo programReleaseInfo; - ; auto programRelease = programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); ProgramPtr ProgramManaged(Program, programRelease); From cb57e20df7198d81a4e268cb6545a761547eedc0 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 12:33:58 +0100 Subject: [PATCH 04/21] Call releaseDefaultContexts in shutdown_win --- sycl/source/detail/global_handler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 2e1c4216249bd..04fecd69495d0 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -307,6 +307,7 @@ void GlobalHandler::drainThreadPool() { // accidentally retain device handles. etc void shutdown_win() { GlobalHandler *&Handler = GlobalHandler::getInstancePtr(); + Handler->releaseDefaultContexts(); Handler->unloadPlugins(); } #else From 93dc3deeb81a1741f9f82d23d071bb05671e03ed Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 12:54:55 +0100 Subject: [PATCH 05/21] Fix include_deps test --- sycl/test/include_deps/sycl_detail_core.hpp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index 400fb2c13c493..6cb1be75681ee 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -145,6 +145,7 @@ // CHECK-NEXT: handler.hpp // CHECK-NEXT: detail/reduction_forward.hpp // CHECK-NEXT: detail/ur.hpp +// CHECK-NEXT: ur_api_funcs.def // CHECK-NEXT: ext/intel/experimental/fp_control_kernel_properties.hpp // CHECK-NEXT: ext/intel/experimental/kernel_execution_properties.hpp // CHECK-NEXT: ext/oneapi/bindless_images_interop.hpp From 6ce1e6aeeae3e5f634bd21792409baf4669e0342 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 12:55:09 +0100 Subject: [PATCH 06/21] Reenable failing tests on Windows --- sycl/test-e2e/Basic/queue/release.cpp | 3 +-- sycl/test-e2e/KernelAndProgram/disable-caching.cpp | 3 --- .../Regression/context_is_destroyed_after_exception.cpp | 3 +-- sycl/test-e2e/Regression/pi_release.cpp | 3 --- sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp | 3 +-- 5 files changed, 3 insertions(+), 12 deletions(-) diff --git a/sycl/test-e2e/Basic/queue/release.cpp b/sycl/test-e2e/Basic/queue/release.cpp index fe788c59c4bf7..2ca6451a98c07 100644 --- a/sycl/test-e2e/Basic/queue/release.cpp +++ b/sycl/test-e2e/Basic/queue/release.cpp @@ -1,8 +1,7 @@ // RUN: %{build} -o %t.out // RUN: env SYCL_UR_TRACE=2 %{run} %t.out | FileCheck %s // -// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 -// XFAIL: hip_nvidia, windows +// XFAIL: hip_nvidia #include int main() { diff --git a/sycl/test-e2e/KernelAndProgram/disable-caching.cpp b/sycl/test-e2e/KernelAndProgram/disable-caching.cpp index 5e8ef4045d641..265145d8e49d1 100644 --- a/sycl/test-e2e/KernelAndProgram/disable-caching.cpp +++ b/sycl/test-e2e/KernelAndProgram/disable-caching.cpp @@ -7,9 +7,6 @@ // RUN: env ZE_DEBUG=-6 SYCL_UR_TRACE=2 %{run} %t.out \ // RUN: | FileCheck %s --check-prefixes=CHECK-CACHE -// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 -// XFAIL: windows - #include #include diff --git a/sycl/test-e2e/Regression/context_is_destroyed_after_exception.cpp b/sycl/test-e2e/Regression/context_is_destroyed_after_exception.cpp index 703103f0d1a62..e92dcaa3a6f57 100644 --- a/sycl/test-e2e/Regression/context_is_destroyed_after_exception.cpp +++ b/sycl/test-e2e/Regression/context_is_destroyed_after_exception.cpp @@ -3,8 +3,7 @@ // RUN: %{build} -o %t.out // RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s // -// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 -// XFAIL: hip_nvidia, windows +// XFAIL: hip_nvidia #include diff --git a/sycl/test-e2e/Regression/pi_release.cpp b/sycl/test-e2e/Regression/pi_release.cpp index 1a28a27d184d9..90102e5cf0e20 100644 --- a/sycl/test-e2e/Regression/pi_release.cpp +++ b/sycl/test-e2e/Regression/pi_release.cpp @@ -1,9 +1,6 @@ // REQUIRES: opencl || level_zero || cuda // RUN: %{build} -o %t.out // RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s -// -// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 -// XFAIL: windows #include diff --git a/sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp b/sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp index dcd1492b63511..3fc020e82e712 100644 --- a/sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp +++ b/sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp @@ -1,8 +1,7 @@ // RUN: %{build} -Wno-error=unused-command-line-argument -fsycl-dead-args-optimization -o %t.out // RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s // -// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 -// XFAIL: hip_nvidia, windows +// XFAIL: hip_nvidia //==------------------- ReleaseResourcesTests.cpp --------------------------==// // From 3c5c74db5366e1450a571871d3bd593ec0dd38fa Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 13:07:14 +0100 Subject: [PATCH 07/21] Don't pull windows.h into the headers --- sycl/include/sycl/detail/ur.hpp | 7 ++----- sycl/source/detail/windows_ur.cpp | 5 +++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index 4937fef944ed3..03344317469c8 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -18,10 +18,6 @@ #include #include #include -#ifdef _WIN32 -#define NOMINMAX -#include -#endif #include #include @@ -60,12 +56,13 @@ enum class UrApiKind { template struct UrFuncInfo {}; #ifdef _WIN32 +void *GetWinProcAddress(void *module, const char *funcName); #define _UR_API(api) \ template <> struct UrFuncInfo { \ using FuncPtrT = decltype(&::api); \ inline const char *getFuncName() { return #api; } \ inline FuncPtrT getFuncPtr(void *module) { \ - return (FuncPtrT)GetProcAddress((HMODULE)module, #api); \ + return (FuncPtrT)GetWinProcAddress(module, #api); \ } \ }; #include diff --git a/sycl/source/detail/windows_ur.cpp b/sycl/source/detail/windows_ur.cpp index 3f5cb2e914f21..19f436a8e490c 100644 --- a/sycl/source/detail/windows_ur.cpp +++ b/sycl/source/detail/windows_ur.cpp @@ -20,6 +20,11 @@ namespace sycl { inline namespace _V1 { namespace detail { + +void *GetWinProcAddress(void *module, const char *funcName) { + return (void *)GetProcAddress((HMODULE)module, funcName); +} + namespace ur { void *loadOsLibrary(const std::string &LibraryPath) { From b1c737cdc0293c3fa781221bd4cd010bdcd1309b Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 13:41:26 +0100 Subject: [PATCH 08/21] Add missing UR loader dependency --- sycl/source/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 17fc29900b3de..f0067a45b20a4 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -189,6 +189,8 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) PRIVATE UnifiedRuntimeLoader ) + else() + add_dependencies(${LIB_NAME} UnifiedRuntimeLoader) endif() target_include_directories(${LIB_NAME} From e6d7eec382ce4408c84a10c3d8c398d0dbd4fab1 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 13:45:37 +0100 Subject: [PATCH 09/21] Don't pull the proxy loader into the headers --- sycl/source/detail/plugin.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/plugin.hpp index 858d9221d4c25..ac5c750393565 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -15,10 +15,6 @@ #include #include -#ifdef _WIN32 -#include "ur_win_proxy_loader.hpp" -#endif - #include #ifdef XPTI_ENABLE_INSTRUMENTATION // Include the headers necessary for emitting traces using the trace framework From 1dc8b925959367e5a051b17417c4b49a1ffb6fb6 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 14:23:39 +0100 Subject: [PATCH 10/21] Keep linking unit tests with UR loader directly --- sycl/cmake/modules/AddSYCLUnitTest.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sycl/cmake/modules/AddSYCLUnitTest.cmake b/sycl/cmake/modules/AddSYCLUnitTest.cmake index 2464cb13013cf..076d0caa752a8 100644 --- a/sycl/cmake/modules/AddSYCLUnitTest.cmake +++ b/sycl/cmake/modules/AddSYCLUnitTest.cmake @@ -82,6 +82,10 @@ macro(add_sycl_unittest test_dirname link_variant) target_link_libraries(${test_dirname} PRIVATE sycl-jit) endif(SYCL_ENABLE_EXTENSION_JIT) + if(WIN32) + target_link_libraries(${test_dirname} PRIVATE UnifiedRuntimeLoader) + endif() + target_include_directories(${test_dirname} PRIVATE SYSTEM ${sycl_inc_dir} From ae77ba84606d6564472298e3e2fd780a0962bab2 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Tue, 3 Sep 2024 17:06:15 +0100 Subject: [PATCH 11/21] Refactor UR function ptrs --- sycl/include/sycl/detail/ur.hpp | 23 ++++++++++++++++--- sycl/source/detail/global_handler.cpp | 2 +- sycl/source/detail/plugin.hpp | 6 +++-- sycl/source/detail/posix_ur.cpp | 2 +- .../program_manager/program_manager.cpp | 6 ++--- sycl/source/detail/ur.cpp | 19 ++++++++------- sycl/source/detail/windows_ur.cpp | 2 +- 7 files changed, 41 insertions(+), 19 deletions(-) diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index 03344317469c8..1320cf5e82449 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -53,15 +53,31 @@ enum class UrApiKind { #undef _UR_API }; +struct UrFuncPtrMapT { +#define _UR_API(api) decltype(&::api) pfn_##api = nullptr; +#include +#undef _UR_API +}; + template struct UrFuncInfo {}; #ifdef _WIN32 void *GetWinProcAddress(void *module, const char *funcName); +inline void PopulateUrFuncPtrTable(UrFuncPtrMapT *funcs, void *module) { +#define _UR_API(api) \ + funcs->pfn_##api = (decltype(&::api))GetWinProcAddress(module, #api); +#include +#undef _UR_API +} + #define _UR_API(api) \ template <> struct UrFuncInfo { \ using FuncPtrT = decltype(&::api); \ inline const char *getFuncName() { return #api; } \ - inline FuncPtrT getFuncPtr(void *module) { \ + inline FuncPtrT getFuncPtr(const UrFuncPtrMapT *funcs) { \ + return funcs->pfn_##api; \ + } \ + inline FuncPtrT getFuncPtrFromModule(void *module) { \ return (FuncPtrT)GetWinProcAddress(module, #api); \ } \ }; @@ -72,7 +88,8 @@ void *GetWinProcAddress(void *module, const char *funcName); template <> struct UrFuncInfo { \ using FuncPtrT = decltype(&::api); \ inline const char *getFuncName() { return #api; } \ - constexpr inline FuncPtrT getFuncPtr(void *) { return &api; } \ + constexpr inline FuncPtrT getFuncPtr(const void *) { return &api; } \ + constexpr inline FuncPtrT getFuncPtrFromModule(void *) { return &api; } \ }; #include #undef _UR_API @@ -106,7 +123,7 @@ int unloadOsLibrary(void *Library); // library, implementation is OS dependent. void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName); -void *loadURLoaderLibrary(); +void *getURLoaderLibrary(); // Performs UR one-time initialization. std::vector & diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 04fecd69495d0..a2c7bfa8e4795 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -275,7 +275,7 @@ void GlobalHandler::unloadPlugins() { UrFuncInfo loaderTearDownInfo; auto loaderTearDown = - loaderTearDownInfo.getFuncPtr(ur::loadURLoaderLibrary()); + loaderTearDownInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); loaderTearDown(); // urLoaderTearDown(); diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/plugin.hpp index ac5c750393565..d3aa1264025c4 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -51,7 +51,8 @@ class plugin { MPluginMutex(std::make_shared()) { #ifdef _WIN32 - UrLoaderHandle = ur::loadURLoaderLibrary(); + UrLoaderHandle = ur::getURLoaderLibrary(); + PopulateUrFuncPtrTable(&UrFuncPtrs, UrLoaderHandle); #endif } @@ -123,7 +124,7 @@ class plugin { ur_result_t R = UR_RESULT_SUCCESS; if (!adapterReleased) { detail::UrFuncInfo UrApiInfo; - auto F = UrApiInfo.getFuncPtr(UrLoaderHandle); + auto F = UrApiInfo.getFuncPtr(&UrFuncPtrs); R = F(Args...); } return R; @@ -220,6 +221,7 @@ class plugin { // index of this vector corresponds to the index in UrPlatforms vector. std::vector LastDeviceIds; void *UrLoaderHandle = nullptr; + UrFuncPtrMapT UrFuncPtrs; }; // class plugin using PluginPtr = std::shared_ptr; diff --git a/sycl/source/detail/posix_ur.cpp b/sycl/source/detail/posix_ur.cpp index cab046fa5b9e9..07b829c6a035b 100644 --- a/sycl/source/detail/posix_ur.cpp +++ b/sycl/source/detail/posix_ur.cpp @@ -35,7 +35,7 @@ void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName) { return dlsym(Library, FunctionName.c_str()); } -void *loadURLoaderLibrary() { return nullptr; } +void *getURLoaderLibrary() { return nullptr; } } // namespace detail::ur } // namespace _V1 diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 7d29694e1757c..fb30de4695499 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -805,7 +805,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( UrFuncInfo programReleaseInfo; auto programRelease = - programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + programReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); ProgramPtr ProgramManaged(NativePrg, programRelease); // Link a fallback implementation of device libraries if they are not @@ -2555,7 +2555,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, UrFuncInfo programReleaseInfo; auto programRelease = - programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + programReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); ProgramPtr ProgramManaged(NativePrg, programRelease); // Link a fallback implementation of device libraries if they are not @@ -2769,7 +2769,7 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( auto &Plugin = DeviceImpl->getPlugin(); UrFuncInfo programReleaseInfo; auto programRelease = - programReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + programReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); ProgramPtr ProgramManaged(Program, programRelease); std::string CompileOpts; diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index 00478d01a1b75..6842d863638ee 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -109,25 +109,28 @@ static void initializePlugins(std::vector &Plugins, UrFuncInfo loaderConfigCreateInfo; auto loaderConfigCreate = - loaderConfigCreateInfo.getFuncPtr(ur::loadURLoaderLibrary()); + loaderConfigCreateInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); UrFuncInfo loaderConfigEnableLayerInfo; auto loaderConfigEnableLayer = - loaderConfigEnableLayerInfo.getFuncPtr(ur::loadURLoaderLibrary()); + loaderConfigEnableLayerInfo.getFuncPtrFromModule( + ur::getURLoaderLibrary()); UrFuncInfo loaderConfigReleaseInfo; auto loaderConfigRelease = - loaderConfigReleaseInfo.getFuncPtr(ur::loadURLoaderLibrary()); + loaderConfigReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); UrFuncInfo loaderConfigSetCodeLocationCallbackInfo; auto loaderConfigSetCodeLocationCallback = - loaderConfigSetCodeLocationCallbackInfo.getFuncPtr( - ur::loadURLoaderLibrary()); + loaderConfigSetCodeLocationCallbackInfo.getFuncPtrFromModule( + ur::getURLoaderLibrary()); UrFuncInfo loaderInitInfo; - auto loaderInit = loaderInitInfo.getFuncPtr(ur::loadURLoaderLibrary()); + auto loaderInit = + loaderInitInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); UrFuncInfo adapterGet_Info; - auto adapterGet = adapterGet_Info.getFuncPtr(ur::loadURLoaderLibrary()); + auto adapterGet = + adapterGet_Info.getFuncPtrFromModule(ur::getURLoaderLibrary()); UrFuncInfo adapterGetInfoInfo; auto adapterGetInfo = - adapterGetInfoInfo.getFuncPtr(ur::loadURLoaderLibrary()); + adapterGetInfoInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); bool OwnLoaderConfig = false; // If we weren't provided with a custom config handle create our own. diff --git a/sycl/source/detail/windows_ur.cpp b/sycl/source/detail/windows_ur.cpp index 19f436a8e490c..a8d5c57f08213 100644 --- a/sycl/source/detail/windows_ur.cpp +++ b/sycl/source/detail/windows_ur.cpp @@ -75,7 +75,7 @@ static std::filesystem::path getCurrentDSODirPath() { return std::filesystem::path(Path); } -void *loadURLoaderLibrary() { +void *getURLoaderLibrary() { const std::filesystem::path LibSYCLDir = getCurrentDSODirPath(); return getPreloadedPlugin(LibSYCLDir / std::string("ur_loader.dll")); } From a76ee6d435e52725cde6d194c439e551a7c6d8d6 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Wed, 4 Sep 2024 12:15:27 +0100 Subject: [PATCH 12/21] Link unittest executables with the proxy loader --- sycl/cmake/modules/AddSYCLUnitTest.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/cmake/modules/AddSYCLUnitTest.cmake b/sycl/cmake/modules/AddSYCLUnitTest.cmake index 076d0caa752a8..41a78866512c4 100644 --- a/sycl/cmake/modules/AddSYCLUnitTest.cmake +++ b/sycl/cmake/modules/AddSYCLUnitTest.cmake @@ -83,7 +83,7 @@ macro(add_sycl_unittest test_dirname link_variant) endif(SYCL_ENABLE_EXTENSION_JIT) if(WIN32) - target_link_libraries(${test_dirname} PRIVATE UnifiedRuntimeLoader) + target_link_libraries(${test_dirname} PRIVATE UnifiedRuntimeLoader ur_win_proxy_loader) endif() target_include_directories(${test_dirname} From 56d338c159dba68f601f87768a8f0ef36c6c41e5 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Wed, 4 Sep 2024 14:40:27 +0100 Subject: [PATCH 13/21] Simplify the proxy loader by only preloading the UR loader --- sycl/source/detail/windows_ur.cpp | 5 +- .../ur_win_proxy_loader.cpp | 73 ++----------------- .../ur_win_proxy_loader.hpp | 3 +- 3 files changed, 10 insertions(+), 71 deletions(-) diff --git a/sycl/source/detail/windows_ur.cpp b/sycl/source/detail/windows_ur.cpp index a8d5c57f08213..6f8d1f7ae6bdf 100644 --- a/sycl/source/detail/windows_ur.cpp +++ b/sycl/source/detail/windows_ur.cpp @@ -75,10 +75,7 @@ static std::filesystem::path getCurrentDSODirPath() { return std::filesystem::path(Path); } -void *getURLoaderLibrary() { - const std::filesystem::path LibSYCLDir = getCurrentDSODirPath(); - return getPreloadedPlugin(LibSYCLDir / std::string("ur_loader.dll")); -} +void *getURLoaderLibrary() { return getPreloadedURLib(); } } // namespace ur } // namespace detail diff --git a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp index 7538475eb9616..b4f8bb0d39054 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp @@ -83,31 +83,17 @@ std::wstring getCurrentDSODir() { return Path; } -// these are cribbed from include/sycl/detail/ur.hpp -// a new plugin must be added to both places. #ifdef _MSC_VER #define __SYCL_UNIFIED_RUNTIME_LOADER_NAME "ur_loader.dll" -#define __SYCL_OPENCL_ADAPTER_NAME "ur_adapter_opencl.dll" -#define __SYCL_LEVEL_ZERO_ADAPTER_NAME "ur_adapter_level_zero.dll" -#define __SYCL_CUDA_ADAPTER_NAME "ur_adapter_cuda.dll" -#define __SYCL_HIP_ADAPTER_NAME "ur_adapter_hip.dll" -#define __SYCL_NATIVE_CPU_ADAPTER_NAME "ur_adapter_native_cpu.dll" #else // llvm-mingw #define __SYCL_UNIFIED_RUNTIME_LOADER_NAME "libur_loader.dll" -#define __SYCL_OPENCL_ADAPTER_NAME "libur_adapter_opencl.dll" -#define __SYCL_LEVEL_ZERO_ADAPTER_NAME "libur_adapter_level_zero.dll" -#define __SYCL_CUDA_ADAPTER_NAME "libur_adapter_cuda.dll" -#define __SYCL_HIP_ADAPTER_NAME "libur_adapter_hip.dll" -#define __SYCL_NATIVE_CPU_ADAPTER_NAME "libur_adapter_native_cpu.dll" #endif // ------------------------------------ -using MapT = std::map; - -MapT &getDllMap() { - static MapT dllMap; - return dllMap; +void *&getDllHandle() { + static void* dllHandle = nullptr; + return dllHandle; } /// Load the plugin libraries and store them in a map. @@ -130,24 +116,13 @@ void preloadLibraries() { // this path duplicates sycl/detail/ur.cpp:initializePlugins std::filesystem::path LibSYCLDir(getCurrentDSODir()); - MapT &dllMap = getDllMap(); - // When searching for dependencies of the plugins limit the // list of directories to %windows%\system32 and the directory that contains // the loaded DLL (the plugin). This is necessary to avoid loading dlls from // current directory and some other directories which are considered unsafe. - auto loadPlugin = [&](auto pluginName, - DWORD flags = LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | - LOAD_LIBRARY_SEARCH_SYSTEM32) { - auto path = LibSYCLDir / pluginName; - dllMap.emplace(path, LoadLibraryEx(path.wstring().c_str(), NULL, flags)); - }; - loadPlugin(__SYCL_UNIFIED_RUNTIME_LOADER_NAME); - loadPlugin(__SYCL_OPENCL_ADAPTER_NAME); - loadPlugin(__SYCL_LEVEL_ZERO_ADAPTER_NAME); - loadPlugin(__SYCL_CUDA_ADAPTER_NAME); - loadPlugin(__SYCL_HIP_ADAPTER_NAME); - loadPlugin(__SYCL_NATIVE_CPU_ADAPTER_NAME); + DWORD flags = LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32; + auto path = LibSYCLDir / __SYCL_UNIFIED_RUNTIME_LOADER_NAME; + getDllHandle() = LoadLibraryEx(path.wstring().c_str(), NULL, flags); // Restore system error handling. (void)SetErrorMode(SavedMode); @@ -158,40 +133,8 @@ void preloadLibraries() { /// windows_pi.cpp:loadOsPluginLibrary() calls this to get the DLL loaded /// earlier. -__declspec(dllexport) void *getPreloadedPlugin( - const std::filesystem::path &PluginPath) { - - MapT &dllMap = getDllMap(); - - // All entries in the dllMap have the same parent directory. - // To avoid case sensivity issues, we don't want to do string comparison but - // just make sure that directory of the entires in the map and directory of - // the PluginPath are equivalent (point to the same physical location). - auto match = dllMap.end(); - std::error_code ec; - if (!dllMap.empty() && - std::filesystem::equivalent((dllMap.begin())->first.parent_path(), - PluginPath.parent_path(), ec)) { - // Now we can search only by filename. Result might be nullptr (not found), - // which is perfectly valid. - match = - std::find_if(dllMap.begin(), dllMap.end(), - [&](const std::pair &v) { - return v.first.filename() == PluginPath.filename(); - }); - } - - if (match == dllMap.end()) { - // unit testing? return nullptr (not found) rather than risk asserting below - if (PluginPath.string().find("unittests") != std::string::npos) - return nullptr; - - // Otherwise, asking for something we don't know about at all, is an issue. - std::cout << "unknown plugin: " << PluginPath << std::endl; - assert(false && "getPreloadedPlugin was given an unknown plugin path."); - return nullptr; - } - return match->second; +__declspec(dllexport) void *getPreloadedURLib() { + return getDllHandle(); } BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module diff --git a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.hpp b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.hpp index 5c1b887fe11f4..c3c8f8ea0725c 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.hpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.hpp @@ -12,6 +12,5 @@ #include #include -__declspec(dllexport) void *getPreloadedPlugin( - const std::filesystem::path &PluginPath); +__declspec(dllexport) void *getPreloadedURLib(); #endif From 96cf079a477406032a7175bd5eeebe44c5cf7302 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Wed, 4 Sep 2024 14:52:56 +0100 Subject: [PATCH 14/21] Fix formatting --- sycl/cmake/modules/FetchUnifiedRuntime.cmake | 3 ++- sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/FetchUnifiedRuntime.cmake index 8f033a8c78bf9..862a808912558 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/FetchUnifiedRuntime.cmake @@ -23,7 +23,8 @@ option(SYCL_UR_USE_FETCH_CONTENT set(SYCL_UR_SOURCE_DIR "" CACHE PATH "Path to root of Unified Runtime repository") - set(SYCL_UMF_DISABLE_HWLOC ON CACHE BOOL "Disable hwloc support in UMF") +option(SYCL_UMF_DISABLE_HWLOC + "Disable hwloc support in UMF" ON) # Here we override the defaults to disable building tests from unified-runtime set(UR_BUILD_EXAMPLES OFF CACHE BOOL "Build example applications." FORCE) diff --git a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp index b4f8bb0d39054..96713fadee6d4 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp @@ -92,7 +92,7 @@ std::wstring getCurrentDSODir() { // ------------------------------------ void *&getDllHandle() { - static void* dllHandle = nullptr; + static void *dllHandle = nullptr; return dllHandle; } @@ -133,9 +133,7 @@ void preloadLibraries() { /// windows_pi.cpp:loadOsPluginLibrary() calls this to get the DLL loaded /// earlier. -__declspec(dllexport) void *getPreloadedURLib() { - return getDllHandle(); -} +__declspec(dllexport) void *getPreloadedURLib() { return getDllHandle(); } BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module DWORD fdwReason, // reason for calling function From 45145f3210a327d199728b835b8c6b7a45641add Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Wed, 4 Sep 2024 14:59:43 +0100 Subject: [PATCH 15/21] Bump UR tag --- sycl/cmake/modules/FetchUnifiedRuntime.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/FetchUnifiedRuntime.cmake index 862a808912558..a380e53a5f196 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/FetchUnifiedRuntime.cmake @@ -116,14 +116,14 @@ if(SYCL_UR_USE_FETCH_CONTENT) CACHE PATH "Path to external '${name}' adapter source dir" FORCE) endfunction() - set(UNIFIED_RUNTIME_REPO "https://github.com/callumfare/unified-runtime.git") - # commit b766009add8dc41ad03e2a63be9f6ed40eea4c55 (HEAD, origin/main, origin/HEAD) - # Merge: 608e9184 c3c57284 + set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") + # commit 229869c516c6b54d1b6df338e101cdae0eaa057b + # Merge: 02ffa904 3ba6bba5 # Author: Omar Ahmed - # Date: Tue Aug 27 16:30:04 2024 +0100 - # Merge pull request #2011 from nrspruit/fix_opencl_usm_align_check - # [OpenCL] Fix USM alignment error check to occur always and return nulllptr - set(UNIFIED_RUNTIME_TAG callum/ur_api_def) + # Date: Wed Sep 4 14:53:16 2024 +0100 + # Merge pull request #2045 from callumfare/callum/ur_api_def + # Generate .def file with all UR entry points + set(UNIFIED_RUNTIME_TAG 229869c516c6b54d1b6df338e101cdae0eaa057b) set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") # Due to the use of dependentloadflag and no installer for UMF and hwloc we need From ce5a55fc906b62a8130705347afb0e0db0d5fd37 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Wed, 4 Sep 2024 16:12:16 +0100 Subject: [PATCH 16/21] Preload all known adapter libraries --- .../ur_win_proxy_loader.cpp | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp index 96713fadee6d4..832d20a71179a 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp @@ -83,10 +83,22 @@ std::wstring getCurrentDSODir() { return Path; } +// these are cribbed from include/sycl/detail/ur.hpp +// a new plugin must be added to both places. #ifdef _MSC_VER #define __SYCL_UNIFIED_RUNTIME_LOADER_NAME "ur_loader.dll" +#define __SYCL_OPENCL_ADAPTER_NAME "ur_adapter_opencl.dll" +#define __SYCL_LEVEL_ZERO_ADAPTER_NAME "ur_adapter_level_zero.dll" +#define __SYCL_CUDA_ADAPTER_NAME "ur_adapter_cuda.dll" +#define __SYCL_HIP_ADAPTER_NAME "ur_adapter_hip.dll" +#define __SYCL_NATIVE_CPU_ADAPTER_NAME "ur_adapter_native_cpu.dll" #else // llvm-mingw #define __SYCL_UNIFIED_RUNTIME_LOADER_NAME "libur_loader.dll" +#define __SYCL_OPENCL_ADAPTER_NAME "libur_adapter_opencl.dll" +#define __SYCL_LEVEL_ZERO_ADAPTER_NAME "libur_adapter_level_zero.dll" +#define __SYCL_CUDA_ADAPTER_NAME "libur_adapter_cuda.dll" +#define __SYCL_HIP_ADAPTER_NAME "libur_adapter_hip.dll" +#define __SYCL_NATIVE_CPU_ADAPTER_NAME "libur_adapter_native_cpu.dll" #endif // ------------------------------------ @@ -96,7 +108,7 @@ void *&getDllHandle() { return dllHandle; } -/// Load the plugin libraries and store them in a map. +/// Load the plugin libraries void preloadLibraries() { // Suppress system errors. // Tells the system to not display the critical-error-handler message box. @@ -120,9 +132,20 @@ void preloadLibraries() { // list of directories to %windows%\system32 and the directory that contains // the loaded DLL (the plugin). This is necessary to avoid loading dlls from // current directory and some other directories which are considered unsafe. - DWORD flags = LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32; - auto path = LibSYCLDir / __SYCL_UNIFIED_RUNTIME_LOADER_NAME; - getDllHandle() = LoadLibraryEx(path.wstring().c_str(), NULL, flags); + auto loadPlugin = [&](auto pluginName, + DWORD flags = LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | + LOAD_LIBRARY_SEARCH_SYSTEM32) { + auto path = LibSYCLDir / pluginName; + return LoadLibraryEx(path.wstring().c_str(), NULL, flags); + }; + // We keep the UR Loader handle so it can be fetched by the runtime, but the + // adapter libraries themselves won't be used. + getDllHandle() = loadPlugin(__SYCL_UNIFIED_RUNTIME_LOADER_NAME); + loadPlugin(__SYCL_OPENCL_ADAPTER_NAME); + loadPlugin(__SYCL_LEVEL_ZERO_ADAPTER_NAME); + loadPlugin(__SYCL_CUDA_ADAPTER_NAME); + loadPlugin(__SYCL_HIP_ADAPTER_NAME); + loadPlugin(__SYCL_NATIVE_CPU_ADAPTER_NAME); // Restore system error handling. (void)SetErrorMode(SavedMode); From bf7fe5686539dbc2d640d0cad41a7714868f098d Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Thu, 5 Sep 2024 11:44:28 +0100 Subject: [PATCH 17/21] Revert "Call releaseDefaultContexts in shutdown_win" This reverts commit cb57e20df7198d81a4e268cb6545a761547eedc0. --- sycl/source/detail/global_handler.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 579cca5d150dc..0623be269edaf 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -307,7 +307,6 @@ void GlobalHandler::drainThreadPool() { // accidentally retain device handles. etc void shutdown_win() { GlobalHandler *&Handler = GlobalHandler::getInstancePtr(); - Handler->releaseDefaultContexts(); Handler->unloadPlugins(); } #else From 781216610212ff359c8a13553be1c6a8db4c9b88 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Thu, 5 Sep 2024 11:45:00 +0100 Subject: [PATCH 18/21] Revert "Reenable failing tests on Windows" This reverts commit 6ce1e6aeeae3e5f634bd21792409baf4669e0342. --- sycl/test-e2e/Basic/queue/release.cpp | 3 ++- sycl/test-e2e/KernelAndProgram/disable-caching.cpp | 3 +++ .../Regression/context_is_destroyed_after_exception.cpp | 3 ++- sycl/test-e2e/Regression/pi_release.cpp | 3 +++ sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp | 3 ++- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sycl/test-e2e/Basic/queue/release.cpp b/sycl/test-e2e/Basic/queue/release.cpp index 2ca6451a98c07..fe788c59c4bf7 100644 --- a/sycl/test-e2e/Basic/queue/release.cpp +++ b/sycl/test-e2e/Basic/queue/release.cpp @@ -1,7 +1,8 @@ // RUN: %{build} -o %t.out // RUN: env SYCL_UR_TRACE=2 %{run} %t.out | FileCheck %s // -// XFAIL: hip_nvidia +// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 +// XFAIL: hip_nvidia, windows #include int main() { diff --git a/sycl/test-e2e/KernelAndProgram/disable-caching.cpp b/sycl/test-e2e/KernelAndProgram/disable-caching.cpp index 265145d8e49d1..5e8ef4045d641 100644 --- a/sycl/test-e2e/KernelAndProgram/disable-caching.cpp +++ b/sycl/test-e2e/KernelAndProgram/disable-caching.cpp @@ -7,6 +7,9 @@ // RUN: env ZE_DEBUG=-6 SYCL_UR_TRACE=2 %{run} %t.out \ // RUN: | FileCheck %s --check-prefixes=CHECK-CACHE +// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 +// XFAIL: windows + #include #include diff --git a/sycl/test-e2e/Regression/context_is_destroyed_after_exception.cpp b/sycl/test-e2e/Regression/context_is_destroyed_after_exception.cpp index e92dcaa3a6f57..703103f0d1a62 100644 --- a/sycl/test-e2e/Regression/context_is_destroyed_after_exception.cpp +++ b/sycl/test-e2e/Regression/context_is_destroyed_after_exception.cpp @@ -3,7 +3,8 @@ // RUN: %{build} -o %t.out // RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s // -// XFAIL: hip_nvidia +// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 +// XFAIL: hip_nvidia, windows #include diff --git a/sycl/test-e2e/Regression/pi_release.cpp b/sycl/test-e2e/Regression/pi_release.cpp index 90102e5cf0e20..1a28a27d184d9 100644 --- a/sycl/test-e2e/Regression/pi_release.cpp +++ b/sycl/test-e2e/Regression/pi_release.cpp @@ -1,6 +1,9 @@ // REQUIRES: opencl || level_zero || cuda // RUN: %{build} -o %t.out // RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s +// +// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 +// XFAIL: windows #include diff --git a/sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp b/sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp index 3fc020e82e712..dcd1492b63511 100644 --- a/sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp +++ b/sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp @@ -1,7 +1,8 @@ // RUN: %{build} -Wno-error=unused-command-line-argument -fsycl-dead-args-optimization -o %t.out // RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s // -// XFAIL: hip_nvidia +// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768 +// XFAIL: hip_nvidia, windows //==------------------- ReleaseResourcesTests.cpp --------------------------==// // From 96711eba5050624742da9ed0982b911dfa001a82 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Thu, 5 Sep 2024 17:10:37 +0100 Subject: [PATCH 19/21] Fix tracing in ur_win_proxy_loader --- .../forward_progress_kernel_param_L0_gpu.cpp | 1 + sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sycl/test-e2e/forward_progress/forward_progress_kernel_param_L0_gpu.cpp b/sycl/test-e2e/forward_progress/forward_progress_kernel_param_L0_gpu.cpp index 003840a8c1299..8a4a6cc2e0904 100644 --- a/sycl/test-e2e/forward_progress/forward_progress_kernel_param_L0_gpu.cpp +++ b/sycl/test-e2e/forward_progress/forward_progress_kernel_param_L0_gpu.cpp @@ -136,4 +136,5 @@ int main() { check_props(q); check_props(q); check_props(q); + q.wait(); } diff --git a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp index 832d20a71179a..7b1bbde7a1dc3 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp @@ -162,23 +162,23 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module DWORD fdwReason, // reason for calling function LPVOID lpReserved) // reserved { - bool PrintPiTrace = false; - static const char *PiTrace = std::getenv("SYCL_PI_TRACE"); - static const int PiTraceValue = PiTrace ? std::stoi(PiTrace) : 0; - if (PiTraceValue == -1 || PiTraceValue == 2) { // Means print all PI traces - PrintPiTrace = true; + bool PrintUrTrace = false; + static const char *UrTrace = std::getenv("SYCL_UR_TRACE"); + static const int UrTraceValue = UrTrace ? std::stoi(UrTrace) : 0; + if (UrTraceValue == -1 || UrTraceValue == 2) { // Means print all UR traces + PrintUrTrace = true; } switch (fdwReason) { case DLL_PROCESS_ATTACH: - if (PrintPiTrace) + if (PrintUrTrace) std::cout << "---> DLL_PROCESS_ATTACH ur_win_proxy_loader.dll\n" << std::endl; preloadLibraries(); break; case DLL_PROCESS_DETACH: - if (PrintPiTrace) + if (PrintUrTrace) std::cout << "---> DLL_PROCESS_DETACH ur_win_proxy_loader.dll\n" << std::endl; break; From 37052cedfa1af88919b22bf650bea54d1720ab1d Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Fri, 6 Sep 2024 08:26:09 +0100 Subject: [PATCH 20/21] Fix unintentionally updated test --- .../forward_progress/forward_progress_kernel_param_L0_gpu.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/sycl/test-e2e/forward_progress/forward_progress_kernel_param_L0_gpu.cpp b/sycl/test-e2e/forward_progress/forward_progress_kernel_param_L0_gpu.cpp index 8a4a6cc2e0904..003840a8c1299 100644 --- a/sycl/test-e2e/forward_progress/forward_progress_kernel_param_L0_gpu.cpp +++ b/sycl/test-e2e/forward_progress/forward_progress_kernel_param_L0_gpu.cpp @@ -136,5 +136,4 @@ int main() { check_props(q); check_props(q); check_props(q); - q.wait(); } From 58d5182abfd6f9ed787fad30a0291c6fdbe84992 Mon Sep 17 00:00:00 2001 From: Callum Fare Date: Fri, 6 Sep 2024 11:10:09 +0100 Subject: [PATCH 21/21] Ignore malformed SYCL_UR_TRACE in the proxy loader --- sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp index 7b1bbde7a1dc3..d99312a6600b0 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp @@ -164,7 +164,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module { bool PrintUrTrace = false; static const char *UrTrace = std::getenv("SYCL_UR_TRACE"); - static const int UrTraceValue = UrTrace ? std::stoi(UrTrace) : 0; + static int UrTraceValue = 0; + if (UrTrace) { + try { + UrTraceValue = std::stoi(UrTrace); + } catch (...) { + // ignore malformed SYCL_UR_TRACE + } + } + if (UrTraceValue == -1 || UrTraceValue == 2) { // Means print all UR traces PrintUrTrace = true; }