From 46ae4871368d7265e3f825f872d498a5dfb3295c Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 4 Jul 2025 19:18:11 +0200 Subject: [PATCH 1/8] [SYCL][NFC] Make sycl_mem_obj::getAdapter() return by reference --- sycl/source/detail/buffer_impl.cpp | 6 +++--- sycl/source/detail/sycl_mem_obj_t.cpp | 21 ++++++++++----------- sycl/source/detail/sycl_mem_obj_t.hpp | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 676f49a63007d..98b8ad057ffa5 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -52,11 +52,11 @@ void buffer_impl::addInteropObject( if (std::find(Handles.begin(), Handles.end(), ur::cast(MInteropMemObject)) == Handles.end()) { - const AdapterPtr &Adapter = getAdapter(); - Adapter->call( + adapter_impl &Adapter = getAdapter(); + Adapter.call( ur::cast(MInteropMemObject)); ur_native_handle_t NativeHandle = 0; - Adapter->call(MInteropMemObject, nullptr, + Adapter.call(MInteropMemObject, nullptr, &NativeHandle); Handles.push_back(NativeHandle); } diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 87fc643459b18..91a8f82a2103d 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -36,20 +36,20 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, MSharedPtrStorage(nullptr), MHostPtrProvided(true), MOwnNativeHandle(OwnNativeHandle) { ur_context_handle_t Context = nullptr; - const AdapterPtr &Adapter = getAdapter(); + adapter_impl &Adapter = getAdapter(); ur_mem_native_properties_t MemProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Adapter->call( + Adapter.call( MemObject, MInteropContext->getHandleRef(), &MemProperties, &MInteropMemObject); // Get the size of the buffer in bytes - Adapter->call(MInteropMemObject, UR_MEM_INFO_SIZE, + Adapter.call(MInteropMemObject, UR_MEM_INFO_SIZE, sizeof(size_t), &MSizeInBytes, nullptr); - Adapter->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, + Adapter.call(MInteropMemObject, UR_MEM_INFO_CONTEXT, sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) @@ -84,7 +84,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, MSharedPtrStorage(nullptr), MHostPtrProvided(true), MOwnNativeHandle(OwnNativeHandle) { ur_context_handle_t Context = nullptr; - const AdapterPtr &Adapter = getAdapter(); + adapter_impl &Adapter = getAdapter(); ur_image_desc_t Desc = {}; Desc.stype = UR_STRUCTURE_TYPE_IMAGE_DESC; @@ -101,11 +101,11 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, ur_mem_native_properties_t NativeProperties = { UR_STRUCTURE_TYPE_MEM_NATIVE_PROPERTIES, nullptr, OwnNativeHandle}; - Adapter->call( + Adapter.call( MemObject, MInteropContext->getHandleRef(), &Format, &Desc, &NativeProperties, &MInteropMemObject); - Adapter->call(MInteropMemObject, UR_MEM_INFO_CONTEXT, + Adapter.call(MInteropMemObject, UR_MEM_INFO_CONTEXT, sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) @@ -157,14 +157,13 @@ void SYCLMemObjT::updateHostMemory() { releaseHostMem(MShadowCopy); if (MOpenCLInterop) { - const AdapterPtr &Adapter = getAdapter(); - Adapter->call(MInteropMemObject); + getAdapter().call(MInteropMemObject); } } -const AdapterPtr &SYCLMemObjT::getAdapter() const { +adapter_impl &SYCLMemObjT::getAdapter() const { assert((MInteropContext != nullptr) && "Trying to get Adapter from SYCLMemObjT with nullptr ContextImpl."); - return (MInteropContext->getAdapter()); + return *(MInteropContext->getAdapter()); } bool SYCLMemObjT::isInterop() const { return MOpenCLInterop; } diff --git a/sycl/source/detail/sycl_mem_obj_t.hpp b/sycl/source/detail/sycl_mem_obj_t.hpp index a0b5c6b24f529..e5f8b7a4d3bda 100644 --- a/sycl/source/detail/sycl_mem_obj_t.hpp +++ b/sycl/source/detail/sycl_mem_obj_t.hpp @@ -90,7 +90,7 @@ class SYCLMemObjT : public SYCLMemObjI { virtual ~SYCLMemObjT() = default; - const AdapterPtr &getAdapter() const; + adapter_impl &getAdapter() const; size_t getSizeInBytes() const noexcept override { return MSizeInBytes; } __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") From 40086d1728ec861f14256f39533e8eec59e58493 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 4 Jul 2025 19:19:23 +0200 Subject: [PATCH 2/8] clang-format --- sycl/source/detail/buffer_impl.cpp | 2 +- sycl/source/detail/sycl_mem_obj_t.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 98b8ad057ffa5..48389490e956d 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -57,7 +57,7 @@ void buffer_impl::addInteropObject( ur::cast(MInteropMemObject)); ur_native_handle_t NativeHandle = 0; Adapter.call(MInteropMemObject, nullptr, - &NativeHandle); + &NativeHandle); Handles.push_back(NativeHandle); } } diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 91a8f82a2103d..11b00538b14ac 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -46,11 +46,10 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, // Get the size of the buffer in bytes Adapter.call(MInteropMemObject, UR_MEM_INFO_SIZE, - sizeof(size_t), &MSizeInBytes, - nullptr); + sizeof(size_t), &MSizeInBytes, nullptr); Adapter.call(MInteropMemObject, UR_MEM_INFO_CONTEXT, - sizeof(Context), &Context, nullptr); + sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) throw sycl::exception( @@ -106,7 +105,7 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject, &NativeProperties, &MInteropMemObject); Adapter.call(MInteropMemObject, UR_MEM_INFO_CONTEXT, - sizeof(Context), &Context, nullptr); + sizeof(Context), &Context, nullptr); if (MInteropContext->getHandleRef() != Context) throw sycl::exception( From 0cda7c16b4f7e49af63314a031c43741445fc488 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 4 Jul 2025 19:44:22 +0200 Subject: [PATCH 3/8] [SYCL][NFC] Make kernel_impl::getAdapter() return by reference --- .../detail/error_handling/error_handling.cpp | 4 +- .../detail/error_handling/error_handling.hpp | 2 +- sycl/source/detail/kernel_impl.cpp | 6 +-- sycl/source/detail/kernel_impl.hpp | 18 ++++---- sycl/source/detail/kernel_info.hpp | 42 +++++++++---------- sycl/source/detail/scheduler/commands.cpp | 2 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/sycl/source/detail/error_handling/error_handling.cpp b/sycl/source/detail/error_handling/error_handling.cpp index 230151d381109..c33852cd08cd8 100644 --- a/sycl/source/detail/error_handling/error_handling.cpp +++ b/sycl/source/detail/error_handling/error_handling.cpp @@ -469,7 +469,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 AdapterPtr &Adapter) { + adapter_impl &Adapter) { assert(Error != UR_RESULT_SUCCESS && "Success is expected to be handled on caller side"); switch (Error) { @@ -483,7 +483,7 @@ void handleErrorOrWarning(ur_result_t Error, ur_kernel_group_info_t Descriptor, break; // TODO: Handle other error codes default: - Adapter->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 f6e6ffde09f10..ce6cc45554311 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 AdapterPtr &); + adapter_impl &); } // namespace kernel_get_group_info } // namespace detail diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index 8ef45146fecd8..3a8434f35f8d4 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -28,7 +28,7 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, context_impl &Context, MIsInterop(true), MKernelArgMaskPtr{ArgMask} { ur_context_handle_t UrContext = nullptr; // Using the adapter from the passed ContextImpl - getAdapter()->call( + getAdapter().call( MKernel, UR_KERNEL_INFO_CONTEXT, sizeof(UrContext), &UrContext, nullptr); if (Context.getHandleRef() != UrContext) throw sycl::exception( @@ -61,7 +61,7 @@ kernel_impl::kernel_impl(ur_kernel_handle_t Kernel, context_impl &ContextImpl, kernel_impl::~kernel_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions - getAdapter()->call(MKernel); + getAdapter().call(MKernel); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~kernel_impl", e); } @@ -135,7 +135,7 @@ void kernel_impl::enableUSMIndirectAccess() const { // Some UR Adapters (like OpenCL) require this call to enable USM // For others, UR will turn this into a NOP. bool EnableAccess = true; - getAdapter()->call( + getAdapter().call( MKernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &EnableAccess); } diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 5a57f1b14fde4..5645dbaf196c9 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -75,13 +75,13 @@ class kernel_impl { /// \return a valid cl_kernel instance cl_kernel get() const { ur_native_handle_t nativeHandle = 0; - getAdapter()->call(MKernel, + getAdapter().call(MKernel, &nativeHandle); __SYCL_OCL_CALL(clRetainKernel, ur::cast(nativeHandle)); return ur::cast(nativeHandle); } - const AdapterPtr &getAdapter() const { return MContext->getAdapter(); } + adapter_impl &getAdapter() const { return *MContext->getAdapter(); } /// Query information from the kernel object using the info::kernel_info /// descriptor. @@ -360,7 +360,7 @@ kernel_impl::queryMaxNumWorkGroups(queue Queue, throw exception(sycl::make_error_code(errc::invalid), "The launch work-group size cannot be zero."); - const auto &Adapter = getAdapter(); + adapter_impl &Adapter = getAdapter(); const auto &Handle = getHandleRef(); auto Device = Queue.get_device(); auto DeviceHandleRef = sycl::detail::getSyclObjImpl(Device)->getHandleRef(); @@ -373,7 +373,7 @@ kernel_impl::queryMaxNumWorkGroups(queue Queue, WG[2] = WorkGroupSize[2]; uint32_t GroupCount{0}; - if (auto Result = Adapter->call_nocheck< + if (auto Result = Adapter.call_nocheck< UrApiKind::urKernelSuggestMaxCooperativeGroupCount>( Handle, DeviceHandleRef, Dimensions, WG, DynamicLocalMemorySize, &GroupCount); @@ -381,7 +381,7 @@ kernel_impl::queryMaxNumWorkGroups(queue Queue, Result != UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE) { // The feature is supported and the group size is valid. Check for other // errors and throw if any. - Adapter->checkUrResult(Result); + Adapter.checkUrResult(Result); return GroupCount; } @@ -452,12 +452,12 @@ inline typename syclex::info::kernel_queue_specific::max_work_group_size:: kernel_impl::ext_oneapi_get_info< syclex::info::kernel_queue_specific::max_work_group_size>( queue Queue) const { - const auto &Adapter = getAdapter(); + adapter_impl &Adapter = getAdapter(); const auto DeviceNativeHandle = getSyclObjImpl(Queue.get_device())->getHandleRef(); size_t KernelWGSize = 0; - Adapter->call( + Adapter.call( MKernel, DeviceNativeHandle, UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t), &KernelWGSize, nullptr); return KernelWGSize; @@ -508,11 +508,11 @@ ADD_TEMPLATE_METHOD_SPEC(3) if (WG.size() == 0) \ throw exception(sycl::make_error_code(errc::invalid), \ "The work-group size cannot be zero."); \ - const auto &Adapter = getAdapter(); \ + adapter_impl &Adapter = getAdapter(); \ const auto DeviceNativeHandle = \ getSyclObjImpl(Queue.get_device())->getHandleRef(); \ uint32_t KernelSubWGSize = 0; \ - Adapter->call(MKernel, DeviceNativeHandle, Reg, \ + Adapter.call(MKernel, DeviceNativeHandle, Reg, \ sizeof(uint32_t), &KernelSubWGSize, \ nullptr); \ return KernelSubWGSize; \ diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index 424d853250456..d03550553eb66 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -45,20 +45,20 @@ template typename std::enable_if< std::is_same::value, std::string>::type -get_kernel_info(ur_kernel_handle_t Kernel, const AdapterPtr &Adapter) { +get_kernel_info(ur_kernel_handle_t Kernel, adapter_impl &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 - Adapter->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 - Adapter->call(Kernel, UrInfoCode::value, + Adapter.call(Kernel, UrInfoCode::value, ResultSize, Result.data(), nullptr); return std::string(Result.data()); } @@ -66,11 +66,11 @@ get_kernel_info(ur_kernel_handle_t Kernel, const AdapterPtr &Adapter) { template typename std::enable_if< std::is_same::value, uint32_t>::type -get_kernel_info(ur_kernel_handle_t Kernel, const AdapterPtr &Adapter) { +get_kernel_info(ur_kernel_handle_t Kernel, adapter_impl &Adapter) { ur_result_t Result = UR_RESULT_SUCCESS; // TODO catch an exception and put it to list of asynchronous exceptions - Adapter->call(Kernel, UrInfoCode::value, + Adapter.call(Kernel, UrInfoCode::value, sizeof(uint32_t), &Result, nullptr); return Result; } @@ -80,9 +80,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 AdapterPtr &Adapter, void *Result, + adapter_impl &Adapter, void *Result, size_t Size) { - Adapter->call( + Adapter.call( Kernel, Device, UrInfoCode::value, Size, Result, nullptr); } @@ -90,8 +90,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 AdapterPtr &Adapter, void *Result, size_t Size) { - Adapter->call(Kernel, UrInfoCode::value, + adapter_impl &Adapter, void *Result, size_t Size) { + Adapter.call(Kernel, UrInfoCode::value, Size, Result, nullptr); } @@ -100,9 +100,9 @@ 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 AdapterPtr &Adapter, void *Result, + adapter_impl &Adapter, void *Result, size_t Size) { - ur_result_t Error = Adapter->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, @@ -115,7 +115,7 @@ 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 AdapterPtr &Adapter) { + adapter_impl &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); typename Param::return_type Result = {}; @@ -131,7 +131,7 @@ typename std::enable_if< sycl::range<3>>::type get_kernel_device_specific_info(ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const AdapterPtr &Adapter) { + adapter_impl &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); size_t Result[3] = {0, 0, 0}; @@ -148,7 +148,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 AdapterPtr &Adapter) { + adapter_impl &Adapter) { static_assert(is_kernel_device_specific_info_desc::value, "Unexpected kernel_device_specific information descriptor"); static_assert(std::is_same::value, @@ -159,7 +159,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 - Adapter->call( + Adapter.call( Kernel, Device, UrInfoCode::value, sizeof(uint32_t), &Result, nullptr); @@ -171,33 +171,33 @@ inline ext::intel::info::kernel_device_specific::spill_memory_size::return_type get_kernel_device_specific_info< ext::intel::info::kernel_device_specific::spill_memory_size>( ur_kernel_handle_t Kernel, ur_device_handle_t Device, - const AdapterPtr &Adapter) { + adapter_impl &Adapter) { size_t ResultSize = 0; // First call to get the number of device images - Adapter->call( + Adapter.call( Kernel, UR_KERNEL_INFO_SPILL_MEM_SIZE, 0, nullptr, &ResultSize); size_t DeviceCount = ResultSize / sizeof(uint32_t); // Second call to retrieve the data std::vector Device2SpillMap(DeviceCount); - Adapter->call( + Adapter.call( Kernel, UR_KERNEL_INFO_SPILL_MEM_SIZE, ResultSize, Device2SpillMap.data(), nullptr); ur_program_handle_t Program; - Adapter->call(Kernel, UR_KERNEL_INFO_PROGRAM, + Adapter.call(Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); // Retrieve the associated device list size_t URDevicesSize = 0; - Adapter->call(Program, UR_PROGRAM_INFO_DEVICES, + Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, 0, nullptr, &URDevicesSize); std::vector URDevices(URDevicesSize / sizeof(ur_device_handle_t)); - Adapter->call(Program, UR_PROGRAM_INFO_DEVICES, + Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, URDevicesSize, URDevices.data(), nullptr); assert(Device2SpillMap.size() == URDevices.size()); diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index aee8319e0f068..3b90c13e9e3a1 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -2271,7 +2271,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.getAdapter()); + Kernel, DeviceImpl.getHandleRef(), *DeviceImpl.getAdapter()); if (WGSize[0] == 0) { WGSize = {1, 1, 1}; From 091d3145a42c6b18ea7066a69616e6b286d29fe0 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 4 Jul 2025 19:44:36 +0200 Subject: [PATCH 4/8] clang-format --- .../detail/error_handling/error_handling.hpp | 3 +-- sycl/source/detail/kernel_impl.hpp | 15 +++++++------- sycl/source/detail/kernel_info.hpp | 20 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sycl/source/detail/error_handling/error_handling.hpp b/sycl/source/detail/error_handling/error_handling.hpp index ce6cc45554311..2f0dbb8d783ca 100644 --- a/sycl/source/detail/error_handling/error_handling.hpp +++ b/sycl/source/detail/error_handling/error_handling.hpp @@ -31,8 +31,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, - adapter_impl &); +void handleErrorOrWarning(ur_result_t, ur_kernel_group_info_t, adapter_impl &); } // namespace kernel_get_group_info } // namespace detail diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 5645dbaf196c9..6908197da667f 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -76,7 +76,7 @@ class kernel_impl { cl_kernel get() const { ur_native_handle_t nativeHandle = 0; getAdapter().call(MKernel, - &nativeHandle); + &nativeHandle); __SYCL_OCL_CALL(clRetainKernel, ur::cast(nativeHandle)); return ur::cast(nativeHandle); } @@ -373,10 +373,11 @@ kernel_impl::queryMaxNumWorkGroups(queue Queue, WG[2] = WorkGroupSize[2]; uint32_t GroupCount{0}; - if (auto Result = Adapter.call_nocheck< - UrApiKind::urKernelSuggestMaxCooperativeGroupCount>( - Handle, DeviceHandleRef, Dimensions, WG, DynamicLocalMemorySize, - &GroupCount); + if (auto Result = + Adapter + .call_nocheck( + Handle, DeviceHandleRef, Dimensions, WG, + DynamicLocalMemorySize, &GroupCount); Result != UR_RESULT_ERROR_UNSUPPORTED_FEATURE && Result != UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE) { // The feature is supported and the group size is valid. Check for other @@ -513,8 +514,8 @@ ADD_TEMPLATE_METHOD_SPEC(3) getSyclObjImpl(Queue.get_device())->getHandleRef(); \ uint32_t KernelSubWGSize = 0; \ Adapter.call(MKernel, DeviceNativeHandle, Reg, \ - sizeof(uint32_t), &KernelSubWGSize, \ - nullptr); \ + sizeof(uint32_t), &KernelSubWGSize, \ + nullptr); \ return KernelSubWGSize; \ } diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index d03550553eb66..0c98cbfc11fed 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -52,14 +52,14 @@ get_kernel_info(ur_kernel_handle_t Kernel, adapter_impl &Adapter) { // TODO catch an exception and put it to list of asynchronous exceptions Adapter.call(Kernel, UrInfoCode::value, 0, - nullptr, &ResultSize); + nullptr, &ResultSize); if (ResultSize == 0) { return ""; } std::vector Result(ResultSize); // TODO catch an exception and put it to list of asynchronous exceptions Adapter.call(Kernel, UrInfoCode::value, - ResultSize, Result.data(), nullptr); + ResultSize, Result.data(), nullptr); return std::string(Result.data()); } @@ -71,7 +71,7 @@ get_kernel_info(ur_kernel_handle_t Kernel, adapter_impl &Adapter) { // TODO catch an exception and put it to list of asynchronous exceptions Adapter.call(Kernel, UrInfoCode::value, - sizeof(uint32_t), &Result, nullptr); + sizeof(uint32_t), &Result, nullptr); return Result; } @@ -92,7 +92,7 @@ get_kernel_device_specific_info_helper( ur_kernel_handle_t Kernel, [[maybe_unused]] ur_device_handle_t Device, adapter_impl &Adapter, void *Result, size_t Size) { Adapter.call(Kernel, UrInfoCode::value, - Size, Result, nullptr); + Size, Result, nullptr); } template @@ -188,18 +188,18 @@ get_kernel_device_specific_info< ur_program_handle_t Program; Adapter.call(Kernel, UR_KERNEL_INFO_PROGRAM, - sizeof(ur_program_handle_t), - &Program, nullptr); + sizeof(ur_program_handle_t), + &Program, nullptr); // Retrieve the associated device list size_t URDevicesSize = 0; - Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, - 0, nullptr, &URDevicesSize); + Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, 0, + nullptr, &URDevicesSize); std::vector URDevices(URDevicesSize / sizeof(ur_device_handle_t)); Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, - URDevicesSize, URDevices.data(), - nullptr); + URDevicesSize, URDevices.data(), + nullptr); assert(Device2SpillMap.size() == URDevices.size()); // Map the result back to the program devices. UR provides the following From 34bf72601a8aec272517d79117a8f3662586e0b5 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 4 Jul 2025 21:54:21 +0200 Subject: [PATCH 5/8] [SYCL][NFC] temporary --- sycl/source/detail/buffer_impl.cpp | 5 +-- sycl/source/detail/context_impl.hpp | 4 +- sycl/source/detail/device_impl.cpp | 28 +++++++------- sycl/source/detail/device_impl.hpp | 28 +++++++------- .../detail/error_handling/error_handling.cpp | 38 +++++++++---------- sycl/source/detail/kernel_bundle_impl.hpp | 2 +- .../detail/persistent_device_code_cache.cpp | 10 ++--- sycl/source/detail/platform_impl.cpp | 4 +- sycl/source/detail/platform_impl.hpp | 10 ++--- .../program_manager/program_manager.cpp | 10 ++--- sycl/source/detail/scheduler/commands.cpp | 2 +- sycl/source/detail/ur.hpp | 4 +- sycl/source/device.cpp | 28 +++++++------- sycl/source/handler.cpp | 2 +- sycl/source/kernel_bundle.cpp | 4 +- 15 files changed, 89 insertions(+), 90 deletions(-) diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 48389490e956d..0e44650e2d1e2 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -83,13 +83,12 @@ buffer_impl::getNativeVector(backend BackendName) const { if (Platform.getBackend() != BackendName) continue; - auto Adapter = Platform.getAdapter(); - + adapter_impl &Adapter = Platform.getAdapter(); 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. - Adapter->call(NativeMem, /*Dev*/ nullptr, + Adapter.call(NativeMem, /*Dev*/ nullptr, &Handle); Handles.push_back(Handle); diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 819b3c10a7efd..7248c89707be1 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -94,7 +94,7 @@ class context_impl : public std::enable_shared_from_this { const async_handler &get_async_handler() const; /// \return the Adapter associated with the platform of this context. - const AdapterPtr &getAdapter() const { return MPlatform->getAdapter(); } + const AdapterPtr &getAdapter() const { return &MPlatform->getAdapter(); } /// \return the PlatformImpl associated with this context. platform_impl &getPlatformImpl() const { return *MPlatform; } @@ -382,7 +382,7 @@ inline auto get_ur_handles(const sycl::device &syclDevice, inline auto get_ur_handles(const sycl::device &syclDevice) { auto &implDevice = *sycl::detail::getSyclObjImpl(syclDevice); ur_device_handle_t urDevice = implDevice.getHandleRef(); - return std::tuple{urDevice, implDevice.getAdapter()}; + return std::tuple{urDevice, &implDevice.getAdapter()}; } } // namespace _V1 diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index a7729d19ce3e2..7022a21a8a9dc 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -32,16 +32,16 @@ device_impl::device_impl(ur_device_handle_t Device, platform_impl &Platform, MCache{*this} { // Interoperability Constructor already calls DeviceRetain in // urDeviceCreateWithNativeHandle. - getAdapter()->call(MDevice); + getAdapter().call(MDevice); } device_impl::~device_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions - const AdapterPtr &Adapter = getAdapter(); + adapter_impl &Adapter = getAdapter(); ur_result_t Err = - Adapter->call_nocheck(MDevice); - __SYCL_CHECK_UR_CODE_NO_EXC(Err, Adapter->getBackend()); + Adapter.call_nocheck(MDevice); + __SYCL_CHECK_UR_CODE_NO_EXC(Err, Adapter.getBackend()); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_impl", e); } @@ -123,8 +123,8 @@ std::vector device_impl::create_sub_devices( size_t SubDevicesCount) const { std::vector SubDevices(SubDevicesCount); uint32_t ReturnedSubDevices = 0; - const AdapterPtr &Adapter = getAdapter(); - Adapter->call( + adapter_impl &Adapter = getAdapter(); + Adapter.call( MDevice, Properties, SubDevicesCount, SubDevices.data(), &ReturnedSubDevices); if (ReturnedSubDevices != SubDevicesCount) { @@ -270,8 +270,8 @@ std::vector device_impl::create_sub_devices( Properties.pProperties = &Prop; uint32_t SubDevicesCount = 0; - const AdapterPtr &Adapter = getAdapter(); - Adapter->call( + adapter_impl &Adapter = getAdapter(); + Adapter.call( MDevice, &Properties, 0, nullptr, &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); @@ -295,17 +295,17 @@ std::vector device_impl::create_sub_devices() const { Properties.PropCount = 1; uint32_t SubDevicesCount = 0; - const AdapterPtr &Adapter = getAdapter(); - Adapter->call(MDevice, &Properties, 0, nullptr, + adapter_impl &Adapter = getAdapter(); + Adapter.call(MDevice, &Properties, 0, nullptr, &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); } ur_native_handle_t device_impl::getNative() const { - auto Adapter = getAdapter(); + adapter_impl &Adapter = getAdapter(); ur_native_handle_t Handle; - Adapter->call(getHandleRef(), &Handle); + Adapter.call(getHandleRef(), &Handle); if (getBackend() == backend::opencl) { __SYCL_OCL_CALL(clRetainDevice, ur::cast(Handle)); } @@ -327,7 +327,7 @@ uint64_t device_impl::getCurrentDeviceTime() { auto GetGlobalTimestamps = [this](ur_device_handle_t Device, uint64_t *DeviceTime, uint64_t *HostTime) { auto Result = - getAdapter()->call_nocheck( + getAdapter().call_nocheck( Device, DeviceTime, HostTime); if (Result == UR_RESULT_ERROR_INVALID_OPERATION) { // NOTE(UR port): Removed the call to GetLastError because we shouldn't @@ -339,7 +339,7 @@ uint64_t device_impl::getCurrentDeviceTime() { "Device and/or backend does not support querying timestamp."), UR_RESULT_ERROR_INVALID_OPERATION); } else { - getAdapter()->checkUrResult(Result); + getAdapter().checkUrResult(Result); } }; diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 4cd5fc622082a..163cdd04063b5 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -113,7 +113,7 @@ class device_impl : public std::enable_shared_from_this { bool has_info_desc(ur_device_info_t Desc) const { size_t return_size = 0; - return getAdapter()->call_nocheck( + return getAdapter().call_nocheck( MDevice, Desc, 0, nullptr, &return_size) == UR_RESULT_SUCCESS; } @@ -153,7 +153,7 @@ class device_impl : public std::enable_shared_from_this { !check_type_in_v); size_t ResultSize = 0; ur_result_t Error = - getAdapter()->call_nocheck( + getAdapter().call_nocheck( getHandleRef(), Desc, 0, nullptr, &ResultSize); if (Error != UR_RESULT_SUCCESS) return {Error}; @@ -161,7 +161,7 @@ class device_impl : public std::enable_shared_from_this { return {ur_ret_t{}}; ur_ret_t Result(ResultSize / sizeof(typename ur_ret_t::value_type)); - Error = getAdapter()->call_nocheck( + Error = getAdapter().call_nocheck( getHandleRef(), Desc, ResultSize, Result.data(), nullptr); if (Error != UR_RESULT_SUCCESS) return {Error}; @@ -169,7 +169,7 @@ class device_impl : public std::enable_shared_from_this { } else { ur_ret_t Result; ur_result_t Error = - getAdapter()->call_nocheck( + getAdapter().call_nocheck( getHandleRef(), Desc, sizeof(Result), &Result, nullptr); if (Error == UR_RESULT_SUCCESS) return {Result}; @@ -188,18 +188,18 @@ class device_impl : public std::enable_shared_from_this { return urGetInfoString(*this, Desc); } else if constexpr (is_std_vector_v) { size_t ResultSize = 0; - getAdapter()->call(getHandleRef(), Desc, 0, + getAdapter().call(getHandleRef(), Desc, 0, nullptr, &ResultSize); if (ResultSize == 0) return ur_ret_t{}; ur_ret_t Result(ResultSize / sizeof(typename ur_ret_t::value_type)); - getAdapter()->call( + getAdapter().call( getHandleRef(), Desc, ResultSize, Result.data(), nullptr); return Result; } else { ur_ret_t Result; - getAdapter()->call( + getAdapter().call( getHandleRef(), Desc, sizeof(Result), &Result, nullptr); return Result; } @@ -468,7 +468,7 @@ class device_impl : public std::enable_shared_from_this { platform get_platform() const; /// \return the associated adapter with this device. - const AdapterPtr &getAdapter() const { return MPlatform->getAdapter(); } + adapter_impl &getAdapter() const { return MPlatform->getAdapter(); } /// Check SYCL extension support by device /// @@ -724,7 +724,7 @@ class device_impl : public std::enable_shared_from_this { CASE(info::device::platform) { return createSyclObjFromImpl( platform_impl::getOrMakePlatformImpl( - get_info_impl(), *getAdapter())); + get_info_impl(), getAdapter())); } CASE(info::device::profile) { @@ -940,7 +940,7 @@ class device_impl : public std::enable_shared_from_this { // TODO: std::array ? size_t result[3]; - getAdapter()->call( + getAdapter().call( getHandleRef(), UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, sizeof(result), &result, nullptr); return id<3>(std::min(Limit, result[2]), std::min(Limit, result[1]), @@ -1011,7 +1011,7 @@ class device_impl : public std::enable_shared_from_this { ur_result_t Err = Devs.error(); if (Err == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) return std::vector{}; - getAdapter()->checkUrResult(Err); + getAdapter().checkUrResult(Err); } std::vector Result; @@ -1488,7 +1488,7 @@ class device_impl : public std::enable_shared_from_this { CASE(ext_oneapi_graph) { ur_device_command_buffer_update_capability_flags_t UpdateCapabilities; bool CallSuccessful = - getAdapter()->call_nocheck( + getAdapter().call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_CAPABILITIES_EXP, sizeof(UpdateCapabilities), &UpdateCapabilities, nullptr) == UR_RESULT_SUCCESS; @@ -1510,7 +1510,7 @@ class device_impl : public std::enable_shared_from_this { CASE(ext_oneapi_limited_graph) { bool SupportsCommandBuffers = false; bool CallSuccessful = - getAdapter()->call_nocheck( + getAdapter().call_nocheck( MDevice, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP, sizeof(SupportsCommandBuffers), &SupportsCommandBuffers, nullptr) == UR_RESULT_SUCCESS; @@ -1875,7 +1875,7 @@ class device_impl : public std::enable_shared_from_this { // Not all devices support this device info query return std::nullopt; } - getAdapter()->checkUrResult(Err); + getAdapter().checkUrResult(Err); } auto Val = static_cast(DeviceIp.value()); diff --git a/sycl/source/detail/error_handling/error_handling.cpp b/sycl/source/detail/error_handling/error_handling.cpp index c33852cd08cd8..83732fbc455c1 100644 --- a/sycl/source/detail/error_handling/error_handling.cpp +++ b/sycl/source/detail/error_handling/error_handling.cpp @@ -37,9 +37,9 @@ void handleOutOfResources(const device_impl &DeviceImpl, const size_t TotalNumberOfWIs = NDRDesc.LocalSize[0] * NDRDesc.LocalSize[1] * NDRDesc.LocalSize[2]; - const AdapterPtr &Adapter = DeviceImpl.getAdapter(); + adapter_impl &Adapter = DeviceImpl.getAdapter(); uint32_t NumRegisters = 0; - Adapter->call(Kernel, UR_KERNEL_INFO_NUM_REGS, + Adapter.call(Kernel, UR_KERNEL_INFO_NUM_REGS, sizeof(NumRegisters), &NumRegisters, nullptr); @@ -96,32 +96,32 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, IsLevelZero = true; } - const AdapterPtr &Adapter = DeviceImpl.getAdapter(); + adapter_impl &Adapter = DeviceImpl.getAdapter(); ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t CompileWGSize[3] = {0}; - Adapter->call( + Adapter.call( Kernel, Device, UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(size_t) * 3, CompileWGSize, nullptr); size_t CompileMaxWGSize[3] = {0}; - ur_result_t URRes = Adapter->call_nocheck( + ur_result_t URRes = Adapter.call_nocheck( Kernel, Device, UR_KERNEL_GROUP_INFO_COMPILE_MAX_WORK_GROUP_SIZE, sizeof(size_t) * 3, CompileMaxWGSize, nullptr); if (URRes != UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { - Adapter->checkUrResult(URRes); + Adapter.checkUrResult(URRes); } size_t CompileMaxLinearWGSize = 0; - URRes = Adapter->call_nocheck( + URRes = Adapter.call_nocheck( Kernel, Device, UR_KERNEL_GROUP_INFO_COMPILE_MAX_LINEAR_WORK_GROUP_SIZE, sizeof(size_t), &CompileMaxLinearWGSize, nullptr); if (URRes != UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { - Adapter->checkUrResult(URRes); + Adapter.checkUrResult(URRes); } size_t MaxWGSize = 0; - Adapter->call( + Adapter.call( Device, UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t), &MaxWGSize, nullptr); @@ -186,7 +186,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, } size_t MaxThreadsPerBlock[3] = {}; - Adapter->call( + Adapter.call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxThreadsPerBlock), MaxThreadsPerBlock, nullptr); @@ -232,7 +232,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; - Adapter->call( + Adapter.call( Kernel, Device, UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t), &KernelWGSize, nullptr); if (TotalNumberOfWIs > KernelWGSize) @@ -284,15 +284,15 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, // work-group given by local_work_size ur_program_handle_t Program = nullptr; - Adapter->call( + Adapter.call( Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); size_t OptsSize = 0; - Adapter->call( + Adapter.call( Program, Device, UR_PROGRAM_BUILD_INFO_OPTIONS, 0, nullptr, &OptsSize); std::string Opts(OptsSize, '\0'); - Adapter->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; @@ -351,12 +351,12 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, void handleInvalidWorkItemSize(const device_impl &DeviceImpl, const NDRDescT &NDRDesc) { - const AdapterPtr &Adapter = DeviceImpl.getAdapter(); + adapter_impl &Adapter = DeviceImpl.getAdapter(); ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t MaxWISize[] = {0, 0, 0}; - Adapter->call( + Adapter.call( Device, UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxWISize), &MaxWISize, nullptr); for (unsigned I = 0; I < NDRDesc.Dims; I++) { @@ -371,11 +371,11 @@ void handleInvalidWorkItemSize(const device_impl &DeviceImpl, void handleInvalidValue(const device_impl &DeviceImpl, const NDRDescT &NDRDesc) { - const AdapterPtr &Adapter = DeviceImpl.getAdapter(); + adapter_impl &Adapter = DeviceImpl.getAdapter(); ur_device_handle_t Device = DeviceImpl.getHandleRef(); size_t MaxNWGs[] = {0, 0, 0}; - Adapter->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++) { @@ -452,7 +452,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.getAdapter()->checkUrResult(Error); + return DeviceImpl.getAdapter().checkUrResult(Error); // TODO: Handle other error codes diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 0d144ac47a18d..b93136dcebc0f 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -736,7 +736,7 @@ class kernel_bundle_impl device_impl &DeviceImpl = *getSyclObjImpl(Dev); bool SupportContextMemcpy = false; - DeviceImpl.getAdapter()->call( + DeviceImpl.getAdapter().call( DeviceImpl.getHandleRef(), UR_DEVICE_INFO_USM_CONTEXT_MEMCPY_SUPPORT_EXP, sizeof(SupportContextMemcpy), &SupportContextMemcpy, nullptr); diff --git a/sycl/source/detail/persistent_device_code_cache.cpp b/sycl/source/detail/persistent_device_code_cache.cpp index 36175d8a9a8ff..05ed6d118d53b 100644 --- a/sycl/source/detail/persistent_device_code_cache.cpp +++ b/sycl/source/detail/persistent_device_code_cache.cpp @@ -129,19 +129,19 @@ getProgramBinaryData(const ur_program_handle_t &NativePrg, const std::vector &Devices) { assert(!Devices.empty() && "At least one device is expected"); // We expect all devices to be from the same platform/adpater. - auto Adapter = detail::getSyclObjImpl(Devices[0])->getAdapter(); + adapter_impl &Adapter = detail::getSyclObjImpl(Devices[0])->getAdapter(); unsigned int DeviceNum = 0; - Adapter->call( + Adapter.call( NativePrg, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(DeviceNum), &DeviceNum, nullptr); std::vector URDevices(DeviceNum); - Adapter->call( + Adapter.call( NativePrg, UR_PROGRAM_INFO_DEVICES, sizeof(ur_device_handle_t) * URDevices.size(), URDevices.data(), nullptr); std::vector BinarySizes(DeviceNum); - Adapter->call( + Adapter.call( NativePrg, UR_PROGRAM_INFO_BINARY_SIZES, sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), nullptr); @@ -152,7 +152,7 @@ getProgramBinaryData(const ur_program_handle_t &NativePrg, Pointers.push_back(Binaries[I].data()); } - Adapter->call( + Adapter.call( NativePrg, UR_PROGRAM_INFO_BINARIES, sizeof(char *) * Pointers.size(), Pointers.data(), nullptr); diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index 80d60ad54c6d8..bc3c3cc6d4643 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -580,9 +580,9 @@ bool platform_impl::supports_usm() const { } ur_native_handle_t platform_impl::getNative() const { - const auto &Adapter = getAdapter(); + adapter_impl &Adapter = getAdapter(); ur_native_handle_t Handle = 0; - Adapter->call(getHandleRef(), &Handle); + Adapter.call(getHandleRef(), &Handle); return Handle; } diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index 4561a604242db..b488c52ebc5b1 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -102,17 +102,17 @@ class platform_impl : public std::enable_shared_from_this { /// Get backend option. void getBackendOption(const char *frontend_option, const char **backend_option) const { - const auto &Adapter = getAdapter(); + adapter_impl &Adapter = getAdapter(); ur_result_t Err = - Adapter->call_nocheck( + Adapter.call_nocheck( MPlatform, frontend_option, backend_option); - Adapter->checkUrResult(Err); + Adapter.checkUrResult(Err); } /// \return an instance of OpenCL cl_platform_id. cl_platform_id get() const { ur_native_handle_t nativeHandle = 0; - getAdapter()->call(MPlatform, + getAdapter().call(MPlatform, &nativeHandle); return ur::cast(nativeHandle); } @@ -136,7 +136,7 @@ class platform_impl : public std::enable_shared_from_this { static std::vector get_platforms(); // \return the Adapter associated with this platform. - const AdapterPtr &getAdapter() const { return MAdapter; } + adapter_impl &getAdapter() const { return *MAdapter; } /// Gets the native handle of the SYCL platform. /// diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index cfd23e820b37c..0e8dc084f36ad 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -583,7 +583,7 @@ static const char *getUrDeviceTarget(const char *URDeviceTarget) { static bool compatibleWithDevice(const RTDeviceBinaryImage *BinImage, const device_impl &DeviceImpl) { - auto &Adapter = DeviceImpl.getAdapter(); + adapter_impl &Adapter = DeviceImpl.getAdapter(); const ur_device_handle_t &URDeviceHandle = DeviceImpl.getHandleRef(); @@ -596,7 +596,7 @@ static bool compatibleWithDevice(const RTDeviceBinaryImage *BinImage, ur_device_binary_t UrBinary{}; UrBinary.pDeviceTargetSpec = getUrDeviceTarget(DevBin.DeviceTargetSpec); - ur_result_t Error = Adapter->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) @@ -641,7 +641,7 @@ bool ProgramManager::shouldBF16DeviceImageBeUsed( enum { DEVICELIB_FALLBACK = 0, DEVICELIB_NATIVE }; ur_bool_t NativeBF16Supported = false; ur_result_t CallSuccessful = - DeviceImpl.getAdapter()->call_nocheck( + DeviceImpl.getAdapter().call_nocheck( DeviceImpl.getHandleRef(), UR_DEVICE_INFO_BFLOAT16_CONVERSIONS_NATIVE, sizeof(ur_bool_t), &NativeBF16Supported, nullptr); @@ -3289,7 +3289,7 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( context_impl &ContextImpl = *detail::getSyclObjImpl(Context); auto Program = createURProgram(Img, ContextImpl, {Device}); detail::device_impl &DeviceImpl = *detail::getSyclObjImpl(Device); - auto &Adapter = DeviceImpl.getAdapter(); + adapter_impl &Adapter = DeviceImpl.getAdapter(); UrFuncInfo programReleaseInfo; auto programRelease = programReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary()); @@ -3306,7 +3306,7 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( /*For non SPIR-V devices DeviceLibReqdMask is always 0*/ 0, ExtraProgramsToLink); ur_kernel_handle_t UrKernel{nullptr}; - Adapter->call( + Adapter.call( BuildProgram.get(), KernelName.data(), &UrKernel); { std::lock_guard KernelIDsGuard(m_KernelIDsMutex); diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 3b90c13e9e3a1..aee8319e0f068 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -2271,7 +2271,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.getAdapter()); + Kernel, DeviceImpl.getHandleRef(), DeviceImpl.getAdapter()); if (WGSize[0] == 0) { WGSize = {1, 1, 1}; diff --git a/sycl/source/detail/ur.hpp b/sycl/source/detail/ur.hpp index efd14e6934ec6..d71fb7a9dd777 100644 --- a/sycl/source/detail/ur.hpp +++ b/sycl/source/detail/ur.hpp @@ -47,7 +47,7 @@ std::string urGetInfoString(SyclImplTy &SyclImpl, DescTy Desc) { auto &Adapter = SyclImpl.getAdapter(); size_t ResultSize = 0; auto Handle = SyclImpl.getHandleRef(); - Adapter->template call(Handle, Desc, + Adapter.template call(Handle, Desc, /*propSize=*/0, /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) @@ -59,7 +59,7 @@ std::string urGetInfoString(SyclImplTy &SyclImpl, DescTy Desc) { // UR counts null terminator in the size, std::string doesn't. Adjust by "-1" // for that. Result.resize(ResultSize - 1); - Adapter->template call(Handle, Desc, ResultSize, Result.data(), + Adapter.template call(Handle, Desc, ResultSize, Result.data(), nullptr); return Result; diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 0d50b59d42ce4..de306dc1203dd 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -220,8 +220,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 Adapter = impl->getAdapter(); - Adapter->call(Device, Peer); + detail::adapter_impl &Adapter = impl->getAdapter(); + Adapter.call(Device, Peer); } } @@ -229,8 +229,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 Adapter = impl->getAdapter(); - Adapter->call(Device, + detail::adapter_impl &Adapter = impl->getAdapter(); + Adapter.call(Device, Peer); } } @@ -254,9 +254,9 @@ bool device::ext_oneapi_can_access_peer(const device &peer, throw sycl::exception(make_error_code(errc::invalid), "Unrecognized peer access attribute."); }(); - auto Adapter = impl->getAdapter(); + detail::adapter_impl &Adapter = impl->getAdapter(); int value = 0; - Adapter->call( + Adapter.call( Device, Peer, UrAttr, sizeof(int), &value, nullptr); return value == 1; @@ -285,9 +285,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 Adapter = impl->getAdapter(); + detail::adapter_impl &Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Adapter->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; @@ -299,9 +299,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 Adapter = impl->getAdapter(); + detail::adapter_impl &Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Adapter->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; @@ -314,9 +314,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 Adapter = impl->getAdapter(); + detail::adapter_impl &Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Adapter->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; @@ -327,9 +327,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 Adapter = impl->getAdapter(); + detail::adapter_impl &Adapter = impl->getAdapter(); uint32_t ipVersion = 0; - auto res = Adapter->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/handler.cpp b/sycl/source/handler.cpp index 9c1f9068096b9..b8f431f18e6d8 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2322,7 +2322,7 @@ kernel_bundle handler::getKernelBundle() const { std::optional> handler::getMaxWorkGroups() { device_impl &DeviceImpl = impl->get_device(); std::array UrResult = {}; - auto Ret = DeviceImpl.getAdapter()->call_nocheck( + auto Ret = DeviceImpl.getAdapter().call_nocheck( DeviceImpl.getHandleRef(), UrInfoCode< ext::oneapi::experimental::info::device::max_work_groups<3>>::value, diff --git a/sycl/source/kernel_bundle.cpp b/sycl/source/kernel_bundle.cpp index 8fbeb5e98bc57..59c089a8ac95e 100644 --- a/sycl/source/kernel_bundle.cpp +++ b/sycl/source/kernel_bundle.cpp @@ -424,7 +424,7 @@ bool is_source_kernel_bundle_supported( if (DeviceImplVec.empty()) return false; - const AdapterPtr &Adapter = DeviceImplVec[0]->getAdapter(); + detail::adapter_impl &Adapter = DeviceImplVec[0]->getAdapter(); std::vector IPVersionVec; IPVersionVec.reserve(DeviceImplVec.size()); @@ -432,7 +432,7 @@ bool is_source_kernel_bundle_supported( std::back_inserter(IPVersionVec), [&](device_impl *Dev) { uint32_t ipVersion = 0; ur_device_handle_t DeviceHandle = Dev->getHandleRef(); - Adapter->call( + Adapter.call( DeviceHandle, UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); return ipVersion; From 1db1d19e8718a50c584db7db95de8fde7b2f2915 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 4 Jul 2025 23:31:48 +0200 Subject: [PATCH 6/8] Make context_impl::getAdapter() return by ref --- sycl/source/detail/async_alloc.cpp | 8 +- sycl/source/detail/context_impl.cpp | 34 +++--- sycl/source/detail/context_impl.hpp | 4 +- .../source/detail/device_global_map_entry.cpp | 4 +- sycl/source/detail/device_image_impl.cpp | 4 +- sycl/source/detail/device_image_impl.hpp | 38 +++--- sycl/source/detail/event_impl.cpp | 2 +- sycl/source/detail/graph/graph_impl.cpp | 18 +-- sycl/source/detail/graph/memory_pool.cpp | 4 +- sycl/source/detail/image_impl.cpp | 8 +- sycl/source/detail/kernel_impl.hpp | 6 +- sycl/source/detail/kernel_program_cache.cpp | 2 +- sycl/source/detail/mem_alloc_helper.hpp | 8 +- sycl/source/detail/memory_manager.cpp | 80 ++++++------- sycl/source/detail/memory_pool_impl.cpp | 32 ++--- sycl/source/detail/physical_mem_impl.hpp | 14 +-- .../program_manager/program_manager.cpp | 110 +++++++++--------- sycl/source/detail/queue_impl.hpp | 6 +- sycl/source/detail/sampler_impl.cpp | 20 ++-- sycl/source/detail/scheduler/commands.cpp | 12 +- sycl/source/detail/sycl_mem_obj_t.cpp | 2 +- sycl/source/detail/ur.cpp | 2 +- sycl/source/detail/usm/usm_impl.cpp | 10 +- sycl/source/handler.cpp | 4 +- 24 files changed, 216 insertions(+), 216 deletions(-) diff --git a/sycl/source/detail/async_alloc.cpp b/sycl/source/detail/async_alloc.cpp index 96861fa8a587c..351ebac3c2ad5 100644 --- a/sycl/source/detail/async_alloc.cpp +++ b/sycl/source/detail/async_alloc.cpp @@ -68,7 +68,7 @@ void *async_malloc(sycl::handler &h, sycl::usm::alloc kind, size_t size) { sycl::make_error_code(sycl::errc::feature_not_supported), "Only device backed asynchronous allocations are supported!"); - auto &Adapter = h.getContextImpl().getAdapter(); + detail::adapter_impl &Adapter = h.getContextImpl().getAdapter(); // Get CG event dependencies for this allocation. const auto &DepEvents = h.impl->CGData.MEvents; @@ -84,7 +84,7 @@ void *async_malloc(sycl::handler &h, sycl::usm::alloc kind, size_t size) { alloc = Graph->getMemPool().malloc(size, kind, DepNodes); } else { ur_queue_handle_t Q = h.impl->get_queue().getHandleRef(); - Adapter->call( Q, (ur_usm_pool_handle_t)0, size, nullptr, UREvents.size(), UREvents.data(), &alloc, &Event); @@ -118,7 +118,7 @@ __SYCL_EXPORT void *async_malloc(const sycl::queue &q, sycl::usm::alloc kind, __SYCL_EXPORT void *async_malloc_from_pool(sycl::handler &h, size_t size, const memory_pool &pool) { - auto &Adapter = h.getContextImpl().getAdapter(); + detail::adapter_impl &Adapter = h.getContextImpl().getAdapter(); detail::memory_pool_impl &memPoolImpl = *detail::getSyclObjImpl(pool); // Get CG event dependencies for this allocation. @@ -138,7 +138,7 @@ __SYCL_EXPORT void *async_malloc_from_pool(sycl::handler &h, size_t size, detail::getSyclObjImpl(pool).get()); } else { ur_queue_handle_t Q = h.impl->get_queue().getHandleRef(); - Adapter->call( Q, memPoolImpl.get_handle(), size, nullptr, UREvents.size(), UREvents.data(), &alloc, &Event); diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index 941f2a2e8456e..d60713a9b2b94 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -54,7 +54,7 @@ context_impl::context_impl(const std::vector Devices, DeviceIds.push_back(getSyclObjImpl(D)->getHandleRef()); } - getAdapter()->call( + getAdapter().call( DeviceIds.size(), DeviceIds.data(), nullptr, &MContext); MKernelProgramCache.setContextPtr(this); @@ -102,16 +102,16 @@ context_impl::context_impl(ur_context_handle_t UrContext, // TODO: Move this backend-specific retain of the context to SYCL-2020 style // make_context interop, when that is created. if (getBackend() == sycl::backend::opencl) { - getAdapter()->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 - getAdapter()->call(MContext); + getAdapter().call(MContext); ur_native_handle_t nativeHandle = 0; - getAdapter()->call(MContext, + getAdapter().call(MContext, &nativeHandle); return ur::cast(nativeHandle); } @@ -120,7 +120,7 @@ context_impl::~context_impl() { try { // Free all events associated with the initialization of device globals. for (auto &DeviceGlobalInitializer : MDeviceGlobalInitializers) - DeviceGlobalInitializer.second.ClearEvents(getAdapter()); + DeviceGlobalInitializer.second.ClearEvents(&getAdapter()); // Free all device_global USM allocations associated with this context. for (const void *DeviceGlobal : MAssociatedDeviceGlobals) { DeviceGlobalMapEntry *DGEntry = @@ -130,10 +130,10 @@ context_impl::~context_impl() { } for (auto LibProg : MCachedLibPrograms) { assert(LibProg.second && "Null program must not be kept in the cache"); - getAdapter()->call(LibProg.second); + getAdapter().call(LibProg.second); } // TODO catch an exception and put it to list of asynchronous exceptions - getAdapter()->call_nocheck(MContext); + getAdapter().call_nocheck(MContext); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~context_impl", e); } @@ -146,7 +146,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->getAdapter()); + &this->getAdapter()); } template <> platform context_impl::get_info() const { return createSyclObjFromImpl(*MPlatform); @@ -292,9 +292,9 @@ context_impl::findMatchingDeviceImpl(ur_device_handle_t &DeviceUR) const { } ur_native_handle_t context_impl::getNative() const { - const auto &Adapter = getAdapter(); + detail::adapter_impl &Adapter = getAdapter(); ur_native_handle_t Handle; - Adapter->call(getHandleRef(), &Handle); + Adapter.call(getHandleRef(), &Handle); if (getBackend() == backend::opencl) { __SYCL_OCL_CALL(clRetainContext, ur::cast(Handle)); } @@ -345,7 +345,7 @@ std::vector context_impl::initializeDeviceGlobals( if (!MDeviceGlobalNotInitializedCnt.load(std::memory_order_acquire)) return {}; - const AdapterPtr &Adapter = getAdapter(); + detail::adapter_impl &Adapter = getAdapter(); device_impl &DeviceImpl = QueueImpl.getDeviceImpl(); std::lock_guard NativeProgramLock(MDeviceGlobalInitializersMutex); auto ImgIt = MDeviceGlobalInitializers.find( @@ -365,11 +365,11 @@ std::vector context_impl::initializeDeviceGlobals( InitEventsRef.begin(), InitEventsRef.end(), [&Adapter](const ur_event_handle_t &Event) { return get_event_info( - Event, *Adapter) == info::event_command_status::complete; + Event, Adapter) == info::event_command_status::complete; }); // Release the removed events. for (auto EventIt = NewEnd; EventIt != InitEventsRef.end(); ++EventIt) - Adapter->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. @@ -431,14 +431,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(*Adapter)) + 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(); - Adapter->call( + Adapter.call( QueueImpl.getHandleRef(), NativePrg, DeviceGlobalEntry->MUniqueId.c_str(), false, sizeof(void *), 0, &USMPtr, 0, nullptr, &InitEvent); @@ -577,7 +577,7 @@ context_impl::get_default_memory_pool(const context &Context, detail::device_impl &DevImpl = *detail::getSyclObjImpl(Device); ur_device_handle_t DeviceHandle = DevImpl.getHandleRef(); - const sycl::detail::AdapterPtr &Adapter = this->getAdapter(); + detail::adapter_impl &Adapter = this->getAdapter(); // Check dev is already in our list of device pool pairs. if (auto it = std::find_if(MMemPoolImplPtrs.begin(), MMemPoolImplPtrs.end(), @@ -590,7 +590,7 @@ context_impl::get_default_memory_pool(const context &Context, // The memory_pool_impl does not exist for this device yet. ur_usm_pool_handle_t PoolHandle; - Adapter->call( this->getHandleRef(), DeviceHandle, &PoolHandle); diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 819b3c10a7efd..22f56de9a7833 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -94,7 +94,7 @@ class context_impl : public std::enable_shared_from_this { const async_handler &get_async_handler() const; /// \return the Adapter associated with the platform of this context. - const AdapterPtr &getAdapter() const { return MPlatform->getAdapter(); } + adapter_impl &getAdapter() const { return *MPlatform->getAdapter(); } /// \return the PlatformImpl associated with this context. platform_impl &getPlatformImpl() const { return *MPlatform; } @@ -367,7 +367,7 @@ void GetCapabilitiesIntersectionSet(const std::vector &Devices, // convenient to be able to reference them without extra `detail::`. inline auto get_ur_handles(sycl::detail::context_impl &Ctx) { ur_context_handle_t urCtx = Ctx.getHandleRef(); - return std::tuple{urCtx, Ctx.getAdapter()}; + return std::tuple{urCtx, &Ctx.getAdapter()}; } inline auto get_ur_handles(const sycl::context &syclContext) { return get_ur_handles(*sycl::detail::getSyclObjImpl(syclContext)); diff --git a/sycl/source/detail/device_global_map_entry.cpp b/sycl/source/detail/device_global_map_entry.cpp index 907a54d3fb2db..2b036aa1b72d2 100644 --- a/sycl/source/detail/device_global_map_entry.cpp +++ b/sycl/source/detail/device_global_map_entry.cpp @@ -160,7 +160,7 @@ void DeviceGlobalMapEntry::removeAssociatedResources( DeviceGlobalUSMMem &USMMem = USMPtrIt->second; detail::usm::freeInternal(USMMem.MPtr, CtxImpl); if (USMMem.MInitEvent.has_value()) - CtxImpl->getAdapter()->call( + CtxImpl->getAdapter().call( *USMMem.MInitEvent); #ifndef NDEBUG // For debugging we set the event and memory to some recognizable values @@ -185,7 +185,7 @@ void DeviceGlobalMapEntry::cleanup() { DeviceGlobalUSMMem &USMMem = USMPtrIt.second; detail::usm::freeInternal(USMMem.MPtr, CtxImpl); if (USMMem.MInitEvent.has_value()) - CtxImpl->getAdapter()->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_image_impl.cpp b/sycl/source/detail/device_image_impl.cpp index ea0935935dbaa..878027119f4a8 100644 --- a/sycl/source/detail/device_image_impl.cpp +++ b/sycl/source/detail/device_image_impl.cpp @@ -42,9 +42,9 @@ std::shared_ptr device_image_impl::tryGetExtensionKernel( } ur_program_handle_t UrProgram = get_ur_program_ref(); - const AdapterPtr &Adapter = getSyclObjImpl(Context)->getAdapter(); + detail::adapter_impl &Adapter = getSyclObjImpl(Context)->getAdapter(); ur_kernel_handle_t UrKernel = nullptr; - Adapter->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/device_image_impl.hpp b/sycl/source/detail/device_image_impl.hpp index 60f75e3e97d18..6c47082f7cd9a 100644 --- a/sycl/source/detail/device_image_impl.hpp +++ b/sycl/source/detail/device_image_impl.hpp @@ -573,7 +573,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 AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); + adapter_impl &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 @@ -605,10 +605,10 @@ class device_image_impl ur_native_handle_t getNative() const { assert(MProgram); context_impl &ContextImpl = *detail::getSyclObjImpl(MContext); - const AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); ur_native_handle_t NativeProgram = 0; - Adapter->call(MProgram, + Adapter.call(MProgram, &NativeProgram); if (ContextImpl.getBackend() == backend::opencl) __SYCL_OCL_CALL(clRetainProgram, ur::cast(NativeProgram)); @@ -619,12 +619,12 @@ class device_image_impl ~device_image_impl() { try { if (MProgram) { - const AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); - Adapter->call(MProgram); + adapter_impl &Adapter = getSyclObjImpl(MContext)->getAdapter(); + Adapter.call(MProgram); } if (MSpecConstsBuffer) { std::lock_guard Lock{MSpecConstAccessMtx}; - const AdapterPtr &Adapter = getSyclObjImpl(MContext)->getAdapter(); + adapter_impl &Adapter = getSyclObjImpl(MContext)->getAdapter(); memReleaseHelper(Adapter, MSpecConstsBuffer); } } catch (std::exception &e) { @@ -779,23 +779,23 @@ class device_image_impl Devices, BuildOptions, *SourceStrPtr, UrProgram); } - const AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); if (!FetchedFromCache) UrProgram = createProgramFromSource(Devices, BuildOptions, LogPtr); std::string XsFlags = extractXsFlags(BuildOptions, MRTCBinInfo->MLanguage); - auto Res = Adapter->call_nocheck( + auto Res = Adapter.call_nocheck( UrProgram, DeviceVec.size(), DeviceVec.data(), XsFlags.c_str()); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Adapter->call_nocheck( + Res = Adapter.call_nocheck( ContextImpl.getHandleRef(), UrProgram, XsFlags.c_str()); } - Adapter->checkUrResult(Res); + Adapter.checkUrResult(Res); // Get the number of kernels in the program. size_t NumKernels; - Adapter->call( + Adapter.call( UrProgram, UR_PROGRAM_INFO_NUM_KERNELS, sizeof(size_t), &NumKernels, nullptr); @@ -912,7 +912,7 @@ class device_image_impl const std::vector &BuildOptions, const std::string &SourceStr, ur_program_handle_t &UrProgram) const { sycl::detail::context_impl &ContextImpl = *getSyclObjImpl(MContext); - const AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); std::string UserArgs = syclex::detail::userArgsAsString(BuildOptions); @@ -940,7 +940,7 @@ class device_image_impl Properties.count = 0; Properties.pMetadatas = nullptr; - Adapter->call( + Adapter.call( ContextImpl.getHandleRef(), DeviceHandles.size(), DeviceHandles.data(), Lengths.data(), Binaries.data(), &Properties, &UrProgram); @@ -1235,7 +1235,7 @@ class device_image_impl const std::vector &Options, std::string *LogPtr) const { sycl::detail::context_impl &ContextImpl = *getSyclObjImpl(MContext); - const AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); const auto spirv = [&]() -> std::vector { switch (MRTCBinInfo->MLanguage) { case syclex::source_language::opencl: { @@ -1246,7 +1246,7 @@ class device_image_impl std::transform(Devices.begin(), Devices.end(), IPVersionVec.begin(), [&](const sycl::device &SyclDev) { uint32_t ipVersion = 0; - Adapter->call( + Adapter.call( getSyclObjImpl(SyclDev)->getHandleRef(), UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t), &ipVersion, nullptr); @@ -1272,7 +1272,7 @@ class device_image_impl }(); ur_program_handle_t UrProgram = nullptr; - Adapter->call(ContextImpl.getHandleRef(), + Adapter.call(ContextImpl.getHandleRef(), spirv.data(), spirv.size(), nullptr, &UrProgram); // program created by urProgramCreateWithIL is implicitly retained. @@ -1285,16 +1285,16 @@ class device_image_impl } static std::vector - getKernelNamesFromURProgram(const AdapterPtr &Adapter, + getKernelNamesFromURProgram(adapter_impl &Adapter, ur_program_handle_t UrProgram) { // Get the kernel names. size_t KernelNamesSize; - Adapter->call( + Adapter.call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, 0, nullptr, &KernelNamesSize); // semi-colon delimited list of kernel names. std::string KernelNamesStr(KernelNamesSize, ' '); - Adapter->call( + Adapter.call( UrProgram, UR_PROGRAM_INFO_KERNEL_NAMES, KernelNamesStr.size(), &KernelNamesStr[0], nullptr); return detail::split_string(KernelNamesStr, ';'); diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index da740354c9f7c..e98013ec5b1bf 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -150,7 +150,7 @@ context_impl &event_impl::getContextImpl() { adapter_impl &event_impl::getAdapter() { initContextIfNeeded(); - return *MContext->getAdapter(); + return MContext->getAdapter(); } void event_impl::setStateIncomplete() { MState = HES_NotComplete; } diff --git a/sycl/source/detail/graph/graph_impl.cpp b/sycl/source/detail/graph/graph_impl.cpp index a24e6c7f7843e..b6b898726d3a3 100644 --- a/sycl/source/detail/graph/graph_impl.cpp +++ b/sycl/source/detail/graph/graph_impl.cpp @@ -906,10 +906,10 @@ void exec_graph_impl::createCommandBuffers( UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, MIsUpdatable, Partition->MIsInOrderGraph && !MEnableProfiling, MEnableProfiling}; context_impl &ContextImpl = *sycl::detail::getSyclObjImpl(MContext); - const sycl::detail::AdapterPtr &Adapter = ContextImpl.getAdapter(); + sycl::detail::adapter_impl &Adapter = ContextImpl.getAdapter(); sycl::detail::device_impl &DeviceImpl = *sycl::detail::getSyclObjImpl(Device); ur_result_t Res = - Adapter->call_nocheck( + Adapter.call_nocheck( ContextImpl.getHandleRef(), DeviceImpl.getHandleRef(), &Desc, &OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { @@ -941,7 +941,7 @@ void exec_graph_impl::createCommandBuffers( } Res = Adapter - ->call_nocheck( + .call_nocheck( OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { throw sycl::exception(errc::invalid, @@ -982,7 +982,7 @@ exec_graph_impl::~exec_graph_impl() { try { MGraphImpl->markExecGraphDestroyed(); - const sycl::detail::AdapterPtr &Adapter = + sycl::detail::adapter_impl &Adapter = sycl::detail::getSyclObjImpl(MContext)->getAdapter(); MSchedule.clear(); @@ -993,7 +993,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 = Adapter->call_nocheck< + ur_result_t Res = Adapter.call_nocheck< sycl::detail::UrApiKind::urCommandBufferReleaseExp>(CmdBuf); (void)Res; assert(Res == UR_RESULT_SUCCESS); @@ -1636,7 +1636,7 @@ void exec_graph_impl::populateURKernelUpdateStructs( ur_exp_command_buffer_update_kernel_launch_desc_t &UpdateDesc) const { sycl::detail::context_impl &ContextImpl = *sycl::detail::getSyclObjImpl(MContext); - const sycl::detail::AdapterPtr &Adapter = ContextImpl.getAdapter(); + sycl::detail::adapter_impl &Adapter = ContextImpl.getAdapter(); sycl::detail::device_impl &DeviceImpl = *sycl::detail::getSyclObjImpl(MGraphImpl->getDevice()); @@ -1689,7 +1689,7 @@ void exec_graph_impl::populateURKernelUpdateStructs( if (NDRDesc.LocalSize[0] != 0) LocalSize = &NDRDesc.LocalSize[0]; else { - Adapter->call( + Adapter.call( UrKernel, DeviceImpl.getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -1884,8 +1884,8 @@ void exec_graph_impl::updateURImpl( } context_impl &ContextImpl = *sycl::detail::getSyclObjImpl(MContext); - const sycl::detail::AdapterPtr &Adapter = ContextImpl.getAdapter(); - Adapter->call( + sycl::detail::adapter_impl &Adapter = ContextImpl.getAdapter(); + Adapter.call( CommandBuffer, UpdateDescList.size(), UpdateDescList.data()); } diff --git a/sycl/source/detail/graph/memory_pool.cpp b/sycl/source/detail/graph/memory_pool.cpp index fdbf90df56bee..fbe5fa636b359 100644 --- a/sycl/source/detail/graph/memory_pool.cpp +++ b/sycl/source/detail/graph/memory_pool.cpp @@ -42,7 +42,7 @@ graph_mem_pool::malloc(size_t Size, usm::alloc AllocType, case usm::alloc::device: { context_impl &CtxImpl = *getSyclObjImpl(MContext); - auto &Adapter = CtxImpl.getAdapter(); + adapter_impl &Adapter = CtxImpl.getAdapter(); size_t Granularity = get_mem_granularity(MDevice, MContext); uintptr_t StartPtr = 0; @@ -58,7 +58,7 @@ graph_mem_pool::malloc(size_t Size, usm::alloc AllocType, } // If no allocation could be reused, do a new virtual reservation - Adapter->call( CtxImpl.getHandleRef(), reinterpret_cast(StartPtr), AlignedSize, &Alloc); diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index 47dce9d800dfd..62f38c09fbb1d 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(context_impl &Context, ur_image_info_t Info, T &Dest, ur_mem_handle_t InteropMemObject) { - const AdapterPtr &Adapter = Context.getAdapter(); - Adapter->call(InteropMemObject, Info, sizeof(T), + adapter_impl &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); detail::context_impl &Context = *getSyclObjImpl(SyclContext); - const AdapterPtr &Adapter = Context.getAdapter(); - Adapter->call(Mem, UR_MEM_INFO_SIZE, sizeof(size_t), + adapter_impl &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_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 5a57f1b14fde4..75df485c528d7 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -81,7 +81,7 @@ class kernel_impl { return ur::cast(nativeHandle); } - const AdapterPtr &getAdapter() const { return MContext->getAdapter(); } + const AdapterPtr &getAdapter() const { return &MContext->getAdapter(); } /// Query information from the kernel object using the info::kernel_info /// descriptor. @@ -216,10 +216,10 @@ class kernel_impl { const DeviceImageImplPtr &getDeviceImage() const { return MDeviceImageImpl; } ur_native_handle_t getNative() const { - const AdapterPtr &Adapter = MContext->getAdapter(); + adapter_impl &Adapter = MContext->getAdapter(); ur_native_handle_t NativeKernel = 0; - Adapter->call(MKernel, &NativeKernel); + Adapter.call(MKernel, &NativeKernel); if (MContext->getBackend() == backend::opencl) __SYCL_OCL_CALL(clRetainKernel, ur::cast(NativeKernel)); diff --git a/sycl/source/detail/kernel_program_cache.cpp b/sycl/source/detail/kernel_program_cache.cpp index 46b0685c3545b..33946dcfa66ab 100644 --- a/sycl/source/detail/kernel_program_cache.cpp +++ b/sycl/source/detail/kernel_program_cache.cpp @@ -13,7 +13,7 @@ namespace sycl { inline namespace _V1 { namespace detail { const adapter_impl &KernelProgramCache::getAdapter() { - return *(MParentContext->getAdapter()); + return MParentContext->getAdapter(); } ur_context_handle_t KernelProgramCache::getURContext() const { diff --git a/sycl/source/detail/mem_alloc_helper.hpp b/sycl/source/detail/mem_alloc_helper.hpp index 88e4d742fcec6..ad227cad702e9 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 AdapterPtr &Adapter, ur_context_handle_t Ctx, +void memBufferCreateHelper(adapter_impl &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 AdapterPtr &Adapter, ur_mem_handle_t Mem); -void memBufferMapHelper(const AdapterPtr &Adapter, +void memReleaseHelper(adapter_impl &Adapter, ur_mem_handle_t Mem); +void memBufferMapHelper(adapter_impl &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 AdapterPtr &Adapter, ur_queue_handle_t command_queue, +void memUnmapHelper(adapter_impl &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 077cd918decb9..fee79dc30761b 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -133,7 +133,7 @@ static void waitForEvents(const std::vector &Events) { } } -void memBufferCreateHelper(const AdapterPtr &Adapter, ur_context_handle_t Ctx, +void memBufferCreateHelper(adapter_impl &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 AdapterPtr &Adapter, 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. - Adapter->call_nocheck( + Adapter.call_nocheck( *RetMem, /*Dev*/ nullptr, &Ptr); emitMemAllocEndTrace(MemObjID, (uintptr_t)(Ptr), Size, 0 /* guard zone */, CorrID); }}; #endif if (Size) - Adapter->call(Ctx, Flags, Size, Props, + Adapter.call(Ctx, Flags, Size, Props, RetMem); } } -void memReleaseHelper(const AdapterPtr &Adapter, ur_mem_handle_t Mem) { +void memReleaseHelper(adapter_impl &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 AdapterPtr &Adapter, 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. - Adapter->call_nocheck(Mem, /*Dev*/ nullptr, + Adapter.call_nocheck(Mem, /*Dev*/ nullptr, &PtrHandle); Ptr = (uintptr_t)(PtrHandle); } @@ -194,7 +194,7 @@ void memReleaseHelper(const AdapterPtr &Adapter, ur_mem_handle_t Mem) { xpti::utils::finally _{ [&] { emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; #endif - Adapter->call(Mem); + Adapter.call(Mem); } } @@ -275,7 +275,7 @@ void MemoryManager::releaseMemObj(context_impl *TargetContext, return; } - const AdapterPtr &Adapter = TargetContext->getAdapter(); + adapter_impl &Adapter = TargetContext->getAdapter(); memReleaseHelper(Adapter, ur::cast(MemAllocation)); } @@ -343,8 +343,8 @@ void *MemoryManager::allocateImageObject(context_impl *TargetContext, getMemObjCreationFlags(UserPtr, HostPtrReadOnly); ur_mem_handle_t NewMem = nullptr; - const AdapterPtr &Adapter = TargetContext->getAdapter(); - Adapter->call(TargetContext->getHandleRef(), + adapter_impl &Adapter = TargetContext->getAdapter(); + Adapter.call(TargetContext->getHandleRef(), CreationFlags, &Format, &Desc, UserPtr, &NewMem); return NewMem; @@ -361,7 +361,7 @@ MemoryManager::allocateBufferObject(context_impl *TargetContext, void *UserPtr, CreationFlags |= UR_MEM_FLAG_ALLOC_HOST_POINTER; ur_mem_handle_t NewMem = nullptr; - const AdapterPtr &Adapter = TargetContext->getAdapter(); + adapter_impl &Adapter = TargetContext->getAdapter(); ur_buffer_properties_t AllocProps = {UR_STRUCTURE_TYPE_BUFFER_PROPERTIES, nullptr, UserPtr}; @@ -448,8 +448,8 @@ void *MemoryManager::allocateMemSubBuffer(context_impl *TargetContext, ur_buffer_region_t Region = {UR_STRUCTURE_TYPE_BUFFER_REGION, nullptr, Offset, SizeInBytes}; ur_mem_handle_t NewMem; - const AdapterPtr &Adapter = TargetContext->getAdapter(); - Error = Adapter->call_nocheck( + adapter_impl &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(context_impl *TargetContext, "a multiple of the memory base address alignment"), Error); - Adapter->checkUrResult(Error); + Adapter.checkUrResult(Error); return NewMem; } @@ -896,8 +896,8 @@ void MemoryManager::context_copy_usm(const void *SrcMem, context_impl *Context, if (!SrcMem || !DstMem) throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory copy operation."); - const AdapterPtr &Adapter = Context->getAdapter(); - Adapter->call(Context->getHandleRef(), + adapter_impl &Adapter = Context->getAdapter(); + Adapter.call(Context->getHandleRef(), DstMem, SrcMem, Len); } @@ -1241,7 +1241,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( assert(SYCLMemObj && "The SYCLMemObj is nullptr"); (void)DstAccessRange; - const AdapterPtr &Adapter = Context->getAdapter(); + adapter_impl &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1260,7 +1260,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( } if (1 == DimDst && 1 == DimSrc) { - Adapter->call( + Adapter.call( CommandBuffer, sycl::detail::ur::cast(SrcMem), sycl::detail::ur::cast(DstMem), SrcXOffBytes, DstXOffBytes, SrcAccessRangeWidthBytes, Deps.size(), Deps.data(), 0, @@ -1286,7 +1286,7 @@ void MemoryManager::ext_oneapi_copyD2D_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - Adapter->call( + Adapter.call( CommandBuffer, sycl::detail::ur::cast(SrcMem), sycl::detail::ur::cast(DstMem), SrcOrigin, DstOrigin, Region, SrcRowPitch, SrcSlicePitch, DstRowPitch, DstSlicePitch, @@ -1305,7 +1305,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const AdapterPtr &Adapter = Context->getAdapter(); + adapter_impl &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1325,7 +1325,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( if (1 == DimDst && 1 == DimSrc) { ur_result_t Result = - Adapter->call_nocheck( + Adapter.call_nocheck( CommandBuffer, sycl::detail::ur::cast(SrcMem), SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes, Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, @@ -1336,7 +1336,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 { - Adapter->checkUrResult(Result); + Adapter.checkUrResult(Result); } } else { size_t BufferRowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes; @@ -1354,7 +1354,7 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - ur_result_t Result = Adapter->call_nocheck< + ur_result_t Result = Adapter.call_nocheck< UrApiKind::urCommandBufferAppendMemBufferReadRectExp>( CommandBuffer, sycl::detail::ur::cast(SrcMem), BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, @@ -1365,7 +1365,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 { - Adapter->checkUrResult(Result); + Adapter.checkUrResult(Result); } } } @@ -1381,7 +1381,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const AdapterPtr &Adapter = Context->getAdapter(); + adapter_impl &Adapter = Context->getAdapter(); detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType(); TermPositions SrcPos, DstPos; @@ -1402,7 +1402,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( if (1 == DimDst && 1 == DimSrc) { ur_result_t Result = Adapter - ->call_nocheck( + .call_nocheck( CommandBuffer, sycl::detail::ur::cast(DstMem), DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, @@ -1413,7 +1413,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 { - Adapter->checkUrResult(Result); + Adapter.checkUrResult(Result); } } else { size_t BufferRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes; @@ -1431,7 +1431,7 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( DstAccessRange[DstPos.YTerm], DstAccessRange[DstPos.ZTerm]}; - ur_result_t Result = Adapter->call_nocheck< + ur_result_t Result = Adapter.call_nocheck< UrApiKind::urCommandBufferAppendMemBufferWriteRectExp>( CommandBuffer, sycl::detail::ur::cast(DstMem), BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, @@ -1443,7 +1443,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 { - Adapter->checkUrResult(Result); + Adapter.checkUrResult(Result); } } } @@ -1457,9 +1457,9 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer( throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory copy operation."); - const AdapterPtr &Adapter = Context->getAdapter(); + adapter_impl &Adapter = Context->getAdapter(); ur_result_t Result = - Adapter->call_nocheck( + Adapter.call_nocheck( CommandBuffer, DstMem, SrcMem, Len, Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, nullptr); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { @@ -1467,7 +1467,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 { - Adapter->checkUrResult(Result); + Adapter.checkUrResult(Result); } } @@ -1482,9 +1482,9 @@ void MemoryManager::ext_oneapi_fill_usm_cmd_buffer( throw exception(make_error_code(errc::invalid), "NULL pointer argument in memory fill operation."); - const AdapterPtr &Adapter = Context->getAdapter(); + adapter_impl &Adapter = Context->getAdapter(); ur_result_t Result = - Adapter->call_nocheck( + Adapter.call_nocheck( CommandBuffer, DstMem, Pattern.data(), Pattern.size(), Len, Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, nullptr); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { @@ -1492,7 +1492,7 @@ void MemoryManager::ext_oneapi_fill_usm_cmd_buffer( sycl::make_error_code(sycl::errc::feature_not_supported), "USM fill command not supported by graph backend"); } else { - Adapter->checkUrResult(Result); + Adapter.checkUrResult(Result); } } @@ -1506,7 +1506,7 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( ur_exp_command_buffer_sync_point_t *OutSyncPoint) { assert(SYCLMemObj && "The SYCLMemObj is nullptr"); - const AdapterPtr &Adapter = Context->getAdapter(); + adapter_impl &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"); @@ -1521,7 +1521,7 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer( size_t RangeMultiplier = AccessRange[0] * AccessRange[1] * AccessRange[2]; if (RangesUsable && OffsetUsable) { - Adapter->call( + Adapter.call( CommandBuffer, ur::cast(Mem), Pattern, PatternSize, AccessOffset[0] * ElementSize, RangeMultiplier * ElementSize, Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, nullptr); @@ -1538,8 +1538,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 AdapterPtr &Adapter = Context->getAdapter(); - Adapter->call( + adapter_impl &Adapter = Context->getAdapter(); + Adapter.call( CommandBuffer, Mem, Length, ur_usm_migration_flags_t(0), Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, nullptr); } @@ -1550,8 +1550,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 AdapterPtr &Adapter = Context->getAdapter(); - Adapter->call( + adapter_impl &Adapter = Context->getAdapter(); + Adapter.call( CommandBuffer, Mem, Length, Advice, Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, nullptr); } diff --git a/sycl/source/detail/memory_pool_impl.cpp b/sycl/source/detail/memory_pool_impl.cpp index ba200a51a5347..8f075b2e8dc15 100644 --- a/sycl/source/detail/memory_pool_impl.cpp +++ b/sycl/source/detail/memory_pool_impl.cpp @@ -100,11 +100,11 @@ memory_pool_impl::~memory_pool_impl() { } size_t memory_pool_impl::get_threshold() const { - const sycl::detail::AdapterPtr &Adapter = MContextImplPtr->getAdapter(); + detail::adapter_impl &Adapter = MContextImplPtr->getAdapter(); size_t threshold = 0; Adapter - ->call( + .call( MPoolHandle, UR_USM_POOL_INFO_RELEASE_THRESHOLD_EXP, &threshold, nullptr); @@ -112,11 +112,11 @@ size_t memory_pool_impl::get_threshold() const { } size_t memory_pool_impl::get_reserved_size_current() const { - const sycl::detail::AdapterPtr &Adapter = MContextImplPtr->getAdapter(); + detail::adapter_impl &Adapter = MContextImplPtr->getAdapter(); size_t resSizeCurrent = 0; Adapter - ->call( + .call( MPoolHandle, UR_USM_POOL_INFO_RESERVED_CURRENT_EXP, &resSizeCurrent, nullptr); @@ -124,11 +124,11 @@ size_t memory_pool_impl::get_reserved_size_current() const { } size_t memory_pool_impl::get_reserved_size_high() const { - const sycl::detail::AdapterPtr &Adapter = MContextImplPtr->getAdapter(); + detail::adapter_impl &Adapter = MContextImplPtr->getAdapter(); size_t resSizeHigh = 0; Adapter - ->call( + .call( MPoolHandle, UR_USM_POOL_INFO_RESERVED_HIGH_EXP, &resSizeHigh, nullptr); @@ -136,11 +136,11 @@ size_t memory_pool_impl::get_reserved_size_high() const { } size_t memory_pool_impl::get_used_size_current() const { - const sycl::detail::AdapterPtr &Adapter = MContextImplPtr->getAdapter(); + detail::adapter_impl &Adapter = MContextImplPtr->getAdapter(); size_t usedSizeCurrent = 0; Adapter - ->call( + .call( MPoolHandle, UR_USM_POOL_INFO_USED_CURRENT_EXP, &usedSizeCurrent, nullptr); @@ -148,41 +148,41 @@ size_t memory_pool_impl::get_used_size_current() const { } size_t memory_pool_impl::get_used_size_high() const { - const sycl::detail::AdapterPtr &Adapter = MContextImplPtr->getAdapter(); + detail::adapter_impl &Adapter = MContextImplPtr->getAdapter(); size_t usedSizeHigh = 0; Adapter - ->call( + .call( MPoolHandle, UR_USM_POOL_INFO_USED_HIGH_EXP, &usedSizeHigh, nullptr); return usedSizeHigh; } void memory_pool_impl::set_new_threshold(size_t newThreshold) { - const sycl::detail::AdapterPtr &Adapter = MContextImplPtr->getAdapter(); + detail::adapter_impl &Adapter = MContextImplPtr->getAdapter(); Adapter - ->call( + .call( MPoolHandle, UR_USM_POOL_INFO_RELEASE_THRESHOLD_EXP, &newThreshold, 8 /*uint64_t*/); } void memory_pool_impl::reset_reserved_size_high() { - const sycl::detail::AdapterPtr &Adapter = MContextImplPtr->getAdapter(); + detail::adapter_impl &Adapter = MContextImplPtr->getAdapter(); uint64_t resetVal = 0; // Reset to zero Adapter - ->call( + .call( MPoolHandle, UR_USM_POOL_INFO_RESERVED_HIGH_EXP, static_cast(&resetVal), 8 /*uint64_t*/); } void memory_pool_impl::reset_used_size_high() { - const sycl::detail::AdapterPtr &Adapter = MContextImplPtr->getAdapter(); + detail::adapter_impl &Adapter = MContextImplPtr->getAdapter(); uint64_t resetVal = 0; // Reset to zero Adapter - ->call( + .call( MPoolHandle, UR_USM_POOL_INFO_USED_HIGH_EXP, static_cast(&resetVal), 8 /*uint64_t*/); } diff --git a/sycl/source/detail/physical_mem_impl.hpp b/sycl/source/detail/physical_mem_impl.hpp index c38fcfcd339b3..e28885efcf1b3 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(DeviceImpl), MContext(getSyclObjImpl(SyclContext)), MNumBytes(NumBytes) { - const AdapterPtr &Adapter = MContext->getAdapter(); + adapter_impl &Adapter = MContext->getAdapter(); - auto Err = Adapter->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."); - Adapter->checkUrResult(Err); + Adapter.checkUrResult(Err); } ~physical_mem_impl() noexcept(false) { - const AdapterPtr &Adapter = MContext->getAdapter(); - Adapter->call(MPhysicalMem); + adapter_impl &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 AdapterPtr &Adapter = MContext->getAdapter(); + adapter_impl &Adapter = MContext->getAdapter(); void *ResultPtr = reinterpret_cast(Ptr); - Adapter->call(MContext->getHandleRef(), + Adapter.call(MContext->getHandleRef(), ResultPtr, NumBytes, MPhysicalMem, Offset, AccessFlags); return ResultPtr; diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index cfd23e820b37c..773a4ca33b67d 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -56,12 +56,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 AdapterPtr &Adapter) { + adapter_impl &Adapter) { if (SYCLConfig::get() != nullptr) { constexpr char SpecValue = 1; ur_specialization_constant_info_t SpecConstInfo = { ITTSpecConstId, sizeof(char), &SpecValue}; - Adapter->call( + Adapter.call( Prog, 1, &SpecConstInfo); } } @@ -74,7 +74,7 @@ static ur_program_handle_t createBinaryProgram(context_impl &Context, const std::vector &Devices, const uint8_t **Binaries, size_t *Lengths, const std::vector &Metadata) { - const AdapterPtr &Adapter = Context.getAdapter(); + adapter_impl &Adapter = Context.getAdapter(); ur_program_handle_t Program; std::vector DeviceHandles; std::transform( @@ -88,7 +88,7 @@ createBinaryProgram(context_impl &Context, const std::vector &Devices, Properties.pMetadatas = Metadata.data(); assert(Devices.size() > 0 && "No devices provided for program creation"); - Adapter->call( + Adapter.call( Context.getHandleRef(), DeviceHandles.size(), DeviceHandles.data(), Lengths, Binaries, &Properties, &Program); if (BinaryStatus != UR_RESULT_SUCCESS) { @@ -105,8 +105,8 @@ static ur_program_handle_t createSpirvProgram(context_impl &Context, const unsigned char *Data, size_t DataLen) { ur_program_handle_t Program = nullptr; - const AdapterPtr &Adapter = Context.getAdapter(); - Adapter->call(Context.getHandleRef(), Data, + adapter_impl &Adapter = Context.getAdapter(); + Adapter.call(Context.getHandleRef(), Data, DataLen, nullptr, &Program); return Program; } @@ -337,7 +337,7 @@ appendCompileOptionsForGRFSizeProperties(std::string &CompileOpts, static void appendCompileOptionsFromImage(std::string &CompileOpts, const RTDeviceBinaryImage &Img, const std::vector &Devs, - const AdapterPtr &) { + adapter_impl &) { // 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. @@ -481,7 +481,7 @@ static void applyOptionsFromImage(std::string &CompileOpts, std::string &LinkOpts, const RTDeviceBinaryImage &Img, const std::vector &Devices, - const AdapterPtr &Adapter) { + adapter_impl &Adapter) { appendCompileOptionsFromImage(CompileOpts, Img, Devices, Adapter); appendLinkOptionsFromImage(LinkOpts, Img); } @@ -837,7 +837,7 @@ ProgramManager::collectDependentDeviceImagesForVirtualFunctions( static void setSpecializationConstants(device_image_impl &InputImpl, ur_program_handle_t Prog, - const AdapterPtr &Adapter) { + adapter_impl &Adapter) { std::lock_guard Lock{InputImpl.get_spec_const_data_lock()}; const std::map> &SpecConstData = InputImpl.get_spec_const_data_ref(); @@ -851,7 +851,7 @@ static void setSpecializationConstants(device_image_impl &InputImpl, ur_specialization_constant_info_t SpecConstInfo = { SpecIDDesc.ID, SpecIDDesc.Size, SpecConsts.data() + SpecIDDesc.BlobOffset}; - Adapter->call( + Adapter.call( Prog, 1, &SpecConstInfo); } } @@ -879,7 +879,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( RootDevImpl = &ParentDev; } - ContextImpl.getAdapter()->call( + ContextImpl.getAdapter().call( RootDevImpl->getHandleRef(), UR_DEVICE_INFO_BUILD_ON_SUBDEVICE, sizeof(ur_bool_t), &MustBuildOnSubdevice, nullptr); } @@ -921,7 +921,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( applyOptionsFromEnvironment(CompileOpts, LinkOpts); auto BuildF = [this, &ImgWithDeps, &DevImgWithDeps, &ContextImpl, &Devs, &CompileOpts, &LinkOpts, &SpecConsts] { - const AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); const RTDeviceBinaryImage &MainImg = *ImgWithDeps.getMain(); applyOptionsFromImage(CompileOpts, LinkOpts, MainImg, Devs, Adapter); // Should always come last! @@ -995,7 +995,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( // Those extra programs won't be used anymore, just the final linked result for (ur_program_handle_t Prg : ProgramsToLink) - Adapter->call(Prg); + Adapter.call(Prg); emitBuiltProgramInfo(BuiltProgram.get(), ContextImpl); { @@ -1056,7 +1056,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( // Here we have multiple devices a program is built for, so add the program to // the cache for all subsets of provided list of devices. - const AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); // If we linked any extra device images, then we need to // cache them as well. auto CacheLinkedImages = [&Adapter, &Cache, &CacheKey, &ResProgram, @@ -1072,7 +1072,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( if (DidInsert) { // For every cached copy of the program, we need to increment its // refcount - Adapter->call(ResProgram); + Adapter.call(ResProgram); } } }; @@ -1105,7 +1105,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( if (DidInsert) { // For every cached copy of the program, we need to increment its // refcount - Adapter->call(ResProgram); + Adapter.call(ResProgram); } CacheLinkedImages(); // getOrBuild is not supposed to return nullptr @@ -1117,7 +1117,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. - Adapter->call(ResProgram); + Adapter.call(ResProgram); return ResProgram; } @@ -1150,8 +1150,8 @@ FastKernelCacheValPtr ProgramManager::getOrCreateKernel( auto BuildF = [this, &Program, &KernelName, &ContextImpl] { ur_kernel_handle_t Kernel = nullptr; - const AdapterPtr &Adapter = ContextImpl.getAdapter(); - Adapter->call( + adapter_impl &Adapter = ContextImpl.getAdapter(); + Adapter.call( Program, KernelName.data(), &Kernel); // Only set UR_USM_INDIRECT_ACCESS if the platform can handle it. @@ -1159,7 +1159,7 @@ FastKernelCacheValPtr ProgramManager::getOrCreateKernel( // 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; - Adapter->call( + Adapter.call( Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &UrTrue); } @@ -1180,7 +1180,7 @@ FastKernelCacheValPtr ProgramManager::getOrCreateKernel( // nullptr for the mutex. auto [Kernel, ArgMask] = BuildF(); return std::make_shared( - Kernel, nullptr, ArgMask, Program, *ContextImpl.getAdapter()); + Kernel, nullptr, ArgMask, Program, ContextImpl.getAdapter()); } auto BuildResult = Cache.getOrBuild(GetCachedBuildF, BuildF); @@ -1189,12 +1189,12 @@ FastKernelCacheValPtr ProgramManager::getOrCreateKernel( const KernelArgMaskPairT &KernelArgMaskPair = BuildResult->Val; auto ret_val = std::make_shared( KernelArgMaskPair.first, &(BuildResult->MBuildResultMutex), - KernelArgMaskPair.second, Program, *ContextImpl.getAdapter()); + KernelArgMaskPair.second, Program, ContextImpl.getAdapter()); // If caching is enabled, one copy of the kernel handle will be // stored in FastKernelCacheVal, and one is in // KernelProgramCache::MKernelsPerProgramCache. To cover // MKernelsPerProgramCache, we need to increase the ref count of the kernel. - ContextImpl.getAdapter()->call( + ContextImpl.getAdapter().call( KernelArgMaskPair.first); Cache.saveKernel(KernelName, UrDevice, ret_val, CacheHintPtr); return ret_val; @@ -1204,8 +1204,8 @@ ur_program_handle_t ProgramManager::getUrProgramFromUrKernel(ur_kernel_handle_t Kernel, context_impl &Context) { ur_program_handle_t Program; - const AdapterPtr &Adapter = Context.getAdapter(); - Adapter->call(Kernel, UR_KERNEL_INFO_PROGRAM, + adapter_impl &Adapter = Context.getAdapter(); + Adapter.call(Kernel, UR_KERNEL_INFO_PROGRAM, sizeof(ur_program_handle_t), &Program, nullptr); return Program; @@ -1215,12 +1215,12 @@ std::string ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, context_impl &Context) { size_t URDevicesSize = 0; - const AdapterPtr &Adapter = Context.getAdapter(); - Adapter->call(Program, UR_PROGRAM_INFO_DEVICES, + adapter_impl &Adapter = Context.getAdapter(); + Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, 0, nullptr, &URDevicesSize); std::vector URDevices(URDevicesSize / sizeof(ur_device_handle_t)); - Adapter->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 " + @@ -1228,12 +1228,12 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, for (ur_device_handle_t &Device : URDevices) { std::string DeviceBuildInfoString; size_t DeviceBuildInfoStrSize = 0; - Adapter->call( + Adapter.call( Program, Device, UR_PROGRAM_BUILD_INFO_LOG, 0, nullptr, &DeviceBuildInfoStrSize); if (DeviceBuildInfoStrSize > 0) { std::vector DeviceBuildInfo(DeviceBuildInfoStrSize); - Adapter->call( + Adapter.call( Program, Device, UR_PROGRAM_BUILD_INFO_LOG, DeviceBuildInfoStrSize, DeviceBuildInfo.data(), nullptr); DeviceBuildInfoString = std::string(DeviceBuildInfo.data()); @@ -1241,11 +1241,11 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, std::string DeviceNameString; size_t DeviceNameStrSize = 0; - Adapter->call(Device, UR_DEVICE_INFO_NAME, 0, + Adapter.call(Device, UR_DEVICE_INFO_NAME, 0, nullptr, &DeviceNameStrSize); if (DeviceNameStrSize > 0) { std::vector DeviceName(DeviceNameStrSize); - Adapter->call(Device, UR_DEVICE_INFO_NAME, + Adapter.call(Device, UR_DEVICE_INFO_NAME, DeviceNameStrSize, DeviceName.data(), nullptr); DeviceNameString = std::string(DeviceName.data()); @@ -1342,16 +1342,16 @@ static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { return Ext->second; } -static ur_result_t doCompile(const AdapterPtr &Adapter, +static ur_result_t doCompile(adapter_impl &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 = Adapter->call_nocheck( + auto Result = Adapter.call_nocheck( Program, NumDevs, Devs, Opts); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - return Adapter->call_nocheck(Ctx, Program, + return Adapter.call_nocheck(Ctx, Program, Opts); } return Result; @@ -1407,7 +1407,7 @@ loadDeviceLibFallback(context_impl &Context, DeviceLibExt Extension, // Insert URProgram into the cache for all devices that we compiled it for. // Retain UR program for each record in the cache. - const AdapterPtr &Adapter = Context.getAdapter(); + adapter_impl &Adapter = Context.getAdapter(); // UR program handle is stored in the cache for each device that we compiled // it for. We have to retain UR program for each record in the cache. We need @@ -1416,7 +1416,7 @@ loadDeviceLibFallback(context_impl &Context, DeviceLibExt Extension, size_t RetainCount = IsProgramCreated ? DevicesToCompile.size() - 1 : DevicesToCompile.size(); for (size_t I = 0; I < RetainCount; ++I) - Adapter->call(URProgram); + Adapter.call(URProgram); for (auto Dev : DevicesToCompile) CachedLibPrograms[std::make_pair(Extension, Dev)] = URProgram; @@ -1543,7 +1543,7 @@ const RTDeviceBinaryImage *getBinImageFromMultiMap( uint32_t ImgInd = 0; // Ask the native runtime under the given context to choose the device image // it prefers. - ContextImpl.getAdapter()->call( + ContextImpl.getAdapter().call( DeviceImpl.getHandleRef(), UrBinaries.data(), UrBinaries.size(), &ImgInd); return DeviceFilteredImgs[ImgInd]; } @@ -1624,7 +1624,7 @@ const RTDeviceBinaryImage &ProgramManager::getDeviceImage( getUrDeviceTarget(RawImgs[BinaryCount]->DeviceTargetSpec); } - ContextImpl.getAdapter()->call( + ContextImpl.getAdapter().call( DeviceImpl.getHandleRef(), UrBinaries.data(), UrBinaries.size(), &ImgInd); ImageIterator = ImageSet.begin(); @@ -1766,15 +1766,15 @@ ProgramManager::ProgramPtr ProgramManager::build( static const char *ForceLinkEnv = std::getenv("SYCL_FORCE_LINK"); static bool ForceLink = ForceLinkEnv && (*ForceLinkEnv == '1'); - const AdapterPtr &Adapter = Context.getAdapter(); + adapter_impl &Adapter = Context.getAdapter(); if (LinkPrograms.empty() && ExtraProgramsToLink.empty() && !ForceLink) { const std::string &Options = LinkOptions.empty() ? CompileOptions : (CompileOptions + " " + LinkOptions); - ur_result_t Error = Adapter->call_nocheck( + ur_result_t Error = Adapter.call_nocheck( Program.get(), Devices.size(), Devices.data(), Options.c_str()); if (Error == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Error = Adapter->call_nocheck( + Error = Adapter.call_nocheck( Context.getHandleRef(), Program.get(), Options.c_str()); } @@ -1791,7 +1791,7 @@ ProgramManager::ProgramPtr ProgramManager::build( if (!CreatedFromBinary) { auto Res = doCompile(Adapter, Program.get(), Devices.size(), Devices.data(), Context.getHandleRef(), CompileOptions.c_str()); - Adapter->checkUrResult(Res); + Adapter.checkUrResult(Res); } LinkPrograms.push_back(Program.get()); @@ -1799,19 +1799,19 @@ ProgramManager::ProgramPtr ProgramManager::build( if (!CreatedFromBinary) { auto Res = doCompile(Adapter, Prg, Devices.size(), Devices.data(), Context.getHandleRef(), CompileOptions.c_str()); - Adapter->checkUrResult(Res); + Adapter.checkUrResult(Res); } LinkPrograms.push_back(Prg); } ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Adapter->call_nocheck( + auto Res = Adapter.call_nocheck( Context.getHandleRef(), Devices.size(), Devices.data(), LinkPrograms.size(), LinkPrograms.data(), LinkOptions.c_str(), &LinkedProg); if (Res == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { - Res = Adapter->call_nocheck( + Res = Adapter.call_nocheck( Context.getHandleRef(), LinkPrograms.size(), LinkPrograms.data(), LinkOptions.c_str(), &LinkedProg); } @@ -1837,7 +1837,7 @@ ProgramManager::ProgramPtr ProgramManager::build( getProgramBuildLog(LinkedProg, Context)), Error); } - Adapter->checkUrResult(Error); + Adapter.checkUrResult(Error); } return Program; } @@ -2861,7 +2861,7 @@ ProgramManager::compile(const DevImgPlainWithDeps &ImgWithDeps, for (const device_image_plain &DeviceImage : ImgWithDeps.getAll()) { device_image_impl &InputImpl = *getSyclObjImpl(DeviceImage); - const AdapterPtr &Adapter = + adapter_impl &Adapter = getSyclObjImpl(InputImpl.get_context())->getAdapter(); ur_program_handle_t Prog = @@ -3004,16 +3004,16 @@ ProgramManager::link(const std::vector &Imgs, appendLinkEnvironmentVariablesThatAppend(LinkOptionsStr); const context &Context = FirstImgImpl.get_context(); context_impl &ContextImpl = *getSyclObjImpl(Context); - const AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); ur_program_handle_t LinkedProg = nullptr; auto doLink = [&] { - auto Res = Adapter->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 = Adapter->call_nocheck( + Res = Adapter.call_nocheck( ContextImpl.getHandleRef(), URPrograms.size(), URPrograms.data(), LinkOptionsStr.c_str(), &LinkedProg); } @@ -3196,14 +3196,14 @@ ProgramManager::getOrCreateKernel(const context &Context, auto BuildF = [this, &Program, &KernelName, &Ctx] { ur_kernel_handle_t Kernel = nullptr; - const AdapterPtr &Adapter = Ctx.getAdapter(); - Adapter->call(Program, KernelName.data(), + adapter_impl &Adapter = Ctx.getAdapter(); + Adapter.call(Program, KernelName.data(), &Kernel); // Only set UR_USM_INDIRECT_ACCESS if the platform can handle it. if (Ctx.getPlatformImpl().supports_usm()) { bool EnableAccess = true; - Adapter->call( + Adapter.call( Kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(ur_bool_t), nullptr, &EnableAccess); } @@ -3235,7 +3235,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.getAdapter()->call(BuildResult->Val.first); + Ctx.getAdapter().call(BuildResult->Val.first); return std::make_tuple(BuildResult->Val.first, &(BuildResult->MBuildResultMutex), BuildResult->Val.second); diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 4f72df634302d..4c44befea219d 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -194,10 +194,10 @@ class queue_impl : public std::enable_shared_from_this { private_tag) : MDevice([&]() -> device_impl & { ur_device_handle_t DeviceUr{}; - const AdapterPtr &Adapter = Context.getAdapter(); + adapter_impl &Adapter = Context.getAdapter(); // TODO catch an exception and put it to list of asynchronous // exceptions - Adapter->call( + Adapter.call( UrQueue, UR_QUEUE_INFO_DEVICE, sizeof(DeviceUr), &DeviceUr, nullptr); device_impl *Device = Context.findMatchingDeviceImpl(DeviceUr); @@ -285,7 +285,7 @@ class queue_impl : public std::enable_shared_from_this { return createSyclObjFromImpl(MContext); } - adapter_impl &getAdapter() const { return *MContext->getAdapter(); } + adapter_impl &getAdapter() const { return MContext->getAdapter(); } #ifndef __INTEL_PREVIEW_BREAKING_CHANGES const std::shared_ptr &getContextImplPtr() const { diff --git a/sycl/source/detail/sampler_impl.cpp b/sycl/source/detail/sampler_impl.cpp index 4aae3821fbd8c..2a2d97bd21201 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -25,16 +25,16 @@ sampler_impl::sampler_impl(coordinate_normalization_mode normalizationMode, } sampler_impl::sampler_impl(cl_sampler clSampler, context_impl &syclContext) { - const AdapterPtr &Adapter = syclContext.getAdapter(); + adapter_impl &Adapter = syclContext.getAdapter(); ur_sampler_handle_t Sampler{}; - Adapter->call( + Adapter.call( reinterpret_cast(clSampler), syclContext.getHandleRef(), nullptr, &Sampler); MContextToSampler[syclContext.shared_from_this()] = Sampler; bool NormalizedCoords; - Adapter->call( + Adapter.call( Sampler, UR_SAMPLER_INFO_NORMALIZED_COORDS, sizeof(ur_bool_t), &NormalizedCoords, nullptr); MCoordNormMode = NormalizedCoords @@ -42,7 +42,7 @@ sampler_impl::sampler_impl(cl_sampler clSampler, context_impl &syclContext) { : coordinate_normalization_mode::unnormalized; ur_sampler_addressing_mode_t AddrMode; - Adapter->call( + Adapter.call( Sampler, UR_SAMPLER_INFO_ADDRESSING_MODE, sizeof(ur_sampler_addressing_mode_t), &AddrMode, nullptr); switch (AddrMode) { @@ -65,7 +65,7 @@ sampler_impl::sampler_impl(cl_sampler clSampler, context_impl &syclContext) { } ur_sampler_filter_mode_t FiltMode; - Adapter->call( + Adapter.call( Sampler, UR_SAMPLER_INFO_FILTER_MODE, sizeof(ur_sampler_filter_mode_t), &FiltMode, nullptr); switch (FiltMode) { @@ -85,8 +85,8 @@ sampler_impl::~sampler_impl() { for (auto &Iter : MContextToSampler) { // TODO catch an exception and add it to the list of asynchronous // exceptions - const AdapterPtr &Adapter = Iter.first->getAdapter(); - Adapter->call(Iter.second); + adapter_impl &Adapter = Iter.first->getAdapter(); + Adapter.call(Iter.second); } } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~sample_impl", e); @@ -138,16 +138,16 @@ sampler_impl::getOrCreateSampler(context_impl &ContextImpl) { ur_result_t errcode_ret = UR_RESULT_SUCCESS; ur_sampler_handle_t resultSampler = nullptr; - const AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); - errcode_ret = Adapter->call_nocheck( + errcode_ret = Adapter.call_nocheck( ContextImpl.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."); - Adapter->checkUrResult(errcode_ret); + Adapter.checkUrResult(errcode_ret); std::lock_guard Lock(MMutex); MContextToSampler[ContextImplPtr] = resultSampler; diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index aee8319e0f068..2867a39b3372b 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -541,7 +541,7 @@ void Command::waitForEvents(queue_impl *Queue, std::vector RawEvents = getUrEvents(CtxWithEvents.second); if (!RawEvents.empty()) { - CtxWithEvents.first->getAdapter()->call( + CtxWithEvents.first->getAdapter().call( RawEvents.size(), RawEvents.data()); } } @@ -2606,11 +2606,11 @@ ur_result_t enqueueImpCommandBufferKernel( AltUrKernels.push_back(AltUrKernel); } - const sycl::detail::AdapterPtr &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); auto SetFunc = [&Adapter, &UrKernel, &DeviceImageImpl, &ContextImpl, &getMemAllocationFunc](sycl::detail::ArgDesc &Arg, size_t NextTrueIndex) { - sycl::detail::SetArgBasedOnType(*Adapter, UrKernel, DeviceImageImpl.get(), + sycl::detail::SetArgBasedOnType(Adapter, UrKernel, DeviceImageImpl.get(), getMemAllocationFunc, ContextImpl, Arg, NextTrueIndex); }; @@ -2632,7 +2632,7 @@ ur_result_t enqueueImpCommandBufferKernel( if (HasLocalSize) LocalSize = &NDRDesc.LocalSize[0]; else { - Adapter->call( + Adapter.call( UrKernel, DeviceImpl.getHandleRef(), UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, sizeof(RequiredWGSize), RequiredWGSize, @@ -2649,13 +2649,13 @@ ur_result_t enqueueImpCommandBufferKernel( // we query the descriptor here to check if a handle is required. ur_exp_command_buffer_desc_t CommandBufferDesc{}; - Adapter->call( + Adapter.call( CommandBuffer, ur_exp_command_buffer_info_t::UR_EXP_COMMAND_BUFFER_INFO_DESCRIPTOR, sizeof(ur_exp_command_buffer_desc_t), &CommandBufferDesc, nullptr); ur_result_t Res = - Adapter->call_nocheck( + Adapter.call_nocheck( CommandBuffer, UrKernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0], &NDRDesc.GlobalSize[0], LocalSize, AltUrKernels.size(), AltUrKernels.size() ? AltUrKernels.data() : nullptr, diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 87fc643459b18..9e5627817c3af 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -164,7 +164,7 @@ void SYCLMemObjT::updateHostMemory() { const AdapterPtr &SYCLMemObjT::getAdapter() const { assert((MInteropContext != nullptr) && "Trying to get Adapter from SYCLMemObjT with nullptr ContextImpl."); - return (MInteropContext->getAdapter()); + return &(MInteropContext->getAdapter()); } bool SYCLMemObjT::isInterop() const { return MOpenCLInterop; } diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index 2fa9ceb7a8a09..8f003bba54348 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -50,7 +50,7 @@ void contextSetExtendedDeleter(const sycl::context &context, pi_context_extended_deleter func, void *user_data) { context_impl &Ctx = *getSyclObjImpl(context); - adapter_impl &Adapter = *Ctx.getAdapter(); + adapter_impl &Adapter = Ctx.getAdapter(); Adapter.call( Ctx.getHandleRef(), reinterpret_cast(func), user_data); diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index aa62c4756dbd2..4e6e9750c3484 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -129,7 +129,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, return nullptr; ur_context_handle_t C = CtxImpl->getHandleRef(); - const AdapterPtr &Adapter = CtxImpl->getAdapter(); + adapter_impl &Adapter = CtxImpl->getAdapter(); ur_result_t Error = UR_RESULT_ERROR_INVALID_VALUE; ur_device_handle_t Dev; @@ -155,7 +155,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDesc.pNext = &UsmLocationDesc; } - Error = Adapter->call_nocheck( + Error = Adapter.call_nocheck( C, Dev, &UsmDesc, /*pool=*/nullptr, Size, &RetVal); @@ -192,7 +192,7 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, UsmDeviceDesc.pNext = &UsmLocationDesc; } - Error = Adapter->call_nocheck( + Error = Adapter.call_nocheck( C, Dev, &UsmDesc, /*pool=*/nullptr, Size, &RetVal); @@ -249,8 +249,8 @@ void freeInternal(void *Ptr, const context_impl *CtxImpl) { if (Ptr == nullptr) return; ur_context_handle_t C = CtxImpl->getHandleRef(); - const AdapterPtr &Adapter = CtxImpl->getAdapter(); - Adapter->call(C, Ptr); + adapter_impl &Adapter = CtxImpl->getAdapter(); + Adapter.call(C, Ptr); } void free(void *Ptr, const context &Ctxt, diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 9c1f9068096b9..edda6df418f9e 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2040,9 +2040,9 @@ void handler::depends_on(const std::vector &Events) { static bool checkContextSupports(detail::context_impl &ContextImpl, ur_context_info_t InfoQuery) { - auto &Adapter = ContextImpl.getAdapter(); + adapter_impl &Adapter = ContextImpl.getAdapter(); ur_bool_t SupportsOp = false; - Adapter->call(ContextImpl.getHandleRef(), + Adapter.call(ContextImpl.getHandleRef(), InfoQuery, sizeof(ur_bool_t), &SupportsOp, nullptr); return SupportsOp; From d0030839b5aa602b03f5f7edd76e6c2727a355a3 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 4 Jul 2025 23:46:55 +0200 Subject: [PATCH 7/8] Fix merge conflict --- sycl/source/detail/context_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index fe124466458b2..6aa7ba2bc8715 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -94,7 +94,7 @@ class context_impl : public std::enable_shared_from_this { const async_handler &get_async_handler() const; /// \return the Adapter associated with the platform of this context. - adapter_impl &getAdapter() const { return *MPlatform->getAdapter(); } + adapter_impl &getAdapter() const { return MPlatform->getAdapter(); } /// \return the PlatformImpl associated with this context. platform_impl &getPlatformImpl() const { return *MPlatform; } From e3be22aa08a56d192096b0ace6f341a6dfa1b029 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 4 Jul 2025 23:47:13 +0200 Subject: [PATCH 8/8] clang format --- sycl/source/detail/async_alloc.cpp | 4 +-- sycl/source/detail/buffer_impl.cpp | 2 +- sycl/source/detail/context_impl.cpp | 4 +-- .../source/detail/device_global_map_entry.cpp | 3 +- sycl/source/detail/device_image_impl.cpp | 2 +- sycl/source/detail/device_image_impl.hpp | 7 ++-- sycl/source/detail/device_impl.cpp | 5 ++- sycl/source/detail/device_impl.hpp | 12 +++---- .../detail/error_handling/error_handling.cpp | 14 ++++---- sycl/source/detail/graph/graph_impl.cpp | 6 ++-- sycl/source/detail/graph/memory_pool.cpp | 2 +- sycl/source/detail/image_impl.cpp | 4 +-- sycl/source/detail/mem_alloc_helper.hpp | 7 ++-- sycl/source/detail/memory_manager.cpp | 35 ++++++++++--------- .../detail/persistent_device_code_cache.cpp | 6 ++-- sycl/source/detail/physical_mem_impl.hpp | 4 +-- sycl/source/detail/platform_impl.hpp | 2 +- .../program_manager/program_manager.cpp | 31 ++++++++-------- sycl/source/detail/queue_impl.hpp | 6 ++-- sycl/source/detail/ur.hpp | 6 ++-- sycl/source/device.cpp | 3 +- sycl/source/handler.cpp | 4 +-- 22 files changed, 81 insertions(+), 88 deletions(-) diff --git a/sycl/source/detail/async_alloc.cpp b/sycl/source/detail/async_alloc.cpp index 351ebac3c2ad5..29e309ccc0ca2 100644 --- a/sycl/source/detail/async_alloc.cpp +++ b/sycl/source/detail/async_alloc.cpp @@ -85,7 +85,7 @@ void *async_malloc(sycl::handler &h, sycl::usm::alloc kind, size_t size) { } else { ur_queue_handle_t Q = h.impl->get_queue().getHandleRef(); Adapter.call( + sycl::detail::UrApiKind::urEnqueueUSMDeviceAllocExp>( Q, (ur_usm_pool_handle_t)0, size, nullptr, UREvents.size(), UREvents.data(), &alloc, &Event); } @@ -139,7 +139,7 @@ __SYCL_EXPORT void *async_malloc_from_pool(sycl::handler &h, size_t size, } else { ur_queue_handle_t Q = h.impl->get_queue().getHandleRef(); Adapter.call( + sycl::detail::UrApiKind::urEnqueueUSMDeviceAllocExp>( Q, memPoolImpl.get_handle(), size, nullptr, UREvents.size(), UREvents.data(), &alloc, &Event); } diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 0e44650e2d1e2..54f0c70cf7bc1 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -89,7 +89,7 @@ buffer_impl::getNativeVector(backend BackendName) const { // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. Adapter.call(NativeMem, /*Dev*/ nullptr, - &Handle); + &Handle); Handles.push_back(Handle); if (Platform.getBackend() == backend::opencl) { diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index d60713a9b2b94..25755426ebc21 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -112,7 +112,7 @@ cl_context context_impl::get() const { getAdapter().call(MContext); ur_native_handle_t nativeHandle = 0; getAdapter().call(MContext, - &nativeHandle); + &nativeHandle); return ur::cast(nativeHandle); } @@ -591,7 +591,7 @@ context_impl::get_default_memory_pool(const context &Context, // The memory_pool_impl does not exist for this device yet. ur_usm_pool_handle_t PoolHandle; Adapter.call( + sycl::detail::UrApiKind::urUSMPoolGetDefaultDevicePoolExp>( this->getHandleRef(), DeviceHandle, &PoolHandle); auto MemPoolImplPtr = std::make_shared< diff --git a/sycl/source/detail/device_global_map_entry.cpp b/sycl/source/detail/device_global_map_entry.cpp index 2b036aa1b72d2..d79715e52c1e2 100644 --- a/sycl/source/detail/device_global_map_entry.cpp +++ b/sycl/source/detail/device_global_map_entry.cpp @@ -185,8 +185,7 @@ void DeviceGlobalMapEntry::cleanup() { DeviceGlobalUSMMem &USMMem = USMPtrIt.second; detail::usm::freeInternal(USMMem.MPtr, CtxImpl); if (USMMem.MInitEvent.has_value()) - CtxImpl->getAdapter().call( - *USMMem.MInitEvent); + CtxImpl->getAdapter().call(*USMMem.MInitEvent); #ifndef NDEBUG // For debugging we set the event and memory to some recognizable values // to allow us to check that this cleanup happens before erasure. diff --git a/sycl/source/detail/device_image_impl.cpp b/sycl/source/detail/device_image_impl.cpp index 878027119f4a8..be62bbf3bbf9b 100644 --- a/sycl/source/detail/device_image_impl.cpp +++ b/sycl/source/detail/device_image_impl.cpp @@ -45,7 +45,7 @@ std::shared_ptr device_image_impl::tryGetExtensionKernel( detail::adapter_impl &Adapter = getSyclObjImpl(Context)->getAdapter(); ur_kernel_handle_t UrKernel = nullptr; Adapter.call(UrProgram, AdjustedName.c_str(), - &UrKernel); + &UrKernel); // Kernel created by urKernelCreate is implicitly retained. const KernelArgMask *ArgMask = nullptr; diff --git a/sycl/source/detail/device_image_impl.hpp b/sycl/source/detail/device_image_impl.hpp index 6c47082f7cd9a..0cbc009cc88c7 100644 --- a/sycl/source/detail/device_image_impl.hpp +++ b/sycl/source/detail/device_image_impl.hpp @@ -608,8 +608,7 @@ class device_image_impl adapter_impl &Adapter = ContextImpl.getAdapter(); ur_native_handle_t NativeProgram = 0; - Adapter.call(MProgram, - &NativeProgram); + Adapter.call(MProgram, &NativeProgram); if (ContextImpl.getBackend() == backend::opencl) __SYCL_OCL_CALL(clRetainProgram, ur::cast(NativeProgram)); @@ -1273,8 +1272,8 @@ class device_image_impl ur_program_handle_t UrProgram = nullptr; Adapter.call(ContextImpl.getHandleRef(), - spirv.data(), spirv.size(), - nullptr, &UrProgram); + spirv.data(), spirv.size(), + nullptr, &UrProgram); // program created by urProgramCreateWithIL is implicitly retained. if (UrProgram == nullptr) throw sycl::exception( diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 7022a21a8a9dc..d3c577b774082 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -39,8 +39,7 @@ device_impl::~device_impl() { try { // TODO catch an exception and put it to list of asynchronous exceptions adapter_impl &Adapter = getAdapter(); - ur_result_t Err = - Adapter.call_nocheck(MDevice); + ur_result_t Err = Adapter.call_nocheck(MDevice); __SYCL_CHECK_UR_CODE_NO_EXC(Err, Adapter.getBackend()); } catch (std::exception &e) { __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_impl", e); @@ -297,7 +296,7 @@ std::vector device_impl::create_sub_devices() const { uint32_t SubDevicesCount = 0; adapter_impl &Adapter = getAdapter(); Adapter.call(MDevice, &Properties, 0, nullptr, - &SubDevicesCount); + &SubDevicesCount); return create_sub_devices(&Properties, SubDevicesCount); } diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 163cdd04063b5..306411cc7e3b6 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -152,9 +152,8 @@ class device_impl : public std::enable_shared_from_this { static_assert( !check_type_in_v); size_t ResultSize = 0; - ur_result_t Error = - getAdapter().call_nocheck( - getHandleRef(), Desc, 0, nullptr, &ResultSize); + ur_result_t Error = getAdapter().call_nocheck( + getHandleRef(), Desc, 0, nullptr, &ResultSize); if (Error != UR_RESULT_SUCCESS) return {Error}; if (ResultSize == 0) @@ -168,9 +167,8 @@ class device_impl : public std::enable_shared_from_this { return {Result}; } else { ur_ret_t Result; - ur_result_t Error = - getAdapter().call_nocheck( - getHandleRef(), Desc, sizeof(Result), &Result, nullptr); + ur_result_t Error = getAdapter().call_nocheck( + getHandleRef(), Desc, sizeof(Result), &Result, nullptr); if (Error == UR_RESULT_SUCCESS) return {Result}; else @@ -189,7 +187,7 @@ class device_impl : public std::enable_shared_from_this { } else if constexpr (is_std_vector_v) { size_t ResultSize = 0; getAdapter().call(getHandleRef(), Desc, 0, - nullptr, &ResultSize); + nullptr, &ResultSize); if (ResultSize == 0) return ur_ret_t{}; diff --git a/sycl/source/detail/error_handling/error_handling.cpp b/sycl/source/detail/error_handling/error_handling.cpp index 83732fbc455c1..53cd2eb84969a 100644 --- a/sycl/source/detail/error_handling/error_handling.cpp +++ b/sycl/source/detail/error_handling/error_handling.cpp @@ -40,8 +40,8 @@ void handleOutOfResources(const device_impl &DeviceImpl, adapter_impl &Adapter = DeviceImpl.getAdapter(); uint32_t NumRegisters = 0; Adapter.call(Kernel, UR_KERNEL_INFO_NUM_REGS, - sizeof(NumRegisters), - &NumRegisters, nullptr); + sizeof(NumRegisters), + &NumRegisters, nullptr); uint32_t MaxRegistersPerBlock = DeviceImpl.get_info( - Device, UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, sizeof(size_t), &MaxWGSize, - nullptr); + Adapter.call(Device, + UR_DEVICE_INFO_MAX_WORK_GROUP_SIZE, + sizeof(size_t), &MaxWGSize, nullptr); const bool HasLocalSize = (NDRDesc.LocalSize[0] != 0); @@ -376,8 +376,8 @@ void handleInvalidValue(const device_impl &DeviceImpl, size_t MaxNWGs[] = {0, 0, 0}; Adapter.call(Device, - UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, - sizeof(MaxNWGs), &MaxNWGs, nullptr); + UR_DEVICE_INFO_MAX_WORK_GROUPS_3D, + sizeof(MaxNWGs), &MaxNWGs, nullptr); for (unsigned int I = 0; I < NDRDesc.Dims; I++) { size_t NWgs = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; if (NWgs > MaxNWGs[I]) diff --git a/sycl/source/detail/graph/graph_impl.cpp b/sycl/source/detail/graph/graph_impl.cpp index b6b898726d3a3..3a3c3bd10d32d 100644 --- a/sycl/source/detail/graph/graph_impl.cpp +++ b/sycl/source/detail/graph/graph_impl.cpp @@ -940,9 +940,9 @@ void exec_graph_impl::createCommandBuffers( } } - Res = Adapter - .call_nocheck( - OutCommandBuffer); + Res = + Adapter.call_nocheck( + OutCommandBuffer); if (Res != UR_RESULT_SUCCESS) { throw sycl::exception(errc::invalid, "Failed to finalize UR command-buffer"); diff --git a/sycl/source/detail/graph/memory_pool.cpp b/sycl/source/detail/graph/memory_pool.cpp index fbe5fa636b359..e86f92bb14058 100644 --- a/sycl/source/detail/graph/memory_pool.cpp +++ b/sycl/source/detail/graph/memory_pool.cpp @@ -59,7 +59,7 @@ graph_mem_pool::malloc(size_t Size, usm::alloc AllocType, // If no allocation could be reused, do a new virtual reservation Adapter.call( + sycl::detail::UrApiKind::urVirtualMemReserve>( CtxImpl.getHandleRef(), reinterpret_cast(StartPtr), AlignedSize, &Alloc); diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index 62f38c09fbb1d..43568f7dfe6c0 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -263,7 +263,7 @@ static void getImageInfo(context_impl &Context, ur_image_info_t Info, T &Dest, ur_mem_handle_t InteropMemObject) { adapter_impl &Adapter = Context.getAdapter(); Adapter.call(InteropMemObject, Info, sizeof(T), - &Dest, nullptr); + &Dest, nullptr); } image_impl::image_impl(cl_mem MemObject, const context &SyclContext, @@ -277,7 +277,7 @@ image_impl::image_impl(cl_mem MemObject, const context &SyclContext, detail::context_impl &Context = *getSyclObjImpl(SyclContext); adapter_impl &Adapter = Context.getAdapter(); Adapter.call(Mem, UR_MEM_INFO_SIZE, sizeof(size_t), - &(BaseT::MSizeInBytes), nullptr); + &(BaseT::MSizeInBytes), nullptr); ur_image_format_t Format; getImageInfo(Context, UR_IMAGE_INFO_FORMAT, Format, Mem); diff --git a/sycl/source/detail/mem_alloc_helper.hpp b/sycl/source/detail/mem_alloc_helper.hpp index ad227cad702e9..196cbd08ac566 100644 --- a/sycl/source/detail/mem_alloc_helper.hpp +++ b/sycl/source/detail/mem_alloc_helper.hpp @@ -18,10 +18,9 @@ void memBufferCreateHelper(adapter_impl &Adapter, ur_context_handle_t Ctx, ur_mem_handle_t *RetMem, const ur_buffer_properties_t *Props = nullptr); void memReleaseHelper(adapter_impl &Adapter, ur_mem_handle_t Mem); -void memBufferMapHelper(adapter_impl &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, +void memBufferMapHelper(adapter_impl &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); diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index fee79dc30761b..b89fec45fbeda 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -163,7 +163,7 @@ void memBufferCreateHelper(adapter_impl &Adapter, ur_context_handle_t Ctx, #endif if (Size) Adapter.call(Ctx, Flags, Size, Props, - RetMem); + RetMem); } } @@ -183,7 +183,7 @@ void memReleaseHelper(adapter_impl &Adapter, ur_mem_handle_t Mem) { // resident on, so pass nullptr for Device param. Buffer interop may not be // supported by all backends. Adapter.call_nocheck(Mem, /*Dev*/ nullptr, - &PtrHandle); + &PtrHandle); Ptr = (uintptr_t)(PtrHandle); } #endif @@ -345,8 +345,8 @@ void *MemoryManager::allocateImageObject(context_impl *TargetContext, ur_mem_handle_t NewMem = nullptr; adapter_impl &Adapter = TargetContext->getAdapter(); Adapter.call(TargetContext->getHandleRef(), - CreationFlags, &Format, &Desc, - UserPtr, &NewMem); + CreationFlags, &Format, &Desc, + UserPtr, &NewMem); return NewMem; } @@ -898,7 +898,7 @@ void MemoryManager::context_copy_usm(const void *SrcMem, context_impl *Context, "NULL pointer argument in memory copy operation."); adapter_impl &Adapter = Context->getAdapter(); Adapter.call(Context->getHandleRef(), - DstMem, SrcMem, Len); + DstMem, SrcMem, Len); } void MemoryManager::fill_usm(void *Mem, queue_impl &Queue, size_t Length, @@ -1354,12 +1354,14 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer( SrcAccessRange[SrcPos.YTerm], SrcAccessRange[SrcPos.ZTerm]}; - ur_result_t Result = Adapter.call_nocheck< - UrApiKind::urCommandBufferAppendMemBufferReadRectExp>( - CommandBuffer, sycl::detail::ur::cast(SrcMem), - BufferOffset, HostOffset, RectRegion, BufferRowPitch, BufferSlicePitch, - HostRowPitch, HostSlicePitch, DstMem, Deps.size(), Deps.data(), 0, - nullptr, OutSyncPoint, nullptr, nullptr); + ur_result_t Result = + Adapter + .call_nocheck( + CommandBuffer, sycl::detail::ur::cast(SrcMem), + BufferOffset, HostOffset, RectRegion, BufferRowPitch, + BufferSlicePitch, HostRowPitch, HostSlicePitch, DstMem, + Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, + nullptr); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( sycl::make_error_code(sycl::errc::feature_not_supported), @@ -1401,12 +1403,11 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer( if (1 == DimDst && 1 == DimSrc) { ur_result_t Result = - Adapter - .call_nocheck( - CommandBuffer, sycl::detail::ur::cast(DstMem), - DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, - Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, - nullptr); + Adapter.call_nocheck( + CommandBuffer, sycl::detail::ur::cast(DstMem), + DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes, + Deps.size(), Deps.data(), 0, nullptr, OutSyncPoint, nullptr, + nullptr); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { throw sycl::exception( diff --git a/sycl/source/detail/persistent_device_code_cache.cpp b/sycl/source/detail/persistent_device_code_cache.cpp index 05ed6d118d53b..51f4570b26477 100644 --- a/sycl/source/detail/persistent_device_code_cache.cpp +++ b/sycl/source/detail/persistent_device_code_cache.cpp @@ -152,9 +152,9 @@ getProgramBinaryData(const ur_program_handle_t &NativePrg, Pointers.push_back(Binaries[I].data()); } - Adapter.call( - NativePrg, UR_PROGRAM_INFO_BINARIES, sizeof(char *) * Pointers.size(), - Pointers.data(), nullptr); + Adapter.call(NativePrg, UR_PROGRAM_INFO_BINARIES, + sizeof(char *) * Pointers.size(), + Pointers.data(), nullptr); // Select only binaries for the input devices preserving one to one // correpsondence. diff --git a/sycl/source/detail/physical_mem_impl.hpp b/sycl/source/detail/physical_mem_impl.hpp index e28885efcf1b3..7c926d2634928 100644 --- a/sycl/source/detail/physical_mem_impl.hpp +++ b/sycl/source/detail/physical_mem_impl.hpp @@ -66,8 +66,8 @@ class physical_mem_impl { adapter_impl &Adapter = MContext->getAdapter(); void *ResultPtr = reinterpret_cast(Ptr); Adapter.call(MContext->getHandleRef(), - ResultPtr, NumBytes, MPhysicalMem, - Offset, AccessFlags); + ResultPtr, NumBytes, MPhysicalMem, + Offset, AccessFlags); return ResultPtr; } diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index b488c52ebc5b1..6d14563e4b1a4 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -113,7 +113,7 @@ class platform_impl : public std::enable_shared_from_this { cl_platform_id get() const { ur_native_handle_t nativeHandle = 0; getAdapter().call(MPlatform, - &nativeHandle); + &nativeHandle); return ur::cast(nativeHandle); } diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index def01e6b3dcf0..1bbe6d5e68b69 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -107,7 +107,7 @@ static ur_program_handle_t createSpirvProgram(context_impl &Context, ur_program_handle_t Program = nullptr; adapter_impl &Adapter = Context.getAdapter(); Adapter.call(Context.getHandleRef(), Data, - DataLen, nullptr, &Program); + DataLen, nullptr, &Program); return Program; } @@ -1206,8 +1206,8 @@ ProgramManager::getUrProgramFromUrKernel(ur_kernel_handle_t Kernel, ur_program_handle_t Program; adapter_impl &Adapter = Context.getAdapter(); Adapter.call(Kernel, UR_KERNEL_INFO_PROGRAM, - sizeof(ur_program_handle_t), - &Program, nullptr); + sizeof(ur_program_handle_t), + &Program, nullptr); return Program; } @@ -1216,13 +1216,13 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, context_impl &Context) { size_t URDevicesSize = 0; adapter_impl &Adapter = Context.getAdapter(); - Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, - 0, nullptr, &URDevicesSize); + Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, 0, + nullptr, &URDevicesSize); std::vector URDevices(URDevicesSize / sizeof(ur_device_handle_t)); Adapter.call(Program, UR_PROGRAM_INFO_DEVICES, - URDevicesSize, URDevices.data(), - nullptr); + URDevicesSize, URDevices.data(), + nullptr); std::string Log = "The program was built for " + std::to_string(URDevices.size()) + " devices"; for (ur_device_handle_t &Device : URDevices) { @@ -1242,12 +1242,12 @@ ProgramManager::getProgramBuildLog(const ur_program_handle_t &Program, std::string DeviceNameString; size_t DeviceNameStrSize = 0; Adapter.call(Device, UR_DEVICE_INFO_NAME, 0, - nullptr, &DeviceNameStrSize); + nullptr, &DeviceNameStrSize); if (DeviceNameStrSize > 0) { std::vector DeviceName(DeviceNameStrSize); Adapter.call(Device, UR_DEVICE_INFO_NAME, - DeviceNameStrSize, - DeviceName.data(), nullptr); + DeviceNameStrSize, + DeviceName.data(), nullptr); DeviceNameString = std::string(DeviceName.data()); } Log += "\nBuild program log for '" + DeviceNameString + "':\n" + @@ -1342,17 +1342,16 @@ static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { return Ext->second; } -static ur_result_t doCompile(adapter_impl &Adapter, - ur_program_handle_t Program, uint32_t NumDevs, - ur_device_handle_t *Devs, ur_context_handle_t Ctx, - const char *Opts) { +static ur_result_t doCompile(adapter_impl &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 = Adapter.call_nocheck( Program, NumDevs, Devs, Opts); if (Result == UR_RESULT_ERROR_UNSUPPORTED_FEATURE) { return Adapter.call_nocheck(Ctx, Program, - Opts); + Opts); } return Result; } @@ -3198,7 +3197,7 @@ ProgramManager::getOrCreateKernel(const context &Context, adapter_impl &Adapter = Ctx.getAdapter(); Adapter.call(Program, KernelName.data(), - &Kernel); + &Kernel); // Only set UR_USM_INDIRECT_ACCESS if the platform can handle it. if (Ctx.getPlatformImpl().supports_usm()) { diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 4c44befea219d..b3e7eb4bbe17f 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -197,9 +197,9 @@ class queue_impl : public std::enable_shared_from_this { adapter_impl &Adapter = Context.getAdapter(); // TODO catch an exception and put it to list of asynchronous // exceptions - Adapter.call( - UrQueue, UR_QUEUE_INFO_DEVICE, sizeof(DeviceUr), &DeviceUr, - nullptr); + Adapter.call(UrQueue, UR_QUEUE_INFO_DEVICE, + sizeof(DeviceUr), &DeviceUr, + nullptr); device_impl *Device = Context.findMatchingDeviceImpl(DeviceUr); if (Device == nullptr) { throw sycl::exception( diff --git a/sycl/source/detail/ur.hpp b/sycl/source/detail/ur.hpp index d71fb7a9dd777..62aea03c3d393 100644 --- a/sycl/source/detail/ur.hpp +++ b/sycl/source/detail/ur.hpp @@ -48,8 +48,8 @@ std::string urGetInfoString(SyclImplTy &SyclImpl, DescTy Desc) { size_t ResultSize = 0; auto Handle = SyclImpl.getHandleRef(); Adapter.template call(Handle, Desc, - /*propSize=*/0, - /*pPropValue=*/nullptr, &ResultSize); + /*propSize=*/0, + /*pPropValue=*/nullptr, &ResultSize); if (ResultSize == 0) return std::string{}; @@ -60,7 +60,7 @@ std::string urGetInfoString(SyclImplTy &SyclImpl, DescTy Desc) { // for that. Result.resize(ResultSize - 1); Adapter.template call(Handle, Desc, ResultSize, Result.data(), - nullptr); + nullptr); return Result; } diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index de306dc1203dd..dc206b55dac44 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -230,8 +230,7 @@ void device::ext_oneapi_disable_peer_access(const device &peer) { ur_device_handle_t Peer = peer.impl->getHandleRef(); if (Device != Peer) { detail::adapter_impl &Adapter = impl->getAdapter(); - Adapter.call(Device, - Peer); + Adapter.call(Device, Peer); } } diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 61bdc12263489..f67768bf00967 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2043,8 +2043,8 @@ static bool checkContextSupports(detail::context_impl &ContextImpl, adapter_impl &Adapter = ContextImpl.getAdapter(); ur_bool_t SupportsOp = false; Adapter.call(ContextImpl.getHandleRef(), - InfoQuery, sizeof(ur_bool_t), - &SupportsOp, nullptr); + InfoQuery, sizeof(ur_bool_t), + &SupportsOp, nullptr); return SupportsOp; }