diff --git a/llvm-spirv/CMakeLists.txt b/llvm-spirv/CMakeLists.txt index a90a7017a218f..b1ef887e727d9 100644 --- a/llvm-spirv/CMakeLists.txt +++ b/llvm-spirv/CMakeLists.txt @@ -113,28 +113,28 @@ endif() set(LLVM_SPIRV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) # first try locating SPIRV-Tools via pkgconfig (the old way) -pkg_search_module(SPIRV_TOOLS SPIRV-Tools) -if (NOT SPIRV_TOOLS_FOUND) - # then try locating SPIRV-Tools via cmake (the new way) - find_package(SPIRV-Tools) - find_package(SPIRV-Tools-tools) - if (SPIRV-Tools_FOUND AND SPIRV-Tools-tools_FOUND) - set(SPIRV_TOOLS_FOUND TRUE) - # check for the existance of library targets in the found packages - if(TARGET SPIRV-Tools-shared) - # use the shared libary target if present - set(SPIRV-Tools-library SPIRV-Tools-shared) - elseif(TARGET SPIRV-Tools-static) - # otherwise fallback to the static library target - set(SPIRV-Tools-library SPIRV-Tools-static) - else() - message(FATAL_ERROR "Found SPIRV-Tools package but neither " - "SPIRV-Tools-shared or SPIRV-Tools-static targets exist.") - endif() - set(SPIRV_TOOLS_LDFLAGS ${SPIRV-Tools-library}) - get_target_property(SPIRV_TOOLS_INCLUDE_DIRS ${SPIRV-Tools-library} INTERFACE_INCLUDE_DIRECTORIES) - endif() -endif() +#pkg_search_module(SPIRV_TOOLS SPIRV-Tools) +#if (NOT SPIRV_TOOLS_FOUND) +# # then try locating SPIRV-Tools via cmake (the new way) +# find_package(SPIRV-Tools) +# find_package(SPIRV-Tools-tools) +# if (SPIRV-Tools_FOUND AND SPIRV-Tools-tools_FOUND) +# set(SPIRV_TOOLS_FOUND TRUE) +# # check for the existance of library targets in the found packages +# if(TARGET SPIRV-Tools-shared) +# # use the shared libary target if present +# set(SPIRV-Tools-library SPIRV-Tools-shared) +# elseif(TARGET SPIRV-Tools-static) +# # otherwise fallback to the static library target +# set(SPIRV-Tools-library SPIRV-Tools-static) +# else() +# message(FATAL_ERROR "Found SPIRV-Tools package but neither " +# "SPIRV-Tools-shared or SPIRV-Tools-static targets exist.") +# endif() +# set(SPIRV_TOOLS_LDFLAGS ${SPIRV-Tools-library}) +# get_target_property(SPIRV_TOOLS_INCLUDE_DIRS ${SPIRV-Tools-library} INTERFACE_INCLUDE_DIRECTORIES) +# endif() +#endif() if (NOT SPIRV_TOOLS_FOUND) message(STATUS "SPIRV-Tools not found; project will be built without " diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index 1320cf5e82449..6d7d36e6155b5 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -103,12 +103,12 @@ __SYCL_EXPORT void contextSetExtendedDeleter(const sycl::context &constext, void *user_data); } -class plugin; -using PluginPtr = std::shared_ptr; +class adapter; +using AdapterPtr = std::shared_ptr; // TODO: To be removed as this was only introduced for esimd which was removed. template -__SYCL_EXPORT void *getPluginOpaqueData(void *opaquedata_arg); +__SYCL_EXPORT void *getAdapterOpaqueData(void *opaquedata_arg); namespace ur { // Function to load a shared library @@ -126,11 +126,11 @@ void *getOsLibraryFuncAddress(void *Library, const std::string &FunctionName); void *getURLoaderLibrary(); // Performs UR one-time initialization. -std::vector & +std::vector & initializeUr(ur_loader_config_handle_t LoaderConfig = nullptr); -// Get the plugin serving given backend. -template const PluginPtr &getPlugin(); +// Get the adapter serving given backend. +template const AdapterPtr &getAdapter(); // The SYCL_UR_TRACE sets what we will trace. // This is a bit-mask of various things we'd want to trace. diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 6181a41e6ef8c..8cbd98707a932 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -768,16 +768,16 @@ class __SYCL_EXPORT handler { int ArgIndex); /* The kernel passed to StoreLambda can take an id, an item or an nd_item as - * its argument. Since esimd plugin directly invokes the kernel (doesn’t use - * piKernelSetArg), the kernel argument type must be known to the plugin. - * However, passing kernel argument type to the plugin requires changing ABI + * its argument. Since esimd adapter directly invokes the kernel (doesn’t use + * urKernelSetArg), the kernel argument type must be known to the plugin. + * However, passing kernel argument type to the adapter requires changing ABI * in HostKernel class. To overcome this problem, helpers below wrap the * “original” kernel with a functor that always takes an nd_item as argument. * A functor is used instead of a lambda because extractArgsAndReqsFromLambda * needs access to the “original” kernel and keeps references to its internal * data, i.e. the kernel passed as argument cannot be local in scope. The * functor itself is again encapsulated in a std::function since functor’s - * type is unknown to the plugin. + * type is unknown to the adapter. */ // For 'id, item w/wo offset, nd_item' kernel arguments diff --git a/sycl/source/backend.cpp b/sycl/source/backend.cpp index e8d2d23f5fbce..1692faec814d7 100644 --- a/sycl/source/backend.cpp +++ b/sycl/source/backend.cpp @@ -11,7 +11,7 @@ #include "detail/kernel_bundle_impl.hpp" #include "detail/kernel_id_impl.hpp" #include "detail/platform_impl.hpp" -#include "detail/plugin.hpp" +#include "detail/adapter.hpp" #include "detail/queue_impl.hpp" #include "sycl/detail/impl_utils.hpp" #include @@ -29,20 +29,20 @@ namespace sycl { inline namespace _V1 { namespace detail { -static const PluginPtr &getPlugin(backend Backend) { +static const AdapterPtr &getAdapter(backend Backend) { switch (Backend) { case backend::opencl: - return ur::getPlugin(); + return ur::getAdapter(); case backend::ext_oneapi_level_zero: - return ur::getPlugin(); + return ur::getAdapter(); case backend::ext_oneapi_cuda: - return ur::getPlugin(); + return ur::getAdapter(); case backend::ext_oneapi_hip: - return ur::getPlugin(); + return ur::getAdapter(); default: throw sycl::exception( sycl::make_error_code(sycl::errc::runtime), - "getPlugin: Unsupported backend " + + "getAdapter: Unsupported backend " + detail::codeToString(UR_RESULT_ERROR_INVALID_OPERATION)); } } @@ -68,34 +68,34 @@ backend convertUrBackend(ur_platform_backend_t UrBackend) { } platform make_platform(ur_native_handle_t NativeHandle, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); // Create UR platform first. ur_platform_handle_t UrPlatform = nullptr; - Plugin->call( - NativeHandle, Plugin->getUrAdapter(), nullptr, &UrPlatform); + Adapter->call( + NativeHandle, Adapter->getUrAdapter(), nullptr, &UrPlatform); return detail::createSyclObjFromImpl( - platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin)); + platform_impl::getOrMakePlatformImpl(UrPlatform, Adapter)); } __SYCL_EXPORT device make_device(ur_native_handle_t NativeHandle, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); ur_device_handle_t UrDevice = nullptr; - Plugin->call( - NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice); + Adapter->call( + NativeHandle, Adapter->getUrAdapter(), nullptr, &UrDevice); // Construct the SYCL device from UR device. return detail::createSyclObjFromImpl( - std::make_shared(UrDevice, Plugin)); + std::make_shared(UrDevice, Adapter)); } __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle, const async_handler &Handler, backend Backend, bool KeepOwnership, const std::vector &DeviceList) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); ur_context_handle_t UrContext = nullptr; ur_context_native_properties_t Properties{}; @@ -105,12 +105,12 @@ __SYCL_EXPORT context make_context(ur_native_handle_t NativeHandle, for (const auto &Dev : DeviceList) { DeviceHandles.push_back(detail::getSyclObjImpl(Dev)->getHandleRef()); } - Plugin->call( - NativeHandle, Plugin->getUrAdapter(), DeviceHandles.size(), + Adapter->call( + NativeHandle, Adapter->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)); + UrContext, Handler, Adapter, DeviceList, !KeepOwnership)); } __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, @@ -120,7 +120,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, const async_handler &Handler, backend Backend) { ur_device_handle_t UrDevice = Device ? getSyclObjImpl(*Device)->getHandleRef() : nullptr; - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); const auto &ContextImpl = getSyclObjImpl(Context); if (PropList.has_property()) { @@ -150,7 +150,7 @@ __SYCL_EXPORT queue make_queue(ur_native_handle_t NativeHandle, // Create UR queue first. ur_queue_handle_t UrQueue = nullptr; - Plugin->call( + Adapter->call( NativeHandle, ContextImpl->getHandleRef(), UrDevice, &NativeProperties, &UrQueue); // Construct the SYCL queue from UR queue. @@ -166,7 +166,7 @@ __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle, __SYCL_EXPORT event make_event(ur_native_handle_t NativeHandle, const context &Context, bool KeepOwnership, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); const auto &ContextImpl = getSyclObjImpl(Context); ur_event_handle_t UrEvent = nullptr; @@ -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( + Adapter->call( NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrEvent); event Event = detail::createSyclObjFromImpl( std::make_shared(UrEvent, Context)); if (Backend == backend::opencl) - Plugin->call(UrEvent); + Adapter->call(UrEvent); return Event; } @@ -188,7 +188,7 @@ std::shared_ptr make_kernel_bundle(ur_native_handle_t NativeHandle, const context &TargetContext, bool KeepOwnership, bundle_state State, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); const auto &ContextImpl = getSyclObjImpl(TargetContext); ur_program_handle_t UrProgram = nullptr; @@ -196,7 +196,7 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_NATIVE_PROPERTIES; Properties.isNativeHandleOwned = !KeepOwnership; - Plugin->call( + Adapter->call( NativeHandle, ContextImpl->getHandleRef(), &Properties, &UrProgram); if (UrProgram == nullptr) throw sycl::exception( @@ -204,44 +204,44 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, "urProgramCreateWithNativeHandle resulted in a null program handle."); if (ContextImpl->getBackend() == backend::opencl) - Plugin->call(UrProgram); + Adapter->call(UrProgram); std::vector ProgramDevices; uint32_t NumDevices = 0; - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, nullptr); ProgramDevices.resize(NumDevices); - Plugin->call( + Adapter->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( + Adapter->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( + auto Res = Adapter->call_nocheck( UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), UrProgram, nullptr); } - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); } else if (State == bundle_state::executable) { - auto Res = Plugin->call_nocheck( + auto Res = Adapter->call_nocheck( UrProgram, 1, &Dev, nullptr); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), UrProgram, nullptr); } - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); } break; @@ -254,15 +254,15 @@ 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( + auto Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), 1, &Dev, 1, &UrProgram, nullptr, &UrLinkedProgram); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), 1, &UrProgram, nullptr, &UrLinkedProgram); } - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); if (UrLinkedProgram != nullptr) { UrProgram = UrLinkedProgram; } @@ -284,9 +284,9 @@ make_kernel_bundle(ur_native_handle_t NativeHandle, Devices.reserve(ProgramDevices.size()); std::transform( ProgramDevices.begin(), ProgramDevices.end(), std::back_inserter(Devices), - [&Plugin](const auto &Dev) { + [&Adapter](const auto &Dev) { auto Platform = - detail::platform_impl::getPlatformFromUrDevice(Dev, Plugin); + detail::platform_impl::getPlatformFromUrDevice(Dev, Adapter); auto DeviceImpl = Platform->getOrMakeDeviceImpl(Dev, Platform); return createSyclObjFromImpl(DeviceImpl); }); @@ -316,7 +316,7 @@ kernel make_kernel(const context &TargetContext, const kernel_bundle &KernelBundle, ur_native_handle_t NativeHandle, bool KeepOwnership, backend Backend) { - const auto &Plugin = getPlugin(Backend); + const auto &Adapter = getAdapter(Backend); const auto &ContextImpl = getSyclObjImpl(TargetContext); const auto KernelBundleImpl = getSyclObjImpl(KernelBundle); @@ -346,12 +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( + Adapter->call( NativeHandle, ContextImpl->getHandleRef(), UrProgram, &Properties, &UrKernel); if (Backend == backend::opencl) - Plugin->call(UrKernel); + Adapter->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 74c860b136028..e47ecc38da0ca 100644 --- a/sycl/source/backend/level_zero.cpp +++ b/sycl/source/backend/level_zero.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include -#include +#include #include #include #include @@ -19,12 +19,12 @@ using namespace sycl::detail; __SYCL_EXPORT device make_device(const platform &Platform, ur_native_handle_t NativeHandle) { - const auto &Plugin = ur::getPlugin(); + const auto &Adapter = ur::getAdapter(); const auto &PlatformImpl = getSyclObjImpl(Platform); // Create UR device first. ur_device_handle_t UrDevice; - Plugin->call( - NativeHandle, Plugin->getUrAdapter(), nullptr, &UrDevice); + Adapter->call( + NativeHandle, Adapter->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 491a167656f58..0de5b5c463469 100644 --- a/sycl/source/backend/opencl.cpp +++ b/sycl/source/backend/opencl.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -32,21 +32,21 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, std::shared_ptr PlatformImpl = getSyclObjImpl(SyclPlatform); - ur_platform_handle_t PluginPlatform = PlatformImpl->getHandleRef(); - const PluginPtr &Plugin = PlatformImpl->getPlugin(); + ur_platform_handle_t AdapterPlatform = PlatformImpl->getHandleRef(); + const AdapterPtr &Adapter = PlatformImpl->getAdapter(); - // Manual invocation of plugin API to avoid using deprecated + // Manual invocation of UR API to avoid using deprecated // info::platform::extensions call. size_t ResultSize = 0; - Plugin->call( - PluginPlatform, UR_PLATFORM_INFO_EXTENSIONS, + Adapter->call( + AdapterPlatform, UR_PLATFORM_INFO_EXTENSIONS, /*propSize=*/0, /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) return false; std::unique_ptr Result(new char[ResultSize]); - Plugin->call(PluginPlatform, + Adapter->call(AdapterPlatform, UR_PLATFORM_INFO_EXTENSIONS, ResultSize, Result.get(), nullptr); @@ -64,13 +64,13 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, std::shared_ptr DeviceImpl = getSyclObjImpl(SyclDevice); - ur_device_handle_t PluginDevice = DeviceImpl->getHandleRef(); - const PluginPtr &Plugin = DeviceImpl->getPlugin(); + ur_device_handle_t AdapterDevice = DeviceImpl->getHandleRef(); + const AdapterPtr &Adapter = DeviceImpl->getAdapter(); - // Manual invocation of plugin API to avoid using deprecated + // Manual invocation of UR API to avoid using deprecated // info::device::extensions call. size_t ResultSize = 0; - Plugin->call(PluginDevice, + Adapter->call(AdapterDevice, UR_DEVICE_INFO_EXTENSIONS, /*propSize=*/0, /*pPropValue=*/nullptr, &ResultSize); @@ -78,7 +78,7 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, return false; std::unique_ptr Result(new char[ResultSize]); - Plugin->call(PluginDevice, + Adapter->call(AdapterDevice, UR_DEVICE_INFO_EXTENSIONS, ResultSize, Result.get(), nullptr); diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index a60be1251bcba..3afbb0520d996 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -72,16 +72,16 @@ context::context(const std::vector &DeviceList, PropList); } context::context(cl_context ClContext, async_handler AsyncHandler) { - const auto &Plugin = sycl::detail::ur::getPlugin(); + const auto &Adapter = sycl::detail::ur::getAdapter(); ur_context_handle_t hContext = nullptr; ur_native_handle_t nativeHandle = reinterpret_cast(ClContext); - Plugin->call( - nativeHandle, Plugin->getUrAdapter(), 0, nullptr, nullptr, &hContext); + Adapter->call( + nativeHandle, Adapter->getUrAdapter(), 0, nullptr, nullptr, &hContext); impl = std::make_shared( - hContext, AsyncHandler, Plugin); + hContext, AsyncHandler, Adapter); } template diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/adapter.hpp similarity index 85% rename from sycl/source/detail/plugin.hpp rename to sycl/source/detail/adapter.hpp index 22f9ed96cb589..1f655f91fd2fe 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/adapter.hpp @@ -1,4 +1,4 @@ -//==- plugin.hpp -----------------------------------------------------------==// +//==- adapter.hpp -----------------------------------------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -37,18 +37,18 @@ namespace sycl { inline namespace _V1 { namespace detail { -/// The plugin class provides a unified interface to the underlying low-level +/// The adapter class provides a unified interface to the underlying low-level /// runtimes for the device-agnostic SYCL runtime. /// /// \ingroup sycl_ur -class plugin { +class adapter { public: - plugin() = delete; + adapter() = delete; - plugin(ur_adapter_handle_t adapter, backend UseBackend) + adapter(ur_adapter_handle_t adapter, backend UseBackend) : MAdapter(adapter), MBackend(UseBackend), TracingMutex(std::make_shared()), - MPluginMutex(std::make_shared()) { + MAdapterMutex(std::make_shared()) { #ifdef _WIN32 UrLoaderHandle = ur::getURLoaderLibrary(); @@ -56,13 +56,13 @@ class plugin { #endif } - // Disallow accidental copies of plugins - plugin &operator=(const plugin &) = delete; - plugin(const plugin &) = delete; - plugin &operator=(plugin &&other) noexcept = delete; - plugin(plugin &&other) noexcept = delete; + // Disallow accidental copies of adapters + adapter &operator=(const adapter &) = delete; + adapter(const adapter &) = delete; + adapter &operator=(adapter &&other) noexcept = delete; + adapter(adapter &&other) noexcept = delete; - ~plugin() = default; + ~adapter() = default; /// \throw SYCL 2020 exception(errc) if ur_result is not UR_RESULT_SUCCESS template @@ -114,12 +114,12 @@ class plugin { /// /// Usage: /// \code{cpp} - /// ur_result_t Err = Plugin->call(Args); - /// Plugin->checkUrResult(Err); // Checks Result and throws a runtime_error + /// ur_result_t Err = Adapter->call(Args); + /// Adapter->checkUrResult(Err); // Checks Result and throws a runtime_error /// // exception. /// \endcode /// - /// \sa plugin::checkUrResult + /// \sa adapter::checkUrResult template ur_result_t call_nocheck(ArgsT... Args) const { ur_result_t R = UR_RESULT_SUCCESS; @@ -147,9 +147,9 @@ class plugin { checkUrResult(Err); } - /// Tells if this plugin can serve specified backend. - /// For example, Unified Runtime plugin will be able to serve - /// multiple backends as determined by the platforms reported by the plugin. + /// Tells if this adapter can serve specified backend. + /// For example, Unified Runtime adapter will be able to serve + /// multiple backends as determined by the platforms reported by the adapter. bool hasBackend(backend Backend) const { return Backend == MBackend; } void release() { @@ -170,7 +170,7 @@ class plugin { return UrPlatforms.size() - 1; } - // Device ids are consecutive across platforms within a plugin. + // Device ids are consecutive across platforms within a adapter. // We need to return the same starting index for the given platform. // So, instead of returing the last device id of the given platform, // return the last device id of the predecessor platform. @@ -204,7 +204,7 @@ class plugin { return It != UrPlatforms.end(); } - std::shared_ptr getPluginMutex() { return MPluginMutex; } + std::shared_ptr getAdapterMutex() { return MAdapterMutex; } bool adapterReleased = false; private: @@ -214,8 +214,8 @@ class plugin { // Mutex to guard UrPlatforms and LastDeviceIds. // Note that this is a temporary solution until we implement the global // Device/Platform cache later. - std::shared_ptr MPluginMutex; - // vector of UrPlatforms that belong to this plugin + std::shared_ptr MAdapterMutex; + // vector of UrPlatforms that belong to this adapter std::once_flag PlatformsPopulated; std::vector UrPlatforms; // represents the unique ids of the last device of each platform @@ -225,9 +225,9 @@ class plugin { void *UrLoaderHandle = nullptr; #endif UrFuncPtrMapT UrFuncPtrs; -}; // class plugin +}; // class adapter -using PluginPtr = std::shared_ptr; +using AdapterPtr = std::shared_ptr; } // namespace detail } // namespace _V1 diff --git a/sycl/source/detail/allowlist.cpp b/sycl/source/detail/allowlist.cpp index 2aee3418f536a..0339f1db3283c 100644 --- a/sycl/source/detail/allowlist.cpp +++ b/sycl/source/detail/allowlist.cpp @@ -345,7 +345,7 @@ bool deviceIsAllowed(const DeviceDescT &DeviceDesc, } void applyAllowList(std::vector &UrDevices, - ur_platform_handle_t UrPlatform, const PluginPtr &Plugin) { + ur_platform_handle_t UrPlatform, const AdapterPtr &Adapter) { AllowListParsedT AllowListParsed = parseAllowList(SYCLConfig::get()); @@ -354,7 +354,7 @@ void applyAllowList(std::vector &UrDevices, // Get platform's backend and put it to DeviceDesc DeviceDescT DeviceDesc; - auto PlatformImpl = platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin); + auto PlatformImpl = platform_impl::getOrMakePlatformImpl(UrPlatform, Adapter); backend Backend = PlatformImpl->getBackend(); for (const auto &SyclBe : getSyclBeMap()) { @@ -366,18 +366,18 @@ void applyAllowList(std::vector &UrDevices, // get PlatformVersion value and put it to DeviceDesc DeviceDesc.emplace(PlatformVersionKeyName, sycl::detail::get_platform_info( - UrPlatform, Plugin)); + UrPlatform, Adapter)); // get PlatformName value and put it to DeviceDesc DeviceDesc.emplace(PlatformNameKeyName, sycl::detail::get_platform_info( - UrPlatform, Plugin)); + UrPlatform, Adapter)); int InsertIDx = 0; for (ur_device_handle_t Device : 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( + Adapter->call( Device, UR_DEVICE_INFO_TYPE, sizeof(UrDevType), &UrDevType, nullptr); // TODO need mechanism to do these casts, there's a bunch of this sort of // thing diff --git a/sycl/source/detail/allowlist.hpp b/sycl/source/detail/allowlist.hpp index aa29bd59e4551..8f3d204033e9c 100644 --- a/sycl/source/detail/allowlist.hpp +++ b/sycl/source/detail/allowlist.hpp @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include @@ -28,7 +28,7 @@ bool deviceIsAllowed(const DeviceDescT &DeviceDesc, const AllowListParsedT &AllowListParsed); void applyAllowList(std::vector &UrDevices, - ur_platform_handle_t UrPlatform, const PluginPtr &Plugin); + ur_platform_handle_t UrPlatform, const AdapterPtr &Adapter); } // namespace detail } // namespace _V1 diff --git a/sycl/source/detail/bindless_images.cpp b/sycl/source/detail/bindless_images.cpp index 78e1235df74df..4c1a072ed97b0 100644 --- a/sycl/source/detail/bindless_images.cpp +++ b/sycl/source/detail/bindless_images.cpp @@ -117,9 +117,9 @@ __SYCL_EXPORT void destroy_image_handle(unsampled_image_handle &imageHandle, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); - Plugin->call< + Adapter->call< sycl::errc::runtime, sycl::detail::UrApiKind::urBindlessImagesUnsampledImageHandleDestroyExp>( C, Device, imageHandle.raw_handle); @@ -140,9 +140,9 @@ __SYCL_EXPORT void destroy_image_handle(sampled_image_handle &imageHandle, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); - Plugin->call< + Adapter->call< sycl::errc::runtime, sycl::detail::UrApiKind::urBindlessImagesSampledImageHandleDestroyExp>( C, Device, imageHandle.raw_handle); @@ -165,7 +165,7 @@ alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_desc_t urDesc; ur_image_format_t urFormat; @@ -174,7 +174,7 @@ alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice, image_mem_handle retHandle; // Call impl. - Plugin->callcall( C, Device, &urFormat, &urDesc, reinterpret_cast( @@ -198,11 +198,11 @@ __SYCL_EXPORT image_mem_handle get_mip_level_mem_handle( std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); // Call impl. image_mem_handle individual_image; - Plugin->callcall( C, Device, mipMem.raw_handle, level, &individual_image.raw_handle); @@ -226,17 +226,17 @@ __SYCL_EXPORT void free_image_mem(image_mem_handle memHandle, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); if (memHandle.raw_handle != 0) { if (imageType == image_type::mipmap) { - Plugin->callcall( C, Device, memHandle.raw_handle); } else if (imageType == image_type::standard || imageType == image_type::array || imageType == image_type::cubemap) { - Plugin->callcall( C, Device, memHandle.raw_handle); } else { @@ -277,7 +277,7 @@ create_image(image_mem_handle memHandle, const image_descriptor &desc, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_desc_t urDesc; ur_image_format_t urFormat; @@ -285,7 +285,7 @@ create_image(image_mem_handle memHandle, const image_descriptor &desc, // Call impl. ur_exp_image_mem_native_handle_t urImageHandle; - Plugin + Adapter ->call( C, Device, memHandle.raw_handle, &urFormat, &urDesc, &urImageHandle); @@ -382,7 +382,7 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_sampler_desc_t UrSamplerProps{ UR_STRUCTURE_TYPE_SAMPLER_DESC, nullptr, @@ -413,7 +413,7 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, UrAddrModes.pNext = &UrCubemapProps; ur_sampler_handle_t urSampler = nullptr; - Plugin->call( + Adapter->call( C, &UrSamplerProps, &urSampler); ur_image_desc_t urDesc; @@ -422,7 +422,7 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler, // Call impl. ur_exp_image_mem_native_handle_t urImageHandle; - Plugin->callcall( C, Device, reinterpret_cast(devPtr), &urFormat, &urDesc, urSampler, &urImageHandle); @@ -447,7 +447,7 @@ __SYCL_EXPORT external_mem import_external_memory( std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_exp_external_mem_handle_t urExternalMem = nullptr; ur_exp_file_descriptor_t urFileDescriptor = {}; @@ -460,7 +460,7 @@ __SYCL_EXPORT external_mem import_external_memory( // For `resource_fd` external memory type, the handle type is always // `OPAQUE_FD`. No need for a switch statement like we have for win32 // resources. - Plugin + Adapter ->call( C, Device, externalMemDesc.size_in_bytes, @@ -488,7 +488,7 @@ __SYCL_EXPORT external_mem import_external_memory( std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_exp_external_mem_handle_t urExternalMem = nullptr; ur_exp_win32_handle_t urWin32Handle = {}; @@ -512,7 +512,7 @@ __SYCL_EXPORT external_mem import_external_memory( "Invalid memory handle type"); } - Plugin + Adapter ->call( C, Device, externalMemDesc.size_in_bytes, urHandleType, @@ -542,7 +542,7 @@ image_mem_handle map_external_image_memory(external_mem extMem, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_desc_t urDesc; ur_image_format_t urFormat; @@ -551,7 +551,7 @@ image_mem_handle map_external_image_memory(external_mem extMem, ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle}; image_mem_handle retHandle; - Plugin->callcall( C, Device, &urFormat, &urDesc, urExternalMem, &retHandle.raw_handle); @@ -576,12 +576,12 @@ void *map_external_linear_memory(external_mem extMem, uint64_t offset, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle}; void *retMemory; - Plugin->call< + Adapter->call< sycl::errc::invalid, sycl::detail::UrApiKind::urBindlessImagesMapExternalLinearMemoryExp>( C, Device, offset, size, urExternalMem, &retMemory); @@ -605,9 +605,9 @@ __SYCL_EXPORT void release_external_memory(external_mem extMem, std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); - Plugin + Adapter ->call( C, Device, extMem.raw_handle); @@ -625,7 +625,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( const sycl::device &syclDevice, const sycl::context &syclContext) { std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_context_handle_t C = CtxImpl->getHandleRef(); std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); @@ -641,7 +641,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( // For this specialization of `import_external_semaphore` the handleType is // always `OPAQUE_FD`. - Plugin->call< + Adapter->call< sycl::errc::invalid, sycl::detail::UrApiKind::urBindlessImagesImportExternalSemaphoreExp>( C, Device, UR_EXP_EXTERNAL_SEMAPHORE_TYPE_OPAQUE_FD, &urExternalSemDesc, @@ -665,7 +665,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( const sycl::device &syclDevice, const sycl::context &syclContext) { std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_context_handle_t C = CtxImpl->getHandleRef(); std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); @@ -693,7 +693,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore( "Invalid semaphore handle type"); } - Plugin->call< + Adapter->call< sycl::errc::invalid, sycl::detail::UrApiKind::urBindlessImagesImportExternalSemaphoreExp>( C, Device, urHandleType, &urExternalSemDesc, &urExternalSemaphore); @@ -716,13 +716,13 @@ release_external_semaphore(external_semaphore externalSemaphore, const sycl::context &syclContext) { std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_context_handle_t C = CtxImpl->getHandleRef(); std::shared_ptr DevImpl = sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t Device = DevImpl->getHandleRef(); - Plugin->call< + Adapter->call< sycl::errc::invalid, sycl::detail::UrApiKind::urBindlessImagesReleaseExternalSemaphoreExp>( C, Device, externalSemaphore.raw_handle); @@ -741,21 +741,21 @@ __SYCL_EXPORT sycl::range<3> get_image_range(const image_mem_handle memHandle, std::ignore = syclDevice; std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); size_t Width = 0, Height = 0, Depth = 0; - Plugin->callcall( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_WIDTH, &Width, nullptr); - Plugin->callcall( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_HEIGHT, &Height, nullptr); - Plugin->callcall( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_DEPTH, &Depth, nullptr); @@ -776,11 +776,11 @@ get_image_channel_type(const image_mem_handle memHandle, std::ignore = syclDevice; std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_format_t URFormat; - Plugin->callcall( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, &URFormat, nullptr); @@ -813,11 +813,11 @@ __SYCL_EXPORT void *pitched_alloc_device(size_t *resultPitch, sycl::detail::getSyclObjImpl(syclContext); ur_context_handle_t UrContext = CtxImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_device_handle_t UrDevice = sycl::detail::getSyclObjImpl(syclDevice)->getHandleRef(); - Plugin->callcall( UrContext, UrDevice, nullptr, nullptr, widthInBytes, height, elementSizeBytes, &RetVal, resultPitch); @@ -863,10 +863,10 @@ get_image_num_channels(const image_mem_handle memHandle, std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(syclContext); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_image_format_t URFormat = {}; - Plugin->callcall( CtxImpl->getHandleRef(), memHandle.raw_handle, UR_IMAGE_INFO_FORMAT, &URFormat, nullptr); diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 3aa0e06ee7ced..2ad1117cc3e28 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -51,11 +51,11 @@ void buffer_impl::addInteropObject( if (std::find(Handles.begin(), Handles.end(), ur::cast(MInteropMemObject)) == Handles.end()) { - const PluginPtr &Plugin = getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = getAdapter(); + Adapter->call( ur::cast(MInteropMemObject)); ur_native_handle_t NativeHandle = 0; - Plugin->call(MInteropMemObject, nullptr, + Adapter->call(MInteropMemObject, nullptr, &NativeHandle); Handles.push_back(NativeHandle); } @@ -83,17 +83,17 @@ buffer_impl::getNativeVector(backend BackendName) const { if (Platform->getBackend() != BackendName) continue; - auto Plugin = Platform->getPlugin(); + auto Adapter = Platform->getAdapter(); if (Platform->getBackend() == backend::opencl) { - Plugin->call(NativeMem); + Adapter->call(NativeMem); } ur_native_handle_t Handle = 0; // When doing buffer interop we don't know what device the memory should be // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. - Plugin->call(NativeMem, /*Dev*/ nullptr, + Adapter->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 36d7b1b6b8904..8d936d4e94353 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -59,14 +59,14 @@ context_impl::context_impl(const std::vector Devices, DeviceIds.push_back(getSyclObjImpl(D)->getHandleRef()); } - getPlugin()->call( + getAdapter()->call( DeviceIds.size(), DeviceIds.data(), nullptr, &MContext); MKernelProgramCache.setContextPtr(this); } context_impl::context_impl(ur_context_handle_t UrContext, - async_handler AsyncHandler, const PluginPtr &Plugin, + async_handler AsyncHandler, const AdapterPtr &Adapter, const std::vector &DeviceList, bool OwnedByRuntime) : MOwnedByRuntime(OwnedByRuntime), MAsyncHandler(AsyncHandler), @@ -78,12 +78,12 @@ 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( + Adapter->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( + Adapter->call( MContext, UR_CONTEXT_INFO_DEVICES, sizeof(ur_device_handle_t) * DevicesNum, &DeviceIds[0], nullptr); @@ -93,7 +93,7 @@ context_impl::context_impl(ur_context_handle_t UrContext, "No devices in the provided device list and native context."); std::shared_ptr Platform = - platform_impl::getPlatformFromUrDevice(DeviceIds[0], Plugin); + platform_impl::getPlatformFromUrDevice(DeviceIds[0], Adapter); for (ur_device_handle_t Dev : DeviceIds) { MDevices.emplace_back(createSyclObjFromImpl( Platform->getOrMakeDeviceImpl(Dev, Platform))); @@ -101,22 +101,22 @@ context_impl::context_impl(ur_context_handle_t UrContext, MPlatform = Platform; } // TODO catch an exception and put it to list of asynchronous exceptions - // getPlugin() will be the same as the Plugin passed. This should be taken + // getAdapter() will be the same as the Adapter passed. This should be taken // care of when creating device object. // // TODO: Move this backend-specific retain of the context to SYCL-2020 style // make_context interop, when that is created. if (getBackend() == sycl::backend::opencl) { - getPlugin()->call(MContext); + getAdapter()->call(MContext); } MKernelProgramCache.setContextPtr(this); } cl_context context_impl::get() const { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(MContext); + getAdapter()->call(MContext); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(MContext, + getAdapter()->call(MContext, &nativeHandle); return ur::cast(nativeHandle); } @@ -125,7 +125,7 @@ context_impl::~context_impl() { try { // Free all events associated with the initialization of device globals. for (auto &DeviceGlobalInitializer : MDeviceGlobalInitializers) - DeviceGlobalInitializer.second.ClearEvents(getPlugin()); + DeviceGlobalInitializer.second.ClearEvents(getAdapter()); // Free all device_global USM allocations associated with this context. for (const void *DeviceGlobal : MAssociatedDeviceGlobals) { DeviceGlobalMapEntry *DGEntry = @@ -135,10 +135,10 @@ context_impl::~context_impl() { } for (auto LibProg : MCachedLibPrograms) { assert(LibProg.second && "Null program must not be kept in the cache"); - getPlugin()->call(LibProg.second); + getAdapter()->call(LibProg.second); } // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call_nocheck(MContext); + getAdapter()->call_nocheck(MContext); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~context_impl", e); } @@ -151,7 +151,7 @@ const async_handler &context_impl::get_async_handler() const { template <> uint32_t context_impl::get_info() const { return get_context_info(this->getHandleRef(), - this->getPlugin()); + this->getAdapter()); } template <> platform context_impl::get_info() const { return createSyclObjFromImpl(MPlatform); @@ -292,11 +292,11 @@ context_impl::findMatchingDeviceImpl(ur_device_handle_t &DeviceUR) const { } ur_native_handle_t context_impl::getNative() const { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); if (getBackend() == backend::opencl) - Plugin->call(getHandleRef()); + Adapter->call(getHandleRef()); ur_native_handle_t Handle; - Plugin->call(getHandleRef(), &Handle); + Adapter->call(getHandleRef(), &Handle); return Handle; } @@ -332,7 +332,7 @@ void context_impl::addDeviceGlobalInitializer( std::vector context_impl::initializeDeviceGlobals( ur_program_handle_t NativePrg, const std::shared_ptr &QueueImpl) { - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); const DeviceImplPtr &DeviceImpl = QueueImpl->getDeviceImplPtr(); std::lock_guard NativeProgramLock(MDeviceGlobalInitializersMutex); auto ImgIt = MDeviceGlobalInitializers.find( @@ -350,14 +350,14 @@ std::vector context_impl::initializeDeviceGlobals( // Initialization has begun but we do not know if the events are done. auto NewEnd = std::remove_if( InitEventsRef.begin(), InitEventsRef.end(), - [&Plugin](const ur_event_handle_t &Event) { + [&Adapter](const ur_event_handle_t &Event) { return get_event_info( - Event, Plugin) == info::event_command_status::complete; + Event, Adapter) == info::event_command_status::complete; return false; }); // Release the removed events. for (auto EventIt = NewEnd; EventIt != InitEventsRef.end(); ++EventIt) - Plugin->call(*EventIt); + Adapter->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. @@ -407,14 +407,14 @@ std::vector context_impl::initializeDeviceGlobals( // are cleaned up separately from cleaning up the device global USM memory // this must retain the event. { - if (OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Plugin)) + if (OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Adapter)) InitEventsRef.push_back(ZIEvent.TransferOwnership()); } // Write the pointer to the device global and store the event in the // initialize events list. ur_event_handle_t InitEvent; void *const &USMPtr = DeviceGlobalUSM.getPtr(); - Plugin->call( + Adapter->call( QueueImpl->getHandleRef(), NativePrg, DeviceGlobalEntry->MUniqueId.c_str(), false, sizeof(void *), 0, &USMPtr, 0, nullptr, &InitEvent); @@ -426,9 +426,9 @@ std::vector context_impl::initializeDeviceGlobals( } void context_impl::DeviceGlobalInitializer::ClearEvents( - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { for (const ur_event_handle_t &Event : MDeviceGlobalInitEvents) - Plugin->call(Event); + Adapter->call(Event); MDeviceGlobalInitEvents.clear(); } diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 48fb83f5807d9..2013ab1c73df6 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -65,11 +65,11 @@ class context_impl { /// /// \param UrContext is an instance of a valid plug-in context handle. /// \param AsyncHandler is an instance of async_handler. - /// \param Plugin is the reference to the underlying Plugin that this + /// \param Adapter is the reference to the underlying Adapter that this /// \param OwnedByRuntime is the flag if ownership is kept by user or /// transferred to runtime context_impl(ur_context_handle_t UrContext, async_handler AsyncHandler, - const PluginPtr &Plugin, + const AdapterPtr &Adapter, const std::vector &DeviceList = {}, bool OwnedByRuntime = true); @@ -85,8 +85,8 @@ class context_impl { /// \return an instance of SYCL async_handler. const async_handler &get_async_handler() const; - /// \return the Plugin associated with the platform of this context. - const PluginPtr &getPlugin() const { return MPlatform->getPlugin(); } + /// \return the Adapter associated with the platform of this context. + const AdapterPtr &getAdapter() const { return MPlatform->getAdapter(); } /// \return the PlatformImpl associated with this context. PlatformImplPtr getPlatformImpl() const { return MPlatform; } @@ -269,7 +269,7 @@ class context_impl { } /// Clears all events of the initializer. This will not acquire the lock. - void ClearEvents(const PluginPtr &Plugin); + void ClearEvents(const AdapterPtr &Adapter); /// The binary image of the program. const RTDeviceBinaryImage *MBinImage = nullptr; diff --git a/sycl/source/detail/context_info.hpp b/sycl/source/detail/context_info.hpp index 75e1b64580e83..1ec31e712a82d 100644 --- a/sycl/source/detail/context_info.hpp +++ b/sycl/source/detail/context_info.hpp @@ -19,12 +19,12 @@ namespace detail { template typename Param::return_type get_context_info(ur_context_handle_t Ctx, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_context_info_desc::value, "Invalid context information descriptor"); typename Param::return_type Result = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Ctx, UrInfoCode::value, + Adapter->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 aceb1437660a4..a097c778f034c 100644 --- a/sycl/source/detail/device_global_map_entry.cpp +++ b/sycl/source/detail/device_global_map_entry.cpp @@ -25,20 +25,20 @@ DeviceGlobalUSMMem::~DeviceGlobalUSMMem() { assert(!MInitEvent.has_value() && "MInitEvent has not been cleaned up."); } -OwnedUrEvent DeviceGlobalUSMMem::getInitEvent(const PluginPtr &Plugin) { +OwnedUrEvent DeviceGlobalUSMMem::getInitEvent(const AdapterPtr &Adapter) { std::lock_guard Lock(MInitEventMutex); // If there is a init event we can remove it if it is done. if (MInitEvent.has_value()) { if (get_event_info( - *MInitEvent, Plugin) == info::event_command_status::complete) { - Plugin->call(*MInitEvent); + *MInitEvent, Adapter) == info::event_command_status::complete) { + Adapter->call(*MInitEvent); MInitEvent = {}; - return OwnedUrEvent(Plugin); + return OwnedUrEvent(Adapter); } else { - return OwnedUrEvent(*MInitEvent, Plugin); + return OwnedUrEvent(*MInitEvent, Adapter); } } - return OwnedUrEvent(Plugin); + return OwnedUrEvent(Adapter); } DeviceGlobalUSMMem &DeviceGlobalMapEntry::getOrAllocateDeviceGlobalUSM( @@ -100,7 +100,7 @@ void DeviceGlobalMapEntry::removeAssociatedResources( DeviceGlobalUSMMem &USMMem = USMPtrIt->second; detail::usm::freeInternal(USMMem.MPtr, CtxImpl); if (USMMem.MInitEvent.has_value()) - CtxImpl->getPlugin()->call( + CtxImpl->getAdapter()->call( *USMMem.MInitEvent); #ifndef NDEBUG // For debugging we set the event and memory to some recognizable values diff --git a/sycl/source/detail/device_global_map_entry.hpp b/sycl/source/detail/device_global_map_entry.hpp index f507b2d9b8060..fc4bae13161ed 100644 --- a/sycl/source/detail/device_global_map_entry.hpp +++ b/sycl/source/detail/device_global_map_entry.hpp @@ -39,7 +39,7 @@ struct DeviceGlobalUSMMem { // Gets the initialization event if it exists. If not the OwnedUrEvent // will contain no event. - OwnedUrEvent getInitEvent(const PluginPtr &Plugin); + OwnedUrEvent getInitEvent(const AdapterPtr &Adapter); private: void *MPtr; diff --git a/sycl/source/detail/device_image_impl.hpp b/sycl/source/detail/device_image_impl.hpp index 285d3c6103daa..6a2d763d4671c 100644 --- a/sycl/source/detail/device_image_impl.hpp +++ b/sycl/source/detail/device_image_impl.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -266,7 +266,7 @@ class device_image_impl { ur_mem_handle_t &get_spec_const_buffer_ref() noexcept { std::lock_guard Lock{MSpecConstAccessMtx}; if (nullptr == MSpecConstsBuffer && !MSpecConstsBlob.empty()) { - const PluginPtr &Plugin = getSyclObjImpl(MContext)->getPlugin(); + const AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); // Uses UR_MEM_FLAGS_HOST_PTR_COPY instead of UR_MEM_FLAGS_HOST_PTR_USE // since post-enqueue cleanup might trigger destruction of // device_image_impl and, as a result, destruction of MSpecConstsBlob @@ -276,7 +276,7 @@ class device_image_impl { nullptr, MSpecConstsBlob.data()}; try { memBufferCreateHelper( - Plugin, detail::getSyclObjImpl(MContext)->getHandleRef(), + Adapter, detail::getSyclObjImpl(MContext)->getHandleRef(), UR_MEM_FLAG_READ_WRITE | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER, MSpecConstsBlob.size(), &MSpecConstsBuffer, &Properties); } catch (std::exception &e) { @@ -298,12 +298,12 @@ class device_image_impl { ur_native_handle_t getNative() const { assert(MProgram); const auto &ContextImplPtr = detail::getSyclObjImpl(MContext); - const PluginPtr &Plugin = ContextImplPtr->getPlugin(); + const AdapterPtr &Adapter = ContextImplPtr->getAdapter(); if (ContextImplPtr->getBackend() == backend::opencl) - Plugin->call(MProgram); + Adapter->call(MProgram); ur_native_handle_t NativeProgram = 0; - Plugin->call(MProgram, &NativeProgram); + Adapter->call(MProgram, &NativeProgram); return NativeProgram; } @@ -311,13 +311,13 @@ class device_image_impl { ~device_image_impl() { try { if (MProgram) { - const PluginPtr &Plugin = getSyclObjImpl(MContext)->getPlugin(); - Plugin->call(MProgram); + const AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); + Adapter->call(MProgram); } if (MSpecConstsBuffer) { std::lock_guard Lock{MSpecConstAccessMtx}; - const PluginPtr &Plugin = getSyclObjImpl(MContext)->getPlugin(); - memReleaseHelper(Plugin, MSpecConstsBuffer); + const AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); + memReleaseHelper(Adapter, MSpecConstsBuffer); } } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_image_impl", e); diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index ff5db2ec19531..b4957209e5c0e 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -19,22 +19,22 @@ inline namespace _V1 { namespace detail { device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, - const PluginPtr &Plugin) - : device_impl(InteropDeviceHandle, nullptr, nullptr, Plugin) {} + const AdapterPtr &Adapter) + : device_impl(InteropDeviceHandle, nullptr, nullptr, Adapter) {} /// Constructs a SYCL device instance using the provided /// UR device instance. device_impl::device_impl(ur_device_handle_t Device, PlatformImplPtr Platform) - : device_impl(0, Device, Platform, Platform->getPlugin()) {} + : device_impl(0, Device, Platform, Platform->getAdapter()) {} /// Constructs a SYCL device instance using the provided /// UR device instance. -device_impl::device_impl(ur_device_handle_t Device, const PluginPtr &Plugin) - : device_impl(0, Device, nullptr, Plugin) {} +device_impl::device_impl(ur_device_handle_t Device, const AdapterPtr &Adapter) + : device_impl(0, Device, nullptr, Adapter) {} device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, ur_device_handle_t Device, PlatformImplPtr Platform, - const PluginPtr &Plugin) + const AdapterPtr &Adapter) : MDevice(Device), MDeviceHostBaseTime(std::make_pair(0, 0)) { bool InteroperabilityConstructor = false; if (Device == nullptr) { @@ -42,19 +42,19 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, // Get UR device from the raw device handle. // NOTE: this is for OpenCL interop only (and should go away). // With SYCL-2020 BE generalization "make" functions are used instead. - Plugin->call( - InteropDeviceHandle, Plugin->getUrAdapter(), nullptr, &MDevice); + Adapter->call( + InteropDeviceHandle, Adapter->getUrAdapter(), nullptr, &MDevice); InteroperabilityConstructor = true; } // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->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( + Adapter->call( MDevice, UR_DEVICE_INFO_PARENT_DEVICE, sizeof(ur_device_handle_t), &MRootDevice, nullptr); } @@ -63,12 +63,12 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, // TODO catch an exception and put it to list of asynchronous exceptions // Interoperability Constructor already calls DeviceRetain in // urDeviceCreateWithNativeHandle. - Plugin->call(MDevice); + Adapter->call(MDevice); } // set MPlatform if (!Platform) { - Platform = platform_impl::getPlatformFromUrDevice(MDevice, Plugin); + Platform = platform_impl::getPlatformFromUrDevice(MDevice, Adapter); } MPlatform = Platform; @@ -79,8 +79,8 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle, 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(MDevice); + const AdapterPtr &Adapter = getAdapter(); + ur_result_t Err = Adapter->call_nocheck(MDevice); __SYCL_CHECK_UR_CODE_NO_EXC(Err); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_impl", e); @@ -96,7 +96,7 @@ bool device_impl::is_affinity_supported( cl_device_id device_impl::get() const { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(MDevice); + getAdapter()->call(MDevice); return ur::cast(getNative()); } @@ -182,8 +182,8 @@ std::vector device_impl::create_sub_devices( size_t SubDevicesCount) const { std::vector SubDevices(SubDevicesCount); uint32_t ReturnedSubDevices = 0; - const PluginPtr &Plugin = getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = getAdapter(); + Adapter->call( MDevice, Properties, SubDevicesCount, SubDevices.data(), &ReturnedSubDevices); if (ReturnedSubDevices != SubDevicesCount) { @@ -303,8 +303,8 @@ std::vector device_impl::create_sub_devices( Properties.pProperties = &Prop; uint32_t SubDevicesCount = 0; - const PluginPtr &Plugin = getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = getAdapter(); + Adapter->call( MDevice, &Properties, 0, nullptr, &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); @@ -328,19 +328,19 @@ std::vector device_impl::create_sub_devices() const { Properties.PropCount = 1; uint32_t SubDevicesCount = 0; - const PluginPtr &Plugin = getPlugin(); - Plugin->call(MDevice, &Properties, 0, nullptr, + const AdapterPtr &Adapter = getAdapter(); + Adapter->call(MDevice, &Properties, 0, nullptr, &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); } ur_native_handle_t device_impl::getNative() const { - auto Plugin = getPlugin(); + auto Adapter = getAdapter(); if (getBackend() == backend::opencl) - Plugin->call(getHandleRef()); + Adapter->call(getHandleRef()); ur_native_handle_t Handle; - Plugin->call(getHandleRef(), &Handle); + Adapter->call(getHandleRef(), &Handle); return Handle; } @@ -407,51 +407,51 @@ 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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + return getAdapter()->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( + auto Result = getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_UUID, 0, nullptr, &return_size); if (Result != UR_RESULT_SUCCESS) { return false; @@ -460,7 +460,7 @@ bool device_impl::has(aspect Aspect) const { assert(return_size <= 16); unsigned char UUID[16]; - return getPlugin()->call_nocheck( + return getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_UUID, 16 * sizeof(unsigned char), UUID, nullptr) == UR_RESULT_SUCCESS; } @@ -474,7 +474,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cuda_async_barrier: { int async_barrier_supported; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_ASYNC_BARRIER, sizeof(int), &async_barrier_supported, nullptr) == UR_RESULT_SUCCESS; return call_successful && async_barrier_supported; @@ -482,7 +482,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_intel_legacy_image: { ur_bool_t legacy_image_support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -490,7 +490,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -498,7 +498,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_shared_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -506,7 +506,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -514,7 +514,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -522,7 +522,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_external_memory_import: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_EXTERNAL_MEMORY_IMPORT_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -530,7 +530,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_external_semaphore_import: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_EXTERNAL_SEMAPHORE_IMPORT_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -538,7 +538,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_mipmap: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -546,7 +546,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_mipmap_anisotropy: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -554,7 +554,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_mipmap_level_reference: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -562,7 +562,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -570,7 +570,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_1d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -578,7 +578,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -586,7 +586,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_2d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -594,7 +594,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_sampled_image_fetch_3d: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -602,7 +602,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cubemap: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -610,7 +610,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_cubemap_seamless_filtering: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -618,7 +618,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_image_array: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_IMAGE_ARRAY_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -626,7 +626,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_unique_addressing_per_dim: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -634,7 +634,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_sample_1d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -642,7 +642,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_bindless_images_sample_2d_usm: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->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; @@ -650,7 +650,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_intel_esimd: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_ESIMD_SUPPORT, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -694,7 +694,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_is_component: { typename sycl_to_ur::type Result; bool CallSuccessful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( getHandleRef(), UrInfoCode::value, @@ -705,7 +705,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_graph: { bool SupportsCommandBufferUpdate = false; bool CallSuccessful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP, sizeof(SupportsCommandBufferUpdate), &SupportsCommandBufferUpdate, nullptr) == UR_RESULT_SUCCESS; @@ -718,7 +718,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_limited_graph: { bool SupportsCommandBuffers = false; bool CallSuccessful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP, sizeof(SupportsCommandBuffers), &SupportsCommandBuffers, nullptr) == UR_RESULT_SUCCESS; @@ -737,7 +737,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_queue_profiling_tag: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -745,7 +745,7 @@ bool device_impl::has(aspect Aspect) const { case aspect::ext_oneapi_virtual_mem: { ur_bool_t support = false; bool call_successful = - getPlugin()->call_nocheck( + getAdapter()->call_nocheck( MDevice, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t), &support, nullptr) == UR_RESULT_SUCCESS; return call_successful && support; @@ -807,14 +807,14 @@ 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( + const auto &Adapter = getAdapter(); + auto Result = Adapter->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() + // getCurrentDeviceTime() call. We need to do it here because getAdapter() // and urDeviceGetGlobalTimestamps calls may take significant amount of time, - // for example on the first call to getPlugin plugins may need to be + // for example on the first call to getAdapter adapters may need to be // initialized. If we use timestamp from the beginning of the function then // the difference between host timestamps of the current // getCurrentDeviceTime and the next getCurrentDeviceTime will be incorrect @@ -833,7 +833,7 @@ uint64_t device_impl::getCurrentDeviceTime() { "Device and/or backend does not support querying timestamp."), UR_RESULT_ERROR_INVALID_OPERATION); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } // Until next sync we will compute device time based on the host time // returned in HostTime, so make this our base host time. @@ -844,9 +844,9 @@ uint64_t device_impl::getCurrentDeviceTime() { } bool device_impl::isGetDeviceAndHostTimerSupported() { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); uint64_t DeviceTime = 0, HostTime = 0; - auto Result = Plugin->call_nocheck( + auto Result = Adapter->call_nocheck( MDevice, &DeviceTime, &HostTime); return Result != UR_RESULT_ERROR_INVALID_OPERATION; } diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 92c55a30b41b9..b38b7582f3f28 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -39,7 +39,7 @@ class device_impl { device_impl(); /// Constructs a SYCL device instance using the provided raw device handle. - explicit device_impl(ur_native_handle_t, const PluginPtr &Plugin); + explicit device_impl(ur_native_handle_t, const AdapterPtr &Adapter); /// Constructs a SYCL device instance using the provided /// UR device instance. @@ -47,7 +47,7 @@ class device_impl { /// Constructs a SYCL device instance using the provided /// UR device instance. - explicit device_impl(ur_device_handle_t Device, const PluginPtr &Plugin); + explicit device_impl(ur_device_handle_t Device, const AdapterPtr &Adapter); ~device_impl(); @@ -103,8 +103,8 @@ class device_impl { /// \return The associated SYCL platform. platform get_platform() const; - /// \return the associated plugin with this device. - const PluginPtr &getPlugin() const { return MPlatform->getPlugin(); } + /// \return the associated adapter with this device. + const AdapterPtr &getAdapter() const { return MPlatform->getAdapter(); } /// Check SYCL extension support by device /// @@ -296,7 +296,7 @@ class device_impl { private: explicit device_impl(ur_native_handle_t InteropDevice, ur_device_handle_t Device, PlatformImplPtr Platform, - const PluginPtr &Plugin); + const AdapterPtr &Adapter); ur_device_handle_t MDevice = 0; ur_device_type_t MType; diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index e57fb55b931e9..3347ae7b0a981 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -142,7 +142,7 @@ template <> struct check_fp_support { template struct get_device_info_impl { static ReturnT get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return ReturnT(result); @@ -153,14 +153,14 @@ template struct get_device_info_impl { template struct get_device_info_impl { static platform get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( + Dev->getAdapter()->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 + // Use the Adapter from the device_impl class after adapter details // are added to the class. return createSyclObjFromImpl( - platform_impl::getOrMakePlatformImpl(result, Dev->getPlugin())); + platform_impl::getOrMakePlatformImpl(result, Dev->getAdapter())); } }; @@ -169,13 +169,13 @@ template struct get_device_info_impl { inline std::string device_impl::get_device_info_string(ur_device_info_t InfoCode) const { size_t resultSize = 0; - getPlugin()->call(getHandleRef(), InfoCode, 0, + getAdapter()->call(getHandleRef(), InfoCode, 0, nullptr, &resultSize); if (resultSize == 0) { return std::string(); } std::unique_ptr result(new char[resultSize]); - getPlugin()->call( + getAdapter()->call( getHandleRef(), InfoCode, resultSize, result.get(), nullptr); return std::string(result.get()); @@ -205,7 +205,7 @@ struct get_device_info_impl, Param> { return {}; } ur_device_fp_capability_flags_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_fp_bitfield(result); @@ -226,7 +226,7 @@ struct get_device_info_impl, info::device::single_fp_config> { static std::vector get(const DeviceImplPtr &Dev) { ur_device_fp_capability_flags_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); return read_fp_bitfield(result); @@ -239,7 +239,7 @@ struct get_device_info_impl, template <> struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_queue_flags_t Properties; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(Properties), &Properties, nullptr); return Properties & UR_QUEUE_FLAG_PROFILING_ENABLE; @@ -252,7 +252,7 @@ struct get_device_info_impl, info::device::atomic_memory_order_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_memory_order_capability_flag_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -266,7 +266,7 @@ struct get_device_info_impl, info::device::atomic_fence_order_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_memory_order_capability_flag_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -280,7 +280,7 @@ struct get_device_info_impl, info::device::atomic_memory_scope_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { size_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -294,7 +294,7 @@ struct get_device_info_impl, info::device::atomic_fence_scope_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { size_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -308,7 +308,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { bool result = false; if (Dev->getBackend() == backend::ext_oneapi_cuda) { - auto Err = Dev->getPlugin()->call_nocheck( + auto Err = Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -326,7 +326,7 @@ struct get_device_info_impl, info::device::execution_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { ur_device_exec_capability_flag_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -392,10 +392,10 @@ struct get_device_info_impl, info::device::partition_properties> { static std::vector get(const DeviceImplPtr &Dev) { auto info_partition = UrInfoCode::value; - const auto &Plugin = Dev->getPlugin(); + const auto &Adapter = Dev->getAdapter(); size_t resultSize; - Plugin->call( + Adapter->call( Dev->getHandleRef(), info_partition, 0, nullptr, &resultSize); size_t arrayLength = resultSize / sizeof(ur_device_partition_t); @@ -404,7 +404,7 @@ struct get_device_info_impl, } std::unique_ptr arrayResult( new ur_device_partition_t[arrayLength]); - Plugin->call(Dev->getHandleRef(), + Adapter->call(Dev->getHandleRef(), info_partition, resultSize, arrayResult.get(), nullptr); @@ -428,7 +428,7 @@ struct get_device_info_impl, static std::vector get(const DeviceImplPtr &Dev) { ur_device_affinity_domain_flags_t result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); @@ -444,7 +444,7 @@ struct get_device_info_impl PartitionProperties; size_t PropertiesSize = 0; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &PropertiesSize); @@ -454,7 +454,7 @@ struct get_device_info_implgetPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); @@ -476,7 +476,7 @@ struct get_device_info_impl PartitionProperties; size_t PropertiesSize = 0; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &PropertiesSize); @@ -486,7 +486,7 @@ struct get_device_info_implgetPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, PropertiesSize, PartitionProperties.data(), nullptr); @@ -502,12 +502,12 @@ struct get_device_info_impl, info::device::sub_group_sizes> { static std::vector get(const DeviceImplPtr &Dev) { size_t resultSize = 0; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &resultSize); std::vector result32(resultSize / sizeof(uint32_t)); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, resultSize, result32.data(), nullptr); @@ -563,7 +563,7 @@ struct get_device_info_impl, info::device::max_work_item_sizes> { static range get(const DeviceImplPtr &Dev) { size_t result[3]; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode>::value, sizeof(result), &result, nullptr); @@ -693,7 +693,7 @@ struct get_device_info_impl< -> std::optional { uint32_t DeviceIp; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::architecture>::value, @@ -702,7 +702,7 @@ struct get_device_info_impl< // Not all devices support this device info query return std::nullopt; } - Dev->getPlugin()->checkUrResult(Err); + Dev->getAdapter()->checkUrResult(Err); for (const auto &Item : ArchList) { if (Item.first == static_cast(DeviceIp)) @@ -725,11 +725,11 @@ struct get_device_info_impl< return ext::oneapi::experimental::architecture::unknown; }; size_t ResultSize = 0; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, 0, nullptr, &ResultSize); std::unique_ptr DeviceArch(new char[ResultSize]); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, ResultSize, DeviceArch.get(), nullptr); std::string DeviceArchCopy(DeviceArch.get()); @@ -972,7 +972,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, @@ -989,7 +989,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, @@ -1006,7 +1006,7 @@ struct get_device_info_impl< size_t Limit = get_device_info_impl::get(Dev); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, @@ -1068,7 +1068,7 @@ struct get_device_info_impl, template <> struct get_device_info_impl { static device get(const DeviceImplPtr &Dev) { typename sycl_to_ur::type result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, sizeof(result), &result, nullptr); if (result == nullptr) @@ -1098,7 +1098,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1116,7 +1116,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1133,7 +1133,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1150,7 +1150,7 @@ struct get_device_info_implgetPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1169,7 +1169,7 @@ struct get_device_info_impl { static bool get(const DeviceImplPtr &Dev) { ur_device_usm_access_capability_flags_t caps; ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, sizeof(ur_device_usm_access_capability_flags_t), &caps, nullptr); @@ -1197,7 +1197,7 @@ struct get_device_info_impl< ext::codeplay::experimental::info::device::max_registers_per_work_group> { static uint32_t get(const DeviceImplPtr &Dev) { uint32_t maxRegsPerWG; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode::value, @@ -1215,7 +1215,7 @@ struct get_device_info_impl< size_t ResultSize = 0; // First call to get DevCount. ur_result_t Err = - Dev->getPlugin()->call_nocheck( + Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode::value, @@ -1229,13 +1229,13 @@ struct get_device_info_impl< // Otherwise, if there was an error from UR it is unexpected and we should // handle it accordingly. - Dev->getPlugin()->checkUrResult(Err); + Dev->getAdapter()->checkUrResult(Err); size_t DevCount = ResultSize / sizeof(ur_device_handle_t); // Second call to get the list. std::vector Devs(DevCount); - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::component_devices>::value, @@ -1260,7 +1260,7 @@ struct get_device_info_impl< "can call this function."); typename sycl_to_ur::type Result; - Dev->getPlugin()->call( + Dev->getAdapter()->call( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::composite_device>::value, diff --git a/sycl/source/detail/error_handling/error_handling.cpp b/sycl/source/detail/error_handling/error_handling.cpp index 7c609adcfcd82..01bbf45585dc0 100644 --- a/sycl/source/detail/error_handling/error_handling.cpp +++ b/sycl/source/detail/error_handling/error_handling.cpp @@ -12,7 +12,7 @@ #include "error_handling.hpp" -#include +#include #include #include @@ -36,9 +36,9 @@ void handleOutOfResources(const device_impl &DeviceImpl, const size_t TotalNumberOfWIs = NDRDesc.LocalSize[0] * NDRDesc.LocalSize[1] * NDRDesc.LocalSize[2]; - const PluginPtr &Plugin = DeviceImpl.getPlugin(); + const AdapterPtr &Adapter = DeviceImpl.getAdapter(); uint32_t NumRegisters = 0; - Plugin->call(Kernel, UR_KERNEL_INFO_NUM_REGS, + Adapter->call(Kernel, UR_KERNEL_INFO_NUM_REGS, sizeof(NumRegisters), &NumRegisters, nullptr); @@ -96,16 +96,16 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, IsLevelZero = true; } - const PluginPtr &Plugin = DeviceImpl.getPlugin(); + const AdapterPtr &Adapter = DeviceImpl.getAdapter(); ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t CompileWGSize[3] = {0}; - Plugin->call( + Adapter->call( Kernel, Device, UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(size_t) * 3, CompileWGSize, nullptr); size_t MaxWGSize = 0; - Plugin->call(Device, + Adapter->call(Device, UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t), &MaxWGSize, nullptr); @@ -149,7 +149,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, if (HasLocalSize) { size_t MaxThreadsPerBlock[3] = {}; - Plugin->call( + Adapter->call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxThreadsPerBlock), MaxThreadsPerBlock, nullptr); @@ -188,7 +188,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // than the value specified by UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE in // table 5.21. size_t KernelWGSize = 0; - Plugin->call( + Adapter->call( Kernel, Device, UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t), &KernelWGSize, nullptr); const size_t TotalNumberOfWIs = @@ -242,15 +242,15 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // work-group given by local_work_size ur_program_handle_t Program = nullptr; - Plugin->call( + Adapter->call( Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); size_t OptsSize = 0; - Plugin->call( + Adapter->call( Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, 0, nullptr, &OptsSize); std::string Opts(OptsSize, '\0'); - Plugin->call( + Adapter->call( Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, OptsSize, &Opts.front(), nullptr); const bool HasStd20 = Opts.find("-cl-std=CL2.0") != std::string::npos; @@ -309,12 +309,12 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, void handleInvalidWorkItemSize(const device_impl &DeviceImpl, const NDRDescT &NDRDesc) { - const PluginPtr &Plugin = DeviceImpl.getPlugin(); + const AdapterPtr &Adapter = DeviceImpl.getAdapter(); ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t MaxWISize[] = {0, 0, 0}; - Plugin->call( + Adapter->call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxWISize), &MaxWISize, nullptr); for (unsigned I = 0; I < NDRDesc.Dims; I++) { @@ -329,11 +329,11 @@ void handleInvalidWorkItemSize(const device_impl &DeviceImpl, void handleInvalidValue(const device_impl &DeviceImpl, const NDRDescT &NDRDesc) { - const PluginPtr &Plugin = DeviceImpl.getPlugin(); + const AdapterPtr &Adapter = DeviceImpl.getAdapter(); ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t MaxNWGs[] = {0, 0, 0}; - Plugin->call(Device, + Adapter->call(Device, UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, sizeof(MaxNWGs), &MaxNWGs, nullptr); for (unsigned int I = 0; I < NDRDesc.Dims; I++) { @@ -418,7 +418,7 @@ void handleErrorOrWarning(ur_result_t Error, const device_impl &DeviceImpl, // an error or a warning. It also ensures that the contents of the error // message buffer (used only by UR_RESULT_ERROR_ADAPTER_SPECIFIC_ERROR) get // handled correctly. - return DeviceImpl.getPlugin()->checkUrResult(Error); + return DeviceImpl.getAdapter()->checkUrResult(Error); // TODO: Handle other error codes @@ -432,7 +432,7 @@ void handleErrorOrWarning(ur_result_t Error, const device_impl &DeviceImpl, namespace detail::kernel_get_group_info { void handleErrorOrWarning(ur_result_t Error, ur_kernel_group_info_t Descriptor, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { assert(Error != UR_RESULT_SUCCESS && "Success is expected to be handled on caller side"); switch (Error) { @@ -446,7 +446,7 @@ void handleErrorOrWarning(ur_result_t Error, ur_kernel_group_info_t Descriptor, break; // TODO: Handle other error codes default: - Plugin->checkUrResult(Error); + Adapter->checkUrResult(Error); break; } } diff --git a/sycl/source/detail/error_handling/error_handling.hpp b/sycl/source/detail/error_handling/error_handling.hpp index 3583eb773e764..f6e6ffde09f10 100644 --- a/sycl/source/detail/error_handling/error_handling.hpp +++ b/sycl/source/detail/error_handling/error_handling.hpp @@ -32,7 +32,7 @@ void handleErrorOrWarning(ur_result_t, const device_impl &, ur_kernel_handle_t, namespace kernel_get_group_info { /// Analyzes error code of urKernelGetGroupInfo. void handleErrorOrWarning(ur_result_t, ur_kernel_group_info_t, - const PluginPtr &); + const AdapterPtr &); } // namespace kernel_get_group_info } // namespace detail diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 7ca70acc6ae4b..73df8c3379bce 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ event_impl::~event_impl() { try { auto Handle = this->getHandle(); if (Handle) - getPlugin()->call(Handle); + getAdapter()->call(Handle); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~event_impl", e); } @@ -57,7 +57,7 @@ void event_impl::waitInternal(bool *Success) { if (!MIsHostEvent && Handle) { // Wait for the native event ur_result_t Err = - getPlugin()->call_nocheck(1, &Handle); + getAdapter()->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). @@ -66,7 +66,7 @@ void event_impl::waitInternal(bool *Success) { Err == UR_RESULT_ERROR_IN_EVENT_LIST_EXEC_STATUS)) *Success = false; else { - getPlugin()->checkUrResult(Err); + getAdapter()->checkUrResult(Err); if (Success != nullptr) *Success = true; } @@ -130,9 +130,9 @@ const ContextImplPtr &event_impl::getContextImpl() { return MContext; } -const PluginPtr &event_impl::getPlugin() { +const AdapterPtr &event_impl::getAdapter() { initContextIfNeeded(); - return MContext->getPlugin(); + return MContext->getAdapter(); } void event_impl::setStateIncomplete() { MState = HES_NotComplete; } @@ -147,7 +147,7 @@ event_impl::event_impl(ur_event_handle_t Event, const context &SyclContext) MIsFlushed(true), MState(HES_Complete) { ur_context_handle_t TempContext; - getPlugin()->call( + getAdapter()->call( this->getHandle(), UR_EVENT_INFO_CONTEXT, sizeof(ur_context_handle_t), &TempContext, nullptr); @@ -302,7 +302,7 @@ event_impl::get_profiling_info() { // For profiling tag events we rely on the submission time reported as // the start time has undefined behavior. return get_event_profiling_info( - this->getHandle(), this->getPlugin()); + this->getHandle(), this->getAdapter()); } // The delay between the submission and the actual start of a CommandBuffer @@ -323,7 +323,7 @@ event_impl::get_profiling_info() { if (MEventFromSubmittedExecCommandBuffer && !MIsHostEvent && Handle) { uint64_t StartTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); if (StartTime < MSubmitTime) MSubmitTime = StartTime; } @@ -339,13 +339,13 @@ event_impl::get_profiling_info() { if (Handle) { auto StartTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); if (!MFallbackProfiling) { return StartTime; } else { auto DeviceBaseTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); return MHostBaseTime - DeviceBaseTime + StartTime; } } @@ -367,13 +367,13 @@ uint64_t event_impl::get_profiling_info() { if (Handle) { auto EndTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); if (!MFallbackProfiling) { return EndTime; } else { auto DeviceBaseTime = get_event_profiling_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); return MHostBaseTime - DeviceBaseTime + EndTime; } } @@ -391,7 +391,7 @@ template <> uint32_t event_impl::get_info() { auto Handle = this->getHandle(); if (!MIsHostEvent && Handle) { return get_event_info(Handle, - this->getPlugin()); + this->getAdapter()); } return 0; } @@ -407,7 +407,7 @@ event_impl::get_info() { auto Handle = this->getHandle(); if (Handle) return get_event_info( - Handle, this->getPlugin()); + Handle, this->getAdapter()); // Command is blocked and not enqueued, UrEvent is not assigned yet else if (MCommand) return sycl::info::event_command_status::submitted; @@ -483,21 +483,21 @@ ur_native_handle_t event_impl::getNative() { return {}; initContextIfNeeded(); - auto Plugin = getPlugin(); + auto Adapter = getAdapter(); auto Handle = getHandle(); if (MIsDefaultConstructed && !Handle) { auto TempContext = MContext.get()->getHandleRef(); ur_event_native_properties_t NativeProperties{}; ur_event_handle_t UREvent = nullptr; - Plugin->call( + Adapter->call( 0, TempContext, &NativeProperties, &UREvent); this->setHandle(UREvent); Handle = UREvent; } if (MContext->getBackend() == backend::opencl) - Plugin->call(Handle); + Adapter->call(Handle); ur_native_handle_t OutHandle; - Plugin->call(Handle, &OutHandle); + Adapter->call(Handle, &OutHandle); return OutHandle; } @@ -538,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( + getAdapter()->call( Handle, UR_EVENT_INFO_COMMAND_EXECUTION_STATUS, sizeof(ur_event_status_t), &Status, nullptr); if (Status == UR_EVENT_STATUS_QUEUED) { - getPlugin()->call(Queue->getHandleRef()); + getAdapter()->call(Queue->getHandleRef()); } MIsFlushed = true; } diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 312bb589760b7..61e644a2f9484 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include #include @@ -27,7 +27,7 @@ class graph_impl; } class context; namespace detail { -class plugin; +class adapter; class context_impl; using ContextImplPtr = std::shared_ptr; class queue_impl; @@ -137,9 +137,9 @@ class event_impl { /// \return a shared pointer to a valid context_impl. const ContextImplPtr &getContextImpl(); - /// \return the Plugin associated with the context of this event. + /// \return the Adapter associated with the context of this event. /// Should be called when this is not a Host Event. - const PluginPtr &getPlugin(); + const AdapterPtr &getAdapter(); /// Associate event with the context. /// diff --git a/sycl/source/detail/event_info.hpp b/sycl/source/detail/event_info.hpp index 119862e08941e..9a9733787093d 100644 --- a/sycl/source/detail/event_info.hpp +++ b/sycl/source/detail/event_info.hpp @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include #include #include @@ -20,24 +20,24 @@ namespace detail { template typename Param::return_type get_event_profiling_info(ur_event_handle_t Event, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_event_profiling_info_desc::value, "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( + Adapter->call( Event, UrInfoCode::value, sizeof(Result), &Result, nullptr); return Result; } template typename Param::return_type get_event_info(ur_event_handle_t Event, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_event_info_desc::value, "Unexpected event info descriptor"); typename Param::return_type Result{0}; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Event, UrInfoCode::value, + Adapter->call(Event, UrInfoCode::value, sizeof(Result), &Result, nullptr); // If the status is UR_EVENT_STATUS_QUEUED We need to change it since QUEUE is diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 0623be269edaf..808cef6666a52 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -170,7 +170,7 @@ Scheduler &GlobalHandler::getScheduler() { // work. So, registering signal handler here because: // 1) getScheduler is likely to be called for any non-trivial application; // 2) first call to getScheduler is likely to be done after main starts. - // The same is done in getPlugins. + // The same is done in getAdapters. enableOnCrashStackPrinting(); return *MScheduler.Inst; } @@ -208,9 +208,9 @@ std::mutex &GlobalHandler::getFilterMutex() { return getOrCreate(MFilterMutex); } -std::vector &GlobalHandler::getPlugins() { +std::vector &GlobalHandler::getAdapters() { enableOnCrashStackPrinting(); - return getOrCreate(MPlugins); + return getOrCreate(MAdapters); } ods_target_list & @@ -262,14 +262,14 @@ bool GlobalHandler::isOkToDefer() const { return OkToDefer; } void GlobalHandler::endDeferredRelease() { OkToDefer = false; } // Note: Split from shutdown so it is available to the unittests for ensuring -// that the mock plugin is the lone plugin. -void GlobalHandler::unloadPlugins() { - // Call to GlobalHandler::instance().getPlugins() initializes plugins. If +// that the mock adapter is the lone adapter. +void GlobalHandler::unloadAdapters() { + // Call to GlobalHandler::instance().getAdapters() initializes adapters. If // user application has loaded SYCL runtime, and never called any APIs, - // there's no need to load and unload plugins. - if (MPlugins.Inst) { - for (const auto &Plugin : getPlugins()) { - Plugin->release(); + // there's no need to load and unload adapters. + if (MAdapters.Inst) { + for (const auto &Adapter : getAdapters()) { + Adapter->release(); } } @@ -280,7 +280,7 @@ void GlobalHandler::unloadPlugins() { // urLoaderTearDown(); // Clear after unload to avoid uses after unload. - getPlugins().clear(); + getAdapters().clear(); } void GlobalHandler::prepareSchedulerToRelease(bool Blocking) { @@ -303,11 +303,11 @@ void GlobalHandler::drainThreadPool() { // threads may be shutdown once the end of main() is reached // making an orderly shutdown difficult. Fortunately, Windows // itself is very aggressive about reclaiming memory. Thus, -// we focus solely on unloading the plugins, so as to not +// we focus solely on unloading the adapters, so as to not // accidentally retain device handles. etc void shutdown_win() { GlobalHandler *&Handler = GlobalHandler::getInstancePtr(); - Handler->unloadPlugins(); + Handler->unloadAdapters(); } #else void shutdown_early() { @@ -337,15 +337,15 @@ void shutdown_late() { if (!Handler) return; - // First, release resources, that may access plugins. + // First, release resources, that may access adapters. Handler->MPlatformCache.Inst.reset(nullptr); Handler->MScheduler.Inst.reset(nullptr); Handler->MProgramManager.Inst.reset(nullptr); - // Clear the plugins and reset the instance if it was there. - Handler->unloadPlugins(); - if (Handler->MPlugins.Inst) - Handler->MPlugins.Inst.reset(nullptr); + // Clear the adapters and reset the instance if it was there. + Handler->unloadAdapters(); + if (Handler->MAdapters.Inst) + Handler->MAdapters.Inst.reset(nullptr); Handler->MXPTIRegistry.Inst.reset(nullptr); diff --git a/sycl/source/detail/global_handler.hpp b/sycl/source/detail/global_handler.hpp index 069fff3dbcdd5..594add1d8fae6 100644 --- a/sycl/source/detail/global_handler.hpp +++ b/sycl/source/detail/global_handler.hpp @@ -22,14 +22,14 @@ class context_impl; class Scheduler; class ProgramManager; class Sync; -class plugin; +class adapter; class ods_target_list; class XPTIRegistry; class ThreadPool; using PlatformImplPtr = std::shared_ptr; using ContextImplPtr = std::shared_ptr; -using PluginPtr = std::shared_ptr; +using AdapterPtr = std::shared_ptr; /// Wrapper class for global data structures with non-trivial destructors. /// @@ -68,7 +68,7 @@ class GlobalHandler { std::mutex &getPlatformToDefaultContextCacheMutex(); std::mutex &getPlatformMapMutex(); std::mutex &getFilterMutex(); - std::vector &getPlugins(); + std::vector &getAdapters(); ods_target_list &getOneapiDeviceSelectorTargets(const std::string &InitValue); XPTIRegistry &getXPTIRegistry(); ThreadPool &getHostTaskThreadPool(); @@ -77,7 +77,7 @@ class GlobalHandler { bool isOkToDefer() const; void endDeferredRelease(); - void unloadPlugins(); + void unloadAdapters(); void releaseDefaultContexts(); void drainThreadPool(); void prepareSchedulerToRelease(bool Blocking); @@ -124,7 +124,7 @@ class GlobalHandler { InstWithLock MPlatformToDefaultContextCacheMutex; InstWithLock MPlatformMapMutex; InstWithLock MFilterMutex; - InstWithLock> MPlugins; + InstWithLock> MAdapters; InstWithLock MOneapiDeviceSelectorTargets; InstWithLock MXPTIRegistry; // Thread pool for host task and event callbacks execution diff --git a/sycl/source/detail/graph_impl.cpp b/sycl/source/detail/graph_impl.cpp index 53d032d5f7672..1a09f9a78c21f 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -718,10 +718,10 @@ void exec_graph_impl::createCommandBuffers( UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, MIsUpdatable, Partition->MIsInOrderGraph && !MEnableProfiling, MEnableProfiling}; auto ContextImpl = sycl::detail::getSyclObjImpl(MContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); auto DeviceImpl = sycl::detail::getSyclObjImpl(Device); ur_result_t Res = - Plugin->call_nocheck( + Adapter->call_nocheck( ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), &Desc, &OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { @@ -764,7 +764,7 @@ void exec_graph_impl::createCommandBuffers( } Res = - Plugin->call_nocheck( + Adapter->call_nocheck( OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { throw sycl::exception(errc::invalid, @@ -798,8 +798,8 @@ exec_graph_impl::exec_graph_impl(sycl::context Context, exec_graph_impl::~exec_graph_impl() { try { - const sycl::detail::PluginPtr &Plugin = - sycl::detail::getSyclObjImpl(MContext)->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = + sycl::detail::getSyclObjImpl(MContext)->getAdapter(); MSchedule.clear(); // We need to wait on all command buffer executions before we can release // them. @@ -811,7 +811,7 @@ 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< + ur_result_t Res = Adapter->call_nocheck< sycl::detail::UrApiKind::urCommandBufferReleaseExp>(CmdBuf); (void)Res; assert(Res == UR_RESULT_SUCCESS); @@ -821,7 +821,7 @@ exec_graph_impl::~exec_graph_impl() { for (auto &Iter : MCommandMap) { if (auto Command = Iter.second; Command) { - ur_result_t Res = Plugin->call_nocheck< + ur_result_t Res = Adapter->call_nocheck< sycl::detail::UrApiKind::urCommandBufferReleaseCommandExp>(Command); (void)Res; assert(Res == UR_RESULT_SUCCESS); @@ -925,7 +925,7 @@ exec_graph_impl::enqueue(const std::shared_ptr &Queue, NewEvent->setHostEnqueueTime(); } ur_result_t Res = - Queue->getPlugin() + Queue->getAdapter() ->call_nocheck< sycl::detail::UrApiKind::urCommandBufferEnqueueExp>( CommandBuffer, Queue->getHandleRef(), 0, nullptr, &UREvent); @@ -1339,7 +1339,7 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { return; } auto ContextImpl = sycl::detail::getSyclObjImpl(MContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); auto DeviceImpl = sycl::detail::getSyclObjImpl(MGraphImpl->getDevice()); // Gather arg information from Node @@ -1399,7 +1399,7 @@ void exec_graph_impl::updateImpl(std::shared_ptr Node) { if (NDRDesc.LocalSize[0] != 0) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( + Adapter->call( UrKernel, DeviceImpl->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -1500,14 +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< + ur_result_t Res = Adapter->call_nocheck< sycl::detail::UrApiKind::urCommandBufferUpdateKernelLaunchExp>( Command, &UpdateDesc); if (UrProgram) { // We retained these objects by calling getOrCreateKernel() - Plugin->call(UrKernel); - Plugin->call(UrProgram); + Adapter->call(UrKernel); + Adapter->call(UrProgram); } if (Res != UR_RESULT_SUCCESS) { diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index f02c7f594a057..3e78542f9318b 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -261,8 +261,8 @@ image_channel_type convertChannelType(ur_image_channel_type_t Type) { template static void getImageInfo(const ContextImplPtr Context, ur_image_info_t Info, T &Dest, ur_mem_handle_t InteropMemObject) { - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(InteropMemObject, Info, sizeof(T), + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(InteropMemObject, Info, sizeof(T), &Dest, nullptr); } @@ -275,8 +275,8 @@ image_impl::image_impl(cl_mem MemObject, const context &SyclContext, MDimensions(Dimensions), MRange({0, 0, 0}) { ur_mem_handle_t Mem = ur::cast(BaseT::MInteropMemObject); const ContextImplPtr Context = getSyclObjImpl(SyclContext); - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(Mem, UR_MEM_INFO_SIZE, sizeof(size_t), + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(Mem, UR_MEM_INFO_SIZE, sizeof(size_t), &(BaseT::MSizeInBytes), nullptr); ur_image_format_t Format; diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 2a128ba9a901e..89c6833a4da27 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -406,7 +406,7 @@ class kernel_bundle_impl { using ContextImplPtr = std::shared_ptr; ContextImplPtr ContextImpl = getSyclObjImpl(MContext); - const PluginPtr &Plugin = ContextImpl->getPlugin(); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); std::vector DeviceVec; DeviceVec.reserve(Devices.size()); @@ -424,7 +424,7 @@ class kernel_bundle_impl { std::transform(DeviceVec.begin(), DeviceVec.end(), IPVersionVec.begin(), [&](ur_device_handle_t d) { uint32_t ipVersion = 0; - Plugin->call( + Adapter->call( d, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); return ipVersion; @@ -452,7 +452,7 @@ class kernel_bundle_impl { }(); ur_program_handle_t UrProgram = nullptr; - Plugin->call(ContextImpl->getHandleRef(), + Adapter->call(ContextImpl->getHandleRef(), spirv.data(), spirv.size(), nullptr, &UrProgram); // program created by urProgramCreateWithIL is implicitly retained. @@ -462,28 +462,28 @@ class kernel_bundle_impl { "urProgramCreateWithIL resulted in a null program handle."); std::string XsFlags = extractXsFlags(BuildOptions); - auto Res = Plugin->call_nocheck( + auto Res = Adapter->call_nocheck( UrProgram, DeviceVec.size(), DeviceVec.data(), XsFlags.c_str()); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Plugin->call_nocheck( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), UrProgram, XsFlags.c_str()); } - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); // Get the number of kernels in the program. size_t NumKernels; - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_NUM_KERNELS, sizeof(size_t), &NumKernels, nullptr); // Get the kernel names. size_t KernelNamesSize; - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, 0, nullptr, &KernelNamesSize); // semi-colon delimited list of kernel names. std::string KernelNamesStr(KernelNamesSize, ' '); - Plugin->call( + Adapter->call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, KernelNamesStr.size(), &KernelNamesStr[0], nullptr); std::vector KernelNames = @@ -535,9 +535,9 @@ class kernel_bundle_impl { detail::getSyclObjImpl(MDeviceImages[0]); ur_program_handle_t UrProgram = DeviceImageImpl->get_ur_program_ref(); ContextImplPtr ContextImpl = getSyclObjImpl(MContext); - const PluginPtr &Plugin = ContextImpl->getPlugin(); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); ur_kernel_handle_t UrKernel = nullptr; - Plugin->call(UrProgram, AdjustedName.c_str(), + Adapter->call(UrProgram, AdjustedName.c_str(), &UrKernel); // Kernel created by urKernelCreate is implicitly retained. diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index faf3695c04e94..f89ef979f7c9e 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -25,8 +25,8 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr Context, MCreatedFromSource(true), MKernelBundleImpl(std::move(KernelBundleImpl)), MIsInterop(true), MKernelArgMaskPtr{ArgMask} { ur_context_handle_t UrContext = nullptr; - // Using the plugin from the passed ContextImpl - getPlugin()->call( + // Using the adapter from the passed ContextImpl + getAdapter()->call( MKernel, UR_KERNEL_INFO_CONTEXT, sizeof(UrContext), &UrContext, nullptr); if (Context->getHandleRef() != UrContext) throw sycl::exception( @@ -34,11 +34,11 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr Context, "Input context must be the same as the context of cl_kernel"); // Enable USM indirect access for interoperability kernels. - // Some UR Plugins (like OpenCL) require this call to enable USM + // Some UR Adapters (like OpenCL) require this call to enable USM // For others, UR will turn this into a NOP. if (Context->getPlatformImpl()->supports_usm()) { bool EnableAccess = true; - getPlugin()->call( + getAdapter()->call( MKernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &EnableAccess); } @@ -59,7 +59,7 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, ContextImplPtr ContextImpl, kernel_impl::~kernel_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions - getPlugin()->call(MKernel); + getAdapter()->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 ab2950e26a856..e8aee0e81750b 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -74,14 +74,14 @@ class kernel_impl { /// /// \return a valid cl_kernel instance cl_kernel get() const { - getPlugin()->call(MKernel); + getAdapter()->call(MKernel); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(MKernel, + getAdapter()->call(MKernel, &nativeHandle); return ur::cast(nativeHandle); } - const PluginPtr &getPlugin() const { return MContext->getPlugin(); } + const AdapterPtr &getAdapter() const { return MContext->getAdapter(); } /// Query information from the kernel object using the info::kernel_info /// descriptor. @@ -132,13 +132,13 @@ class kernel_impl { const DeviceImageImplPtr &getDeviceImage() const { return MDeviceImageImpl; } ur_native_handle_t getNative() const { - const PluginPtr &Plugin = MContext->getPlugin(); + const AdapterPtr &Adapter = MContext->getAdapter(); if (MContext->getBackend() == backend::opencl) - Plugin->call(MKernel); + Adapter->call(MKernel); ur_native_handle_t NativeKernel = 0; - Plugin->call(MKernel, &NativeKernel); + Adapter->call(MKernel, &NativeKernel); return NativeKernel; } @@ -180,7 +180,7 @@ inline typename Param::return_type kernel_impl::get_info() const { if constexpr (std::is_same_v) checkIfValidForNumArgsInfoQuery(); - return get_kernel_info(this->getHandleRef(), getPlugin()); + return get_kernel_info(this->getHandleRef(), getAdapter()); } template <> @@ -205,7 +205,7 @@ kernel_impl::get_info(const device &Device) const { return get_kernel_device_specific_info( this->getHandleRef(), getSyclObjImpl(Device)->getHandleRef(), - getPlugin()); + getAdapter()); } template @@ -214,7 +214,7 @@ kernel_impl::get_info(const device &Device, const sycl::range<3> &WGSize) const { return get_kernel_device_specific_info_with_input( this->getHandleRef(), getSyclObjImpl(Device)->getHandleRef(), WGSize, - getPlugin()); + getAdapter()); } template <> @@ -223,12 +223,12 @@ inline typename ext::oneapi::experimental::info::kernel_queue_specific:: kernel_impl::ext_oneapi_get_info< ext::oneapi::experimental::info::kernel_queue_specific:: max_num_work_group_sync>(const queue &Queue) const { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); const auto &Handle = getHandleRef(); const auto MaxWorkGroupSize = Queue.get_device().get_info(); uint32_t GroupCount = 0; - Plugin->call( + Adapter->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 809a9dd25510e..6c26dedff6845 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -25,20 +25,20 @@ template typename std::enable_if< std::is_same::value, std::string>::type -get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { +get_kernel_info(ur_kernel_handle_t Kernel, const AdapterPtr &Adapter) { static_assert(detail::is_kernel_info_desc::value, "Invalid kernel information descriptor"); size_t ResultSize = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Kernel, UrInfoCode::value, 0, + Adapter->call(Kernel, UrInfoCode::value, 0, nullptr, &ResultSize); if (ResultSize == 0) { return ""; } std::vector Result(ResultSize); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Kernel, UrInfoCode::value, + Adapter->call(Kernel, UrInfoCode::value, ResultSize, Result.data(), nullptr); return std::string(Result.data()); } @@ -46,11 +46,11 @@ get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { template typename std::enable_if< std::is_same::value, uint32_t>::type -get_kernel_info(ur_kernel_handle_t Kernel, const PluginPtr &Plugin) { +get_kernel_info(ur_kernel_handle_t Kernel, const AdapterPtr &Adapter) { ur_result_t Result = UR_RESULT_SUCCESS; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Kernel, UrInfoCode::value, + Adapter->call(Kernel, UrInfoCode::value, sizeof(uint32_t), &Result, nullptr); return Result; } @@ -60,9 +60,9 @@ template typename std::enable_if::value>::type get_kernel_device_specific_info_helper(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const PluginPtr &Plugin, void *Result, + const AdapterPtr &Adapter, void *Result, size_t Size) { - Plugin->call( + Adapter->call( Kernel, Device, UrInfoCode::value, Size, Result, nullptr); } @@ -70,8 +70,8 @@ template typename std::enable_if::value>::type get_kernel_device_specific_info_helper( ur_kernel_handle_t Kernel, [[maybe_unused]] ur_device_handle_t Device, - const PluginPtr &Plugin, void *Result, size_t Size) { - Plugin->call(Kernel, UrInfoCode::value, + const AdapterPtr &Adapter, void *Result, size_t Size) { + Adapter->call(Kernel, UrInfoCode::value, Size, Result, nullptr); } @@ -80,13 +80,13 @@ typename std::enable_if::value && !IsKernelInfo::value>::type get_kernel_device_specific_info_helper(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const PluginPtr &Plugin, void *Result, + const AdapterPtr &Adapter, void *Result, size_t Size) { - ur_result_t Error = Plugin->call_nocheck( + ur_result_t Error = Adapter->call_nocheck( Kernel, Device, UrInfoCode::value, Size, Result, nullptr); if (Error != UR_RESULT_SUCCESS) kernel_get_group_info::handleErrorOrWarning(Error, UrInfoCode::value, - Plugin); + Adapter); } template @@ -95,13 +95,13 @@ typename std::enable_if< typename Param::return_type>::type get_kernel_device_specific_info(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); typename Param::return_type Result = {}; // TODO catch an exception and put it to list of asynchronous exceptions get_kernel_device_specific_info_helper( - Kernel, Device, Plugin, &Result, sizeof(typename Param::return_type)); + Kernel, Device, Adapter, &Result, sizeof(typename Param::return_type)); return Result; } @@ -111,12 +111,12 @@ typename std::enable_if< sycl::range<3>>::type get_kernel_device_specific_info(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); size_t Result[3] = {0, 0, 0}; // TODO catch an exception and put it to list of asynchronous exceptions - get_kernel_device_specific_info_helper(Kernel, Device, Plugin, Result, + get_kernel_device_specific_info_helper(Kernel, Device, Adapter, Result, sizeof(size_t) * 3); return sycl::range<3>(Result[0], Result[1], Result[2]); } @@ -128,7 +128,7 @@ template uint32_t get_kernel_device_specific_info_with_input(ur_kernel_handle_t Kernel, ur_device_handle_t Device, sycl::range<3>, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); static_assert(std::is_same::value, @@ -139,7 +139,7 @@ uint32_t get_kernel_device_specific_info_with_input(ur_kernel_handle_t Kernel, uint32_t Result = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( Kernel, Device, UrInfoCode::value, sizeof(uint32_t), &Result, nullptr); diff --git a/sycl/source/detail/kernel_program_cache.cpp b/sycl/source/detail/kernel_program_cache.cpp index 6916f425ca50f..e73c6dbaa6d53 100644 --- a/sycl/source/detail/kernel_program_cache.cpp +++ b/sycl/source/detail/kernel_program_cache.cpp @@ -8,13 +8,13 @@ #include #include -#include +#include namespace sycl { inline namespace _V1 { namespace detail { -const PluginPtr &KernelProgramCache::getPlugin() { - return MParentContext->getPlugin(); +const AdapterPtr &KernelProgramCache::getAdapter() { + return MParentContext->getAdapter(); } } // namespace detail } // namespace _V1 diff --git a/sycl/source/detail/kernel_program_cache.hpp b/sycl/source/detail/kernel_program_cache.hpp index 44dfd84751afd..0e6323b74e3ef 100644 --- a/sycl/source/detail/kernel_program_cache.hpp +++ b/sycl/source/detail/kernel_program_cache.hpp @@ -90,12 +90,12 @@ class KernelProgramCache { }; struct ProgramBuildResult : public BuildResult { - PluginPtr Plugin; - ProgramBuildResult(const PluginPtr &Plugin) : Plugin(Plugin) { + AdapterPtr Adapter; + ProgramBuildResult(const AdapterPtr &Adapter) : Adapter(Adapter) { Val = nullptr; } - ProgramBuildResult(const PluginPtr &Plugin, BuildState InitialState) - : Plugin(Plugin) { + ProgramBuildResult(const AdapterPtr &Adapter, BuildState InitialState) + : Adapter(Adapter) { Val = nullptr; this->State.store(InitialState); } @@ -103,7 +103,7 @@ class KernelProgramCache { try { if (Val) { ur_result_t Err = - Plugin->call_nocheck(Val); + Adapter->call_nocheck(Val); __SYCL_CHECK_UR_CODE_NO_EXC(Err); } } catch (std::exception &e) { @@ -134,15 +134,15 @@ class KernelProgramCache { using KernelArgMaskPairT = std::pair; struct KernelBuildResult : public BuildResult { - PluginPtr Plugin; - KernelBuildResult(const PluginPtr &Plugin) : Plugin(Plugin) { + AdapterPtr Adapter; + KernelBuildResult(const AdapterPtr &Adapter) : Adapter(Adapter) { Val.first = nullptr; } ~KernelBuildResult() { try { if (Val.first) { ur_result_t Err = - Plugin->call_nocheck(Val.first); + Adapter->call_nocheck(Val.first); __SYCL_CHECK_UR_CODE_NO_EXC(Err); } } catch (std::exception &e) { @@ -188,7 +188,7 @@ class KernelProgramCache { auto &ProgCache = LockedCache.get(); auto [It, DidInsert] = ProgCache.Cache.try_emplace(CacheKey, nullptr); if (DidInsert) { - It->second = std::make_shared(getPlugin()); + It->second = std::make_shared(getAdapter()); // Save reference between the common key and the full key. CommonProgramKeyT CommonKey = std::make_pair(CacheKey.first.second, CacheKey.second); @@ -208,7 +208,7 @@ class KernelProgramCache { auto &ProgCache = LockedCache.get(); auto [It, DidInsert] = ProgCache.Cache.try_emplace(CacheKey, nullptr); if (DidInsert) { - It->second = std::make_shared(getPlugin(), + It->second = std::make_shared(getAdapter(), BuildState::BS_Done); It->second->Val = Program; // Save reference between the common key and the full key. @@ -226,7 +226,7 @@ class KernelProgramCache { auto &Cache = LockedCache.get()[Program]; auto [It, DidInsert] = Cache.try_emplace(KernelName, nullptr); if (DidInsert) - It->second = std::make_shared(getPlugin()); + It->second = std::make_shared(getAdapter()); return std::make_pair(It->second, DidInsert); } @@ -357,7 +357,7 @@ class KernelProgramCache { KernelFastCacheT MKernelFastCache; friend class ::MockKernelProgramCache; - const PluginPtr &getPlugin(); + const AdapterPtr &getAdapter(); }; } // namespace detail } // namespace _V1 diff --git a/sycl/source/detail/mem_alloc_helper.hpp b/sycl/source/detail/mem_alloc_helper.hpp index 69759709c0b47..88e4d742fcec6 100644 --- a/sycl/source/detail/mem_alloc_helper.hpp +++ b/sycl/source/detail/mem_alloc_helper.hpp @@ -13,19 +13,19 @@ namespace sycl { inline namespace _V1 { namespace detail { -void memBufferCreateHelper(const PluginPtr &Plugin, ur_context_handle_t Ctx, +void memBufferCreateHelper(const AdapterPtr &Adapter, ur_context_handle_t Ctx, ur_mem_flags_t Flags, size_t Size, ur_mem_handle_t *RetMem, const ur_buffer_properties_t *Props = nullptr); -void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem); -void memBufferMapHelper(const PluginPtr &Plugin, +void memReleaseHelper(const AdapterPtr &Adapter, ur_mem_handle_t Mem); +void memBufferMapHelper(const AdapterPtr &Adapter, ur_queue_handle_t command_queue, ur_mem_handle_t buffer, bool blocking_map, ur_map_flags_t map_flags, size_t offset, size_t size, uint32_t num_events_in_wait_list, const ur_event_handle_t *event_wait_list, ur_event_handle_t *event, void **ret_map); -void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t command_queue, +void memUnmapHelper(const AdapterPtr &Adapter, ur_queue_handle_t command_queue, ur_mem_handle_t memobj, void *mapped_ptr, uint32_t num_events_in_wait_list, const ur_event_handle_t *event_wait_list, diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index c4281e8df0013..a519a8e6fc1ff 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -122,18 +122,18 @@ static void waitForEvents(const std::vector &Events) { // Assuming all events will be on the same device or // devices associated with the same Backend. if (!Events.empty()) { - const PluginPtr &Plugin = Events[0]->getPlugin(); + const AdapterPtr &Adapter = Events[0]->getAdapter(); std::vector UrEvents(Events.size()); std::transform( Events.begin(), Events.end(), UrEvents.begin(), [](const EventImplPtr &EventImpl) { return EventImpl->getHandle(); }); if (!UrEvents.empty() && UrEvents[0]) { - Plugin->call(UrEvents.size(), &UrEvents[0]); + Adapter->call(UrEvents.size(), &UrEvents[0]); } } } -void memBufferCreateHelper(const PluginPtr &Plugin, ur_context_handle_t Ctx, +void memBufferCreateHelper(const AdapterPtr &Adapter, ur_context_handle_t Ctx, ur_mem_flags_t Flags, size_t Size, ur_mem_handle_t *RetMem, const ur_buffer_properties_t *Props) { @@ -155,19 +155,19 @@ 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( + Adapter->call_nocheck( *RetMem, /*Dev*/ nullptr, &Ptr); emitMemAllocEndTrace(MemObjID, (uintptr_t)(Ptr), Size, 0 /* guard zone */, CorrID); }}; #endif if (Size) - Plugin->call(Ctx, Flags, Size, Props, + Adapter->call(Ctx, Flags, Size, Props, RetMem); } } -void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { +void memReleaseHelper(const AdapterPtr &Adapter, ur_mem_handle_t Mem) { // FIXME urMemRelease does not guarante memory release. It is only true if // reference counter is 1. However, SYCL runtime currently only calls // urMemRetain only for OpenCL interop @@ -182,7 +182,7 @@ void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { // When doing buffer interop we don't know what device the memory should be // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. - Plugin->call_nocheck(Mem, /*Dev*/ nullptr, + Adapter->call_nocheck(Mem, /*Dev*/ nullptr, &PtrHandle); Ptr = (uintptr_t)(PtrHandle); } @@ -194,11 +194,11 @@ void memReleaseHelper(const PluginPtr &Plugin, ur_mem_handle_t Mem) { xpti::utils::finally _{ [&] { emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call(Mem); + Adapter->call(Mem); } } -void memBufferMapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, +void memBufferMapHelper(const AdapterPtr &Adapter, ur_queue_handle_t Queue, ur_mem_handle_t Buffer, bool Blocking, ur_map_flags_t Flags, size_t Offset, size_t Size, uint32_t NumEvents, const ur_event_handle_t *WaitList, @@ -216,12 +216,12 @@ void memBufferMapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, 0 /* guard zone */, CorrID); }}; #endif - Plugin->call(Queue, Buffer, Blocking, Flags, + Adapter->call(Queue, Buffer, Blocking, Flags, Offset, Size, NumEvents, WaitList, Event, RetMap); } -void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, +void memUnmapHelper(const AdapterPtr &Adapter, ur_queue_handle_t Queue, ur_mem_handle_t Mem, void *MappedPtr, uint32_t NumEvents, const ur_event_handle_t *WaitList, ur_event_handle_t *Event) { @@ -241,11 +241,11 @@ void memUnmapHelper(const PluginPtr &Plugin, ur_queue_handle_t Queue, // Always use call_nocheck here, because call may throw an exception, // and this lambda will be called from destructor, which in combination // rewards us with UB. - Plugin->call_nocheck(1, Event); + Adapter->call_nocheck(1, Event); emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Plugin->call(Queue, Mem, MappedPtr, NumEvents, + Adapter->call(Queue, Mem, MappedPtr, NumEvents, WaitList, Event); } } @@ -275,8 +275,8 @@ void MemoryManager::releaseMemObj(ContextImplPtr TargetContext, return; } - const PluginPtr &Plugin = TargetContext->getPlugin(); - memReleaseHelper(Plugin, ur::cast(MemAllocation)); + const AdapterPtr &Adapter = TargetContext->getAdapter(); + memReleaseHelper(Adapter, ur::cast(MemAllocation)); } void *MemoryManager::allocate(ContextImplPtr TargetContext, SYCLMemObjI *MemObj, @@ -318,8 +318,8 @@ void *MemoryManager::allocateInteropMemObject( // Retain the event since it will be released during alloca command // destruction if (nullptr != OutEventToWait) { - const PluginPtr &Plugin = InteropEvent->getPlugin(); - Plugin->call(OutEventToWait); + const AdapterPtr &Adapter = InteropEvent->getAdapter(); + Adapter->call(OutEventToWait); } return UserPtr; } @@ -343,8 +343,8 @@ void *MemoryManager::allocateImageObject(ContextImplPtr TargetContext, getMemObjCreationFlags(UserPtr, HostPtrReadOnly); ur_mem_handle_t NewMem = nullptr; - const PluginPtr &Plugin = TargetContext->getPlugin(); - Plugin->call(TargetContext->getHandleRef(), + const AdapterPtr &Adapter = TargetContext->getAdapter(); + Adapter->call(TargetContext->getHandleRef(), CreationFlags, &Format, &Desc, UserPtr, &NewMem); return NewMem; @@ -361,7 +361,7 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, CreationFlags |= UR_MEM_FLAG_ALLOC_HOST_POINTER; ur_mem_handle_t NewMem = nullptr; - const PluginPtr &Plugin = TargetContext->getPlugin(); + const AdapterPtr &Adapter = TargetContext->getAdapter(); ur_buffer_properties_t AllocProps = {UR_STRUCTURE_TYPE_BUFFER_PROPERTIES, nullptr, UserPtr}; @@ -386,7 +386,7 @@ MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr, *Next = &ChannelProperties; } - memBufferCreateHelper(Plugin, TargetContext->getHandleRef(), CreationFlags, + memBufferCreateHelper(Adapter, TargetContext->getHandleRef(), CreationFlags, Size, &NewMem, &AllocProps); return NewMem; } @@ -448,8 +448,8 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, ur_buffer_region_t Region = {UR_STRUCTURE_TYPE_BUFFER_REGION, nullptr, Offset, SizeInBytes}; ur_mem_handle_t NewMem; - const PluginPtr &Plugin = TargetContext->getPlugin(); - Error = Plugin->call_nocheck( + const AdapterPtr &Adapter = TargetContext->getAdapter(); + Error = Adapter->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) @@ -459,7 +459,7 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, "a multiple of the memory base address alignment"), Error); - Plugin->checkUrResult(Error); + Adapter->checkUrResult(Error); return NewMem; } @@ -508,7 +508,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, assert(TgtQueue && "Destination mem object queue must be not nullptr"); const ur_queue_handle_t Queue = TgtQueue->getHandleRef(); - const PluginPtr &Plugin = TgtQueue->getPlugin(); + const AdapterPtr &Adapter = TgtQueue->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -525,7 +525,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, DstMem, /*blocking_write=*/false, DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -546,7 +546,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, DstMem, /*blocking_write=*/false, BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, @@ -564,7 +564,7 @@ void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, DstAccessRange[DstPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, DstMem, /*blocking_write=*/false, Origin, Region, InputRowPitch, InputSlicePitch, SrcMem, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -585,7 +585,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, assert(SrcQueue && "Source mem object queue is expected to be not nullptr"); const ur_queue_handle_t Queue = SrcQueue->getHandleRef(); - const PluginPtr &Plugin = SrcQueue->getPlugin(); + const AdapterPtr &Adapter = SrcQueue->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -608,7 +608,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, /*blocking_read=*/false, SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -629,7 +629,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, /*blocking_read=*/false, BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch, @@ -647,7 +647,7 @@ void copyD2H(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, false, Offset, Region, RowPitch, SlicePitch, DstMem, DepEvents.size(), DepEvents.data(), &OutEvent); } @@ -667,7 +667,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, "expected to be not nullptr"); const ur_queue_handle_t Queue = SrcQueue->getHandleRef(); - const PluginPtr &Plugin = SrcQueue->getPlugin(); + const AdapterPtr &Adapter = SrcQueue->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -684,7 +684,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, if (1 == DimDst && 1 == DimSrc) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, DstMem, SrcXOffBytes, DstXOffBytes, SrcAccessRangeWidthBytes, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -710,7 +710,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, DstSlicePitch, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -725,7 +725,7 @@ void copyD2D(SYCLMemObjI *SYCLMemObj, ur_mem_handle_t SrcMem, SrcAccessRange[SrcPos.ZTerm]}; if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue, SrcMem, DstMem, SrcOrigin, DstOrigin, Region, DepEvents.size(), DepEvents.data(), &OutEvent); } @@ -807,7 +807,7 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, assert(SYCLMemObj && "The SYCLMemObj is nullptr"); assert(Queue && "Fill should be called only with a valid device queue"); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (SYCLMemObj->getType() == detail::SYCLMemObjI::MemObjType::Buffer) { if (OutEventImpl != nullptr) @@ -822,7 +822,7 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, size_t RangeMultiplier = AccRange[0] * AccRange[1] * AccRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call( + Adapter->call( Queue->getHandleRef(), ur::cast(Mem), Pattern, PatternSize, Offset[0] * ElementSize, RangeMultiplier * ElementSize, DepEvents.size(), DepEvents.data(), &OutEvent); @@ -881,8 +881,8 @@ void *MemoryManager::map(SYCLMemObjI *, void *Mem, QueueImplPtr Queue, void *MappedPtr = nullptr; const size_t BytesToMap = AccessRange[0] * AccessRange[1] * AccessRange[2]; - const PluginPtr &Plugin = Queue->getPlugin(); - memBufferMapHelper(Plugin, Queue->getHandleRef(), + const AdapterPtr &Adapter = Queue->getAdapter(); + memBufferMapHelper(Adapter, Queue->getHandleRef(), ur::cast(Mem), false, Flags, AccessOffset[0], BytesToMap, DepEvents.size(), DepEvents.data(), &OutEvent, &MappedPtr); @@ -900,10 +900,10 @@ void MemoryManager::unmap(SYCLMemObjI *, void *Mem, QueueImplPtr Queue, "Not supported configuration of unmap requested"); } // All DepEvents are to the same Context. - // Using the plugin of the Queue. + // Using the adapter of the Queue. - const PluginPtr &Plugin = Queue->getPlugin(); - memUnmapHelper(Plugin, Queue->getHandleRef(), ur::cast(Mem), + const AdapterPtr &Adapter = Queue->getAdapter(); + memUnmapHelper(Adapter, Queue->getHandleRef(), ur::cast(Mem), MappedPtr, DepEvents.size(), DepEvents.data(), &OutEvent); } @@ -917,7 +917,7 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - SrcQueue->getPlugin()->call( + SrcQueue->getAdapter()->call( SrcQueue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } @@ -928,10 +928,10 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory copy operation."); - const PluginPtr &Plugin = SrcQueue->getPlugin(); + const AdapterPtr &Adapter = SrcQueue->getAdapter(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(SrcQueue->getHandleRef(), + Adapter->call(SrcQueue->getHandleRef(), /* blocking */ false, DstMem, SrcMem, Len, DepEvents.size(), DepEvents.data(), OutEvent); @@ -947,7 +947,7 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -958,8 +958,8 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, "NULL pointer argument in memory fill operation."); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Queue->getHandleRef(), Mem, Pattern.size(), Pattern.data(), Length, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -969,10 +969,10 @@ void MemoryManager::prefetch_usm(void *Mem, QueueImplPtr Queue, size_t Length, ur_event_handle_t *OutEvent, const detail::EventImplPtr &OutEventImpl) { assert(Queue && "USM prefetch must be called with a valid device queue"); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(Queue->getHandleRef(), Mem, + Adapter->call(Queue->getHandleRef(), Mem, Length, 0, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -983,10 +983,10 @@ void MemoryManager::advise_usm(const void *Mem, QueueImplPtr Queue, ur_event_handle_t *OutEvent, const detail::EventImplPtr &OutEventImpl) { assert(Queue && "USM advise must be called with a valid device queue"); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Plugin->call(Queue->getHandleRef(), Mem, + Adapter->call(Queue->getHandleRef(), Mem, Length, Advice, OutEvent); } @@ -1002,7 +1002,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1012,10 +1012,10 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, throw sycl::exception(sycl::make_error_code(errc::invalid), "NULL pointer argument in 2D memory copy operation."); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); bool SupportsUSMMemcpy2D = false; - Plugin->call( + Adapter->call( Queue->getContextImplPtr()->getHandleRef(), UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, sizeof(bool), &SupportsUSMMemcpy2D, nullptr); @@ -1024,7 +1024,7 @@ void MemoryManager::copy_2d_usm(const void *SrcMem, size_t SrcPitch, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); // Direct memcpy2D is supported so we use this function. - Plugin->call( + Adapter->call( Queue->getHandleRef(), /*blocking=*/false, DstMem, DstPitch, SrcMem, SrcPitch, Width, Height, DepEvents.size(), DepEvents.data(), OutEvent); @@ -1055,17 +1055,17 @@ 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( + Adapter->call( Queue->getHandleRef(), /* blocking */ false, DstItBegin, SrcItBegin, Width, DepEvents.size(), DepEvents.data(), CopyEvents.data() + I); - CopyEventsManaged.emplace_back(CopyEvents[I], Plugin, + CopyEventsManaged.emplace_back(CopyEvents[I], Adapter, /*TakeOwnership=*/true); } if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); // Then insert a wait to coalesce the copy events. - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), CopyEvents.size(), CopyEvents.data(), OutEvent); } @@ -1081,7 +1081,7 @@ void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1092,8 +1092,8 @@ void MemoryManager::fill_2d_usm(void *DstMem, QueueImplPtr Queue, size_t Pitch, "NULL pointer argument in 2D memory fill operation."); if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Queue->getHandleRef(), DstMem, Pitch, Pattern.size(), Pattern.data(), Width, Height, DepEvents.size(), DepEvents.data(), OutEvent); } @@ -1110,7 +1110,7 @@ void MemoryManager::memset_2d_usm(void *DstMem, QueueImplPtr Queue, if (!DepEvents.empty()) { if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); - Queue->getPlugin()->call( + Queue->getAdapter()->call( Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), OutEvent); } return; @@ -1141,7 +1141,7 @@ static void memcpyToDeviceGlobalUSM( // OwnedPiEvent will keep the initialization event alive for the duration // of this function call. - OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Queue->getPlugin()); + OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Queue->getAdapter()); // We may need addtional events, so create a non-const dependency events list // to use if we need to modify it. @@ -1176,7 +1176,7 @@ static void memcpyFromDeviceGlobalUSM( // OwnedPiEvent will keep the initialization event alive for the duration // of this function call. - OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Queue->getPlugin()); + OwnedUrEvent ZIEvent = DeviceGlobalUSM.getInitEvent(Queue->getAdapter()); // We may need addtional events, so create a non-const dependency events list // to use if we need to modify it. @@ -1242,8 +1242,8 @@ memcpyToDeviceGlobalDirect(QueueImplPtr Queue, "Direct copy to device global must be called with a valid device queue"); ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Queue->getHandleRef(), Program, DeviceGlobalEntry->MUniqueId.c_str(), false, NumBytes, Offset, Src, DepEvents.size(), DepEvents.data(), OutEvent); @@ -1259,8 +1259,8 @@ memcpyFromDeviceGlobalDirect(QueueImplPtr Queue, "device queue"); ur_program_handle_t Program = getOrBuildProgramForDeviceGlobal(Queue, DeviceGlobalEntry); - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Queue->getHandleRef(), Program, DeviceGlobalEntry->MUniqueId.c_str(), false, NumBytes, Offset, Dest, DepEvents.size(), DepEvents.data(), OutEvent); @@ -1324,7 +1324,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( assert(SYCLMemObj && "The SYCLMemObj is nullptr"); (void)DstAccessRange; - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1343,7 +1343,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - Plugin->call( + Adapter->call( CommandBuffer, sycl::detail::ur::cast(SrcMem), sycl::detail::ur::cast(DstMem), SrcXOffBytes, DstXOffBytes, SrcAccessRangeWidthBytes, Deps.size(), Deps.data(), @@ -1369,7 +1369,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - Plugin->call( + Adapter->call( CommandBuffer, sycl::detail::ur::cast(SrcMem), sycl::detail::ur::cast(DstMem), SrcOrigin, DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, DstSlicePitch, @@ -1388,7 +1388,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1408,7 +1408,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( if (1 == DimDst && 1 == DimSrc) { ur_result_t Result = - Plugin->call_nocheck( + Adapter->call_nocheck( CommandBuffer, sycl::detail::ur::cast(SrcMem), SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, Deps.size(), Deps.data(), OutSyncPoint); @@ -1418,7 +1418,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "Device-to-host buffer copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } else { size_t BufferRowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes; @@ -1436,7 +1436,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck< + ur_result_t Result = Adapter->call_nocheck< UrApiKind::urCommandBufferAppendMemBufferReadRectExp>( CommandBuffer, sycl::detail::ur::cast(SrcMem), BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, @@ -1447,7 +1447,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "Device-to-host buffer copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } } @@ -1463,7 +1463,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1483,7 +1483,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( if (1 == DimDst && 1 == DimSrc) { ur_result_t Result = - Plugin->call_nocheck( + Adapter->call_nocheck( CommandBuffer, sycl::detail::ur::cast(DstMem), DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, Deps.size(), Deps.data(), OutSyncPoint); @@ -1493,7 +1493,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "Host-to-device buffer copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } else { size_t BufferRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes; @@ -1511,7 +1511,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( DstAccessRange[DstPos.YTerm], DstAccessRange[DstPos.ZTerm]}; - ur_result_t Result = Plugin->call_nocheck< + ur_result_t Result = Adapter->call_nocheck< UrApiKind::urCommandBufferAppendMemBufferWriteRectExp>( CommandBuffer, sycl::detail::ur::cast(DstMem), BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, @@ -1523,7 +1523,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "Host-to-device buffer copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } } @@ -1537,9 +1537,9 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer( throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory copy operation."); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); ur_result_t Result = - Plugin->call_nocheck( + Adapter->call_nocheck( CommandBuffer, DstMem, SrcMem, Len, Deps.size(), Deps.data(), OutSyncPoint); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { @@ -1547,7 +1547,7 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "USM copy command not supported by graph backend"); } else { - Plugin->checkUrResult(Result); + Adapter->checkUrResult(Result); } } @@ -1562,8 +1562,8 @@ void MemoryManager::ext_oneapi_fill_usm_cmd_buffer( throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory fill operation."); - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call( CommandBuffer, DstMem, Pattern.data(), Pattern.size(), Len, Deps.size(), Deps.data(), OutSyncPoint); } @@ -1578,7 +1578,7 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); if (SYCLMemObj->getType() != detail::SYCLMemObjI::MemObjType::Buffer) { throw sycl::exception(sycl::make_error_code(sycl::errc::invalid), "Images are not supported in Graphs"); @@ -1593,7 +1593,7 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( size_t RangeMultiplier = AccessRange[0] * AccessRange[1] * AccessRange[2]; if (RangesUsable && OffsetUsable) { - Plugin->call( + Adapter->call( CommandBuffer, ur::cast(Mem), Pattern, PatternSize, AccessOffset[0] * ElementSize, RangeMultiplier * ElementSize, Deps.size(), Deps.data(), OutSyncPoint); @@ -1610,8 +1610,8 @@ void MemoryManager::ext_oneapi_prefetch_usm_cmd_buffer( ur_exp_command_buffer_handle_t CommandBuffer, void *Mem, size_t Length, std::vector Deps, ur_exp_command_buffer_sync_point_t *OutSyncPoint) { - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call( CommandBuffer, Mem, Length, ur_usm_migration_flags_t(0), Deps.size(), Deps.data(), OutSyncPoint); } @@ -1622,8 +1622,8 @@ void MemoryManager::ext_oneapi_advise_usm_cmd_buffer( size_t Length, ur_usm_advice_flags_t Advice, std::vector Deps, ur_exp_command_buffer_sync_point_t *OutSyncPoint) { - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call( CommandBuffer, Mem, Length, Advice, Deps.size(), Deps.data(), OutSyncPoint); } @@ -1647,7 +1647,7 @@ void MemoryManager::copy_image_bindless( sycl::make_error_code(errc::invalid), "NULL pointer argument in bindless image copy operation."); - const detail::PluginPtr &Plugin = Queue->getPlugin(); + const detail::AdapterPtr &Adapter = Queue->getAdapter(); ur_exp_image_copy_region_t CopyRegion{}; CopyRegion.stype = UR_STRUCTURE_TYPE_EXP_IMAGE_COPY_REGION; @@ -1655,7 +1655,7 @@ void MemoryManager::copy_image_bindless( CopyRegion.srcOffset = SrcOffset; CopyRegion.dstOffset = DstOffset; - Plugin->call( + Adapter->call( Queue->getHandleRef(), Src, Dst, &SrcDesc, &DstDesc, &SrcFormat, &DstFormat, &CopyRegion, Flags, DepEvents.size(), DepEvents.data(), OutEvent); diff --git a/sycl/source/detail/persistent_device_code_cache.cpp b/sycl/source/detail/persistent_device_code_cache.cpp index 7484ed00150e2..4fe11650f1539 100644 --- a/sycl/source/detail/persistent_device_code_cache.cpp +++ b/sycl/source/detail/persistent_device_code_cache.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -127,16 +127,16 @@ void PersistentDeviceCodeCache::putItemToDisc( if (DirName.empty()) return; - auto Plugin = detail::getSyclObjImpl(Device)->getPlugin(); + auto Adapter = detail::getSyclObjImpl(Device)->getAdapter(); unsigned int DeviceNum = 0; - Plugin->call( + Adapter->call( NativePrg, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(DeviceNum), &DeviceNum, nullptr); std::vector BinarySizes(DeviceNum); - Plugin->call( + Adapter->call( NativePrg, UR_PROGRAM_INFO_BINARY_SIZES, sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), nullptr); @@ -147,7 +147,7 @@ void PersistentDeviceCodeCache::putItemToDisc( Pointers.push_back(Result[I].data()); } - Plugin->call(NativePrg, UR_PROGRAM_INFO_BINARIES, + Adapter->call(NativePrg, UR_PROGRAM_INFO_BINARIES, sizeof(char *) * Pointers.size(), Pointers.data(), nullptr); size_t i = 0; diff --git a/sycl/source/detail/physical_mem_impl.hpp b/sycl/source/detail/physical_mem_impl.hpp index e31b5c36bfab8..abb6608733d1d 100644 --- a/sycl/source/detail/physical_mem_impl.hpp +++ b/sycl/source/detail/physical_mem_impl.hpp @@ -41,9 +41,9 @@ class physical_mem_impl { size_t NumBytes) : MDevice(getSyclObjImpl(SyclDevice)), MContext(getSyclObjImpl(SyclContext)), MNumBytes(NumBytes) { - const PluginPtr &Plugin = MContext->getPlugin(); + const AdapterPtr &Adapter = MContext->getAdapter(); - auto Err = Plugin->call_nocheck( + auto Err = Adapter->call_nocheck( MContext->getHandleRef(), MDevice->getHandleRef(), MNumBytes, nullptr, &MPhysicalMem); @@ -51,21 +51,21 @@ class physical_mem_impl { Err == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) throw sycl::exception(make_error_code(errc::memory_allocation), "Failed to allocate physical memory."); - Plugin->checkUrResult(Err); + Adapter->checkUrResult(Err); } ~physical_mem_impl() noexcept(false) { - const PluginPtr &Plugin = MContext->getPlugin(); - Plugin->call(MPhysicalMem); + const AdapterPtr &Adapter = MContext->getAdapter(); + Adapter->call(MPhysicalMem); } void *map(uintptr_t Ptr, size_t NumBytes, ext::oneapi::experimental::address_access_mode Mode, size_t Offset) const { auto AccessFlags = AccessModeToVirtualAccessFlags(Mode); - const PluginPtr &Plugin = MContext->getPlugin(); + const AdapterPtr &Adapter = MContext->getAdapter(); void *ResultPtr = reinterpret_cast(Ptr); - Plugin->call(MContext->getHandleRef(), + Adapter->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 fea1abbf3a01e..44b80ab17265f 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -35,7 +35,7 @@ using PlatformImplPtr = std::shared_ptr; PlatformImplPtr platform_impl::getOrMakePlatformImpl(ur_platform_handle_t UrPlatform, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { PlatformImplPtr Result; { const std::lock_guard Guard( @@ -51,7 +51,7 @@ platform_impl::getOrMakePlatformImpl(ur_platform_handle_t UrPlatform, } // Otherwise make the impl - Result = std::make_shared(UrPlatform, Plugin); + Result = std::make_shared(UrPlatform, Adapter); PlatformCache.emplace_back(Result); } @@ -60,13 +60,13 @@ platform_impl::getOrMakePlatformImpl(ur_platform_handle_t UrPlatform, PlatformImplPtr platform_impl::getPlatformFromUrDevice(ur_device_handle_t UrDevice, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { ur_platform_handle_t Plt = nullptr; // TODO catch an exception and put it to list // of asynchronous exceptions - Plugin->call(UrDevice, UR_DEVICE_INFO_PLATFORM, + Adapter->call(UrDevice, UR_DEVICE_INFO_PLATFORM, sizeof(Plt), &Plt, nullptr); - return getOrMakePlatformImpl(Plt, Plugin); + return getOrMakePlatformImpl(Plt, Adapter); } static bool IsBannedPlatform(platform Platform) { @@ -96,15 +96,15 @@ static bool IsBannedPlatform(platform Platform) { IsMatchingOpenCL(Platform, "AMD Accelerated Parallel Processing"); } -// Get the vector of platforms supported by a given UR plugin -// replace uses of this with a helper in plugin object, the plugin +// Get the vector of platforms supported by a given UR adapter +// replace uses of this with a helper in adapter object, the adapter // objects will own the ur adapter handles and they'll need to pass them to // urPlatformsGet - so urPlatformsGet will need to be wrapped with a helper -std::vector platform_impl::getPluginPlatforms(PluginPtr &Plugin, +std::vector platform_impl::getAdapterPlatforms(AdapterPtr &Adapter, bool Supported) { std::vector Platforms; - auto UrPlatforms = Plugin->getUrPlatforms(); + auto UrPlatforms = Adapter->getUrPlatforms(); if (UrPlatforms.empty()) { return Platforms; @@ -112,7 +112,7 @@ std::vector platform_impl::getPluginPlatforms(PluginPtr &Plugin, for (const auto &UrPlatform : UrPlatforms) { platform Platform = detail::createSyclObjFromImpl( - getOrMakePlatformImpl(UrPlatform, Plugin)); + getOrMakePlatformImpl(UrPlatform, Adapter)); const bool IsBanned = IsBannedPlatform(Platform); const bool HasAnyDevices = !Platform.get_devices(info::device_type::all).empty(); @@ -141,15 +141,15 @@ std::vector platform_impl::getPluginPlatforms(PluginPtr &Plugin, std::vector platform_impl::get_unsupported_platforms() { std::vector UnsupportedPlatforms; - std::vector &Plugins = sycl::detail::ur::initializeUr(); + std::vector &Adapters = sycl::detail::ur::initializeUr(); // Ignore UR as it has to be supported. - for (auto &Plugin : Plugins) { - if (Plugin->hasBackend(backend::all)) { + for (auto &Adapter : Adapters) { + if (Adapter->hasBackend(backend::all)) { continue; // skip UR } - std::vector PluginPlatforms = - getPluginPlatforms(Plugin, /*Supported=*/false); - std::copy(PluginPlatforms.begin(), PluginPlatforms.end(), + std::vector AdapterPlatforms = + getAdapterPlatforms(Adapter, /*Supported=*/false); + std::copy(AdapterPlatforms.begin(), AdapterPlatforms.end(), std::back_inserter(UnsupportedPlatforms)); } @@ -157,28 +157,28 @@ std::vector platform_impl::get_unsupported_platforms() { } // This routine has the side effect of registering each platform's last device -// id into each plugin, which is used for device counting. +// id into each adapter, which is used for device counting. std::vector platform_impl::get_platforms() { - // See which platform we want to be served by which plugin. - // There should be just one plugin serving each backend. - std::vector &Plugins = sycl::detail::ur::initializeUr(); - std::vector> PlatformsWithPlugin; + // See which platform we want to be served by which adapter. + // There should be just one adapter serving each backend. + std::vector &Adapters = sycl::detail::ur::initializeUr(); + std::vector> PlatformsWithAdapter; - // Then check backend-specific plugins - for (auto &Plugin : Plugins) { - const auto &PluginPlatforms = getPluginPlatforms(Plugin); - for (const auto &P : PluginPlatforms) { - PlatformsWithPlugin.push_back({P, Plugin}); + // Then check backend-specific adapters + for (auto &Adapter : Adapters) { + const auto &AdapterPlatforms = getAdapterPlatforms(Adapter); + for (const auto &P : AdapterPlatforms) { + PlatformsWithAdapter.push_back({P, Adapter}); } } - // For the selected platforms register them with their plugins + // For the selected platforms register them with their adapters std::vector Platforms; - for (auto &Platform : PlatformsWithPlugin) { - auto &Plugin = Platform.second; - std::lock_guard Guard(*Plugin->getPluginMutex()); - Plugin->getPlatformId(getSyclObjImpl(Platform.first)->getHandleRef()); + for (auto &Platform : PlatformsWithAdapter) { + auto &Adapter = Platform.second; + std::lock_guard Guard(*Adapter->getAdapterMutex()); + Adapter->getPlatformId(getSyclObjImpl(Platform.first)->getHandleRef()); Platforms.push_back(Platform.first); } @@ -227,7 +227,7 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, // Find out backend of the platform ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN; - MPlugin->call( + MAdapter->call( MPlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), &UrBackend, nullptr); backend Backend = convertUrBackend(UrBackend); @@ -235,11 +235,11 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, int InsertIDx = 0; // DeviceIds should be given consecutive numbers across platforms in the same // backend - std::lock_guard Guard(*MPlugin->getPluginMutex()); - int DeviceNum = MPlugin->getStartingDeviceId(MPlatform); + std::lock_guard Guard(*MAdapter->getAdapterMutex()); + int DeviceNum = MAdapter->getStartingDeviceId(MPlatform); for (ur_device_handle_t Device : UrDevices) { ur_device_type_t UrDevType = UR_DEVICE_TYPE_ALL; - MPlugin->call(Device, UR_DEVICE_INFO_TYPE, + MAdapter->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 @@ -300,7 +300,7 @@ platform_impl::filterDeviceFilter(std::vector &UrDevices, // remember the last backend that has gone through this filter function // to assign a unique device id number across platforms that belong to // the same backend. For example, opencl:cpu:0, opencl:acc:1, opencl:gpu:2 - MPlugin->setLastDeviceId(MPlatform, DeviceNum); + MAdapter->setLastDeviceId(MPlatform, DeviceNum); return original_indices; } @@ -491,7 +491,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { } uint32_t NumDevices = 0; - MPlugin->call(MPlatform, UrDeviceType, + MAdapter->call(MPlatform, UrDeviceType, 0, // CP info::device_type::all nullptr, &NumDevices); const backend Backend = getBackend(); @@ -501,23 +501,23 @@ platform_impl::get_devices(info::device_type DeviceType) const { // LastDeviceIds[PlatformId] stay 0 that affects next platform devices num // analysis. Doing adjustment by simple copy of last device num from // previous platform. - // Needs non const plugin reference. - std::vector &Plugins = sycl::detail::ur::initializeUr(); - auto It = std::find_if(Plugins.begin(), Plugins.end(), - [&Platform = MPlatform](PluginPtr &Plugin) { - return Plugin->containsUrPlatform(Platform); + // Needs non const adapter reference. + std::vector &Adapters = sycl::detail::ur::initializeUr(); + auto It = std::find_if(Adapters.begin(), Adapters.end(), + [&Platform = MPlatform](AdapterPtr &Adapter) { + return Adapter->containsUrPlatform(Platform); }); - if (It != Plugins.end()) { - PluginPtr &Plugin = *It; - std::lock_guard Guard(*Plugin->getPluginMutex()); - Plugin->adjustLastDeviceId(MPlatform); + if (It != Adapters.end()) { + AdapterPtr &Adapter = *It; + std::lock_guard Guard(*Adapter->getAdapterMutex()); + Adapter->adjustLastDeviceId(MPlatform); } return Res; } std::vector UrDevices(NumDevices); // TODO catch an exception and put it to list of asynchronous exceptions - MPlugin->call( + MAdapter->call( MPlatform, UrDeviceType, // CP info::device_type::all NumDevices, UrDevices.data(), nullptr); @@ -528,7 +528,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { // Filter out devices that are not present in the SYCL_DEVICE_ALLOWLIST if (SYCLConfig::get()) - applyAllowList(UrDevices, MPlatform, MPlugin); + applyAllowList(UrDevices, MPlatform, MAdapter); // The first step is to filter out devices that are not compatible with // ONEAPI_DEVICE_SELECTOR. This is also the mechanism by which top level @@ -541,7 +541,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { // The next step is to inflate the filtered UrDevices into SYCL Device // objects. - PlatformImplPtr PlatformImpl = getOrMakePlatformImpl(MPlatform, MPlugin); + PlatformImplPtr PlatformImpl = getOrMakePlatformImpl(MPlatform, MAdapter); std::transform( UrDevices.begin(), UrDevices.end(), std::back_inserter(Res), [PlatformImpl](const ur_device_handle_t UrDevice) -> device { @@ -552,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(UrDev); + MAdapter->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 @@ -568,7 +568,7 @@ platform_impl::get_devices(info::device_type DeviceType) const { bool platform_impl::has_extension(const std::string &ExtensionName) const { std::string AllExtensionNames = get_platform_info_string_impl( - MPlatform, getPlugin(), + MPlatform, getAdapter(), detail::UrInfoCode::value); return (AllExtensionNames.find(ExtensionName) != std::string::npos); } @@ -579,15 +579,15 @@ bool platform_impl::supports_usm() const { } ur_native_handle_t platform_impl::getNative() const { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); ur_native_handle_t Handle = 0; - Plugin->call(getHandleRef(), &Handle); + Adapter->call(getHandleRef(), &Handle); return Handle; } template typename Param::return_type platform_impl::get_info() const { - return get_platform_info(this->getHandleRef(), getPlugin()); + return get_platform_info(this->getHandleRef(), getAdapter()); } template <> diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index 41be819e0e133..64e18cacaf68a 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include #include #include @@ -36,13 +36,13 @@ class platform_impl { /// handle. /// /// \param APlatform is a raw plug-in platform handle. - /// \param APlugin is a plug-in handle. + /// \param AAdapter is a plug-in handle. explicit platform_impl(ur_platform_handle_t APlatform, - const std::shared_ptr &APlugin) - : MPlatform(APlatform), MPlugin(APlugin) { + const std::shared_ptr &AAdapter) + : MPlatform(APlatform), MAdapter(AAdapter) { // Find out backend of the platform ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN; - APlugin->call_nocheck( + AAdapter->call_nocheck( APlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t), &UrBackend, nullptr); MBackend = convertUrBackend(UrBackend); @@ -91,17 +91,17 @@ class platform_impl { /// Get backend option. void getBackendOption(const char *frontend_option, const char **backend_option) const { - const auto &Plugin = getPlugin(); + const auto &Adapter = getAdapter(); ur_result_t Err = - Plugin->call_nocheck( + Adapter->call_nocheck( MPlatform, frontend_option, backend_option); - Plugin->checkUrResult(Err); + Adapter->checkUrResult(Err); } /// \return an instance of OpenCL cl_platform_id. cl_platform_id get() const { ur_native_handle_t nativeHandle = 0; - getPlugin()->call(MPlatform, + getAdapter()->call(MPlatform, &nativeHandle); return ur::cast(nativeHandle); } @@ -129,15 +129,15 @@ class platform_impl { /// \return a vector of all unsupported (non-SYCL) platforms. static std::vector get_unsupported_platforms(); - // \return the Plugin associated with this platform. - const PluginPtr &getPlugin() const { return MPlugin; } + // \return the Adapter associated with this platform. + const AdapterPtr &getAdapter() const { return MAdapter; } - /// Sets the platform implementation to use another plugin. + /// Sets the platform implementation to use another adapter. /// - /// \param PluginPtr is a pointer to a plugin instance + /// \param AdapterPtr is a pointer to a adapter instance /// \param Backend is the backend that we want this platform to use - void setPlugin(PluginPtr &PluginPtr, backend Backend) { - MPlugin = PluginPtr; + void setAdapter(AdapterPtr &AdapterPtr, backend Backend) { + MAdapter = AdapterPtr; MBackend = Backend; } @@ -182,11 +182,11 @@ class platform_impl { /// one and cache it. /// /// \param UrPlatform is the UR Platform handle representing the platform - /// \param Plugin is the UR plugin providing the backend for the platform + /// \param Adapter is the UR adapter providing the backend for the platform /// \return the platform_impl representing the UR platform static std::shared_ptr getOrMakePlatformImpl(ur_platform_handle_t UrPlatform, - const PluginPtr &Plugin); + const AdapterPtr &Adapter); /// Queries the cache for the specified platform based on an input device. /// If found, returns the the cached platform_impl, otherwise creates a new @@ -194,11 +194,11 @@ class platform_impl { /// /// \param UrDevice is the UR device handle for the device whose platform is /// desired - /// \param Plugin is the UR plugin providing the backend for the device and + /// \param Adapter is the UR adapter providing the backend for the device and /// platform /// \return the platform_impl that contains the input device static std::shared_ptr - getPlatformFromUrDevice(ur_device_handle_t UrDevice, const PluginPtr &Plugin); + getPlatformFromUrDevice(ur_device_handle_t UrDevice, const AdapterPtr &Adapter); // when getting sub-devices for ONEAPI_DEVICE_SELECTOR we may temporarily // ensure every device is a root one. @@ -207,8 +207,8 @@ class platform_impl { private: std::shared_ptr getDeviceImplHelper(ur_device_handle_t UrDevice); - // Helper to get the vector of platforms supported by a given UR plugin - static std::vector getPluginPlatforms(PluginPtr &Plugin, + // Helper to get the vector of platforms supported by a given UR adapter + static std::vector getAdapterPlatforms(AdapterPtr &Adapter, bool Supported = true); // Helper to filter reportable devices in the platform @@ -220,7 +220,7 @@ class platform_impl { ur_platform_handle_t MPlatform = 0; backend MBackend; - PluginPtr MPlugin; + AdapterPtr MAdapter; std::vector> MDeviceCache; std::mutex MDeviceMapMutex; diff --git a/sycl/source/detail/platform_info.hpp b/sycl/source/detail/platform_info.hpp index 11a7636c3f597..320ae2f709a53 100644 --- a/sycl/source/detail/platform_info.hpp +++ b/sycl/source/detail/platform_info.hpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #pragma once -#include +#include #include #include #include @@ -20,18 +20,18 @@ inline namespace _V1 { namespace detail { inline std::string get_platform_info_string_impl(ur_platform_handle_t Plt, - const PluginPtr &Plugin, + const AdapterPtr &Adapter, ur_platform_info_t UrCode) { size_t ResultSize = 0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Plt, UrCode, 0, nullptr, + Adapter->call(Plt, UrCode, 0, nullptr, &ResultSize); if (ResultSize == 0) { return ""; } std::unique_ptr Result(new char[ResultSize]); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call(Plt, UrCode, ResultSize, + Adapter->call(Plt, UrCode, ResultSize, Result.get(), nullptr); return Result.get(); } @@ -40,21 +40,21 @@ template typename std::enable_if< std::is_same::value, std::string>::type -get_platform_info(ur_platform_handle_t Plt, const PluginPtr &Plugin) { +get_platform_info(ur_platform_handle_t Plt, const AdapterPtr &Adapter) { static_assert(is_platform_info_desc::value, "Invalid platform information descriptor"); - return get_platform_info_string_impl(Plt, Plugin, + return get_platform_info_string_impl(Plt, Adapter, detail::UrInfoCode::value); } template typename std::enable_if::value, std::vector>::type -get_platform_info(ur_platform_handle_t Plt, const PluginPtr &Plugin) { +get_platform_info(ur_platform_handle_t Plt, const AdapterPtr &Adapter) { static_assert(is_platform_info_desc::value, "Invalid platform information descriptor"); std::string Result = get_platform_info_string_impl( - Plt, Plugin, detail::UrInfoCode::value); + Plt, Adapter, detail::UrInfoCode::value); return split_string(Result, ' '); } diff --git a/sycl/source/detail/posix_ur.cpp b/sycl/source/detail/posix_ur.cpp index 07b829c6a035b..18ffeed1cc60e 100644 --- a/sycl/source/detail/posix_ur.cpp +++ b/sycl/source/detail/posix_ur.cpp @@ -19,7 +19,7 @@ namespace detail::ur { void *loadOsLibrary(const std::string &LibraryPath) { // TODO: Check if the option RTLD_NOW is correct. Explore using - // RTLD_DEEPBIND option when there are multiple plugins. + // RTLD_DEEPBIND option when there are multiple adapters. void *so = dlopen(LibraryPath.c_str(), RTLD_NOW); if (!so && trace(TraceLevel::TRACE_ALL)) { char *Error = dlerror(); diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index d6f063e5fada6..1243b803fbb55 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -58,12 +58,12 @@ static constexpr char UseSpvEnv[]("SYCL_USE_KERNEL_SPV"); /// This function enables ITT annotations in SPIR-V module by setting /// a specialization constant if INTEL_LIBITTNOTIFY64 env variable is set. static void enableITTAnnotationsIfNeeded(const ur_program_handle_t &Prog, - const PluginPtr &Plugin) { + const AdapterPtr &Adapter) { if (SYCLConfig::get() != nullptr) { constexpr char SpecValue = 1; ur_specialization_constant_info_t SpecConstInfo = { ITTSpecConstId, sizeof(char), &SpecValue}; - Plugin->call( + Adapter->call( Prog, 1, &SpecConstInfo); } } @@ -76,10 +76,10 @@ static ur_program_handle_t createBinaryProgram(const ContextImplPtr Context, const device &Device, const unsigned char *Data, size_t DataLen, const std::vector Metadata) { - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); #ifndef _NDEBUG uint32_t NumDevices = 0; - Plugin->call(Context->getHandleRef(), + Adapter->call(Context->getHandleRef(), UR_CONTEXT_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, /*param_value_size_ret=*/nullptr); @@ -95,7 +95,7 @@ createBinaryProgram(const ContextImplPtr Context, const device &Device, Properties.pNext = nullptr; Properties.count = Metadata.size(); Properties.pMetadatas = Metadata.data(); - Plugin->call( + Adapter->call( Context->getHandleRef(), UrDevice, DataLen, Data, &Properties, &Program); if (BinaryStatus != UR_RESULT_SUCCESS) { @@ -112,8 +112,8 @@ static ur_program_handle_t createSpirvProgram(const ContextImplPtr Context, const unsigned char *Data, size_t DataLen) { ur_program_handle_t Program = nullptr; - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(Context->getHandleRef(), Data, + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(Context->getHandleRef(), Data, DataLen, nullptr, &Program); return Program; } @@ -323,7 +323,7 @@ appendCompileOptionsForGRFSizeProperties(std::string &CompileOpts, static void appendCompileOptionsFromImage(std::string &CompileOpts, const RTDeviceBinaryImage &Img, const std::vector &Devs, - const PluginPtr &) { + const AdapterPtr &) { // Build options are overridden if environment variables are present. // Environment variables are not changed during program lifecycle so it // is reasonable to use static here to read them only once. @@ -457,8 +457,8 @@ static void applyOptionsFromImage(std::string &CompileOpts, std::string &LinkOpts, const RTDeviceBinaryImage &Img, const std::vector &Devices, - const PluginPtr &Plugin) { - appendCompileOptionsFromImage(CompileOpts, Img, Devices, Plugin); + const AdapterPtr &Adapter) { + appendCompileOptionsFromImage(CompileOpts, Img, Devices, Adapter); appendLinkOptionsFromImage(LinkOpts, Img); } @@ -555,7 +555,7 @@ static bool compatibleWithDevice(RTDeviceBinaryImage *BinImage, const device &Dev) { const std::shared_ptr &DeviceImpl = detail::getSyclObjImpl(Dev); - auto &Plugin = DeviceImpl->getPlugin(); + auto &Adapter = DeviceImpl->getAdapter(); const ur_device_handle_t &URDeviceHandle = DeviceImpl->getHandleRef(); @@ -569,7 +569,7 @@ static bool compatibleWithDevice(RTDeviceBinaryImage *BinImage, ur_device_binary_t UrBinary{}; UrBinary.pDeviceTargetSpec = getUrDeviceTarget(DevBin->DeviceTargetSpec); - ur_result_t Error = Plugin->call_nocheck( + ur_result_t Error = Adapter->call_nocheck( URDeviceHandle, &UrBinary, /*num bin images = */ (uint32_t)1, &SuitableImageID); if (Error != UR_RESULT_SUCCESS && Error != UR_RESULT_ERROR_INVALID_BINARY) @@ -707,9 +707,9 @@ ProgramManager::collectDependentDeviceImagesForVirtualFunctions( static void setSpecializationConstants(const std::shared_ptr &InputImpl, - ur_program_handle_t Prog, const PluginPtr &Plugin) { + ur_program_handle_t Prog, const AdapterPtr &Adapter) { // Set ITT annotation specialization constant if needed. - enableITTAnnotationsIfNeeded(Prog, Plugin); + enableITTAnnotationsIfNeeded(Prog, Adapter); std::lock_guard Lock{InputImpl->get_spec_const_data_lock()}; const std::map> @@ -724,7 +724,7 @@ setSpecializationConstants(const std::shared_ptr &InputImpl, ur_specialization_constant_info_t SpecConstInfo = { SpecIDDesc.ID, SpecIDDesc.Size, SpecConsts.data() + SpecIDDesc.BlobOffset}; - Plugin->call( + Adapter->call( Prog, 1, &SpecConstInfo); } } @@ -759,7 +759,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( } ur_bool_t MustBuildOnSubdevice = true; - ContextImpl->getPlugin()->call( + ContextImpl->getAdapter()->call( RootDevImpl->getHandleRef(), UR_DEVICE_INFO_BUILD_ON_SUBDEVICE, sizeof(ur_bool_t), &MustBuildOnSubdevice, nullptr); @@ -790,8 +790,8 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( auto BuildF = [this, &Img, &Context, &ContextImpl, &Device, &CompileOpts, &LinkOpts, SpecConsts, &DeviceImagesToLink, &AllImages] { - const PluginPtr &Plugin = ContextImpl->getPlugin(); - applyOptionsFromImage(CompileOpts, LinkOpts, Img, {Device}, Plugin); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); + applyOptionsFromImage(CompileOpts, LinkOpts, Img, {Device}, Adapter); // Should always come last! appendCompileEnvironmentVariablesThatAppend(CompileOpts); appendLinkEnvironmentVariablesThatAppend(LinkOpts); @@ -800,7 +800,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( if (!DeviceCodeWasInCache) { if (Img.supportsSpecConstants()) - enableITTAnnotationsIfNeeded(NativePrg, Plugin); + enableITTAnnotationsIfNeeded(NativePrg, Adapter); } UrFuncInfo programReleaseInfo; @@ -837,7 +837,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( createURProgram(*BinImg, Context, Device); if (BinImg->supportsSpecConstants()) - setSpecializationConstants(DeviceImageImpl, NativePrg, Plugin); + setSpecializationConstants(DeviceImageImpl, NativePrg, Adapter); ProgramsToLink.push_back(NativePrg); } @@ -849,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(Prg); + Adapter->call(Prg); emitBuiltProgramInfo(BuiltProgram.get(), ContextImpl); @@ -889,7 +889,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( assert(BuildResult != nullptr && "Invalid build result"); ur_program_handle_t ResProgram = BuildResult->Val; - auto Plugin = ContextImpl->getPlugin(); + auto Adapter = ContextImpl->getAdapter(); // If we linked any extra device images, then we need to // cache them as well. @@ -900,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(ResProgram); + Adapter->call(ResProgram); } } @@ -908,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(ResProgram); + ContextImpl->getAdapter()->call(ResProgram); return ResProgram; } @@ -946,9 +946,9 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, if (std::get(ret_tuple)) { // Pulling a copy of a kernel and program from the cache, // so we need to retain those resources. - ContextImpl->getPlugin()->call( + ContextImpl->getAdapter()->call( std::get(ret_tuple)); - ContextImpl->getPlugin()->call( + ContextImpl->getAdapter()->call( std::get(ret_tuple)); return ret_tuple; } @@ -960,16 +960,16 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, auto BuildF = [this, &Program, &KernelName, &ContextImpl] { ur_kernel_handle_t Kernel = nullptr; - const PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = ContextImpl->getAdapter(); + Adapter->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 + // Some UR Adapters (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( + Adapter->call( Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &UrTrue); } @@ -1003,7 +1003,7 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // kernel. - ContextImpl->getPlugin()->call( + ContextImpl->getAdapter()->call( KernelArgMaskPair.first); Cache.saveKernel(key, ret_val); return ret_val; @@ -1013,8 +1013,8 @@ ur_program_handle_t ProgramManager::getUrProgramFromUrKernel(ur_kernel_handle_t Kernel, const ContextImplPtr Context) { ur_program_handle_t Program; - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(Kernel, UR_KERNEL_INFO_PROGRAM, + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); return Program; @@ -1024,12 +1024,12 @@ std::string ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, const ContextImplPtr Context) { size_t URDevicesSize = 0; - const PluginPtr &Plugin = Context->getPlugin(); - Plugin->call(Program, UR_PROGRAM_INFO_DEVICES, 0, + const AdapterPtr &Adapter = Context->getAdapter(); + Adapter->call(Program, UR_PROGRAM_INFO_DEVICES, 0, nullptr, &URDevicesSize); std::vector URDevices(URDevicesSize / sizeof(ur_device_handle_t)); - Plugin->call(Program, UR_PROGRAM_INFO_DEVICES, + Adapter->call(Program, UR_PROGRAM_INFO_DEVICES, URDevicesSize, URDevices.data(), nullptr); std::string Log = "The program was built for " + @@ -1037,12 +1037,12 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, for (ur_device_handle_t &Device : URDevices) { std::string DeviceBuildInfoString; size_t DeviceBuildInfoStrSize = 0; - Plugin->call( + Adapter->call( Program, Device, UR_PROGRAM_BUILD_INFO_LOG, 0, nullptr, &DeviceBuildInfoStrSize); if (DeviceBuildInfoStrSize > 0) { std::vector DeviceBuildInfo(DeviceBuildInfoStrSize); - Plugin->call( + Adapter->call( Program, Device, UR_PROGRAM_BUILD_INFO_LOG, DeviceBuildInfoStrSize, DeviceBuildInfo.data(), nullptr); DeviceBuildInfoString = std::string(DeviceBuildInfo.data()); @@ -1050,11 +1050,11 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, std::string DeviceNameString; size_t DeviceNameStrSize = 0; - Plugin->call(Device, UR_DEVICE_INFO_NAME, 0, + Adapter->call(Device, UR_DEVICE_INFO_NAME, 0, nullptr, &DeviceNameStrSize); if (DeviceNameStrSize > 0) { std::vector DeviceName(DeviceNameStrSize); - Plugin->call(Device, UR_DEVICE_INFO_NAME, + Adapter->call(Device, UR_DEVICE_INFO_NAME, DeviceNameStrSize, DeviceName.data(), nullptr); DeviceNameString = std::string(DeviceName.data()); @@ -1151,16 +1151,16 @@ static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { return Ext->second; } -static ur_result_t doCompile(const PluginPtr &Plugin, +static ur_result_t doCompile(const AdapterPtr &Adapter, ur_program_handle_t Program, uint32_t NumDevs, ur_device_handle_t *Devs, ur_context_handle_t Ctx, 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( + auto Result = Adapter->call_nocheck( Program, NumDevs, Devs, Opts); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - return Plugin->call_nocheck(Ctx, Program, + return Adapter->call_nocheck(Ctx, Program, Opts); } return Result; @@ -1190,13 +1190,13 @@ static ur_program_handle_t loadDeviceLibFallback(const ContextImplPtr Context, std::string("Failed to load ") + LibFileName); } - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); // TODO no spec constants are used in the std libraries, support in the future // Do not use compile options for library programs: it is not clear if user // options (image options) are supposed to be applied to library program as // well, and what actually happens to a SPIR-V program if we apply them. ur_result_t Error = - doCompile(Plugin, LibProg, 1, &Device, Context->getHandleRef(), ""); + doCompile(Adapter, LibProg, 1, &Device, Context->getHandleRef(), ""); if (Error != UR_RESULT_SUCCESS) { CachedLibPrograms.erase(LibProgIt); throw detail::set_ur_error( @@ -1347,7 +1347,7 @@ RTDeviceBinaryImage *getBinImageFromMultiMap( uint32_t ImgInd = 0; // Ask the native runtime under the given context to choose the device image // it prefers. - getSyclObjImpl(Context)->getPlugin()->call( + getSyclObjImpl(Context)->getAdapter()->call( getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), UrBinaries.size(), &ImgInd); return DeviceFilteredImgs[ImgInd]; @@ -1432,7 +1432,7 @@ RTDeviceBinaryImage &ProgramManager::getDeviceImage( getUrDeviceTarget(RawImgs[BinaryCount]->DeviceTargetSpec); } - getSyclObjImpl(Context)->getPlugin()->call( + getSyclObjImpl(Context)->getAdapter()->call( getSyclObjImpl(Device)->getHandleRef(), UrBinaries.data(), UrBinaries.size(), &ImgInd); @@ -1557,16 +1557,16 @@ ProgramManager::ProgramPtr ProgramManager::build( static const char *ForceLinkEnv = std::getenv("SYCL_FORCE_LINK"); static bool ForceLink = ForceLinkEnv && (*ForceLinkEnv == '1'); - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); if (LinkPrograms.empty() && ExtraProgramsToLink.empty() && !ForceLink) { const std::string &Options = LinkOptions.empty() ? CompileOptions : (CompileOptions + " " + LinkOptions); - ur_result_t Error = Plugin->call_nocheck( + ur_result_t Error = Adapter->call_nocheck( Program.get(), /*num devices =*/1, &Device, Options.c_str()); if (Error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( Context->getHandleRef(), Program.get(), Options.c_str()); } @@ -1581,29 +1581,29 @@ ProgramManager::ProgramPtr ProgramManager::build( // Include the main program and compile/link everything together if (!CreatedFromBinary) { - auto Res = doCompile(Plugin, Program.get(), /*num devices =*/1, &Device, + auto Res = doCompile(Adapter, Program.get(), /*num devices =*/1, &Device, Context->getHandleRef(), CompileOptions.c_str()); - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); } LinkPrograms.push_back(Program.get()); for (ur_program_handle_t Prg : ExtraProgramsToLink) { if (!CreatedFromBinary) { - auto Res = doCompile(Plugin, Prg, /*num devices =*/1, &Device, + auto Res = doCompile(Adapter, Prg, /*num devices =*/1, &Device, Context->getHandleRef(), CompileOptions.c_str()); - Plugin->checkUrResult(Res); + Adapter->checkUrResult(Res); } LinkPrograms.push_back(Prg); } ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck( + auto Res = Adapter->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( + Res = Adapter->call_nocheck( Context->getHandleRef(), LinkPrograms.size(), LinkPrograms.data(), LinkOptions.c_str(), &LinkedProg); } @@ -1629,7 +1629,7 @@ ProgramManager::ProgramPtr ProgramManager::build( getProgramBuildLog(LinkedProg, Context)), Error); } - Plugin->checkUrResult(Error); + Adapter->checkUrResult(Error); } return Program; } @@ -2338,8 +2338,8 @@ ProgramManager::compile(const device_image_plain &DeviceImage, const std::shared_ptr &InputImpl = getSyclObjImpl(DeviceImage); - const PluginPtr &Plugin = - getSyclObjImpl(InputImpl->get_context())->getPlugin(); + const AdapterPtr &Adapter = + getSyclObjImpl(InputImpl->get_context())->getAdapter(); // TODO: Add support for creating non-SPIRV programs from multiple devices. if (InputImpl->get_bin_image_ref()->getFormat() != @@ -2358,7 +2358,7 @@ ProgramManager::compile(const device_image_plain &DeviceImage, InputImpl->get_context(), Devs[0]); if (InputImpl->get_bin_image_ref()->supportsSpecConstants()) - setSpecializationConstants(InputImpl, Prog, Plugin); + setSpecializationConstants(InputImpl, Prog, Adapter); DeviceImageImplPtr ObjectImpl = std::make_shared( InputImpl->get_bin_image_ref(), InputImpl->get_context(), Devs, @@ -2375,11 +2375,11 @@ ProgramManager::compile(const device_image_plain &DeviceImage, std::string CompileOptions; applyCompileOptionsFromEnvironment(CompileOptions); appendCompileOptionsFromImage( - CompileOptions, *(InputImpl->get_bin_image_ref()), Devs, Plugin); + CompileOptions, *(InputImpl->get_bin_image_ref()), Devs, Adapter); // Should always come last! appendCompileEnvironmentVariablesThatAppend(CompileOptions); ur_result_t Error = doCompile( - Plugin, ObjectImpl->get_ur_program_ref(), Devs.size(), URDevices.data(), + Adapter, ObjectImpl->get_ur_program_ref(), Devs.size(), URDevices.data(), getSyclObjImpl(InputImpl->get_context()).get()->getHandleRef(), CompileOptions.c_str()); if (Error != UR_RESULT_SUCCESS) @@ -2417,16 +2417,16 @@ ProgramManager::link(const device_image_plain &DeviceImage, appendLinkEnvironmentVariablesThatAppend(LinkOptionsStr); const context &Context = getSyclObjImpl(DeviceImage)->get_context(); const ContextImplPtr ContextImpl = getSyclObjImpl(Context); - const PluginPtr &Plugin = ContextImpl->getPlugin(); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Plugin->call_nocheck( + auto Res = Adapter->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( + Res = Adapter->call_nocheck( ContextImpl->getHandleRef(), URPrograms.size(), URPrograms.data(), LinkOptionsStr.c_str(), &LinkedProg); } @@ -2536,8 +2536,8 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, auto BuildF = [this, &Context, &Img, &Devs, &CompileOpts, &LinkOpts, &InputImpl, SpecConsts] { ContextImplPtr ContextImpl = getSyclObjImpl(Context); - const PluginPtr &Plugin = ContextImpl->getPlugin(); - applyOptionsFromImage(CompileOpts, LinkOpts, Img, Devs, Plugin); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); + applyOptionsFromImage(CompileOpts, LinkOpts, Img, Devs, Adapter); // Should always come last! appendCompileEnvironmentVariablesThatAppend(CompileOpts); appendLinkEnvironmentVariablesThatAppend(LinkOpts); @@ -2559,7 +2559,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, if (!DeviceCodeWasInCache && InputImpl->get_bin_image_ref()->supportsSpecConstants()) - setSpecializationConstants(InputImpl, NativePrg, Plugin); + setSpecializationConstants(InputImpl, NativePrg, Adapter); UrFuncInfo programReleaseInfo; auto programRelease = @@ -2632,9 +2632,9 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // Cache supports key with once device only, but here we have multiple // devices a program is built for, so add the program to the cache for all // other devices. - const PluginPtr &Plugin = ContextImpl->getPlugin(); - auto CacheOtherDevices = [ResProgram, &Plugin]() { - Plugin->call(ResProgram); + const AdapterPtr &Adapter = ContextImpl->getAdapter(); + auto CacheOtherDevices = [ResProgram, &Adapter]() { + Adapter->call(ResProgram); return ResProgram; }; @@ -2654,7 +2654,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // devive_image_impl shares ownership of PIProgram with, at least, program // cache. The ref counter will be descremented in the destructor of // device_image_impl - Plugin->call(ResProgram); + Adapter->call(ResProgram); DeviceImageImplPtr ExecImpl = std::make_shared( InputImpl->get_bin_image_ref(), Context, Devs, bundle_state::executable, @@ -2682,14 +2682,14 @@ ProgramManager::getOrCreateKernel(const context &Context, auto BuildF = [this, &Program, &KernelName, &Ctx] { ur_kernel_handle_t Kernel = nullptr; - const PluginPtr &Plugin = Ctx->getPlugin(); - Plugin->call(Program, KernelName.c_str(), + const AdapterPtr &Adapter = Ctx->getAdapter(); + Adapter->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( + Adapter->call( Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &EnableAccess); } @@ -2721,7 +2721,7 @@ ProgramManager::getOrCreateKernel(const context &Context, // stored in the cache, and one handle is returned to the // caller. In that case, we need to increase the ref count of the // kernel. - Ctx->getPlugin()->call(BuildResult->Val.first); + Ctx->getAdapter()->call(BuildResult->Val.first); return std::make_tuple(BuildResult->Val.first, &(BuildResult->MBuildResultMutex), BuildResult->Val.second); @@ -2774,7 +2774,7 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( std::cerr << ">>> Adding the kernel to the cache.\n"; auto Program = createURProgram(Img, Context, Device); auto DeviceImpl = detail::getSyclObjImpl(Device); - auto &Plugin = DeviceImpl->getPlugin(); + auto &Adapter = DeviceImpl->getAdapter(); UrFuncInfo programReleaseInfo; auto programRelease = programReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); @@ -2791,7 +2791,7 @@ 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( + Adapter->call( BuildProgram.get(), KernelName.c_str(), &UrKernel); { std::lock_guard KernelIDsGuard(m_KernelIDsMutex); diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index d340d0ecd9c17..0c59d4d08996c 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -59,7 +59,7 @@ getUrEvents(const std::vector &DepEvents) { template <> uint32_t queue_impl::get_info() const { ur_result_t result = UR_RESULT_SUCCESS; - getPlugin()->call( + getAdapter()->call( MQueues[0], UR_QUEUE_INFO_REFERENCE_COUNT, sizeof(result), &result, nullptr); return result; @@ -613,8 +613,8 @@ void queue_impl::wait(const detail::code_location &CodeLoc) { } } if (SupportsPiFinish) { - const PluginPtr &Plugin = getPlugin(); - Plugin->call(getHandleRef()); + const AdapterPtr &Adapter = getAdapter(); + Adapter->call(getHandleRef()); assert(SharedEvents.empty() && "Queues that support calling piQueueFinish " "shouldn't have shared events"); } else { @@ -694,15 +694,15 @@ void queue_impl::destructorNotification() { } ur_native_handle_t queue_impl::getNative(int32_t &NativeHandleDesc) const { - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); if (getContextImplPtr()->getBackend() == backend::opencl) - Plugin->call(MQueues[0]); + Adapter->call(MQueues[0]); ur_native_handle_t Handle{}; ur_queue_native_desc_t UrNativeDesc{UR_STRUCTURE_TYPE_QUEUE_NATIVE_DESC, nullptr, nullptr}; UrNativeDesc.pNativeData = &NativeHandleDesc; - Plugin->call(MQueues[0], &UrNativeDesc, + Adapter->call(MQueues[0], &UrNativeDesc, &Handle); return Handle; } @@ -727,7 +727,7 @@ bool queue_impl::ext_oneapi_empty() const { // Check the status of the backend queue if this is not a host queue. ur_bool_t IsReady = false; - getPlugin()->call( + getAdapter()->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 e15e9bc69503e..e73069d12e085 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -185,9 +185,9 @@ class queue_impl { MQueues.push_back(UrQueue); ur_device_handle_t DeviceUr{}; - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); // TODO catch an exception and put it to list of asynchronous exceptions - Plugin->call( + Adapter->call( MQueues[0], UR_QUEUE_INFO_DEVICE, sizeof(DeviceUr), &DeviceUr, nullptr); MDevice = MContext->findMatchingDeviceImpl(DeviceUr); if (MDevice == nullptr) { @@ -208,7 +208,7 @@ class queue_impl { } public: - /// Constructs a SYCL queue from plugin interoperability handle. + /// Constructs a SYCL queue from adapter interoperability handle. /// /// \param UrQueue is a raw UR queue handle. /// \param Context is a SYCL context to associate with the queue being @@ -226,7 +226,7 @@ class queue_impl { queue_impl_interop(UrQueue); } - /// Constructs a SYCL queue from plugin interoperability handle. + /// Constructs a SYCL queue from adapter interoperability handle. /// /// \param UrQueue is a raw UR queue handle. /// \param Context is a SYCL context to associate with the queue being @@ -254,7 +254,7 @@ class queue_impl { destructorNotification(); #endif throw_asynchronous(); - getPlugin()->call(MQueues[0]); + getAdapter()->call(MQueues[0]); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~queue_impl", e); } @@ -263,9 +263,9 @@ class queue_impl { /// \return an OpenCL interoperability queue handle. cl_command_queue get() { - getPlugin()->call(MQueues[0]); + getAdapter()->call(MQueues[0]); ur_native_handle_t nativeHandle = 0; - getPlugin()->call(MQueues[0], nullptr, + getAdapter()->call(MQueues[0], nullptr, &nativeHandle); return ur::cast(nativeHandle); } @@ -275,7 +275,7 @@ class queue_impl { return createSyclObjFromImpl(MContext); } - const PluginPtr &getPlugin() const { return MContext->getPlugin(); } + const AdapterPtr &getAdapter() const { return MContext->getAdapter(); } const ContextImplPtr &getContextImplPtr() const { return MContext; } @@ -313,7 +313,7 @@ class queue_impl { "recording to a command graph."); } for (const auto &queue : MQueues) { - getPlugin()->call(queue); + getAdapter()->call(queue); } } @@ -433,7 +433,7 @@ class queue_impl { CreationFlags |= UR_QUEUE_FLAG_USE_DEFAULT_STREAM; } if (PropList.has_property()) { - // Pass this flag to the Level Zero plugin to be able to check it from + // Pass this flag to the Level Zero adapter to be able to check it from // queue property. CreationFlags |= UR_QUEUE_FLAG_DISCARD_EVENTS; } @@ -489,7 +489,7 @@ class queue_impl { ur_queue_handle_t Queue{}; ur_context_handle_t Context = MContext->getHandleRef(); ur_device_handle_t Device = MDevice->getHandleRef(); - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); /* sycl::detail::pi::PiQueueProperties Properties[] = { PI_QUEUE_FLAGS, createPiQueueProperties(MPropList, Order), 0, 0, 0}; @@ -505,7 +505,7 @@ class queue_impl { .get_index(); Properties.pNext = &IndexProperties; } - ur_result_t Error = Plugin->call_nocheck( + ur_result_t Error = Adapter->call_nocheck( Context, Device, &Properties, &Queue); // If creating out-of-order queue failed and this property is not @@ -516,7 +516,7 @@ class queue_impl { MEmulateOOO = true; Queue = createQueue(QueueOrder::Ordered); } else { - Plugin->checkUrResult(Error); + Adapter->checkUrResult(Error); } return Queue; @@ -548,7 +548,7 @@ class queue_impl { if (!ReuseQueue) *PIQ = createQueue(QueueOrder::Ordered); else - getPlugin()->call(*PIQ); + getAdapter()->call(*PIQ); return *PIQ; } @@ -719,7 +719,7 @@ class queue_impl { EventImplPtr insertHelperBarrier(const HandlerType &Handler) { auto ResEvent = std::make_shared(Handler.MQueue); ur_event_handle_t UREvent = nullptr; - getPlugin()->call( + getAdapter()->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 cb3e69b6a9a1a..77f151b69c1dd 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -22,16 +22,16 @@ sampler_impl::sampler_impl(coordinate_normalization_mode normalizationMode, MFiltMode(filteringMode), MPropList(propList) {} sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { - const PluginPtr &Plugin = getSyclObjImpl(syclContext)->getPlugin(); + const AdapterPtr &Adapter = getSyclObjImpl(syclContext)->getAdapter(); ur_sampler_handle_t Sampler{}; - Plugin->call( + Adapter->call( reinterpret_cast(clSampler), getSyclObjImpl(syclContext)->getHandleRef(), nullptr, &Sampler); MContextToSampler[syclContext] = Sampler; bool NormalizedCoords; - Plugin->call( + Adapter->call( Sampler, UR_SAMPLER_INFO_NORMALIZED_COORDS, sizeof(ur_bool_t), &NormalizedCoords, nullptr); MCoordNormMode = NormalizedCoords @@ -39,7 +39,7 @@ sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { : coordinate_normalization_mode::unnormalized; ur_sampler_addressing_mode_t AddrMode; - Plugin->call( + Adapter->call( Sampler, UR_SAMPLER_INFO_ADDRESSING_MODE, sizeof(ur_sampler_addressing_mode_t), &AddrMode, nullptr); switch (AddrMode) { @@ -62,7 +62,7 @@ sampler_impl::sampler_impl(cl_sampler clSampler, const context &syclContext) { } ur_sampler_filter_mode_t FiltMode; - Plugin->call( + Adapter->call( Sampler, UR_SAMPLER_INFO_FILTER_MODE, sizeof(ur_sampler_filter_mode_t), &FiltMode, nullptr); switch (FiltMode) { @@ -82,8 +82,8 @@ sampler_impl::~sampler_impl() { for (auto &Iter : MContextToSampler) { // TODO catch an exception and add it to the list of asynchronous // exceptions - const PluginPtr &Plugin = getSyclObjImpl(Iter.first)->getPlugin(); - Plugin->call(Iter.second); + const AdapterPtr &Adapter = getSyclObjImpl(Iter.first)->getAdapter(); + Adapter->call(Iter.second); } } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~sample_impl", e); @@ -130,16 +130,16 @@ ur_sampler_handle_t sampler_impl::getOrCreateSampler(const context &Context) { ur_result_t errcode_ret = UR_RESULT_SUCCESS; ur_sampler_handle_t resultSampler = nullptr; - const PluginPtr &Plugin = getSyclObjImpl(Context)->getPlugin(); + const AdapterPtr &Adapter = getSyclObjImpl(Context)->getAdapter(); - errcode_ret = Plugin->call_nocheck( + errcode_ret = Adapter->call_nocheck( getSyclObjImpl(Context)->getHandleRef(), &desc, &resultSampler); if (errcode_ret == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) throw sycl::exception(sycl::errc::feature_not_supported, "Images are not supported by this device."); - Plugin->checkUrResult(errcode_ret); + Adapter->checkUrResult(errcode_ret); std::lock_guard Lock(MMutex); MContextToSampler[Context] = resultSampler; diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index c5e8fc2c3a2cd..0b827ba9fd9cb 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -334,12 +334,12 @@ class DispatchHostTask { std::vector MReqUrMem; bool waitForEvents() const { - std::map> - RequiredEventsPerPlugin; + std::map> + RequiredEventsPerAdapter; for (const EventImplPtr &Event : MThisCmd->MPreparedDepsEvents) { - const PluginPtr &Plugin = Event->getPlugin(); - RequiredEventsPerPlugin[Plugin].push_back(Event); + const AdapterPtr &Adapter = Event->getAdapter(); + RequiredEventsPerAdapter[Adapter].push_back(Event); } // wait for dependency device events @@ -347,13 +347,13 @@ class DispatchHostTask { // 'sleep' until all of dependency events are complete. We need a bit more // sophisticated waiting mechanism to allow to utilize this thread for any // other available job and resume once all required events are ready. - for (auto &PluginWithEvents : RequiredEventsPerPlugin) { + for (auto &AdapterWithEvents : RequiredEventsPerAdapter) { std::vector RawEvents = - MThisCmd->getUrEvents(PluginWithEvents.second); + MThisCmd->getUrEvents(AdapterWithEvents.second); if (RawEvents.size() == 0) continue; try { - PluginWithEvents.first->call(RawEvents.size(), + AdapterWithEvents.first->call(RawEvents.size(), RawEvents.data()); } catch (const sycl::exception &) { MThisCmd->MEvent->getSubmittedQueue()->reportAsyncException( @@ -423,7 +423,7 @@ class DispatchHostTask { // for host task? auto &Queue = HostTask.MQueue; bool NativeCommandSupport = false; - Queue->getPlugin()->call( + Queue->getAdapter()->call( detail::getSyclObjImpl(Queue->get_device())->getHandleRef(), UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP, sizeof(NativeCommandSupport), &NativeCommandSupport, nullptr); @@ -438,7 +438,7 @@ class DispatchHostTask { // // This entry point is needed in order to migrate memory across // devices in the same context for CUDA and HIP backends - Queue->getPlugin()->call( + Queue->getAdapter()->call( HostTask.MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData, MReqUrMem.size(), MReqUrMem.data(), nullptr, 0, nullptr, nullptr); } else { @@ -532,18 +532,18 @@ void Command::waitForEvents(QueueImplPtr Queue, std::vector RawEvents = getUrEvents(CtxWithEvents.second); if (!RawEvents.empty()) { - CtxWithEvents.first->getPlugin()->call( + CtxWithEvents.first->getAdapter()->call( RawEvents.size(), RawEvents.data()); } } } else { std::vector RawEvents = getUrEvents(EventImpls); flushCrossQueueDeps(EventImpls, MWorkerQueue); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( + Adapter->call( Queue->getHandleRef(), RawEvents.size(), &RawEvents[0], &Event); } } @@ -1421,7 +1421,7 @@ void UnMapMemObject::emitInstrumentationData() { bool UnMapMemObject::producesPiEvent() const { // TODO remove this workaround once the batching issue is addressed in Level - // Zero plugin. + // Zero adapter. // Consider the following scenario on Level Zero: // 1. Kernel A, which uses buffer A, is submitted to queue A. // 2. Kernel B, which uses buffer B, is submitted to queue B. @@ -1429,10 +1429,10 @@ bool UnMapMemObject::producesPiEvent() const { // 4. queueB.wait(). // DPCPP runtime used to treat unmap/write commands for buffer A/B as host // dependencies (i.e. they were waited for prior to enqueueing any command - // that's dependent on them). This allowed Level Zero plugin to detect that + // that's dependent on them). This allowed Level Zero adapter to detect that // each queue is idle on steps 1/2 and submit the command list right away. // This is no longer the case since we started passing these dependencies in - // an event waitlist and Level Zero plugin attempts to batch these commands, + // an event waitlist and Level Zero adapter attempts to batch these commands, // so the execution of kernel B starts only on step 4. This workaround // restores the old behavior in this case until this is resolved. return MQueue && (MQueue->getDeviceImplPtr()->getBackend() != @@ -1523,7 +1523,7 @@ ContextImplPtr MemCpyCommand::getWorkerContext() const { bool MemCpyCommand::producesPiEvent() const { // TODO remove this workaround once the batching issue is addressed in Level - // Zero plugin. + // Zero adapter. // Consider the following scenario on Level Zero: // 1. Kernel A, which uses buffer A, is submitted to queue A. // 2. Kernel B, which uses buffer B, is submitted to queue B. @@ -1531,10 +1531,10 @@ bool MemCpyCommand::producesPiEvent() const { // 4. queueB.wait(). // DPCPP runtime used to treat unmap/write commands for buffer A/B as host // dependencies (i.e. they were waited for prior to enqueueing any command - // that's dependent on them). This allowed Level Zero plugin to detect that + // that's dependent on them). This allowed Level Zero adapter to detect that // each queue is idle on steps 1/2 and submit the command list right away. // This is no longer the case since we started passing these dependencies in - // an event waitlist and Level Zero plugin attempts to batch these commands, + // an event waitlist and Level Zero adapter attempts to batch these commands, // so the execution of kernel B starts only on step 4. This workaround // restores the old behavior in this case until this is resolved. return !MQueue || @@ -2223,7 +2223,7 @@ static void adjustNDRangePerKernel(NDRDescT &NDR, ur_kernel_handle_t Kernel, // avoid get_kernel_work_group_info on every kernel run range<3> WGSize = get_kernel_device_specific_info< sycl::info::kernel_device_specific::compile_work_group_size>( - Kernel, DeviceImpl.getHandleRef(), DeviceImpl.getPlugin()); + Kernel, DeviceImpl.getHandleRef(), DeviceImpl.getAdapter()); if (WGSize[0] == 0) { WGSize = {1, 1, 1}; @@ -2262,7 +2262,7 @@ ur_mem_flags_t AccessModeToUr(access::mode AccessorMode) { } void SetArgBasedOnType( - const PluginPtr &Plugin, ur_kernel_handle_t Kernel, + const AdapterPtr &Adapter, ur_kernel_handle_t Kernel, const std::shared_ptr &DeviceImageImpl, const std::function &getMemAllocationFunc, const sycl::context &Context, detail::ArgDesc &Arg, size_t NextTrueIndex) { @@ -2283,16 +2283,16 @@ void SetArgBasedOnType( ur_kernel_arg_mem_obj_properties_t MemObjData{}; MemObjData.stype = UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES; MemObjData.memoryAccess = AccessModeToUr(Req->MAccessMode); - Plugin->call(Kernel, NextTrueIndex, + Adapter->call(Kernel, NextTrueIndex, &MemObjData, MemArg); break; } case kernel_param_kind_t::kind_std_layout: { if (Arg.MPtr) { - Plugin->call( + Adapter->call( Kernel, NextTrueIndex, Arg.MSize, nullptr, Arg.MPtr); } else { - Plugin->call(Kernel, NextTrueIndex, + Adapter->call(Kernel, NextTrueIndex, Arg.MSize, nullptr); } @@ -2303,7 +2303,7 @@ void SetArgBasedOnType( ur_sampler_handle_t Sampler = (ur_sampler_handle_t)detail::getSyclObjImpl(*SamplerPtr) ->getOrCreateSampler(Context); - Plugin->call(Kernel, NextTrueIndex, + Adapter->call(Kernel, NextTrueIndex, nullptr, Sampler); break; } @@ -2311,7 +2311,7 @@ void SetArgBasedOnType( // We need to de-rerence this to get the actual USM allocation - that's the // pointer UR is expecting. const void *Ptr = *static_cast(Arg.MPtr); - Plugin->call(Kernel, NextTrueIndex, + Adapter->call(Kernel, NextTrueIndex, nullptr, Ptr); break; } @@ -2324,7 +2324,7 @@ void SetArgBasedOnType( MemObjProps.pNext = nullptr; MemObjProps.stype = UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES; MemObjProps.memoryAccess = UR_MEM_FLAG_READ_ONLY; - Plugin->call( + Adapter->call( Kernel, NextTrueIndex, &MemObjProps, SpecConstsBuffer); break; } @@ -2347,7 +2347,7 @@ static ur_result_t SetKernelParamsAndLaunch( bool IsCooperative, bool KernelUsesClusterLaunch, const RTDeviceBinaryImage *BinImage, const std::string &KernelName) { assert(Queue && "Kernel submissions should have an associated queue"); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (SYCLConfig::get()) { std::vector Empty; @@ -2357,9 +2357,9 @@ static ur_result_t SetKernelParamsAndLaunch( : Empty); } - auto setFunc = [&Plugin, Kernel, &DeviceImageImpl, &getMemAllocationFunc, + auto setFunc = [&Adapter, Kernel, &DeviceImageImpl, &getMemAllocationFunc, &Queue](detail::ArgDesc &Arg, size_t NextTrueIndex) { - SetArgBasedOnType(Plugin, Kernel, DeviceImageImpl, getMemAllocationFunc, + SetArgBasedOnType(Adapter, Kernel, DeviceImageImpl, getMemAllocationFunc, Queue->get_context(), Arg, NextTrueIndex); }; @@ -2378,7 +2378,7 @@ static ur_result_t SetKernelParamsAndLaunch( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( + Adapter->call( Kernel, Queue->getDeviceImplPtr()->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -2415,7 +2415,7 @@ static ur_result_t SetKernelParamsAndLaunch( ur_event_handle_t UREvent = nullptr; ur_result_t Error = - Plugin->call_nocheck( + Adapter->call_nocheck( Queue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalSize[0], LocalSize, property_list.size(), property_list.data(), RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], @@ -2429,11 +2429,11 @@ static ur_result_t SetKernelParamsAndLaunch( ur_result_t Error = [&](auto... Args) { if (IsCooperative) { - return Plugin + return Adapter ->call_nocheck( Args...); } - return Plugin->call_nocheck(Args...); + return Adapter->call_nocheck(Args...); }(Queue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], @@ -2454,7 +2454,7 @@ ur_result_t enqueueImpCommandBufferKernel( ur_exp_command_buffer_command_handle_t *OutCommand, const std::function &getMemAllocationFunc) { auto ContextImpl = sycl::detail::getSyclObjImpl(Ctx); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); ur_kernel_handle_t UrKernel = nullptr; ur_program_handle_t UrProgram = nullptr; std::shared_ptr SyclKernelImpl = nullptr; @@ -2490,10 +2490,10 @@ ur_result_t enqueueImpCommandBufferKernel( ContextImpl, DeviceImpl, CommandGroup.MKernelName); } - auto SetFunc = [&Plugin, &UrKernel, &DeviceImageImpl, &Ctx, + auto SetFunc = [&Adapter, &UrKernel, &DeviceImageImpl, &Ctx, &getMemAllocationFunc](sycl::detail::ArgDesc &Arg, size_t NextTrueIndex) { - sycl::detail::SetArgBasedOnType(Plugin, UrKernel, DeviceImageImpl, + sycl::detail::SetArgBasedOnType(Adapter, UrKernel, DeviceImageImpl, getMemAllocationFunc, Ctx, Arg, NextTrueIndex); }; @@ -2515,7 +2515,7 @@ ur_result_t enqueueImpCommandBufferKernel( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Plugin->call( + Adapter->call( UrKernel, DeviceImpl->getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -2529,15 +2529,15 @@ ur_result_t enqueueImpCommandBufferKernel( } ur_result_t Res = - Plugin->call_nocheck( + Adapter->call_nocheck( CommandBuffer, UrKernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, SyncPoints.size(), SyncPoints.size() ? SyncPoints.data() : nullptr, OutSyncPoint, OutCommand); if (!SyclKernelImpl && !Kernel) { - Plugin->call(UrKernel); - Plugin->call(UrProgram); + Adapter->call(UrKernel); + Adapter->call(UrProgram); } if (Res != UR_RESULT_SUCCESS) { @@ -2640,8 +2640,8 @@ void enqueueImpKernel( // provided. if (KernelCacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_SLM || KernelCacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_DATA) { - const PluginPtr &Plugin = Queue->getPlugin(); - Plugin->call( + const AdapterPtr &Adapter = Queue->getAdapter(); + Adapter->call( Kernel, UR_KERNEL_EXEC_INFO_CACHE_CONFIG, sizeof(ur_kernel_cache_config_t), nullptr, &KernelCacheConfig); } @@ -2651,10 +2651,10 @@ void enqueueImpKernel( OutEventImpl, EliminatedArgMask, getMemAllocationFunc, KernelIsCooperative, KernelUsesClusterLaunch, BinImage, KernelName); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); if (!SyclKernelImpl && !MSyclKernel) { - Plugin->call(Kernel); - Plugin->call(Program); + Adapter->call(Kernel); + Adapter->call(Program); } } if (UR_RESULT_SUCCESS != Error) { @@ -2696,7 +2696,7 @@ ur_result_t enqueueReadWriteHostPipe(const QueueImplPtr &Queue, } assert(Program && "Program for this hostpipe is not compiled."); - const PluginPtr &Plugin = Queue->getPlugin(); + const AdapterPtr &Adapter = Queue->getAdapter(); ur_queue_handle_t ur_q = Queue->getHandleRef(); ur_result_t Error; @@ -2706,11 +2706,11 @@ ur_result_t enqueueReadWriteHostPipe(const QueueImplPtr &Queue, if (OutEventImpl != nullptr) OutEventImpl->setHostEnqueueTime(); if (read) { - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( ur_q, Program, PipeName.c_str(), blocking, ptr, size, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], OutEvent); } else { - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( ur_q, Program, PipeName.c_str(), blocking, ptr, size, RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], OutEvent); } @@ -2732,7 +2732,7 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() { flushCrossQueueDeps(EventImpls, MWorkerQueue); std::vector RawEvents = getUrEvents(EventImpls); if (!RawEvents.empty()) { - MQueue->getPlugin()->call(RawEvents.size(), + MQueue->getAdapter()->call(RawEvents.size(), &RawEvents[0]); } @@ -3186,13 +3186,13 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { HostTask->MHostTask->MInteropTask}; ur_bool_t NativeCommandSupport = false; - MQueue->getPlugin()->call( + MQueue->getAdapter()->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( + MQueue->getAdapter()->call( MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData, ReqMems.size(), ReqMems.data(), nullptr, RawEvents.size(), RawEvents.data(), Event); if (Event) @@ -3201,10 +3201,10 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { } case CGType::Barrier: { assert(MQueue && "Barrier submission should have an associated queue"); - const PluginPtr &Plugin = MQueue->getPlugin(); + const AdapterPtr &Adapter = MQueue->getAdapter(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( + Adapter->call( MQueue->getHandleRef(), 0, nullptr, Event); if (Event) MEvent->setHandle(*Event); @@ -3219,10 +3219,10 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { // If Events is empty, then the barrier has no effect. return UR_RESULT_SUCCESS; } - const PluginPtr &Plugin = MQueue->getPlugin(); + const AdapterPtr &Adapter = MQueue->getAdapter(); if (MEvent != nullptr) MEvent->setHostEnqueueTime(); - Plugin->call( + Adapter->call( MQueue->getHandleRef(), UrEvents.size(), &UrEvents[0], Event); if (Event) MEvent->setHandle(*Event); @@ -3230,7 +3230,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { } case CGType::ProfilingTag: { assert(MQueue && "Profiling tag requires a valid queue"); - const auto &Plugin = MQueue->getPlugin(); + const auto &Adapter = MQueue->getAdapter(); // If the queue is not in-order, we need to insert a barrier. This barrier // does not need output events as it will implicitly enforce the following // enqueue is blocked until it finishes. @@ -3239,14 +3239,14 @@ 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( + Adapter->call( MQueue->getHandleRef(), /*num_events_in_wait_list=*/0, /*event_wait_list=*/nullptr, &PreTimestampBarrierEvent); - Plugin->call(PreTimestampBarrierEvent); + Adapter->call(PreTimestampBarrierEvent); } - Plugin->call( + Adapter->call( MQueue->getHandleRef(), /*blocking=*/false, /*num_events_in_wait_list=*/0, /*event_wait_list=*/nullptr, Event); @@ -3298,7 +3298,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { if (MEvent != nullptr) MEvent->setHostEnqueueTime(); ur_result_t Err = - MQueue->getPlugin()->call_nocheck( + MQueue->getAdapter()->call_nocheck( CmdBufferCG->MCommandBuffer, MQueue->getHandleRef(), RawEvents.size(), RawEvents.empty() ? nullptr : &RawEvents[0], Event); @@ -3324,10 +3324,10 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { assert(MQueue && "Semaphore wait submissions should have an associated queue"); CGSemaphoreWait *SemWait = (CGSemaphoreWait *)MCommandGroup.get(); - const detail::PluginPtr &Plugin = MQueue->getPlugin(); + const detail::AdapterPtr &Adapter = MQueue->getAdapter(); auto OptWaitValue = SemWait->getWaitValue(); uint64_t WaitValue = OptWaitValue.has_value() ? OptWaitValue.value() : 0; - Plugin->call( + Adapter->call( MQueue->getHandleRef(), SemWait->getExternalSemaphore(), OptWaitValue.has_value(), WaitValue, 0, nullptr, nullptr); @@ -3337,11 +3337,11 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { assert(MQueue && "Semaphore signal submissions should have an associated queue"); CGSemaphoreSignal *SemSignal = (CGSemaphoreSignal *)MCommandGroup.get(); - const detail::PluginPtr &Plugin = MQueue->getPlugin(); + const detail::AdapterPtr &Adapter = MQueue->getAdapter(); auto OptSignalValue = SemSignal->getSignalValue(); uint64_t SignalValue = OptSignalValue.has_value() ? OptSignalValue.value() : 0; - Plugin->call( + Adapter->call( MQueue->getHandleRef(), SemSignal->getExternalSemaphore(), OptSignalValue.has_value(), SignalValue, 0, nullptr, nullptr); diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 17b285068dc4d..5d6c328595adf 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -737,7 +737,7 @@ ur_result_t enqueueImpCommandBufferKernel( // Refactored from SetKernelParamsAndLaunch to allow it to be used in the graphs // extension. void SetArgBasedOnType( - const detail::PluginPtr &Plugin, ur_kernel_handle_t Kernel, + const detail::AdapterPtr &Adapter, ur_kernel_handle_t Kernel, const std::shared_ptr &DeviceImageImpl, const std::function &getMemAllocationFunc, const sycl::context &Context, detail::ArgDesc &Arg, size_t NextTrueIndex); diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index 2afed97140448..5f95995e279d7 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -754,7 +754,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq( // Can setup link between cl and host allocations only if ((Context == nullptr) != (Record->MCurContext == nullptr)) { // Linked commands assume that the host allocation is reused by the - // plugin runtime and that can lead to unnecessary copy overhead on + // unified runtime and that can lead to unnecessary copy overhead on // devices that do not support host unified memory. Do not link the // allocations in this case. // However, if the user explicitly requests use of pinned host diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 6d5e9f7712de3..716b7ff04c8f5 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -36,19 +36,19 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, MSharedPtrStorage(nullptr), MHostPtrProvided(true), MOwnNativeHandle(OwnNativeHandle) { ur_context_handle_t Context = nullptr; - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); ur_mem_native_properties_t MemProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Plugin->call( + Adapter->call( MemObject, MInteropContext->getHandleRef(), &MemProperties, &MInteropMemObject); // Get the size of the buffer in bytes - Plugin->call(MInteropMemObject, UR_MEM_INFO_SIZE, + Adapter->call(MInteropMemObject, UR_MEM_INFO_SIZE, sizeof(size_t), &MSizeInBytes, nullptr); - Plugin->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, + Adapter->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) @@ -57,7 +57,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, "Input context must be the same as the context of cl_mem"); if (MInteropContext->getBackend() == backend::opencl) - Plugin->call(MInteropMemObject); + Adapter->call(MInteropMemObject); } ur_mem_type_t getImageType(int Dimensions) { @@ -82,7 +82,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, MSharedPtrStorage(nullptr), MHostPtrProvided(true), MOwnNativeHandle(OwnNativeHandle) { ur_context_handle_t Context = nullptr; - const PluginPtr &Plugin = getPlugin(); + const AdapterPtr &Adapter = getAdapter(); ur_image_desc_t Desc = {}; Desc.stype = UR_STRUCTURE_TYPE_IMAGE_DESC; @@ -99,11 +99,11 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, ur_mem_native_properties_t NativeProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Plugin->call( + Adapter->call( MemObject, MInteropContext->getHandleRef(), &Format, &Desc, &NativeProperties, &MInteropMemObject); - Plugin->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, + Adapter->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) @@ -112,7 +112,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, "Input context must be the same as the context of cl_mem"); if (MInteropContext->getBackend() == backend::opencl) - Plugin->call(MInteropMemObject); + Adapter->call(MInteropMemObject); } void SYCLMemObjT::releaseMem(ContextImplPtr Context, void *MemAllocation) { @@ -154,22 +154,22 @@ void SYCLMemObjT::updateHostMemory() { releaseHostMem(MShadowCopy); if (MOpenCLInterop) { - const PluginPtr &Plugin = getPlugin(); - Plugin->call(MInteropMemObject); + const AdapterPtr &Adapter = getAdapter(); + Adapter->call(MInteropMemObject); } } -const PluginPtr &SYCLMemObjT::getPlugin() const { +const AdapterPtr &SYCLMemObjT::getAdapter() const { assert((MInteropContext != nullptr) && - "Trying to get Plugin from SYCLMemObjT with nullptr ContextImpl."); - return (MInteropContext->getPlugin()); + "Trying to get Adapter from SYCLMemObjT with nullptr ContextImpl."); + return (MInteropContext->getAdapter()); } size_t SYCLMemObjT::getBufSizeForContext(const ContextImplPtr &Context, ur_native_handle_t MemObject) { size_t BufSize = 0; - const PluginPtr &Plugin = Context->getPlugin(); + const AdapterPtr &Adapter = Context->getAdapter(); // TODO is there something required to support non-OpenCL backends? - Plugin->call( + Adapter->call( detail::ur::cast(MemObject), UR_MEM_INFO_SIZE, sizeof(size_t), &BufSize, nullptr); return BufSize; diff --git a/sycl/source/detail/sycl_mem_obj_t.hpp b/sycl/source/detail/sycl_mem_obj_t.hpp index 358d7dcc7d214..9eaa73edc67d4 100644 --- a/sycl/source/detail/sycl_mem_obj_t.hpp +++ b/sycl/source/detail/sycl_mem_obj_t.hpp @@ -33,7 +33,7 @@ namespace detail { // Forward declarations class context_impl; class event_impl; -class plugin; +class adapter; using ContextImplPtr = std::shared_ptr; using EventImplPtr = std::shared_ptr; @@ -90,7 +90,7 @@ class SYCLMemObjT : public SYCLMemObjI { virtual ~SYCLMemObjT() = default; - const PluginPtr &getPlugin() const; + const AdapterPtr &getAdapter() const; size_t getSizeInBytes() const noexcept override { return MSizeInBytes; } __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index fb70b92e3b29f..104c2559f02cd 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -15,7 +15,7 @@ #include "context_impl.hpp" #include #include -#include +#include #include #include #include @@ -49,8 +49,8 @@ void contextSetExtendedDeleter(const sycl::context &context, pi_context_extended_deleter func, void *user_data) { auto impl = getSyclObjImpl(context); - const auto &Plugin = impl->getPlugin(); - Plugin->call( + const auto &Adapter = impl->getAdapter(); + Adapter->call( impl->getHandleRef(), reinterpret_cast(func), user_data); } @@ -64,9 +64,9 @@ xpti_td *GSYCLGraphEvent = nullptr; #endif // XPTI_ENABLE_INSTRUMENTATION template -void *getPluginOpaqueData([[maybe_unused]] void *OpaqueDataParam) { - // This was formerly a call to piextPluginGetOpaqueData, a deprecated PI entry - // point introduced for the now deleted ESIMD plugin. All calls to this entry +void *getAdapterOpaqueData([[maybe_unused]] void *OpaqueDataParam) { + // This was formerly a call to piextAdapterGetOpaqueData, a deprecated PI entry + // point introduced for the now deleted ESIMD adapter. All calls to this entry // point returned a similar error code to INVALID_OPERATION and would have // resulted in a similar throw to this one throw exception( @@ -83,13 +83,13 @@ bool trace(TraceLevel Level) { return (TraceLevelMask & Level) == Level; } -static void initializePlugins(std::vector &Plugins, +static void initializeAdapters(std::vector &Adapters, ur_loader_config_handle_t LoaderConfig); bool XPTIInitDone = false; -// Initializes all available Plugins. -std::vector &initializeUr(ur_loader_config_handle_t LoaderConfig) { +// Initializes all available Adapters. +std::vector &initializeUr(ur_loader_config_handle_t LoaderConfig) { // This uses static variable initialization to work around a gcc bug with // std::call_once and exceptions. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146 @@ -101,16 +101,16 @@ std::vector &initializeUr(ur_loader_config_handle_t LoaderConfig) { std::exit(1); } - initializePlugins(GlobalHandler::instance().getPlugins(), LoaderConfig); + initializeAdapters(GlobalHandler::instance().getAdapters(), LoaderConfig); return true; }; static bool Initialized = initializeHelper(); std::ignore = Initialized; - return GlobalHandler::instance().getPlugins(); + return GlobalHandler::instance().getAdapters(); } -static void initializePlugins(std::vector &Plugins, +static void initializeAdapters(std::vector &Adapters, ur_loader_config_handle_t LoaderConfig) { #define CHECK_UR_SUCCESS(Call) __SYCL_CHECK_UR_CODE_NO_EXC(Call) @@ -217,13 +217,13 @@ static void initializePlugins(std::vector &Plugins, } }; - for (const auto &adapter : adapters) { + for (const auto &UrAdapter : adapters) { ur_adapter_backend_t adapterBackend = UR_ADAPTER_BACKEND_UNKNOWN; - CHECK_UR_SUCCESS(adapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, + CHECK_UR_SUCCESS(adapterGetInfo(UrAdapter, UR_ADAPTER_INFO_BACKEND, sizeof(adapterBackend), &adapterBackend, nullptr)); auto syclBackend = UrToSyclBackend(adapterBackend); - Plugins.emplace_back(std::make_shared(adapter, syclBackend)); + Adapters.emplace_back(std::make_shared(UrAdapter, syclBackend)); } #ifdef XPTI_ENABLE_INSTRUMENTATION @@ -238,12 +238,12 @@ static void initializePlugins(std::vector &Plugins, // Initialize the global events just once, in the case ur::initialize() is // called multiple times XPTIInitDone = true; - // Registers a new stream for 'sycl' and any plugin that wants to listen to - // this stream will register itself using this string or stream ID for this - // string. + // Registers a new stream for 'sycl' and any application that wants to listen + // to this stream will register itself using this string or stream ID for + // this string. uint8_t StreamID = xptiRegisterStream(SYCL_STREAM_NAME); - // Let all tool plugins know that a stream by the name of 'sycl' has been - // initialized and will be generating the trace stream. + // Let all tool applications know that a stream by the name of 'sycl' has + // been initialized and will be generating the trace stream. GlobalHandler::instance().getXPTIRegistry().initializeStream( SYCL_STREAM_NAME, GMajVer, GMinVer, GVerStr); // Create a tracepoint to indicate the graph creation @@ -262,26 +262,26 @@ static void initializePlugins(std::vector &Plugins, #undef CHECK_UR_SUCCESS } -// Get the plugin serving given backend. -template const PluginPtr &getPlugin() { - static PluginPtr *Plugin = nullptr; - if (Plugin) - return *Plugin; +// Get the adapter serving given backend. +template const AdapterPtr &getAdapter() { + static AdapterPtr *Adapter = nullptr; + if (Adapter) + return *Adapter; - std::vector &Plugins = ur::initializeUr(); - for (auto &P : Plugins) + std::vector &Adapters = ur::initializeUr(); + for (auto &P : Adapters) if (P->hasBackend(BE)) { - Plugin = &P; - return *Plugin; + Adapter = &P; + return *Adapter; } - throw exception(errc::runtime, "ur::getPlugin couldn't find plugin"); + throw exception(errc::runtime, "ur::getAdapter couldn't find adapter"); } -template const PluginPtr &getPlugin(); -template const PluginPtr &getPlugin(); -template const PluginPtr &getPlugin(); -template const PluginPtr &getPlugin(); +template const AdapterPtr &getAdapter(); +template const AdapterPtr &getAdapter(); +template const AdapterPtr &getAdapter(); +template const AdapterPtr &getAdapter(); // Reads an integer value from ELF data. template diff --git a/sycl/source/detail/ur_utils.hpp b/sycl/source/detail/ur_utils.hpp index e15e5c97a1472..c950e3e7041ad 100644 --- a/sycl/source/detail/ur_utils.hpp +++ b/sycl/source/detail/ur_utils.hpp @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include #include @@ -21,21 +21,21 @@ namespace detail { // RAII object for keeping ownership of a UR event. struct OwnedUrEvent { - OwnedUrEvent(const PluginPtr &Plugin) - : MEvent{std::nullopt}, MPlugin{Plugin} {} - OwnedUrEvent(ur_event_handle_t Event, const PluginPtr &Plugin, + OwnedUrEvent(const AdapterPtr &Adapter) + : MEvent{std::nullopt}, MAdapter{Adapter} {} + OwnedUrEvent(ur_event_handle_t Event, const AdapterPtr &Adapter, bool TakeOwnership = false) - : MEvent(Event), MPlugin(Plugin) { + : MEvent(Event), MAdapter(Adapter) { // If it is not instructed to take ownership, retain the event to share // ownership of it. if (!TakeOwnership) - MPlugin->call(*MEvent); + MAdapter->call(*MEvent); } ~OwnedUrEvent() { try { // Release the event if the ownership was not transferred. if (MEvent.has_value()) - MPlugin->call(*MEvent); + MAdapter->call(*MEvent); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~OwnedUrEvent", e); @@ -43,7 +43,7 @@ struct OwnedUrEvent { } OwnedUrEvent(OwnedUrEvent &&Other) - : MEvent(Other.MEvent), MPlugin(Other.MPlugin) { + : MEvent(Other.MEvent), MAdapter(Other.MAdapter) { Other.MEvent = std::nullopt; } @@ -65,7 +65,7 @@ struct OwnedUrEvent { private: std::optional MEvent; - const PluginPtr &MPlugin; + const AdapterPtr &MAdapter; }; namespace ur { diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index f9f4ebf7beb07..4cd063c8ba62a 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -65,7 +65,7 @@ void *alignedAllocHost(size_t Alignment, size_t Size, const sycl::context &Ctxt, std::shared_ptr CtxImpl = sycl::detail::getSyclObjImpl(Ctxt); ur_context_handle_t C = CtxImpl->getHandleRef(); - const sycl::detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_result_t Error = UR_RESULT_ERROR_INVALID_VALUE; ur_usm_desc_t UsmDesc{}; @@ -86,7 +86,7 @@ void *alignedAllocHost(size_t Alignment, size_t Size, const sycl::context &Ctxt, UsmDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( C, &UsmDesc, /* pool= */ nullptr, Size, &RetVal); @@ -132,7 +132,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, return nullptr; ur_context_handle_t C = CtxImpl->getHandleRef(); - const PluginPtr &Plugin = CtxImpl->getPlugin(); + const AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_result_t Error = UR_RESULT_ERROR_INVALID_VALUE; ur_device_handle_t Dev; @@ -158,7 +158,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( C, Dev, &UsmDesc, /*pool=*/nullptr, Size, &RetVal); @@ -195,7 +195,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDeviceDesc.pNext = &UsmLocationDesc; } - Error = Plugin->call_nocheck( + Error = Adapter->call_nocheck( C, Dev, &UsmDesc, /*pool=*/nullptr, Size, &RetVal); @@ -252,8 +252,8 @@ void freeInternal(void *Ptr, const context_impl *CtxImpl) { if (Ptr == nullptr) return; ur_context_handle_t C = CtxImpl->getHandleRef(); - const PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(C, Ptr); + const AdapterPtr &Adapter = CtxImpl->getAdapter(); + Adapter->call(C, Ptr); } void free(void *Ptr, const context &Ctxt, @@ -531,9 +531,9 @@ alloc get_pointer_type(const void *Ptr, const context &Ctxt) { ur_usm_type_t AllocTy; // query type using UR function - const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); + const detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); ur_result_t Err = - Plugin->call_nocheck( + Adapter->call_nocheck( URCtx, Ptr, UR_USM_ALLOC_INFO_TYPE, sizeof(ur_usm_type_t), &AllocTy, nullptr); @@ -593,8 +593,8 @@ device get_pointer_device(const void *Ptr, const context &Ctxt) { ur_device_handle_t DeviceId; // query device using UR function - const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( + const detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + Adapter->call( URCtx, Ptr, UR_USM_ALLOC_INFO_DEVICE, sizeof(ur_device_handle_t), &DeviceId, nullptr); @@ -616,8 +616,8 @@ static void prepare_for_usm_device_copy(const void *Ptr, size_t Size, std::shared_ptr CtxImpl = detail::getSyclObjImpl(Ctxt); ur_context_handle_t URCtx = CtxImpl->getHandleRef(); // Call the UR function - const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call( + const detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + Adapter->call( URCtx, const_cast(Ptr), Size); } @@ -625,8 +625,8 @@ static void release_from_usm_device_copy(const void *Ptr, const context &Ctxt) { std::shared_ptr CtxImpl = detail::getSyclObjImpl(Ctxt); ur_context_handle_t URCtx = CtxImpl->getHandleRef(); // Call the UR function - const detail::PluginPtr &Plugin = CtxImpl->getPlugin(); - Plugin->call(URCtx, + const detail::AdapterPtr &Adapter = CtxImpl->getAdapter(); + Adapter->call(URCtx, const_cast(Ptr)); } diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 1a4d1cb9c4a75..955b1bf305a6f 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -33,17 +33,17 @@ void force_type(info::device_type &t, const info::device_type &ft) { device::device() : device(default_selector_v) {} device::device(cl_device_id DeviceId) { - auto Plugin = sycl::detail::ur::getPlugin(); + auto Adapter = sycl::detail::ur::getAdapter(); // 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( - detail::ur::cast(DeviceId), Plugin->getUrAdapter(), + Adapter->call( + detail::ur::cast(DeviceId), Adapter->getUrAdapter(), nullptr, &Device); auto Platform = - detail::platform_impl::getPlatformFromUrDevice(Device, Plugin); + detail::platform_impl::getPlatformFromUrDevice(Device, Adapter); impl = Platform->getOrMakeDeviceImpl(Device, Platform); - Plugin->call(impl->getHandleRef()); + Adapter->call(impl->getHandleRef()); } device::device(const device_selector &deviceSelector) { @@ -210,8 +210,8 @@ void device::ext_oneapi_enable_peer_access(const device &peer) { ur_device_handle_t Device = impl->getHandleRef(); ur_device_handle_t Peer = peer.impl->getHandleRef(); if (Device != Peer) { - auto Plugin = impl->getPlugin(); - Plugin->call(Device, Peer); + auto Adapter = impl->getAdapter(); + Adapter->call(Device, Peer); } } @@ -219,8 +219,8 @@ void device::ext_oneapi_disable_peer_access(const device &peer) { ur_device_handle_t Device = impl->getHandleRef(); ur_device_handle_t Peer = peer.impl->getHandleRef(); if (Device != Peer) { - auto Plugin = impl->getPlugin(); - Plugin->call(Device, Peer); + auto Adapter = impl->getAdapter(); + Adapter->call(Device, Peer); } } @@ -246,11 +246,11 @@ bool device::ext_oneapi_can_access_peer(const device &peer, throw sycl::exception(make_error_code(errc::invalid), "Unrecognized peer access attribute."); }(); - auto Plugin = impl->getPlugin(); - Plugin->call( + auto Adapter = impl->getAdapter(); + Adapter->call( Device, Peer, UrAttr, 0, nullptr, &returnSize); - Plugin->call( + Adapter->call( Device, Peer, UrAttr, returnSize, &value, nullptr); return value == 1; @@ -274,9 +274,9 @@ bool device::ext_oneapi_can_compile( bool device::ext_oneapi_supports_cl_c_feature(detail::string_view Feature) { ur_device_handle_t Device = impl->getHandleRef(); - auto Plugin = impl->getPlugin(); + auto Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Plugin->call_nocheck( + auto res = Adapter->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -288,9 +288,9 @@ bool device::ext_oneapi_supports_cl_c_feature(detail::string_view Feature) { bool device::ext_oneapi_supports_cl_c_version( const ext::oneapi::experimental::cl_version &Version) const { ur_device_handle_t Device = impl->getHandleRef(); - auto Plugin = impl->getPlugin(); + auto Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Plugin->call_nocheck( + auto res = Adapter->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -303,9 +303,9 @@ bool device::ext_oneapi_supports_cl_extension( detail::string_view Name, ext::oneapi::experimental::cl_version *VersionPtr) const { ur_device_handle_t Device = impl->getHandleRef(); - auto Plugin = impl->getPlugin(); + auto Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Plugin->call_nocheck( + auto res = Adapter->call_nocheck( Device, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); if (res != UR_RESULT_SUCCESS) return false; @@ -316,9 +316,9 @@ bool device::ext_oneapi_supports_cl_extension( detail::string device::ext_oneapi_cl_profile_impl() const { ur_device_handle_t Device = impl->getHandleRef(); - auto Plugin = impl->getPlugin(); + auto Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Plugin->call_nocheck( + auto res = Adapter->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 c1cd030f68412..df68777ca6df4 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -30,7 +30,7 @@ event::event(cl_event ClEvent, const context &SyclContext) // This is a special interop constructor for OpenCL, so the event must be // retained. // TODO(pi2ur): Don't just cast from cl_event above - impl->getPlugin()->call( + impl->getAdapter()->call( detail::ur::cast(ClEvent)); } diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 50e7d007e537e..414551240d9b3 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -1611,9 +1611,9 @@ void handler::depends_on(const std::vector &Events) { static bool checkContextSupports(const std::shared_ptr &ContextImpl, ur_context_info_t InfoQuery) { - auto &Plugin = ContextImpl->getPlugin(); + auto &Adapter = ContextImpl->getAdapter(); ur_bool_t SupportsOp = false; - Plugin->call(ContextImpl->getHandleRef(), + Adapter->call(ContextImpl->getHandleRef(), InfoQuery, sizeof(ur_bool_t), &SupportsOp, nullptr); return SupportsOp; @@ -1849,7 +1849,7 @@ void handler::setUserFacingNodeType(ext::oneapi::experimental::node_type Type) { std::optional> handler::getMaxWorkGroups() { auto Dev = detail::getSyclObjImpl(detail::getDeviceFromHandler(*this)); std::array UrResult = {}; - auto Ret = Dev->getPlugin()->call_nocheck( + auto Ret = Dev->getAdapter()->call_nocheck( Dev->getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, diff --git a/sycl/source/interop_handle.cpp b/sycl/source/interop_handle.cpp index fa5f5910a2e6a..aabf22702ef5f 100644 --- a/sycl/source/interop_handle.cpp +++ b/sycl/source/interop_handle.cpp @@ -33,9 +33,9 @@ interop_handle::getNativeMem(detail::Requirement *Req) const { "Invalid memory object used inside interop"); } - auto Plugin = MQueue->getPlugin(); + auto Adapter = MQueue->getAdapter(); ur_native_handle_t Handle; - Plugin->call( + Adapter->call( Iter->second, MDevice->getHandleRef(), &Handle); return Handle; } diff --git a/sycl/source/kernel.cpp b/sycl/source/kernel.cpp index f4ec76bcf9e7d..9e701777c6405 100644 --- a/sycl/source/kernel.cpp +++ b/sycl/source/kernel.cpp @@ -18,11 +18,11 @@ inline namespace _V1 { // TODO(pi2ur): Don't cast straight from cl_kernel below kernel::kernel(cl_kernel ClKernel, const context &SyclContext) { - auto Plugin = sycl::detail::ur::getPlugin(); + auto Adapter = sycl::detail::ur::getAdapter(); ur_kernel_handle_t hKernel = nullptr; ur_native_handle_t nativeHandle = reinterpret_cast(ClKernel); - Plugin->call( + Adapter->call( nativeHandle, detail::getSyclObjImpl(SyclContext)->getHandleRef(), nullptr, nullptr, &hKernel); impl = std::make_shared( @@ -30,7 +30,7 @@ kernel::kernel(cl_kernel ClKernel, const context &SyclContext) { // This is a special interop constructor for OpenCL, so the kernel must be // retained. if (get_backend() == backend::opencl) { - impl->getPlugin()->call(hKernel); + impl->getAdapter()->call(hKernel); } } diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index b9ec5073fb7ea..965a8625c1ebf 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -23,12 +23,12 @@ inline namespace _V1 { platform::platform() : platform(default_selector_v) {} platform::platform(cl_platform_id PlatformId) { - auto Plugin = sycl::detail::ur::getPlugin(); + auto Adapter = sycl::detail::ur::getAdapter(); ur_platform_handle_t UrPlatform = nullptr; - Plugin->call( - detail::ur::cast(PlatformId), Plugin->getUrAdapter(), + Adapter->call( + detail::ur::cast(PlatformId), Adapter->getUrAdapter(), /* pProperties = */ nullptr, &UrPlatform); - impl = detail::platform_impl::getOrMakePlatformImpl(UrPlatform, Plugin); + impl = detail::platform_impl::getOrMakePlatformImpl(UrPlatform, Adapter); } // protected constructor for internal use diff --git a/sycl/source/virtual_mem.cpp b/sycl/source/virtual_mem.cpp index 5a9a88f884b60..5519a27ed0d19 100644 --- a/sycl/source/virtual_mem.cpp +++ b/sycl/source/virtual_mem.cpp @@ -45,17 +45,17 @@ __SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice, sycl::detail::getSyclObjImpl(SyclDevice); std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); #ifndef NDEBUG size_t InfoOutputSize; - Plugin->call( + Adapter->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( + Adapter->call( ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery, sizeof(size_t), &Granularity, nullptr); if (Granularity == 0) @@ -117,9 +117,9 @@ __SYCL_EXPORT uintptr_t reserve_virtual_mem(uintptr_t Start, size_t NumBytes, std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); void *OutPtr = nullptr; - Plugin->call( + Adapter->call( ContextImpl->getHandleRef(), reinterpret_cast(Start), NumBytes, &OutPtr); return reinterpret_cast(OutPtr); @@ -129,8 +129,8 @@ __SYCL_EXPORT void free_virtual_mem(uintptr_t Ptr, size_t NumBytes, const context &SyclContext) { std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); + Adapter->call( ContextImpl->getHandleRef(), reinterpret_cast(Ptr), NumBytes); } @@ -140,8 +140,8 @@ __SYCL_EXPORT void set_access_mode(const void *Ptr, size_t NumBytes, auto AccessFlags = sycl::detail::AccessModeToVirtualAccessFlags(Mode); std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); + Adapter->call( ContextImpl->getHandleRef(), Ptr, NumBytes, AccessFlags); } @@ -150,17 +150,17 @@ __SYCL_EXPORT address_access_mode get_access_mode(const void *Ptr, const context &SyclContext) { std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); #ifndef NDEBUG size_t InfoOutputSize = 0; - Plugin->call( + Adapter->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( + Adapter->call( ContextImpl->getHandleRef(), Ptr, NumBytes, UR_VIRTUAL_MEM_INFO_ACCESS_MODE, sizeof(ur_virtual_mem_access_flags_t), &AccessFlags, nullptr); @@ -176,8 +176,8 @@ __SYCL_EXPORT void unmap(const void *Ptr, size_t NumBytes, const context &SyclContext) { std::shared_ptr ContextImpl = sycl::detail::getSyclObjImpl(SyclContext); - const sycl::detail::PluginPtr &Plugin = ContextImpl->getPlugin(); - Plugin->call( + const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter(); + Adapter->call( ContextImpl->getHandleRef(), Ptr, NumBytes); } diff --git a/sycl/unittests/Extensions/CommandGraph/InOrderQueue.cpp b/sycl/unittests/Extensions/CommandGraph/InOrderQueue.cpp index 2c581e46a4e45..f65018d63fb35 100644 --- a/sycl/unittests/Extensions/CommandGraph/InOrderQueue.cpp +++ b/sycl/unittests/Extensions/CommandGraph/InOrderQueue.cpp @@ -419,7 +419,7 @@ TEST_F(CommandGraphTest, InOrderQueueMemsetAndGraph) { experimental::command_graph InOrderGraph{InOrderQueue.get_context(), InOrderQueue.get_device()}; - // The mock plugin should return true for shared USM allocation support by + // The mock adapter should return true for shared USM allocation support by // default. If this fails it means this test needs to redefine the device info // query. ASSERT_TRUE( @@ -497,7 +497,7 @@ TEST_F(CommandGraphTest, InOrderQueueMemcpyAndGraph) { experimental::command_graph InOrderGraph{InOrderQueue.get_context(), InOrderQueue.get_device()}; - // The mock plugin should return true for shared USM allocation support by + // The mock adapter should return true for shared USM allocation support by // default. If this fails it means this test needs to redefine the device info // query. ASSERT_TRUE( diff --git a/sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp b/sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp index 42ff1c6eceabf..b3b9741266898 100644 --- a/sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp +++ b/sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp @@ -33,7 +33,7 @@ TEST(DeviceGetInfo, SupportedDeviceAspects) { Dev.get_info(); // Tests to examine aspects of default mock device, as defined in - // helpers/UrMockPlugin.hpp so these tests all need to be kept in sync with + // helpers/UrMockAdapter.hpp so these tests all need to be kept in sync with // changes to that file. EXPECT_TRUE(containsAspect(DeviceAspects, aspect::gpu)); EXPECT_TRUE(containsAspect(DeviceAspects, aspect::fp16)); diff --git a/sycl/unittests/SYCL2020/HasExtension.cpp b/sycl/unittests/SYCL2020/HasExtension.cpp index 636c363f28616..92f99b7fce7f3 100644 --- a/sycl/unittests/SYCL2020/HasExtension.cpp +++ b/sycl/unittests/SYCL2020/HasExtension.cpp @@ -15,7 +15,7 @@ using namespace sycl; -TEST(HasExtensionID, HasExtensionCallsCorrectPluginMethods) { +TEST(HasExtensionID, HasExtensionCallsCorrectAdapterMethods) { sycl::unittest::UrMock<> Mock; sycl::platform Plt = sycl::platform(); diff --git a/sycl/unittests/SYCL2020/KernelBundle.cpp b/sycl/unittests/SYCL2020/KernelBundle.cpp index 9829f746ac819..cffd194bf08de 100644 --- a/sycl/unittests/SYCL2020/KernelBundle.cpp +++ b/sycl/unittests/SYCL2020/KernelBundle.cpp @@ -488,7 +488,7 @@ ur_result_t redefinedDevicePartitionAfter(void *pParams) { } TEST(KernelBundle, DescendentDevice) { - // Mock a non-OpenCL plugin since use of descendent devices of context members + // Mock a non-OpenCL adapter since use of descendent devices of context members // is not supported there yet. sycl::unittest::UrMock Mock; diff --git a/sycl/unittests/assert/assert.cpp b/sycl/unittests/assert/assert.cpp index 33048f3433932..055a86771a6fa 100644 --- a/sycl/unittests/assert/assert.cpp +++ b/sycl/unittests/assert/assert.cpp @@ -470,9 +470,9 @@ void ParentProcess(int ChildPID, int ChildStdErrFD) { #endif // _WIN32 TEST(Assert, TestPositive) { - // Ensure that the mock plugin is initialized before spawning work. Since the + // Ensure that the mock adapter is initialized before spawning work. Since the // test needs no redefinitions we do not need to create a UrMock<> instance, - // but the mock plugin is still needed to have a valid platform available. + // but the mock adapter is still needed to have a valid platform available. // sycl::unittest::UrMock::InitUr(); #ifndef _WIN32 @@ -526,8 +526,8 @@ TEST(Assert, TestInteropKernelNegative) { auto URKernel = mock::createDummyHandle(); - // TODO use make_kernel. This requires a fix in backend.cpp to get plugin - // from context instead of free getPlugin to alllow for mocking of its methods + // TODO use make_kernel. This requires a fix in backend.cpp to get adapter + // from context instead of free getAdapter to alllow for mocking of its methods sycl::kernel KInterop((cl_kernel)URKernel, Ctx); Queue.submit([&](sycl::handler &H) { H.single_task(KInterop); }); diff --git a/sycl/unittests/helpers/UrMock.hpp b/sycl/unittests/helpers/UrMock.hpp index e4e525a274dbc..5ec613b386273 100644 --- a/sycl/unittests/helpers/UrMock.hpp +++ b/sycl/unittests/helpers/UrMock.hpp @@ -8,11 +8,11 @@ // // This mini-library provides facilities to test the DPC++ Runtime behavior upon // specific results of the underlying low-level API calls. By exploiting the -// Plugin Interface API, the stored addresses of the actual plugin-specific +// Adapter Interface API, the stored addresses of the actual adapter-specific // implementations can be overwritten to point at user-defined mock functions. // -// To make testing independent of existing plugins and devices, all plugins are -// forcefully unloaded and the mock plugin is registered as the only plugin. +// To make testing independent of existing adapters and devices, all adapters are +// forcefully unloaded and the mock adapter is registered as the only adapter. // // While this could be done manually for each unit-testing scenario, the library // aims to rule out the boilerplate, providing helper APIs which can be re-used @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include #include diff --git a/sycl/unittests/scheduler/Commands.cpp b/sycl/unittests/scheduler/Commands.cpp index 0732d9e5ecde8..9ebd256a2f587 100644 --- a/sycl/unittests/scheduler/Commands.cpp +++ b/sycl/unittests/scheduler/Commands.cpp @@ -37,7 +37,7 @@ ur_result_t redefineUrEventGetInfo(void *pParams) { // // This test checks a handling of empty events in WaitWithBarrier command. -// Original reproducer for l0 plugin led to segfault(nullptr dereference): +// Original reproducer for l0 adapter led to segfault(nullptr dereference): // // #include // int main() { diff --git a/sycl/unittests/scheduler/LeafLimitDiffContexts.cpp b/sycl/unittests/scheduler/LeafLimitDiffContexts.cpp index 456dec8f0b5cb..caacbb9651ae3 100644 --- a/sycl/unittests/scheduler/LeafLimitDiffContexts.cpp +++ b/sycl/unittests/scheduler/LeafLimitDiffContexts.cpp @@ -36,8 +36,8 @@ TEST_F(SchedulerTest, LeafLimitDiffContexts) { DisableCleanupName, "1", detail::SYCLConfig::reset}; - // Ensure the mock plugin has been initialized prior to selecting a device. - // unittest::UrMock::EnsureMockPluginInitialized(); + // Ensure the mock adapter has been initialized prior to selecting a device. + // unittest::UrMock::EnsureMockAdapterInitialized(); sycl::unittest::UrMock<> Mock; device Device; diff --git a/sycl/unittests/xpti_trace/NodeCreation.cpp b/sycl/unittests/xpti_trace/NodeCreation.cpp index 257000e3ec2f4..6b963bc8563af 100644 --- a/sycl/unittests/xpti_trace/NodeCreation.cpp +++ b/sycl/unittests/xpti_trace/NodeCreation.cpp @@ -42,7 +42,7 @@ class NodeCreation : public ::testing::Test { "libxptifw.so", [] {}}; unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockPlugin; + sycl::unittest::UrMock<> MockAdapter; static constexpr char FileName[] = "NodeCreation.cpp"; static constexpr char FunctionName[] = "TestCaseExecution"; diff --git a/sycl/unittests/xpti_trace/QueueApiFailures.cpp b/sycl/unittests/xpti_trace/QueueApiFailures.cpp index a250f213cb998..d2756f3b5fb56 100644 --- a/sycl/unittests/xpti_trace/QueueApiFailures.cpp +++ b/sycl/unittests/xpti_trace/QueueApiFailures.cpp @@ -66,7 +66,7 @@ class QueueApiFailures : public ::testing::Test { "libxptifw.so", [] {}}; unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockPlugin; + sycl::unittest::UrMock<> MockAdapter; static constexpr char FileName[] = "QueueApiFailures.cpp"; static constexpr char FunctionName[] = "TestCaseExecution"; diff --git a/sycl/unittests/xpti_trace/QueueIDCheck.cpp b/sycl/unittests/xpti_trace/QueueIDCheck.cpp index 3824d433d6057..5dab29a603b3c 100644 --- a/sycl/unittests/xpti_trace/QueueIDCheck.cpp +++ b/sycl/unittests/xpti_trace/QueueIDCheck.cpp @@ -46,7 +46,7 @@ class QueueID : public ::testing::Test { "libxptifw.so", [] {}}; unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockPlugin; + sycl::unittest::UrMock<> MockAdapter; static constexpr size_t KernelSize = 1;