diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 4655a8756e0b..3c529e7e5aeb 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/cmake/modules/AddSYCLUnitTest.cmake b/sycl/cmake/modules/AddSYCLUnitTest.cmake index 2464cb13013c..41a78866512c 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 ur_win_proxy_loader) + endif() + target_include_directories(${test_dirname} PRIVATE SYSTEM ${sycl_inc_dir} diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index 9f306ad47929..1320cf5e8244 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -17,7 +17,6 @@ #include #include #include -# #include #include @@ -48,6 +47,54 @@ class context; namespace detail { +enum class UrApiKind { +#define _UR_API(api) api, +#include +#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(const UrFuncPtrMapT *funcs) { \ + return funcs->pfn_##api; \ + } \ + inline FuncPtrT getFuncPtrFromModule(void *module) { \ + return (FuncPtrT)GetWinProcAddress(module, #api); \ + } \ + }; +#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(const void *) { return &api; } \ + constexpr inline FuncPtrT getFuncPtrFromModule(void *) { return &api; } \ + }; +#include +#undef _UR_API +#endif + 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 +123,8 @@ int unloadOsLibrary(void *Library); // library, implementation is OS dependent. void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName); +void *getURLoaderLibrary(); + // 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 6e67f64bcc2a..5e7cdead48f2 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -168,7 +168,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 ) @@ -183,11 +182,19 @@ 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 + ) + else() + add_dependencies(${LIB_NAME} UnifiedRuntimeLoader) + endif() + target_include_directories(${LIB_NAME} PRIVATE "${UNIFIED_RUNTIME_SRC_INCLUDE_DIR}" diff --git a/sycl/source/backend.cpp b/sycl/source/backend.cpp index e4e85bf79504..e8d2d23f5fbc 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(urPlatformCreateWithNativeHandle, 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(urDeviceCreateWithNativeHandle, 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(urContextCreateWithNativeHandle, 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(urQueueCreateWithNativeHandle, 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(urEventCreateWithNativeHandle, 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(urEventRetain, UrEvent); + Plugin->call(UrEvent); return Event; } @@ -196,50 +196,50 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call(urProgramCreateWithNativeHandle, NativeHandle, - ContextImpl->getHandleRef(), &Properties, &UrProgram); + Plugin->call( + NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrProgram); if (UrProgram == nullptr) throw sycl::exception( sycl::make_error_code(sycl::errc::invalid), "urProgramCreateWithNativeHandle resulted in a null program handle."); 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, - sizeof(NumDevices), &NumDevices, nullptr); + Plugin->call( + UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, + nullptr); ProgramDevices.resize(NumDevices); - Plugin->call(urProgramGetInfo, 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(urProgramGetBuildInfo, 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(urProgramCompileExp, UrProgram, 1, &Dev, - nullptr); + auto Res = Plugin->call_nocheck( + UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck(urProgramCompile, - ContextImpl->getHandleRef(), UrProgram, - nullptr); + Res = Plugin->call_nocheck( + ContextImpl->getHandleRef(), UrProgram, nullptr); } Plugin->checkUrResult(Res); } else if (State == bundle_state::executable) { - auto Res = Plugin->call_nocheck(urProgramBuildExp, UrProgram, 1, &Dev, - nullptr); + 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); } @@ -254,12 +254,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(urProgramLinkExp, 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(urProgramLink, ContextImpl->getHandleRef(), - 1, &UrProgram, nullptr, &UrLinkedProgram); + Res = Plugin->call_nocheck( + ContextImpl->getHandleRef(), 1, &UrProgram, nullptr, + &UrLinkedProgram); } Plugin->checkUrResult(Res); if (UrLinkedProgram != nullptr) { @@ -345,11 +346,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(urKernelCreateWithNativeHandle, NativeHandle, - ContextImpl->getHandleRef(), UrProgram, &Properties, &UrKernel); + 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 26218fed618e..74c860b13602 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(urDeviceCreateWithNativeHandle, 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 ba6c2576adac..491a167656f5 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(urPlatformGetInfo, 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(urPlatformGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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 3e88e9d80cb4..a60be1251bcb 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(urContextCreateWithNativeHandle, 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 2c487e49e470..2aee3418f536 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(urDeviceGetInfo, 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 457411313381..78e1235df74d 100644 --- a/sycl/source/detail/bindless_images.cpp +++ b/sycl/source/detail/bindless_images.cpp @@ -119,9 +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( - urBindlessImagesUnsampledImageHandleDestroyExp, 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, @@ -141,9 +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( - urBindlessImagesSampledImageHandleDestroyExp, 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, @@ -172,9 +174,11 @@ alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice, image_mem_handle retHandle; // Call impl. - Plugin->call( - urBindlessImagesImageAllocateExp, C, Device, &urFormat, &urDesc, - reinterpret_cast(&retHandle.raw_handle)); + Plugin->call( + C, Device, &urFormat, &urDesc, + reinterpret_cast( + &retHandle.raw_handle)); return retHandle; } @@ -198,9 +202,9 @@ __SYCL_EXPORT image_mem_handle get_mip_level_mem_handle( // Call impl. image_mem_handle individual_image; - Plugin->call(urBindlessImagesMipmapGetLevelExp, 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; } @@ -226,13 +230,15 @@ __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,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(urBindlessImagesUnsampledImageCreateExp, C, - Device, memHandle.raw_handle, &urFormat, - &urDesc, &urImageHandle); + Plugin + ->call( + C, Device, memHandle.raw_handle, &urFormat, &urDesc, &urImageHandle); return unsampled_image_handle{urImageHandle}; } @@ -406,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(urSamplerCreate, C, &UrSamplerProps, - &urSampler); + Plugin->call( + C, &UrSamplerProps, &urSampler); ur_image_desc_t urDesc; ur_image_format_t urFormat; @@ -415,10 +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( - urBindlessImagesSampledImageCreateExp, 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}; } @@ -453,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(urBindlessImagesImportExternalMemoryExp, 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}; } @@ -503,10 +512,11 @@ __SYCL_EXPORT external_mem import_external_memory( "Invalid memory handle type"); } - Plugin->call(urBindlessImagesImportExternalMemoryExp, C, - Device, externalMemDesc.size_in_bytes, - urHandleType, &urExternalMemDescriptor, - &urExternalMem); + Plugin + ->call( + C, Device, externalMemDesc.size_in_bytes, urHandleType, + &urExternalMemDescriptor, &urExternalMem); return external_mem{urExternalMem}; } @@ -541,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(urBindlessImagesMapExternalArrayExp, C, - Device, &urFormat, &urDesc, urExternalMem, - &retHandle.raw_handle); + Plugin->call( + C, Device, &urFormat, &urDesc, urExternalMem, &retHandle.raw_handle); return image_mem_handle{retHandle}; } @@ -571,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(urBindlessImagesMapExternalLinearMemoryExp, - C, Device, offset, size, urExternalMem, - &retMemory); + Plugin->call< + sycl::errc::invalid, + sycl::detail::UrApiKind::urBindlessImagesMapExternalLinearMemoryExp>( + C, Device, offset, size, urExternalMem, &retMemory); return retMemory; } @@ -596,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(urBindlessImagesReleaseExternalMemoryExp, C, - Device, extMem.raw_handle); + Plugin + ->call( + C, Device, extMem.raw_handle); } __SYCL_EXPORT void release_external_memory(external_mem extMem, @@ -628,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(urBindlessImagesImportExternalSemaphoreExp, - 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}; @@ -679,9 +693,10 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( "Invalid semaphore handle type"); } - Plugin->call(urBindlessImagesImportExternalSemaphoreExp, - 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}; @@ -707,8 +722,10 @@ release_external_semaphore(external_semaphore externalSemaphore, sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - Plugin->call(urBindlessImagesReleaseExternalSemaphoreExp, - C, Device, externalSemaphore.raw_handle); + Plugin->call< + sycl::errc::invalid, + sycl::detail::UrApiKind::urBindlessImagesReleaseExternalSemaphoreExp>( + C, Device, externalSemaphore.raw_handle); } __SYCL_EXPORT void @@ -728,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(urBindlessImagesImageGetInfoExp, - 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(urBindlessImagesImageGetInfoExp, - 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(urBindlessImagesImageGetInfoExp, - 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}; } @@ -763,9 +780,10 @@ get_image_channel_type(const image_mem_handle memHandle, ur_image_format_t URFormat; - Plugin->call(urBindlessImagesImageGetInfoExp, 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); @@ -799,9 +817,10 @@ __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, - height, elementSizeBytes, &RetVal, resultPitch); + Plugin->call( + UrContext, UrDevice, nullptr, nullptr, widthInBytes, height, + elementSizeBytes, &RetVal, resultPitch); return RetVal; } @@ -847,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(urBindlessImagesImageGetInfoExp, 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 1a7c7825a041..3aa0e06ee7ce 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(urMemRetain, ur::cast(MInteropMemObject)); + Plugin->call( + ur::cast(MInteropMemObject)); ur_native_handle_t NativeHandle = 0; - Plugin->call(urMemGetNativeHandle, 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(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 d738053302e5..36d7b1b6b890 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(urContextCreate, 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(urContextGetInfo, 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(urContextGetInfo, 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(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 +135,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 +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(urContextRetain, getHandleRef()); + Plugin->call(getHandleRef()); ur_native_handle_t Handle; - Plugin->call(urContextGetNativeHandle, 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(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,10 +414,10 @@ std::vector context_impl::initializeDeviceGlobals( // initialize events list. ur_event_handle_t InitEvent; void *const &USMPtr = DeviceGlobalUSM.getPtr(); - Plugin->call(urEnqueueDeviceGlobalVariableWrite, - QueueImpl->getHandleRef(), NativePrg, - DeviceGlobalEntry->MUniqueId.c_str(), false, sizeof(void *), - 0, &USMPtr, 0, nullptr, &InitEvent); + Plugin->call( + 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(urEventRelease, Event); + Plugin->call(Event); MDeviceGlobalInitEvents.clear(); } diff --git a/sycl/source/detail/context_info.hpp b/sycl/source/detail/context_info.hpp index b4ba1f1ec775..75e1b64580e8 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(urContextGetInfo, 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 d12c1de36d02..aceb1437660a 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,8 @@ 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 0786457d3a7c..285d3c6103da 100644 --- a/sycl/source/detail/device_image_impl.hpp +++ b/sycl/source/detail/device_image_impl.hpp @@ -301,9 +301,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; } @@ -312,7 +312,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 bd58c49803c0..ff5db2ec1953 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(urDeviceCreateWithNativeHandle, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceRetain, MDevice); + Plugin->call(MDevice); } // set MPlatform @@ -79,7 +80,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_UR_CODE_NO_EXC(Err); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_impl", e); @@ -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(urDeviceRetain, 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(urDevicePartition, 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(urDevicePartition, 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(urDevicePartition, 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(urDeviceRetain, getHandleRef()); + Plugin->call(getHandleRef()); ur_native_handle_t Handle; - Plugin->call(urDeviceGetNativeHandle, getHandleRef(), &Handle); + Plugin->call(getHandleRef(), &Handle); return Handle; } @@ -406,54 +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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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( - urDeviceGetInfo, 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(urDeviceGetInfo, 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( - urDeviceGetInfo, 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(urDeviceGetInfo, 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( - urDeviceGetInfo, 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(urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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(urDeviceGetInfo, 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; } @@ -461,9 +460,9 @@ 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, - 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 @@ -475,203 +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( - 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, - 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(urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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(urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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: @@ -713,8 +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( - urDeviceGetInfo, getHandleRef(), + getPlugin()->call_nocheck( + getHandleRef(), UrInfoCode::value, sizeof(Result), &Result, nullptr) == UR_RESULT_SUCCESS; @@ -724,9 +705,8 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_graph: { bool SupportsCommandBufferUpdate = false; bool CallSuccessful = - getPlugin()->call_nocheck( - urDeviceGetInfo, 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) { @@ -738,8 +718,8 @@ 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,18 +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( - urDeviceGetInfo, 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( - urDeviceGetInfo, 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: { @@ -829,9 +808,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(urDeviceGetGlobalTimestamps, 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() @@ -868,8 +846,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(urDeviceGetGlobalTimestamps, 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 2341bd1d3736..e57fb55b931e 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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,8 +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( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryOrderBitfield(result); @@ -266,8 +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( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryOrderBitfield(result); @@ -280,8 +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( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryScopeBitfield(result); @@ -294,8 +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( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return readMemoryScopeBitfield(result); @@ -308,8 +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( - urDeviceGetInfo, Dev->getHandleRef(), + auto Err = Dev->getPlugin()->call_nocheck( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); if (Err != UR_RESULT_SUCCESS) { @@ -326,8 +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( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_execution_bitfield(result); @@ -395,8 +395,8 @@ struct get_device_info_impl, const auto &Plugin = Dev->getPlugin(); size_t resultSize; - Plugin->call(urDeviceGetInfo, 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) { @@ -404,8 +404,9 @@ struct get_device_info_impl, } std::unique_ptr arrayResult( new ur_device_partition_t[arrayLength]); - Plugin->call(urDeviceGetInfo, 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) { @@ -427,8 +428,8 @@ 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 +444,8 @@ 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 +454,8 @@ struct get_device_info_implgetPlugin()->call( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); @@ -475,8 +476,8 @@ 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 +486,8 @@ 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,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(urDeviceGetInfo, 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(urDeviceGetInfo, 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()); @@ -562,8 +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( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode>::value, sizeof(result), &result, nullptr); return construct_range(result); @@ -691,11 +692,12 @@ 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(), - 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; @@ -723,13 +725,13 @@ struct get_device_info_impl< return ext::oneapi::experimental::architecture::unknown; }; size_t ResultSize = 0; - Dev->getPlugin()->call(urDeviceGetInfo, 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(urDeviceGetInfo, 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(":")); @@ -970,8 +972,8 @@ 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 +989,8 @@ 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 +1006,8 @@ 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,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(urDeviceGetInfo, 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"); @@ -1095,10 +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( - urDeviceGetInfo, 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 @@ -1112,10 +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( - urDeviceGetInfo, 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 @@ -1128,10 +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( - urDeviceGetInfo, 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); @@ -1144,10 +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( - urDeviceGetInfo, 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 @@ -1162,10 +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( - urDeviceGetInfo, 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); @@ -1190,8 +1197,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( - urDeviceGetInfo, Dev->getHandleRef(), + Dev->getPlugin()->call( + Dev->getHandleRef(), UrInfoCode::value, sizeof(maxRegsPerWG), &maxRegsPerWG, nullptr); @@ -1207,11 +1214,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( - urDeviceGetInfo, 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. @@ -1227,8 +1235,8 @@ 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); @@ -1252,8 +1260,8 @@ 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 3780b526b5fc..7c609adcfcd8 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(urKernelGetInfo, 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(urKernelGetGroupInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urKernelGetGroupInfo, 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(urKernelGetInfo, 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(urProgramGetBuildInfo, 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(urProgramGetBuildInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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 27ddafdde10f..7ca70acc6ae4 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,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(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,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(urEventGetInfo, 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(urEventCreateWithNativeHandle, 0, TempContext, - &NativeProperties, &UREvent); + 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 +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(urEventGetInfo, 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(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 ba8cf469d5c2..119862e08941 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(urEventGetProfilingInfo, 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(urEventGetInfo, 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 8376212984d7..0623be269eda 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -273,7 +273,11 @@ void GlobalHandler::unloadPlugins() { } } - urLoaderTearDown(); + UrFuncInfo loaderTearDownInfo; + auto loaderTearDown = + loaderTearDownInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); + 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 c349cba8a947..53d032d5f767 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -720,9 +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( - urCommandBufferCreateExp, 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"); } @@ -762,7 +763,9 @@ 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"); @@ -808,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(urCommandBufferReleaseExp, CmdBuf); + ur_result_t Res = Plugin->call_nocheck< + sycl::detail::UrApiKind::urCommandBufferReleaseExp>(CmdBuf); (void)Res; assert(Res == UR_RESULT_SUCCESS); } @@ -818,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(urCommandBufferReleaseCommandExp, Command); + ur_result_t Res = Plugin->call_nocheck< + sycl::detail::UrApiKind::urCommandBufferReleaseCommandExp>(Command); (void)Res; assert(Res == UR_RESULT_SUCCESS); } @@ -921,9 +924,11 @@ 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, - 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( @@ -1394,10 +1399,11 @@ 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(), - 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 || @@ -1494,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(urCommandBufferUpdateKernelLaunchExp, - 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(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 c93b3d59ce75..f02c7f594a05 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(urMemImageGetInfo, 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(urMemGetInfo, 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 92ff84c7efec..2a128ba9a901 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(urDeviceGetInfo, 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,8 +452,9 @@ class kernel_bundle_impl { }(); ur_program_handle_t UrProgram = nullptr; - Plugin->call(urProgramCreateWithIL, 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. if (UrProgram == nullptr) throw sycl::exception( @@ -461,29 +462,30 @@ class kernel_bundle_impl { "urProgramCreateWithIL resulted in a null program handle."); std::string XsFlags = extractXsFlags(BuildOptions); - auto Res = - Plugin->call_nocheck(urProgramBuildExp, 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(urProgramBuild, 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(urProgramGetInfo, 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(urProgramGetInfo, 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(urProgramGetInfo, 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, ';'); @@ -535,7 +537,8 @@ 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 c458e6b3d47f..faf3695c04e9 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(urKernelGetInfo, 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(urKernelSetExecInfo, 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(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 e69ddaa2e3f4..ab2950e26a85 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(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 +135,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,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(urKernelSuggestMaxCooperativeGroupCountExp, 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 397aa44f36e5..809a9dd25510 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(urKernelGetInfo, 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(urKernelGetInfo, 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(urKernelGetInfo, 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(urKernelGetSubGroupInfo, 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(urKernelGetInfo, 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(urKernelGetGroupInfo, 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(urKernelGetSubGroupInfo, 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 7492aa796947..bc800b034179 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(urProgramRelease, Val); + ur_result_t Err = + Plugin->call_nocheck(Val); __SYCL_CHECK_UR_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(urKernelRelease, Val.first); + ur_result_t Err = + Plugin->call_nocheck(Val.first); __SYCL_CHECK_UR_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 437db6c877e2..c4281e8df001 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,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(urMemGetNativeHandle, *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(urMemBufferCreate, 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(urMemGetNativeHandle, 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(urMemRelease, 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(urEnqueueMemBufferMap, 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(urEventWait, 1, Event); + Plugin->call_nocheck(1, Event); emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call(urEnqueueMemUnmap, 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(urEventRetain, 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(urMemImageCreate, TargetContext->getHandleRef(), CreationFlags, - &Format, &Desc, UserPtr, &NewMem); + Plugin->call(TargetContext->getHandleRef(), + CreationFlags, &Format, &Desc, + UserPtr, &NewMem); return NewMem; } @@ -446,9 +449,9 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, SizeInBytes}; ur_mem_handle_t NewMem; const PluginPtr &Plugin = TargetContext->getPlugin(); - Error = Plugin->call_nocheck( - urMemBufferPartition, 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), @@ -522,10 +525,10 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferWrite, 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 = @@ -543,11 +546,11 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferWriteRect, 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; @@ -561,10 +564,10 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemImageWrite, 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); } } @@ -605,10 +608,10 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferRead, 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 = @@ -626,11 +629,11 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferReadRect, 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; @@ -644,9 +647,9 @@ 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, - RowPitch, SlicePitch, DstMem, DepEvents.size(), - DepEvents.data(), &OutEvent); + Plugin->call( + Queue, SrcMem, false, Offset, Region, RowPitch, SlicePitch, DstMem, + DepEvents.size(), DepEvents.data(), &OutEvent); } } @@ -681,9 +684,10 @@ 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, - 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 @@ -706,10 +710,10 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemBufferCopyRect, 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], @@ -721,9 +725,9 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueMemImageCopy, Queue, SrcMem, DstMem, SrcOrigin, - DstOrigin, Region, DepEvents.size(), DepEvents.data(), - &OutEvent); + Plugin->call( + Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, DepEvents.size(), + DepEvents.data(), &OutEvent); } } @@ -818,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(urEnqueueMemBufferFill, 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 @@ -913,8 +917,9 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - SrcQueue->getPlugin()->call(urEnqueueEventsWait, SrcQueue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + SrcQueue->getPlugin()->call( + SrcQueue->getHandleRef(), DepEvents.size(), DepEvents.data(), + OutEvent); } return; } @@ -926,9 +931,10 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, const PluginPtr &Plugin = SrcQueue->getPlugin(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(urEnqueueUSMMemcpy, 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, @@ -941,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(urEnqueueEventsWait, Queue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; } @@ -953,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(urEnqueueUSMFill, 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, @@ -966,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(urEnqueueUSMPrefetch, 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, @@ -979,8 +986,8 @@ 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, - OutEvent); + Plugin->call(Queue->getHandleRef(), Mem, + Length, Advice, OutEvent); } void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, @@ -995,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(urEnqueueEventsWait, Queue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; } @@ -1008,17 +1015,19 @@ 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(), - 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(urEnqueueUSMMemcpy2D, 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; } @@ -1046,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(urEnqueueUSMMemcpy, 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(urEnqueueEventsWait, 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, @@ -1071,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(urEnqueueEventsWait, Queue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; } @@ -1083,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(urEnqueueUSMFill2D, 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, @@ -1100,8 +1110,8 @@ void MemoryManager::memset_2d_usm(void *DstMem, QueueImplPtr Queue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call(urEnqueueEventsWait, Queue->getHandleRef(), - DepEvents.size(), DepEvents.data(), OutEvent); + Queue->getPlugin()->call( + Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; } @@ -1233,9 +1243,10 @@ memcpyToDeviceGlobalDirect(QueueImplPtr Queue, ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call(urEnqueueDeviceGlobalVariableWrite, 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 @@ -1249,9 +1260,10 @@ memcpyFromDeviceGlobalDirect(QueueImplPtr Queue, ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call(urEnqueueDeviceGlobalVariableRead, 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( @@ -1331,11 +1343,11 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - Plugin->call(urCommandBufferAppendMemBufferCopyExp, 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 @@ -1357,11 +1369,11 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - Plugin->call(urCommandBufferAppendMemBufferCopyRectExp, 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); } } @@ -1395,11 +1407,11 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendMemBufferReadExp, 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( @@ -1424,11 +1436,12 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendMemBufferReadRectExp, 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), @@ -1469,11 +1482,11 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendMemBufferWriteExp, 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( @@ -1498,11 +1511,12 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( DstAccessRange[DstPos.YTerm], DstAccessRange[DstPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck( - urCommandBufferAppendMemBufferWriteRectExp, 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( @@ -1524,9 +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( - urCommandBufferAppendUSMMemcpyExp, 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), @@ -1548,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(urCommandBufferAppendUSMFillExp, 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( @@ -1578,10 +1593,10 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( size_t RangeMultiplier = AccessRange[0] * AccessRange[1] * AccessRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call(urCommandBufferAppendMemBufferFillExp, 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 @@ -1596,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(urCommandBufferAppendUSMPrefetchExp, 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( @@ -1608,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(urCommandBufferAppendUSMAdviseExp, 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( @@ -1639,9 +1655,10 @@ void MemoryManager::copy_image_bindless( CopyRegion.srcOffset = SrcOffset; CopyRegion.dstOffset = DstOffset; - Plugin->call(urBindlessImagesImageCopyExp, 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 f41912ddd11b..7484ed00150e 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(urProgramGetInfo, 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(urProgramGetInfo, 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(urProgramGetInfo, 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 9e1d07372077..e31b5c36bfab 100644 --- a/sycl/source/detail/physical_mem_impl.hpp +++ b/sycl/source/detail/physical_mem_impl.hpp @@ -43,9 +43,9 @@ class physical_mem_impl { MContext(getSyclObjImpl(SyclContext)), MNumBytes(NumBytes) { const PluginPtr &Plugin = MContext->getPlugin(); - auto Err = Plugin->call_nocheck( - urPhysicalMemCreate, 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) @@ -56,7 +56,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,8 +65,9 @@ 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, - 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 b0b4042b2af3..fea1abbf3a01 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(urDeviceGetInfo, UrDevice, UR_DEVICE_INFO_PLATFORM, sizeof(Plt), - &Plt, nullptr); + Plugin->call(UrDevice, UR_DEVICE_INFO_PLATFORM, + sizeof(Plt), &Plt, nullptr); return getOrMakePlatformImpl(Plt, Plugin); } @@ -227,8 +227,9 @@ 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, - 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; @@ -238,8 +239,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(urDeviceGetInfo, 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; @@ -489,9 +491,9 @@ platform_impl::get_devices(info::device_type DeviceType) const { } uint32_t NumDevices = 0; - MPlugin->call(urDeviceGet, MPlatform, UrDeviceType, - 0, // CP info::device_type::all - nullptr, &NumDevices); + MPlugin->call(MPlatform, UrDeviceType, + 0, // CP info::device_type::all + nullptr, &NumDevices); const backend Backend = getBackend(); if (NumDevices == 0) { @@ -515,9 +517,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(urDeviceGet, 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 @@ -549,7 +552,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 @@ -578,7 +581,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 2469a77a9e43..41be819e0e13 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(urPlatformGetInfo, 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,15 +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( - 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 20e698eaf239..11a7636c3f59 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(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(), - 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 67fd07521e28..3a44b2309132 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -14,6 +14,7 @@ #include #include #include + #include #ifdef XPTI_ENABLE_INSTRUMENTATION // Include the headers necessary for emitting traces using the trace framework @@ -47,7 +48,13 @@ 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::getURLoaderLibrary(); + PopulateUrFuncPtrTable(&UrFuncPtrs, UrLoaderHandle); +#endif + } // Disallow accidental copies of plugins plugin &operator=(const plugin &) = delete; @@ -63,7 +70,8 @@ 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 (message != nullptr && @@ -90,10 +98,10 @@ 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(), - nullptr); + call(&MAdapter, 1, platformCount, + UrPlatforms.data(), nullptr); // We need one entry in this per platform LastDeviceIds.resize(platformCount); }); @@ -106,16 +114,18 @@ 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 { + template + ur_result_t call_nocheck(ArgsT... Args) const { ur_result_t R = UR_RESULT_SUCCESS; if (!adapterReleased) { + detail::UrFuncInfo UrApiInfo; + auto F = UrApiInfo.getFuncPtr(&UrFuncPtrs); R = F(Args...); } return R; @@ -124,16 +134,16 @@ 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(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(ArgsT... Args) const { + auto Err = call_nocheck(Args...); checkUrResult(Err); } @@ -143,7 +153,7 @@ class plugin { bool hasBackend(backend Backend) const { return Backend == MBackend; } void release() { - call(urAdapterRelease, MAdapter); + call(MAdapter); this->adapterReleased = true; } @@ -211,6 +221,8 @@ 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; + 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 80618428c4ef..07b829c6a035 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 *getURLoaderLibrary() { 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 5b22f0cf7f89..fb30de469549 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(urProgramSetSpecializationConstants, 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(urContextGetInfo, 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(urProgramCreateWithBinary, 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(urProgramCreateWithIL, 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(urDeviceSelectBinary, 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(urProgramSetSpecializationConstants, 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(urDeviceGetInfo, 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,7 +803,10 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( enableITTAnnotationsIfNeeded(NativePrg, Plugin); } - ProgramPtr ProgramManaged(NativePrg, urProgramRelease); + UrFuncInfo programReleaseInfo; + auto programRelease = + programReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); + ProgramPtr ProgramManaged(NativePrg, programRelease); // Link a fallback implementation of device libraries if they are not // supported by a device compiler. @@ -845,7 +849,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 +900,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 +908,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,10 +946,10 @@ 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, - std::get(ret_tuple)); - ContextImpl->getPlugin()->call(urProgramRetain, - std::get(ret_tuple)); + ContextImpl->getPlugin()->call( + std::get(ret_tuple)); + ContextImpl->getPlugin()->call( + std::get(ret_tuple)); return ret_tuple; } } @@ -957,17 +961,17 @@ 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, - 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; @@ -999,7 +1003,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(urKernelRetain, KernelArgMaskPair.first); + ContextImpl->getPlugin()->call( + KernelArgMaskPair.first); Cache.saveKernel(key, ret_val); return ret_val; } @@ -1009,8 +1014,9 @@ 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, - sizeof(ur_program_handle_t), &Program, nullptr); + Plugin->call(Kernel, UR_KERNEL_INFO_PROGRAM, + sizeof(ur_program_handle_t), + &Program, nullptr); return Program; } @@ -1019,36 +1025,38 @@ 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, - &URDevicesSize); + 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, - 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(urProgramGetBuildInfo, 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(urProgramGetBuildInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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" + @@ -1149,10 +1157,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(urProgramCompileExp, Program, NumDevs, Devs, Opts); + auto Result = 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,9 +1341,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( - urDeviceSelectBinary, getSyclObjImpl(Device)->getHandleRef(), - UrBinaries.data(), UrBinaries.size(), &ImgInd); + getSyclObjImpl(Context)->getPlugin()->call( + getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), + UrBinaries.size(), &ImgInd); return DeviceFilteredImgs[ImgInd]; } @@ -1417,9 +1426,9 @@ RTDeviceBinaryImage &ProgramManager::getDeviceImage( getUrDeviceTarget(RawImgs[BinaryCount]->DeviceTargetSpec); } - getSyclObjImpl(Context)->getPlugin()->call( - urDeviceSelectBinary, 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 +1556,12 @@ ProgramManager::ProgramPtr ProgramManager::build( const std::string &Options = LinkOptions.empty() ? CompileOptions : (CompileOptions + " " + LinkOptions); - ur_result_t Error = - Plugin->call_nocheck(urProgramBuildExp, 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(urProgramBuild, 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 +1592,14 @@ ProgramManager::ProgramPtr ProgramManager::build( ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck(urProgramLinkExp, 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(urProgramLink, 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,14 +2414,14 @@ 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(), - 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(urProgramLink, 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; }; @@ -2544,7 +2553,10 @@ 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.getFuncPtrFromModule(ur::getURLoaderLibrary()); + ProgramPtr ProgramManaged(NativePrg, programRelease); // Link a fallback implementation of device libraries if they are not // supported by a device compiler. @@ -2614,7 +2626,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 +2646,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,14 +2675,15 @@ 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, - 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. @@ -2700,7 +2713,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 +2767,10 @@ 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.getFuncPtrFromModule(ur::getURLoaderLibrary()); + ProgramPtr ProgramManaged(Program, programRelease); std::string CompileOpts; std::string LinkOpts; @@ -2767,8 +2783,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 4d8533b82a27..d340d0ecd9c1 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(urQueueGetInfo, 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(urQueueFinish, 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(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; } @@ -725,8 +727,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(urQueueGetInfo, 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 e59e71d1c21c..f1cf8dbd9a32 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -187,8 +187,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(urQueueGetInfo, 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( @@ -252,7 +252,7 @@ class queue_impl { destructorNotification(); #endif throw_asynchronous(); - getPlugin()->call(urQueueRelease, MQueues[0]); + getPlugin()->call(MQueues[0]); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~queue_impl", e); } @@ -261,10 +261,10 @@ 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, - &nativeHandle); + getPlugin()->call(MQueues[0], nullptr, + &nativeHandle); return ur::cast(nativeHandle); } @@ -311,7 +311,7 @@ class queue_impl { "recording to a command graph."); } for (const auto &queue : MQueues) { - getPlugin()->call(urQueueFlush, queue); + getPlugin()->call(queue); } } @@ -503,8 +503,8 @@ class queue_impl { .get_index(); Properties.pNext = &IndexProperties; } - ur_result_t Error = Plugin->call_nocheck(urQueueCreate, 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 @@ -546,7 +546,7 @@ class queue_impl { if (!ReuseQueue) *PIQ = createQueue(QueueOrder::Ordered); else - getPlugin()->call(urQueueFinish, *PIQ); + getPlugin()->call(*PIQ); return *PIQ; } @@ -717,8 +717,8 @@ class queue_impl { EventImplPtr insertHelperBarrier(const HandlerType &Handler) { auto ResEvent = std::make_shared(Handler.MQueue); ur_event_handle_t UREvent = nullptr; - getPlugin()->call(urEnqueueEventsWaitWithBarrier, - Handler.MQueue->getHandleRef(), 0, nullptr, &UREvent); + 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 dd117814fba2..cb3e69b6a9a1 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -24,22 +24,24 @@ 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, - reinterpret_cast(clSampler), - getSyclObjImpl(syclContext)->getHandleRef(), nullptr, &Sampler); + Plugin->call( + reinterpret_cast(clSampler), + getSyclObjImpl(syclContext)->getHandleRef(), nullptr, &Sampler); MContextToSampler[syclContext] = Sampler; bool NormalizedCoords; - Plugin->call(urSamplerGetInfo, 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(urSamplerGetInfo, 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(urSamplerGetInfo, 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(urSamplerRelease, Iter.second); + Plugin->call(Iter.second); } } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~sample_impl", e); @@ -129,9 +132,8 @@ 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, - getSyclObjImpl(Context)->getHandleRef(), - &desc, &resultSampler); + errcode_ret = Plugin->call_nocheck( + 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 e9fda9d7b3e2..c9edad0cbb2f 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -350,8 +350,8 @@ class DispatchHostTask { if (RawEvents.size() == 0) continue; try { - PluginWithEvents.first->call(urEventWait, RawEvents.size(), - RawEvents.data()); + PluginWithEvents.first->call(RawEvents.size(), + RawEvents.data()); } catch (const sycl::exception &) { MThisCmd->MEvent->getSubmittedQueue()->reportAsyncException( std::current_exception()); @@ -420,8 +420,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); @@ -436,10 +435,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( - urEnqueueNativeCommandExp, 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); @@ -531,8 +529,8 @@ void Command::waitForEvents(QueueImplPtr Queue, std::vector RawEvents = getUrEvents(CtxWithEvents.second); if (!RawEvents.empty()) { - CtxWithEvents.first->getPlugin()->call(urEventWait, RawEvents.size(), - RawEvents.data()); + CtxWithEvents.first->getPlugin()->call( + RawEvents.size(), RawEvents.data()); } } } else { @@ -542,8 +540,8 @@ void Command::waitForEvents(QueueImplPtr Queue, if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call(urEnqueueEventsWait, Queue->getHandleRef(), RawEvents.size(), - &RawEvents[0], &Event); + Plugin->call( + Queue->getHandleRef(), RawEvents.size(), &RawEvents[0], &Event); } } } @@ -2282,17 +2280,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(urKernelSetArgMemObj, Kernel, NextTrueIndex, &MemObjData, - MemArg); + 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, - nullptr, Arg.MPtr); + Plugin->call( + Kernel, NextTrueIndex, Arg.MSize, nullptr, Arg.MPtr); } else { - Plugin->call(urKernelSetArgLocal, Kernel, NextTrueIndex, Arg.MSize, - nullptr); + Plugin->call(Kernel, NextTrueIndex, + Arg.MSize, nullptr); } break; @@ -2302,15 +2300,16 @@ void SetArgBasedOnType( ur_sampler_handle_t Sampler = (ur_sampler_handle_t)detail::getSyclObjImpl(*SamplerPtr) ->getOrCreateSampler(Context); - Plugin->call(urKernelSetArgSampler, 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(urKernelSetArgPointer, Kernel, NextTrueIndex, nullptr, Ptr); + Plugin->call(Kernel, NextTrueIndex, + nullptr, Ptr); break; } case kernel_param_kind_t::kind_specialization_constants_buffer: { @@ -2322,8 +2321,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(urKernelSetArgMemObj, Kernel, NextTrueIndex, &MemObjProps, - SpecConstsBuffer); + Plugin->call( + Kernel, NextTrueIndex, &MemObjProps, SpecConstsBuffer); break; } case kernel_param_kind_t::kind_invalid: @@ -2376,11 +2375,11 @@ static ur_result_t SetKernelParamsAndLaunch( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call(urKernelGetGroupInfo, 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 || @@ -2412,12 +2411,12 @@ static ur_result_t SetKernelParamsAndLaunch( } ur_event_handle_t UREvent = nullptr; - ur_result_t Error = Plugin->call_nocheck( - urEnqueueKernelLaunchCustomExp, 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); } @@ -2427,10 +2426,11 @@ static ur_result_t SetKernelParamsAndLaunch( ur_result_t Error = [&](auto... Args) { if (IsCooperative) { - return Plugin->call_nocheck(urEnqueueCooperativeKernelLaunchExp, - Args...); + 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], @@ -2512,10 +2512,11 @@ ur_result_t enqueueImpCommandBufferKernel( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call(urKernelGetGroupInfo, 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 || @@ -2524,15 +2525,16 @@ ur_result_t enqueueImpCommandBufferKernel( LocalSize = RequiredWGSize; } - ur_result_t Res = Plugin->call_nocheck( - urCommandBufferAppendKernelLaunchExp, 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(urKernelRelease, UrKernel); - Plugin->call(urProgramRelease, UrProgram); + Plugin->call(UrKernel); + Plugin->call(UrProgram); } if (Res != UR_RESULT_SUCCESS) { @@ -2636,8 +2638,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( - 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); } @@ -2648,8 +2650,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) { @@ -2701,15 +2703,13 @@ 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, - 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( - urEnqueueWriteHostPipe, 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); @@ -2729,7 +2729,8 @@ 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; @@ -3182,17 +3183,15 @@ 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(), - 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; @@ -3202,8 +3201,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const PluginPtr &Plugin = MQueue->getPlugin(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call(urEnqueueEventsWaitWithBarrier, MQueue->getHandleRef(), 0, - nullptr, Event); + Plugin->call( + MQueue->getHandleRef(), 0, nullptr, Event); if (Event) MEvent->setHandle(*Event); return UR_RESULT_SUCCESS; @@ -3220,8 +3219,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const PluginPtr &Plugin = MQueue->getPlugin(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call(urEnqueueEventsWaitWithBarrier, 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; @@ -3237,16 +3236,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(urEnqueueEventsWaitWithBarrier, MQueue->getHandleRef(), - /*num_events_in_wait_list=*/0, - /*event_wait_list=*/nullptr, &PreTimestampBarrierEvent); - Plugin->call(urEventRelease, PreTimestampBarrierEvent); + Plugin->call( + MQueue->getHandleRef(), + /*num_events_in_wait_list=*/0, + /*event_wait_list=*/nullptr, &PreTimestampBarrierEvent); + Plugin->call(PreTimestampBarrierEvent); } - Plugin->call(urEnqueueTimestampRecordingExp, 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; @@ -3294,10 +3294,11 @@ 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, - 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); @@ -3323,9 +3324,9 @@ 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, - MQueue->getHandleRef(), SemWait->getExternalSemaphore(), - OptWaitValue.has_value(), WaitValue, 0, nullptr, nullptr); + Plugin->call( + MQueue->getHandleRef(), SemWait->getExternalSemaphore(), + OptWaitValue.has_value(), WaitValue, 0, nullptr, nullptr); return UR_RESULT_SUCCESS; } @@ -3337,9 +3338,9 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { auto OptSignalValue = SemSignal->getSignalValue(); uint64_t SignalValue = OptSignalValue.has_value() ? OptSignalValue.value() : 0; - Plugin->call(urBindlessImagesSignalExternalSemaphoreExp, - MQueue->getHandleRef(), SemSignal->getExternalSemaphore(), - OptSignalValue.has_value(), SignalValue, 0, nullptr, nullptr); + Plugin->call( + 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 42e4cfc5a186..6d5e9f7712de 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(urMemBufferCreateWithNativeHandle, MemObject, - MInteropContext->getHandleRef(), &MemProperties, - &MInteropMemObject); + Plugin->call( + MemObject, MInteropContext->getHandleRef(), &MemProperties, + &MInteropMemObject); // Get the size of the buffer in bytes - Plugin->call(urMemGetInfo, MInteropMemObject, UR_MEM_INFO_SIZE, - sizeof(size_t), &MSizeInBytes, nullptr); + Plugin->call(MInteropMemObject, UR_MEM_INFO_SIZE, + sizeof(size_t), &MSizeInBytes, nullptr); - Plugin->call(urMemGetInfo, 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(urMemRetain, 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(urMemImageCreateWithNativeHandle, MemObject, - MInteropContext->getHandleRef(), &Format, &Desc, - &NativeProperties, &MInteropMemObject); + Plugin->call( + MemObject, MInteropContext->getHandleRef(), &Format, &Desc, + &NativeProperties, &MInteropMemObject); - Plugin->call(urMemGetInfo, 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(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,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(urMemGetInfo, 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 5bedb094efe2..fb70b92e3b29 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -50,9 +50,9 @@ void contextSetExtendedDeleter(const sycl::context &context, void *user_data) { auto impl = getSyclObjImpl(context); const auto &Plugin = impl->getPlugin(); - Plugin->call(urContextSetExtendedDeleter, impl->getHandleRef(), - reinterpret_cast(func), - user_data); + Plugin->call( + impl->getHandleRef(), + reinterpret_cast(func), user_data); } } // namespace pi @@ -114,10 +114,35 @@ static void initializePlugins(std::vector &Plugins, ur_loader_config_handle_t LoaderConfig) { #define CHECK_UR_SUCCESS(Call) __SYCL_CHECK_UR_CODE_NO_EXC(Call) + UrFuncInfo loaderConfigCreateInfo; + auto loaderConfigCreate = + loaderConfigCreateInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); + UrFuncInfo loaderConfigEnableLayerInfo; + auto loaderConfigEnableLayer = + loaderConfigEnableLayerInfo.getFuncPtrFromModule( + ur::getURLoaderLibrary()); + UrFuncInfo loaderConfigReleaseInfo; + auto loaderConfigRelease = + loaderConfigReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); + UrFuncInfo + loaderConfigSetCodeLocationCallbackInfo; + auto loaderConfigSetCodeLocationCallback = + loaderConfigSetCodeLocationCallbackInfo.getFuncPtrFromModule( + ur::getURLoaderLibrary()); + UrFuncInfo loaderInitInfo; + auto loaderInit = + loaderInitInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); + UrFuncInfo adapterGet_Info; + auto adapterGet = + adapterGet_Info.getFuncPtrFromModule(ur::getURLoaderLibrary()); + UrFuncInfo adapterGetInfoInfo; + auto adapterGetInfo = + adapterGetInfoInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); + 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; } @@ -128,8 +153,7 @@ static void initializePlugins(std::vector &Plugins, #else setenv("UR_LOG_TRACING", LogOptions, 1); #endif - CHECK_UR_SUCCESS( - urLoaderConfigEnableLayer(LoaderConfig, "UR_LAYER_TRACING")); + CHECK_UR_SUCCESS(loaderConfigEnableLayer(LoaderConfig, "UR_LAYER_TRACING")); } if (trace(TraceLevel::TRACE_BASIC)) { @@ -140,39 +164,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, - nullptr); + 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) { @@ -195,9 +219,9 @@ 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, - sizeof(adapterBackend), &adapterBackend, - nullptr)); + CHECK_UR_SUCCESS(adapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, + 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 335d6ecd11ba..e15e5c97a147 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 3270907ee9a0..f9f4ebf7beb0 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(urUSMHostAlloc, 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(urUSMDeviceAlloc, 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(urUSMSharedAlloc, 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(urUSMFree, C, Ptr); + Plugin->call(C, Ptr); } void free(void *Ptr, const context &Ctxt, @@ -529,9 +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( - urUSMGetMemAllocInfo, 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) @@ -590,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(urUSMGetMemAllocInfo, 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. @@ -612,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(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 +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(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 f730b087a67a..6f8d1f7ae6bd 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) { @@ -70,6 +75,8 @@ static std::filesystem::path getCurrentDSODirPath() { return std::filesystem::path(Path); } +void *getURLoaderLibrary() { return getPreloadedURLib(); } + } // namespace ur } // namespace detail } // namespace _V1 diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index b7872d3e5465..1a4d1cb9c4a7 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, - detail::ur::cast(DeviceId), - Plugin->getUrAdapter(), nullptr, &Device); + 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; } @@ -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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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(urDeviceGetInfo, 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 169829801460..c1cd030f6841 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -30,8 +30,8 @@ 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, - detail::ur::cast(ClEvent)); + impl->getPlugin()->call( + 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 45babb8e730e..db5006832885 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -1604,8 +1604,9 @@ 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, - sizeof(ur_bool_t), &SupportsOp, nullptr); + Plugin->call(ContextImpl->getHandleRef(), + InfoQuery, sizeof(ur_bool_t), + &SupportsOp, nullptr); return SupportsOp; } @@ -1839,8 +1840,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( - 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 0d70f12de3d2..fa5f5910a2e6 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 83b6f2b34645..f4ec76bcf9e7 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(urKernelCreateWithNativeHandle, 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(urKernelRetain, hKernel); + impl->getPlugin()->call(hKernel); } } diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index ea3802894cef..b9ec5073fb7e 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -25,9 +25,9 @@ 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, - detail::ur::cast(PlatformId), - Plugin->getUrAdapter(), /* pProperties = */ nullptr, &UrPlatform); + 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 7ba508692b9b..5a9a88f884b6 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(urVirtualMemGranularityGetInfo, 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(urVirtualMemGranularityGetInfo, ContextImpl->getHandleRef(), - DeviceImpl->getHandleRef(), GranularityQuery, sizeof(size_t), - &Granularity, nullptr); + Plugin->call( + ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery, + sizeof(size_t), &Granularity, nullptr); if (Granularity == 0) throw sycl::exception( sycl::make_error_code(sycl::errc::invalid), @@ -119,8 +119,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(urVirtualMemReserve, ContextImpl->getHandleRef(), - reinterpret_cast(Start), NumBytes, &OutPtr); + Plugin->call( + ContextImpl->getHandleRef(), reinterpret_cast(Start), NumBytes, + &OutPtr); return reinterpret_cast(OutPtr); } @@ -129,8 +130,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(urVirtualMemFree, 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, @@ -140,8 +141,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(urVirtualMemSetAccess, ContextImpl->getHandleRef(), Ptr, - NumBytes, AccessFlags); + Plugin->call( + ContextImpl->getHandleRef(), Ptr, NumBytes, AccessFlags); } __SYCL_EXPORT address_access_mode get_access_mode(const void *Ptr, @@ -152,15 +153,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(urVirtualMemGetInfo, 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(urVirtualMemGetInfo, 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; @@ -174,7 +177,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(urVirtualMemUnmap, ContextImpl->getHandleRef(), Ptr, NumBytes); + Plugin->call( + ContextImpl->getHandleRef(), Ptr, NumBytes); } } // Namespace ext::oneapi::experimental diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index 400fb2c13c49..6cb1be75681e 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 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 7538475eb961..d99312a6600b 100644 --- a/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp +++ b/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp @@ -103,14 +103,12 @@ std::wstring getCurrentDSODir() { // ------------------------------------ -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. +/// Load the plugin libraries void preloadLibraries() { // Suppress system errors. // Tells the system to not display the critical-error-handler message box. @@ -130,8 +128,6 @@ 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 @@ -140,9 +136,11 @@ void preloadLibraries() { 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)); + return LoadLibraryEx(path.wstring().c_str(), NULL, flags); }; - loadPlugin(__SYCL_UNIFIED_RUNTIME_LOADER_NAME); + // 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); @@ -158,63 +156,37 @@ 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 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 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; } 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; 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 5c1b887fe11f..c3c8f8ea0725 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