From 40b2bb1279a4f6ddfc48aa22403415b6b276d1d0 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Mon, 6 May 2024 07:57:12 -0700 Subject: [PATCH 01/13] [SYCL] Add nested calls detection to shortcut functions Signed-off-by: Tikhomirova, Kseniya --- sycl/source/detail/queue_impl.cpp | 64 ++++++++++++++++++++- sycl/source/detail/queue_impl.hpp | 48 +--------------- sycl/test-e2e/Basic/nested_queue_submit.cpp | 55 ++++++++++++++---- 3 files changed, 107 insertions(+), 60 deletions(-) diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index d3adabe185802..e69cd3e450403 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -27,6 +27,20 @@ namespace sycl { inline namespace _V1 { namespace detail { std::atomic queue_impl::MNextAvailableQueueID = 0; +thread_local bool NestedCallsDetector = false; +class NestedCallsTracker { +public: + NestedCallsTracker() { + if (NestedCallsDetector) + throw sycl::exception( + make_error_code(errc::invalid), + "Calls to sycl::queue::submit cannot be nested. Command group " + "function objects should use the sycl::handler API instead."); + NestedCallsDetector = true; + } + + ~NestedCallsTracker() { NestedCallsDetector = false; } +}; static std::vector getPIEvents(const std::vector &DepEvents) { @@ -330,6 +344,48 @@ void queue_impl::addSharedEvent(const event &Event) { MEventsShared.push_back(Event); } +event queue_impl::submit_impl(const std::function &CGF, + const std::shared_ptr &Self, + const std::shared_ptr &PrimaryQueue, + const std::shared_ptr &SecondaryQueue, + const detail::code_location &Loc, + const SubmitPostProcessF *PostProcess) { + // Flag used to detect nested calls to submit and report an error. + + handler Handler(Self, PrimaryQueue, SecondaryQueue, MHostQueue); + Handler.saveCodeLoc(Loc); + + { + NestedCallsTracker tracker; + CGF(Handler); + } + + // Scheduler will later omit events, that are not required to execute tasks. + // Host and interop tasks, however, are not submitted to low-level runtimes + // and require separate dependency management. + const CG::CGTYPE Type = Handler.getType(); + event Event = detail::createSyclObjFromImpl( + std::make_shared()); + + if (PostProcess) { + bool IsKernel = Type == CG::Kernel; + bool KernelUsesAssert = false; + + if (IsKernel) + // Kernel only uses assert if it's non interop one + KernelUsesAssert = !(Handler.MKernel && Handler.MKernel->isInterop()) && + ProgramManager::getInstance().kernelUsesAssert( + Handler.MKernelName.c_str()); + finalizeHandler(Handler, Event); + + (*PostProcess)(IsKernel, KernelUsesAssert, Event); + } else + finalizeHandler(Handler, Event); + + addEvent(Event); + return Event; +} + template event queue_impl::submitWithHandler(const std::shared_ptr &Self, const std::vector &DepEvents, @@ -362,6 +418,7 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr &Self, if (MGraph.expired() && Scheduler::areEventsSafeForSchedulerBypass( ExpandedDepEvents, MContext)) { if (MSupportsDiscardingPiEvents) { + NestedCallsTracker tracker; MemOpFunc(MemOpArgs..., getPIEvents(ExpandedDepEvents), /*PiEvent*/ nullptr, /*EventImplPtr*/ nullptr); return createDiscardedEvent(); @@ -369,8 +426,11 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr &Self, event ResEvent = prepareSYCLEventAssociatedWithQueue(Self); auto EventImpl = detail::getSyclObjImpl(ResEvent); - MemOpFunc(MemOpArgs..., getPIEvents(ExpandedDepEvents), - &EventImpl->getHandleRef(), EventImpl); + { + NestedCallsTracker tracker; + MemOpFunc(MemOpArgs..., getPIEvents(ExpandedDepEvents), + &EventImpl->getHandleRef(), EventImpl); + } if (MContext->is_host()) return MDiscardEvents ? createDiscardedEvent() : event(); diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 231437cd67f19..de99729ce71c7 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -798,53 +798,7 @@ class queue_impl { const std::shared_ptr &PrimaryQueue, const std::shared_ptr &SecondaryQueue, const detail::code_location &Loc, - const SubmitPostProcessF *PostProcess) { - // Flag used to detect nested calls to submit and report an error. - thread_local static bool PreventSubmit = false; - - if (PreventSubmit) { - throw sycl::exception( - make_error_code(errc::invalid), - "Calls to sycl::queue::submit cannot be nested. Command group " - "function objects should use the sycl::handler API instead."); - } - - handler Handler(Self, PrimaryQueue, SecondaryQueue, MHostQueue); - Handler.saveCodeLoc(Loc); - PreventSubmit = true; - try { - CGF(Handler); - } catch (...) { - PreventSubmit = false; - throw; - } - PreventSubmit = false; - - // Scheduler will later omit events, that are not required to execute tasks. - // Host and interop tasks, however, are not submitted to low-level runtimes - // and require separate dependency management. - const CG::CGTYPE Type = Handler.getType(); - event Event = detail::createSyclObjFromImpl( - std::make_shared()); - - if (PostProcess) { - bool IsKernel = Type == CG::Kernel; - bool KernelUsesAssert = false; - - if (IsKernel) - // Kernel only uses assert if it's non interop one - KernelUsesAssert = !(Handler.MKernel && Handler.MKernel->isInterop()) && - ProgramManager::getInstance().kernelUsesAssert( - Handler.MKernelName.c_str()); - finalizeHandler(Handler, Event); - - (*PostProcess)(IsKernel, KernelUsesAssert, Event); - } else - finalizeHandler(Handler, Event); - - addEvent(Event); - return Event; - } + const SubmitPostProcessF *PostProcess); /// Helper function for submitting a memory operation with a handler. /// \param Self is a shared_ptr to this queue. diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index da74c357a27a6..17e1846ddf60b 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -2,13 +2,20 @@ // RUN: %{run} %t.out #include -#include +#include #include -void nestedSubmit() { +void checkExceptionFields(const sycl::exception &e) { + assert(e.code() == sycl::errc::invalid && "Invalid error code"); + assert(std::string(e.what()) == + "Calls to sycl::queue::submit cannot be nested. Command group " + "function objects should use the sycl::handler API instead." && + "Invalid e.what() string"); +} + +void nestedSubmitParallelFor(sycl::queue &q) { uint32_t n = 1024; std::vector array(n); - sycl::queue q{}; { sycl::buffer buf(array.data(), sycl::range<1>{n}); q.submit([&](sycl::handler &h) { @@ -19,16 +26,42 @@ void nestedSubmit() { } } -int main() { +void nestedSubmitMemset(sycl::queue &q) { + uint32_t n = 1024; + int *data = sycl::malloc_shared(n, q); + try { + q.submit([&](sycl::handler &h) { q.memset(data, 0, n * sizeof(int)); }); + } catch (...) { + sycl::free(data, q); + throw; + } + sycl::free(data, q); +} + +void doValidCall(sycl::queue &q) { + q.submit([&](sycl::handler &h) {}); +} + +template void test(CommandSubmitterT QueueSubmit) { + sycl::queue q{}; + bool ExceptionHappened = false; try { - nestedSubmit(); + QueueSubmit(q); } catch (const sycl::exception &e) { - assert(e.code() == sycl::errc::invalid && "Invalid error code"); - assert(std::string(e.what()) == - "Calls to sycl::queue::submit cannot be nested. Command group " - "function objects should use the sycl::handler API instead." && - "Invalid e.what() string"); + checkExceptionFields(e); + ExceptionHappened = true; } - std::cout << "test passed" << std::endl; + assert(ExceptionHappened); + // Checks that queue is in a valid state and we could submit new commands. + doValidCall(q); + q.wait(); +} + +int main() { + test(nestedSubmitParallelFor); + // All shortcut functions has a common part where nested call detection + // happens. Testing only one of them is enough. + test(nestedSubmitMemset); + return EXIT_SUCCESS; } From 48349092c31d26e020a3da033902fcd63a6c25f4 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 14 May 2024 06:28:08 -0700 Subject: [PATCH 02/13] fix clang-format Signed-off-by: Tikhomirova, Kseniya --- sycl/source/detail/queue_impl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 2f406d636daa5..40e6339f10079 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -359,7 +359,7 @@ event queue_impl::submit_impl(const std::function &CGF, NestedCallsTracker tracker; CGF(Handler); } - + // Scheduler will later omit events, that are not required to execute tasks. // Host and interop tasks, however, are not submitted to low-level runtimes // and require separate dependency management. @@ -374,8 +374,8 @@ event queue_impl::submit_impl(const std::function &CGF, if (IsKernel) // Kernel only uses assert if it's non interop one KernelUsesAssert = !(Handler.MKernel && Handler.MKernel->isInterop()) && - ProgramManager::getInstance().kernelUsesAssert( - Handler.MKernelName.c_str()); + ProgramManager::getInstance().kernelUsesAssert( + Handler.MKernelName.c_str()); finalizeHandler(Handler, Type, Event); (*PostProcess)(IsKernel, KernelUsesAssert, Event); From b60adf847f11ca85f98e2d6b8955d4a05d6a2347 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Thu, 16 May 2024 07:45:05 -0700 Subject: [PATCH 03/13] eliminate nested calls from internal code Signed-off-by: Tikhomirova, Kseniya --- sycl/include/sycl/reduction.hpp | 21 +++++++++++++-------- sycl/source/detail/reduction.cpp | 12 ++++++++++++ sycl/test/abi/sycl_symbols_linux.dump | 1 + 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/sycl/include/sycl/reduction.hpp b/sycl/include/sycl/reduction.hpp index fa09337be45a6..e5228ae7e7511 100644 --- a/sycl/include/sycl/reduction.hpp +++ b/sycl/include/sycl/reduction.hpp @@ -92,7 +92,8 @@ using IsReduOptForFastAtomicFetch = std::bool_constant; #else std::bool_constant<((is_sgenfloat_v && sizeof(T) == 4) || - is_sgeninteger_v)&&IsValidAtomicType::value && + is_sgeninteger_v) && + IsValidAtomicType::value && (IsPlus::value || IsMinimum::value || IsMaximum::value || @@ -130,11 +131,12 @@ using IsReduOptForFastReduce = #ifdef SYCL_REDUCTION_DETERMINISTIC std::bool_constant; #else - std::bool_constant<( - (is_sgeninteger_v && (sizeof(T) == 4 || sizeof(T) == 8)) || - is_sgenfloat_v)&&(IsPlus::value || - IsMinimum::value || - IsMaximum::value)>; + std::bool_constant<((is_sgeninteger_v && + (sizeof(T) == 4 || sizeof(T) == 8)) || + is_sgenfloat_v) && + (IsPlus::value || + IsMinimum::value || + IsMaximum::value)>; #endif // std::tuple seems to be a) too heavy and b) not copyable to device now @@ -827,6 +829,10 @@ using __sycl_init_mem_for = std::conditional_t, auto_name, reduction::InitMemKrn>; +__SYCL_EXPORT void +addCounterInit(handler &CGH, std::shared_ptr &Queue, + std::shared_ptr &Counter); + template class reduction_impl_algo { @@ -1067,8 +1073,7 @@ class reduction_impl_algo { std::shared_ptr Counter(malloc_device(1, q), Deleter); CGH.addReduction(Counter); - auto Event = q.memset(Counter.get(), 0, sizeof(int)); - CGH.depends_on(Event); + addCounterInit(CGH, CGH.MQueue, Counter); return Counter.get(); } diff --git a/sycl/source/detail/reduction.cpp b/sycl/source/detail/reduction.cpp index d2b858aabdf74..6fd170746d28d 100644 --- a/sycl/source/detail/reduction.cpp +++ b/sycl/source/detail/reduction.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include +#include #include #include @@ -165,6 +166,17 @@ __SYCL_EXPORT size_t reduGetPreferredWGSize(std::shared_ptr &Queue, return reduGetMaxWGSize(Queue, LocalMemBytesPerWorkItem); } +__SYCL_EXPORT void +addCounterInit(handler &CGH, std::shared_ptr &Queue, + std::shared_ptr &Counter) { + auto EventImpl = std::make_shared(Queue); + EventImpl->setContextImpl(detail::getSyclObjImpl(Queue->get_context())); + EventImpl->setStateIncomplete(); + MemoryManager::fill_usm(Counter.get(), Queue, sizeof(int), 0, {}, + &EventImpl->getHandleRef(), EventImpl); + CGH.depends_on(createSyclObjFromImpl(EventImpl)); +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 95ad0f27b9d12..f4fb13e68e70f 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3314,6 +3314,7 @@ _ZN4sycl3_V16detail13lgamma_r_implEfPi _ZN4sycl3_V16detail13make_platformEmNS0_7backendE _ZN4sycl3_V16detail13select_deviceERKSt8functionIFiRKNS0_6deviceEEE _ZN4sycl3_V16detail13select_deviceERKSt8functionIFiRKNS0_6deviceEEERKNS0_7contextE +_ZN4sycl3_V16detail14addCounterInitERNS0_7handlerERSt10shared_ptrINS1_10queue_implEERS4_IiE _ZN4sycl3_V16detail14getBorderColorENS0_19image_channel_orderE _ZN4sycl3_V16detail14tls_code_loc_t5queryEv _ZN4sycl3_V16detail14tls_code_loc_tC1ERKNS1_13code_locationE From 57e0e3318950beff269b2b0080249df6ff16a0cb Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Fri, 17 May 2024 03:27:49 -0700 Subject: [PATCH 04/13] hip check Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/nested_queue_submit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index 17e1846ddf60b..cabb5cbe42607 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -6,6 +6,8 @@ #include void checkExceptionFields(const sycl::exception &e) { + std::cout << "e.code() = " << e.code() << " message = " << e.what() + << std::endl; assert(e.code() == sycl::errc::invalid && "Invalid error code"); assert(std::string(e.what()) == "Calls to sycl::queue::submit cannot be nested. Command group " From acf2aab96b72843deae3aab391177cfc72e86f0a Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 21 May 2024 02:18:56 -0700 Subject: [PATCH 05/13] simplify malloc requirements Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/nested_queue_submit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index cabb5cbe42607..c9149446afdb5 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -30,7 +30,7 @@ void nestedSubmitParallelFor(sycl::queue &q) { void nestedSubmitMemset(sycl::queue &q) { uint32_t n = 1024; - int *data = sycl::malloc_shared(n, q); + int *data = sycl::malloc_device(n, q); try { q.submit([&](sycl::handler &h) { q.memset(data, 0, n * sizeof(int)); }); } catch (...) { From a65de6612a3e4a0f7a9c539e58f8e00e5af69b46 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 21 May 2024 02:44:42 -0700 Subject: [PATCH 06/13] FIx test Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/nested_queue_submit.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index c9149446afdb5..a603fae190f35 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -44,26 +44,28 @@ void doValidCall(sycl::queue &q) { q.submit([&](sycl::handler &h) {}); } -template void test(CommandSubmitterT QueueSubmit) { - sycl::queue q{}; +template +void test(sycl::queue &Queue, CommandSubmitterT QueueSubmit) { bool ExceptionHappened = false; try { - QueueSubmit(q); + QueueSubmit(Queue); } catch (const sycl::exception &e) { checkExceptionFields(e); ExceptionHappened = true; } assert(ExceptionHappened); // Checks that queue is in a valid state and we could submit new commands. - doValidCall(q); - q.wait(); + doValidCall(Queue); + Queue.wait(); } int main() { - test(nestedSubmitParallelFor); + sycl::queue q{}; + test(q, nestedSubmitParallelFor); // All shortcut functions has a common part where nested call detection // happens. Testing only one of them is enough. - test(nestedSubmitMemset); + if (q.get_device().get_info()) + test(q, nestedSubmitMemset); return EXIT_SUCCESS; } From 414a9824a2af1fdce28a42972c309cef15928f0e Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 21 May 2024 02:44:57 -0700 Subject: [PATCH 07/13] Revert "hip check" This reverts commit 57e0e3318950beff269b2b0080249df6ff16a0cb. --- sycl/test-e2e/Basic/nested_queue_submit.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index a603fae190f35..5b1e23648cc31 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -6,8 +6,6 @@ #include void checkExceptionFields(const sycl::exception &e) { - std::cout << "e.code() = " << e.code() << " message = " << e.what() - << std::endl; assert(e.code() == sycl::errc::invalid && "Invalid error code"); assert(std::string(e.what()) == "Calls to sycl::queue::submit cannot be nested. Command group " From 8ec247a56636b9a4d9fbdf6a6484d4d56527fd22 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Tue, 21 May 2024 03:40:05 -0700 Subject: [PATCH 08/13] update win symbols Signed-off-by: Tikhomirova, Kseniya --- sycl/test/abi/sycl_symbols_windows.dump | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 452f9db0cf197..2843f7fbf7637 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -441,6 +441,12 @@ ??$import_external_semaphore@Uexternal_semaphore_fd@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA?AUinterop_semaphore_handle@01234@U?$external_semaphore_descriptor@Uexternal_semaphore_fd@experimental@oneapi@ext@_V1@sycl@@@01234@AEBVqueue@34@@Z ??$import_external_semaphore@Uresource_fd@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA?AUinterop_semaphore_handle@01234@U?$external_semaphore_descriptor@Uresource_fd@experimental@oneapi@ext@_V1@sycl@@@01234@AEBVdevice@34@AEBVcontext@34@@Z ??$import_external_semaphore@Uresource_fd@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA?AUinterop_semaphore_handle@01234@U?$external_semaphore_descriptor@Uresource_fd@experimental@oneapi@ext@_V1@sycl@@@01234@AEBVqueue@34@@Z +??$update_nd_range@$00@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$nd_range@$00@45@@Z +??$update_nd_range@$01@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$nd_range@$01@45@@Z +??$update_nd_range@$02@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$nd_range@$02@45@@Z +??$update_range@$00@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$range@$00@45@@Z +??$update_range@$01@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$range@$01@45@@Z +??$update_range@$02@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$range@$02@45@@Z ??0AccessorBaseHost@detail@_V1@sycl@@IEAA@AEBV?$shared_ptr@VAccessorImplHost@detail@_V1@sycl@@@std@@@Z ??0AccessorBaseHost@detail@_V1@sycl@@QEAA@$$QEAV0123@@Z ??0AccessorBaseHost@detail@_V1@sycl@@QEAA@AEBV0123@@Z @@ -3920,6 +3926,7 @@ ?add@device_global_map@detail@_V1@sycl@@YAXPEBXPEBD@Z ?add@host_pipe_map@detail@_V1@sycl@@YAXPEBXPEBD@Z ?add@modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA?AVnode@34567@AEBVproperty_list@67@@Z +?addCounterInit@detail@_V1@sycl@@YAXAEAVhandler@23@AEAV?$shared_ptr@Vqueue_impl@detail@_V1@sycl@@@std@@AEAV?$shared_ptr@H@6@@Z ?addGraphLeafDependencies@modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@IEAAXVnode@34567@@Z ?addHostAccessorAndWait@detail@_V1@sycl@@YAXPEAVAccessorImplHost@123@@Z ?addHostSampledImageAccessorAndWait@detail@_V1@sycl@@YAXPEAVSampledImageAccessorImplHost@123@@Z @@ -4341,12 +4348,6 @@ ?get_mip_level_mem_handle@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBA?AUimage_mem_handle@23456@I@Z ?get_name@kernel_id@_V1@sycl@@QEBAPEBDXZ ?get_node_from_event@node@experimental@oneapi@ext@_V1@sycl@@SA?AV123456@Vevent@56@@Z -??$update_nd_range@$00@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$nd_range@$00@45@@Z -??$update_nd_range@$01@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$nd_range@$01@45@@Z -??$update_nd_range@$02@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$nd_range@$02@45@@Z -??$update_range@$00@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$range@$00@45@@Z -??$update_range@$01@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$range@$01@45@@Z -??$update_range@$02@node@experimental@oneapi@ext@_V1@sycl@@QEAAXV?$range@$02@45@@Z ?get_nodes@modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEBA?AV?$vector@Vnode@experimental@oneapi@ext@_V1@sycl@@V?$allocator@Vnode@experimental@oneapi@ext@_V1@sycl@@@std@@@std@@XZ ?get_num_channels@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBAIXZ ?get_pipe_name@pipe_base@experimental@intel@ext@_V1@sycl@@KA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBX@Z From ec7c6b013e6e822a7d9319d2cc13b48862461370 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 22 May 2024 03:08:16 -0700 Subject: [PATCH 09/13] Fix code review comments Signed-off-by: Tikhomirova, Kseniya --- sycl/source/detail/queue_impl.cpp | 2 -- sycl/test-e2e/Basic/nested_queue_submit.cpp | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 40e6339f10079..71df75938c879 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -350,8 +350,6 @@ event queue_impl::submit_impl(const std::function &CGF, const std::shared_ptr &SecondaryQueue, const detail::code_location &Loc, const SubmitPostProcessF *PostProcess) { - // Flag used to detect nested calls to submit and report an error. - handler Handler(Self, PrimaryQueue, SecondaryQueue, MHostQueue); Handler.saveCodeLoc(Loc); diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index 5b1e23648cc31..b878661e41a0e 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -38,7 +38,7 @@ void nestedSubmitMemset(sycl::queue &q) { sycl::free(data, q); } -void doValidCall(sycl::queue &q) { +void submitSimpleKernel(sycl::queue &q) { q.submit([&](sycl::handler &h) {}); } @@ -52,8 +52,9 @@ void test(sycl::queue &Queue, CommandSubmitterT QueueSubmit) { ExceptionHappened = true; } assert(ExceptionHappened); - // Checks that queue is in a valid state and we could submit new commands. - doValidCall(Queue); + // Checks that queue is in a valid state: nested call tracker was cleaned up + // after exception and does not prevent from submission of new commands. + submitSimpleKernel(Queue); Queue.wait(); } From 783910da7743324d53fedd189d92d6e7262f56cd Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 22 May 2024 03:10:57 -0700 Subject: [PATCH 10/13] cleanup Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/nested_queue_submit.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index b878661e41a0e..329e477f322b0 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -38,10 +38,6 @@ void nestedSubmitMemset(sycl::queue &q) { sycl::free(data, q); } -void submitSimpleKernel(sycl::queue &q) { - q.submit([&](sycl::handler &h) {}); -} - template void test(sycl::queue &Queue, CommandSubmitterT QueueSubmit) { bool ExceptionHappened = false; @@ -54,7 +50,7 @@ void test(sycl::queue &Queue, CommandSubmitterT QueueSubmit) { assert(ExceptionHappened); // Checks that queue is in a valid state: nested call tracker was cleaned up // after exception and does not prevent from submission of new commands. - submitSimpleKernel(Queue); + Queue.submit([&](sycl::handler &h) {}); Queue.wait(); } From baf5fd6262858816e38bf6f31f1e1487047d1d10 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 29 May 2024 03:00:33 -0700 Subject: [PATCH 11/13] fix sycl.hpp include Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/nested_queue_submit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index 329e477f322b0..b9ed7cddd91c3 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -1,9 +1,9 @@ // RUN: %{build} -I . -o %t.out // RUN: %{run} %t.out -#include -#include #include +#include +#include void checkExceptionFields(const sycl::exception &e) { assert(e.code() == sycl::errc::invalid && "Invalid error code"); From 0192c327ef89dcc366ff9a1820f2ebc59e6374ab Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 29 May 2024 03:14:37 -0700 Subject: [PATCH 12/13] fix code format Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/nested_queue_submit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index b9ed7cddd91c3..14139a942e0df 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -1,9 +1,9 @@ // RUN: %{build} -I . -o %t.out // RUN: %{run} %t.out -#include #include #include +#include void checkExceptionFields(const sycl::exception &e) { assert(e.code() == sycl::errc::invalid && "Invalid error code"); From e991892557a6e6570d3eaf7e87a9dcab09ff5712 Mon Sep 17 00:00:00 2001 From: "Tikhomirova, Kseniya" Date: Wed, 29 May 2024 05:22:58 -0700 Subject: [PATCH 13/13] fix include Signed-off-by: Tikhomirova, Kseniya --- sycl/test-e2e/Basic/nested_queue_submit.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/test-e2e/Basic/nested_queue_submit.cpp b/sycl/test-e2e/Basic/nested_queue_submit.cpp index 14139a942e0df..dc47c5c7a89ed 100644 --- a/sycl/test-e2e/Basic/nested_queue_submit.cpp +++ b/sycl/test-e2e/Basic/nested_queue_submit.cpp @@ -3,6 +3,7 @@ #include #include +#include #include void checkExceptionFields(const sycl::exception &e) {