diff --git a/sycl/source/detail/helpers.hpp b/sycl/source/detail/helpers.hpp index 1a2d1e49aaeb2..93b7d096b8f31 100644 --- a/sycl/source/detail/helpers.hpp +++ b/sycl/source/detail/helpers.hpp @@ -21,7 +21,6 @@ class event; namespace detail { class CGExecKernel; class queue_impl; -using QueueImplPtr = std::shared_ptr; class RTDeviceBinaryImage; #ifdef __INTEL_PREVIEW_BREAKING_CHANGES diff --git a/sycl/source/detail/memory_manager.hpp b/sycl/source/detail/memory_manager.hpp index 08da3bb25d482..728aaa0e9ebc7 100644 --- a/sycl/source/detail/memory_manager.hpp +++ b/sycl/source/detail/memory_manager.hpp @@ -28,7 +28,6 @@ class queue_impl; class event_impl; class context_impl; -using QueueImplPtr = std::shared_ptr; using EventImplPtr = std::shared_ptr; // The class contains methods that work with memory. All operations with diff --git a/sycl/source/enqueue_functions.cpp b/sycl/source/enqueue_functions.cpp index b45d1b4f9f3cd..db221380f862a 100644 --- a/sycl/source/enqueue_functions.cpp +++ b/sycl/source/enqueue_functions.cpp @@ -15,26 +15,25 @@ namespace ext::oneapi::experimental { __SYCL_EXPORT void memcpy(queue Q, void *Dest, const void *Src, size_t NumBytes, const sycl::detail::code_location &CodeLoc) { - sycl::detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc); - auto QueueImplPtr = sycl::detail::getSyclObjImpl(Q); - QueueImplPtr->memcpy(Dest, Src, NumBytes, {}, - /*CallerNeedsEvent=*/false, TlsCodeLocCapture.query()); + detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc); + detail::getSyclObjImpl(Q)->memcpy(Dest, Src, NumBytes, {}, + /*CallerNeedsEvent=*/false, + TlsCodeLocCapture.query()); } __SYCL_EXPORT void memset(queue Q, void *Ptr, int Value, size_t NumBytes, const sycl::detail::code_location &CodeLoc) { - sycl::detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc); - auto QueueImplPtr = sycl::detail::getSyclObjImpl(Q); - QueueImplPtr->memset(Ptr, Value, NumBytes, {}, - /*CallerNeedsEvent=*/false); + detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc); + detail::getSyclObjImpl(Q)->memset(Ptr, Value, NumBytes, {}, + /*CallerNeedsEvent=*/false); } __SYCL_EXPORT void mem_advise(queue Q, void *Ptr, size_t NumBytes, int Advice, const sycl::detail::code_location &CodeLoc) { - sycl::detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc); - auto QueueImplPtr = sycl::detail::getSyclObjImpl(Q); - QueueImplPtr->mem_advise(Ptr, NumBytes, ur_usm_advice_flags_t(Advice), {}, - /*CallerNeedsEvent=*/false); + detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc); + detail::getSyclObjImpl(Q)->mem_advise(Ptr, NumBytes, + ur_usm_advice_flags_t(Advice), {}, + /*CallerNeedsEvent=*/false); } } // namespace ext::oneapi::experimental diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index 8474760833a93..d0e8078aacfdd 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -328,15 +328,15 @@ void queue::wait_and_throw_proxy(const detail::code_location &CodeLoc) { } static event -getBarrierEventForInorderQueueHelper(const detail::QueueImplPtr QueueImpl) { +getBarrierEventForInorderQueueHelper(detail::queue_impl &QueueImpl) { // This function should not be called when a queue is recording to a graph, // as a graph can record from multiple queues and we cannot guarantee the // last node added by an in-order queue will be the last node added to the // graph. - assert(!QueueImpl->hasCommandGraph() && + assert(!QueueImpl.hasCommandGraph() && "Should not be called in on graph recording."); - sycl::detail::optional LastEvent = QueueImpl->getLastEvent(); + sycl::detail::optional LastEvent = QueueImpl.getLastEvent(); if (LastEvent) return *LastEvent; @@ -353,11 +353,7 @@ getBarrierEventForInorderQueueHelper(const detail::QueueImplPtr QueueImpl) { /// \return a SYCL event object, which corresponds to the queue the command /// group is being enqueued on. event queue::ext_oneapi_submit_barrier(const detail::code_location &CodeLoc) { - if (is_in_order() && !impl->hasCommandGraph() && !impl->MIsProfilingEnabled) { - return getBarrierEventForInorderQueueHelper(impl); - } - - return submit([=](handler &CGH) { CGH.ext_oneapi_barrier(); }, CodeLoc); + return ext_oneapi_submit_barrier(std::vector{}, CodeLoc); } /// Prevents any commands submitted afterward to this queue from executing @@ -379,11 +375,14 @@ event queue::ext_oneapi_submit_barrier(const std::vector &WaitList, }); if (is_in_order() && !impl->hasCommandGraph() && !impl->MIsProfilingEnabled && AllEventsEmptyOrNop) { - return getBarrierEventForInorderQueueHelper(impl); + return getBarrierEventForInorderQueueHelper(*impl); } - return submit([=](handler &CGH) { CGH.ext_oneapi_barrier(WaitList); }, - CodeLoc); + if (WaitList.empty()) + return submit([=](handler &CGH) { CGH.ext_oneapi_barrier(); }, CodeLoc); + else + return submit([=](handler &CGH) { CGH.ext_oneapi_barrier(WaitList); }, + CodeLoc); } template diff --git a/sycl/unittests/Extensions/USMMemcpy2D.cpp b/sycl/unittests/Extensions/USMMemcpy2D.cpp index 546767b55eb7d..e05164d2ac66d 100644 --- a/sycl/unittests/Extensions/USMMemcpy2D.cpp +++ b/sycl/unittests/Extensions/USMMemcpy2D.cpp @@ -280,8 +280,7 @@ TEST(USMMemcpy2DTest, USMMemops2DSupported) { sycl::platform Plt = sycl::platform(); sycl::queue Q{Plt.get_devices()[0]}; - std::shared_ptr QueueImpl = - sycl::detail::getSyclObjImpl(Q); + sycl::detail::queue_impl &QueueImpl = *sycl::detail::getSyclObjImpl(Q); mock::getCallbacks().set_after_callback( "urContextGetInfo", &after_urContextGetInfo); @@ -297,7 +296,7 @@ TEST(USMMemcpy2DTest, USMMemops2DSupported) { Q.ext_oneapi_fill2d(Ptr1, 5, 42l, 4, 2); EXPECT_TRUE(LastMemopsQuery == UR_CONTEXT_INFO_USM_FILL2D_SUPPORT); - EXPECT_EQ(LastFill2D.hQueue, (ur_queue_handle_t)QueueImpl->getHandleRef()); + EXPECT_EQ(LastFill2D.hQueue, (ur_queue_handle_t)QueueImpl.getHandleRef()); EXPECT_EQ(LastFill2D.pMem, (void *)Ptr1); EXPECT_EQ(LastFill2D.pitch, (size_t)5); EXPECT_EQ(LastFill2D.patternSize, sizeof(long)); @@ -306,7 +305,7 @@ TEST(USMMemcpy2DTest, USMMemops2DSupported) { Q.ext_oneapi_memset2d(Ptr1, 5 * sizeof(long), 123, 4 * sizeof(long), 2); EXPECT_TRUE(LastMemopsQuery == UR_CONTEXT_INFO_USM_FILL2D_SUPPORT); - EXPECT_EQ(LastFill2D.hQueue, (ur_queue_handle_t)QueueImpl->getHandleRef()); + EXPECT_EQ(LastFill2D.hQueue, (ur_queue_handle_t)QueueImpl.getHandleRef()); EXPECT_EQ(LastFill2D.pMem, (void *)Ptr1); EXPECT_EQ(LastFill2D.pitch, (size_t)5 * sizeof(long)); EXPECT_EQ(LastFill2D.pattern[0], 123); @@ -316,7 +315,7 @@ TEST(USMMemcpy2DTest, USMMemops2DSupported) { Q.ext_oneapi_memcpy2d(Ptr1, 5 * sizeof(long), Ptr2, 8 * sizeof(long), 4 * sizeof(long), 2); EXPECT_TRUE(LastMemopsQuery == UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT); - EXPECT_EQ(LastMemcpy2D.hQueue, (ur_queue_handle_t)QueueImpl->getHandleRef()); + EXPECT_EQ(LastMemcpy2D.hQueue, (ur_queue_handle_t)QueueImpl.getHandleRef()); EXPECT_EQ(LastMemcpy2D.pDst, (void *)Ptr1); EXPECT_EQ(LastMemcpy2D.dstPitch, (size_t)5 * sizeof(long)); EXPECT_EQ(LastMemcpy2D.pSrc, (void *)Ptr2); @@ -326,7 +325,7 @@ TEST(USMMemcpy2DTest, USMMemops2DSupported) { Q.ext_oneapi_copy2d(Ptr1, 5, Ptr2, 8, 4, 2); EXPECT_TRUE(LastMemopsQuery == UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT); - EXPECT_EQ(LastMemcpy2D.hQueue, (ur_queue_handle_t)QueueImpl->getHandleRef()); + EXPECT_EQ(LastMemcpy2D.hQueue, (ur_queue_handle_t)QueueImpl.getHandleRef()); EXPECT_EQ(LastMemcpy2D.pDst, (void *)Ptr2); EXPECT_EQ(LastMemcpy2D.dstPitch, (size_t)8 * sizeof(long)); EXPECT_EQ(LastMemcpy2D.pSrc, (void *)Ptr1); @@ -381,8 +380,7 @@ TEST(USMMemcpy2DTest, USMFillSupportedOnly) { sycl::platform Plt = sycl::platform(); sycl::queue Q{Plt.get_devices()[0]}; - std::shared_ptr QueueImpl = - sycl::detail::getSyclObjImpl(Q); + sycl::detail::queue_impl &QueueImpl = *sycl::detail::getSyclObjImpl(Q); mock::getCallbacks().set_after_callback( "urContextGetInfo", &after_urContextGetInfo); @@ -402,7 +400,7 @@ TEST(USMMemcpy2DTest, USMFillSupportedOnly) { Q.ext_oneapi_fill2d(Ptr1, 5, 42l, 4, 2); EXPECT_TRUE(LastMemopsQuery == UR_CONTEXT_INFO_USM_FILL2D_SUPPORT); - EXPECT_EQ(LastFill2D.hQueue, QueueImpl->getHandleRef()); + EXPECT_EQ(LastFill2D.hQueue, QueueImpl.getHandleRef()); EXPECT_EQ(LastFill2D.pMem, (void *)Ptr1); EXPECT_EQ(LastFill2D.pitch, (size_t)5); EXPECT_EQ(LastFill2D.patternSize, sizeof(long)); @@ -427,8 +425,7 @@ TEST(USMMemcpy2DTest, USMMemsetSupportedOnly) { sycl::platform Plt = sycl::platform(); sycl::queue Q{Plt.get_devices()[0]}; - std::shared_ptr QueueImpl = - sycl::detail::getSyclObjImpl(Q); + sycl::detail::queue_impl &QueueImpl = *sycl::detail::getSyclObjImpl(Q); // Enable fill + set, they are implemented with the same entry point in the // backend so supporting one means supporting both. @@ -450,7 +447,7 @@ TEST(USMMemcpy2DTest, USMMemsetSupportedOnly) { Q.ext_oneapi_memset2d(Ptr1, 5 * sizeof(long), 123, 4 * sizeof(long), 2); EXPECT_TRUE(LastMemopsQuery == UR_CONTEXT_INFO_USM_FILL2D_SUPPORT); - EXPECT_EQ(LastFill2D.hQueue, QueueImpl->getHandleRef()); + EXPECT_EQ(LastFill2D.hQueue, QueueImpl.getHandleRef()); EXPECT_EQ(LastFill2D.pMem, (void *)Ptr1); EXPECT_EQ(LastFill2D.pitch, (size_t)5 * sizeof(long)); EXPECT_EQ(LastFill2D.pattern[0], 123); @@ -475,8 +472,7 @@ TEST(USMMemcpy2DTest, USMMemcpySupportedOnly) { sycl::platform Plt = sycl::platform(); sycl::queue Q{Plt.get_devices()[0]}; - std::shared_ptr QueueImpl = - sycl::detail::getSyclObjImpl(Q); + sycl::detail::queue_impl &QueueImpl = *sycl::detail::getSyclObjImpl(Q); mock::getCallbacks().set_after_callback( "urContextGetInfo", &after_urContextGetInfo); @@ -505,7 +501,7 @@ TEST(USMMemcpy2DTest, USMMemcpySupportedOnly) { Q.ext_oneapi_memcpy2d(Ptr1, 5 * sizeof(long), Ptr2, 8 * sizeof(long), 4 * sizeof(long), 2); EXPECT_TRUE(LastMemopsQuery == UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT); - EXPECT_EQ(LastMemcpy2D.hQueue, QueueImpl->getHandleRef()); + EXPECT_EQ(LastMemcpy2D.hQueue, QueueImpl.getHandleRef()); EXPECT_EQ(LastMemcpy2D.pDst, (void *)Ptr1); EXPECT_EQ(LastMemcpy2D.dstPitch, (size_t)5 * sizeof(long)); EXPECT_EQ(LastMemcpy2D.pSrc, (void *)Ptr2); @@ -516,7 +512,7 @@ TEST(USMMemcpy2DTest, USMMemcpySupportedOnly) { Q.ext_oneapi_copy2d(Ptr1, 5, Ptr2, 8, 4, 2); EXPECT_TRUE(LastMemopsQuery == UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT); - EXPECT_EQ(LastMemcpy2D.hQueue, QueueImpl->getHandleRef()); + EXPECT_EQ(LastMemcpy2D.hQueue, QueueImpl.getHandleRef()); EXPECT_EQ(LastMemcpy2D.pDst, (void *)Ptr2); EXPECT_EQ(LastMemcpy2D.dstPitch, (size_t)8 * sizeof(long)); EXPECT_EQ(LastMemcpy2D.pSrc, (void *)Ptr1); diff --git a/sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp b/sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp index ff464c6d2a1ee..98554a245e177 100644 --- a/sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp +++ b/sycl/unittests/program_manager/arg_mask/EliminatedArgMask.cpp @@ -135,8 +135,8 @@ class MockHandler : public sycl::handler { public: using sycl::handler::impl; - MockHandler(std::shared_ptr Queue) - : sycl::handler(Queue, /*CallerNeedsEvent*/ true) {} + MockHandler(sycl::detail::queue_impl &Queue) + : sycl::handler(Queue.shared_from_this(), /*CallerNeedsEvent*/ true) {} std::unique_ptr finalize() { auto CGH = static_cast(this); @@ -171,7 +171,7 @@ const sycl::detail::KernelArgMask *getKernelArgMaskFromBundle( EXPECT_FALSE(ExecBundle.empty()) << "Expect non-empty exec kernel bundle"; // Emulating processing of command group function - MockHandler MockCGH(QueueImpl); + MockHandler MockCGH(*QueueImpl); MockCGH.use_kernel_bundle(ExecBundle); MockCGH.single_task([] {}); // Actual kernel does not matter