diff --git a/sycl/cmake/modules/AddSYCLUnitTest.cmake b/sycl/cmake/modules/AddSYCLUnitTest.cmake index b4b01b4fb45ea..9f1fa77774361 100644 --- a/sycl/cmake/modules/AddSYCLUnitTest.cmake +++ b/sycl/cmake/modules/AddSYCLUnitTest.cmake @@ -1,6 +1,6 @@ # Internal function to create SYCL unit tests with code reuse -# add_sycl_unittest_internal(test_dirname SHARED|OBJECT is_preview file1.cpp, file2.cpp ...) -function(add_sycl_unittest_internal test_dirname link_variant is_preview) +# add_sycl_unittest_internal(test_dirname SHARED|OBJECT is_preview is_no_cgh file1.cpp, file2.cpp ...) +function(add_sycl_unittest_internal test_dirname link_variant is_preview is_no_cgh) # Enable exception handling for these unit tests set(LLVM_REQUIRES_EH ON) set(LLVM_REQUIRES_RTTI ON) @@ -34,7 +34,11 @@ function(add_sycl_unittest_internal test_dirname link_variant is_preview) # Chaning CMAKE_CURRENT_BINARY_DIR should not affect this variable in its # parent scope. if (${is_preview}) - set(CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/Preview") + set(CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/Preview") + endif() + + if (${is_no_cgh}) + set(CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/NoCGH") endif() if ("${link_variant}" MATCHES "SHARED") @@ -65,6 +69,18 @@ function(add_sycl_unittest_internal test_dirname link_variant is_preview) set(sycl_cache_suffix "_preview") endif() + if (${is_no_cgh}) + set(sycl_cache_suffix "_no_cgh") + endif() + + if (${is_no_cgh}) + target_compile_definitions( + ${test_dirname} + PRIVATE + __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT + ) + endif() + if (SYCL_ENABLE_XPTI_TRACING) target_compile_definitions(${test_dirname} PRIVATE XPTI_ENABLE_INSTRUMENTATION XPTI_STATIC_LIBRARY) @@ -150,7 +166,6 @@ function(add_sycl_unittest_internal test_dirname link_variant is_preview) -Wno-inconsistent-missing-override ) endif() - target_compile_definitions(${test_dirname} PRIVATE SYCL_DISABLE_FSYCL_SYCLHPP_WARNING) endfunction() @@ -160,6 +175,7 @@ endfunction() # the SYCL preview features enabled. # Produces two binaries, named `basename(test_name_prefix_non_preview)` and `basename(test_name_prefix_preview)` macro(add_sycl_unittest test_name_prefix link_variant) - add_sycl_unittest_internal(${test_name_prefix}_non_preview ${link_variant} FALSE ${ARGN}) - add_sycl_unittest_internal(${test_name_prefix}_preview ${link_variant} TRUE ${ARGN}) + add_sycl_unittest_internal(${test_name_prefix}_non_preview ${link_variant} FALSE FALSE ${ARGN}) + add_sycl_unittest_internal(${test_name_prefix}_no_cgh ${link_variant} FALSE TRUE ${ARGN}) + add_sycl_unittest_internal(${test_name_prefix}_preview ${link_variant} TRUE FALSE ${ARGN}) endmacro() diff --git a/sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp b/sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp index adc48ef08a674..3dc28532b2372 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp @@ -259,10 +259,19 @@ template void nd_launch(queue Q, nd_range Range, const KernelType &KernelObj, ReductionsT &&...Reductions) { - submit(std::move(Q), [&](handler &CGH) { - nd_launch(CGH, Range, KernelObj, - std::forward(Reductions)...); - }); +#ifdef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT + // TODO The handler-less path does not support reductions yet. + if constexpr (sizeof...(ReductionsT) == 0) { + detail::submit_kernel_direct(std::move(Q), empty_properties_t{}, + Range, KernelObj); + } else +#endif + { + submit(std::move(Q), [&](handler &CGH) { + nd_launch(CGH, Range, KernelObj, + std::forward(Reductions)...); + }); + } } template void nd_launch(queue Q, launch_config, Properties> Config, const KernelType &KernelObj, ReductionsT &&...Reductions) { - submit(std::move(Q), [&](handler &CGH) { - nd_launch(CGH, Config, KernelObj, - std::forward(Reductions)...); - }); +#ifdef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT + // TODO The handler-less path does not support reductions yet. + if constexpr (sizeof...(ReductionsT) == 0) { + ext::oneapi::experimental::detail::LaunchConfigAccess, + Properties> + ConfigAccess(Config); + detail::submit_kernel_direct( + std::move(Q), ConfigAccess.getProperties(), ConfigAccess.getRange(), + KernelObj); + } else +#endif + { + submit(std::move(Q), [&](handler &CGH) { + nd_launch(CGH, Config, KernelObj, + std::forward(Reductions)...); + }); + } } template diff --git a/sycl/include/sycl/khr/free_function_commands.hpp b/sycl/include/sycl/khr/free_function_commands.hpp index 4138edd5821e6..c0d2afc4115ad 100644 --- a/sycl/include/sycl/khr/free_function_commands.hpp +++ b/sycl/include/sycl/khr/free_function_commands.hpp @@ -153,27 +153,45 @@ void launch_grouped(const queue &q, range<1> r, range<1> size, const KernelType &k, const sycl::detail::code_location &codeLoc = sycl::detail::code_location::current()) { +#ifdef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT + detail::submit_kernel_direct(q, + ext::oneapi::experimental::empty_properties_t{}, + nd_range<1>(r, size), k); +#else submit( q, [&](handler &h) { launch_grouped(h, r, size, k); }, codeLoc); +#endif } template void launch_grouped(const queue &q, range<2> r, range<2> size, const KernelType &k, const sycl::detail::code_location &codeLoc = sycl::detail::code_location::current()) { +#ifdef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT + detail::submit_kernel_direct(q, + ext::oneapi::experimental::empty_properties_t{}, + nd_range<2>(r, size), k); +#else submit( q, [&](handler &h) { launch_grouped(h, r, size, k); }, codeLoc); +#endif } template void launch_grouped(const queue &q, range<3> r, range<3> size, const KernelType &k, const sycl::detail::code_location &codeLoc = sycl::detail::code_location::current()) { +#ifdef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT + detail::submit_kernel_direct(q, + ext::oneapi::experimental::empty_properties_t{}, + nd_range<3>(r, size), k); +#else submit( q, [&](handler &h) { launch_grouped(h, r, size, k); }, codeLoc); +#endif } template diff --git a/sycl/include/sycl/queue.hpp b/sycl/include/sycl/queue.hpp index 3eb710f32ab60..24fc71e9dff3a 100644 --- a/sycl/include/sycl/queue.hpp +++ b/sycl/include/sycl/queue.hpp @@ -62,6 +62,20 @@ template auto get_native(const SyclObjectT &Obj) -> backend_return_t; +template +event __SYCL_EXPORT submit_kernel_direct_with_event_impl( + const queue &Queue, const nd_range &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + +template +void __SYCL_EXPORT submit_kernel_direct_without_event_impl( + const queue &Queue, const nd_range &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + namespace detail { class queue_impl; @@ -141,6 +155,51 @@ class __SYCL_EXPORT SubmissionInfo { }; } // namespace v1 + +template +auto submit_kernel_direct( + const queue &Queue, PropertiesT Props, const nd_range &Range, + const KernelType &KernelFunc, + const detail::code_location &CodeLoc = detail::code_location::current()) { + // TODO Properties not supported yet + (void)Props; + static_assert( + std::is_same_v, + "Setting properties not supported yet for no-CGH kernel submit."); + detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc); + + using NameT = + typename detail::get_kernel_name_t::name; + using LambdaArgType = + sycl::detail::lambda_arg_type>; + static_assert( + std::is_convertible_v, LambdaArgType>, + "Kernel argument of a sycl::parallel_for with sycl::nd_range " + "must be either sycl::nd_item or be convertible from sycl::nd_item"); + using TransformedArgType = sycl::nd_item; + + std::shared_ptr HostKernel = std::make_shared< + detail::HostKernel>(KernelFunc); + + detail::DeviceKernelInfo *DeviceKernelInfoPtr = + &detail::getDeviceKernelInfo(); + + detail::KernelWrapper::wrap(KernelFunc); + + if constexpr (EventNeeded) { + return submit_kernel_direct_with_event_impl( + Queue, Range, HostKernel, DeviceKernelInfoPtr, + TlsCodeLocCapture.query(), TlsCodeLocCapture.isToplevel()); + } else { + submit_kernel_direct_without_event_impl( + Queue, Range, HostKernel, DeviceKernelInfoPtr, + TlsCodeLocCapture.query(), TlsCodeLocCapture.isToplevel()); + } +} + } // namespace detail namespace ext ::oneapi ::experimental { @@ -3203,11 +3262,21 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase { parallel_for(nd_range Range, RestT &&...Rest) { constexpr detail::code_location CodeLoc = getCodeLocation(); detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc); - return submit( - [&](handler &CGH) { - CGH.template parallel_for(Range, Rest...); - }, - TlsCodeLocCapture.query()); +#ifdef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT + // TODO The handler-less path does not support reductions yet. + if constexpr (sizeof...(RestT) == 1) { + return detail::submit_kernel_direct( + *this, ext::oneapi::experimental::empty_properties_t{}, Range, + Rest...); + } else +#endif + { + return submit( + [&](handler &CGH) { + CGH.template parallel_for(Range, Rest...); + }, + TlsCodeLocCapture.query()); + } } /// parallel_for version with a kernel represented as a lambda + nd_range that diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index c59b5eaa20387..4965ab6e8d729 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -417,6 +417,106 @@ queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF, return EventImpl; } +detail::EventImplPtr queue_impl::submit_kernel_direct_impl( + const NDRDescT &NDRDesc, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, bool CallerNeedsEvent, + const detail::code_location &CodeLoc, bool IsTopCodeLoc) { + + KernelData KData; + + KData.setDeviceKernelInfoPtr(DeviceKernelInfo); + KData.setKernelFunc(HostKernel->getPtr()); + KData.setNDRDesc(NDRDesc); + + auto SubmitKernelFunc = + [&](detail::CG::StorageInitHelper &CGData) -> EventImplPtr { + std::unique_ptr CommandGroup; + std::vector> StreamStorage; + std::vector> AuxiliaryResources; + + KData.extractArgsAndReqsFromLambda(); + + CommandGroup.reset(new detail::CGExecKernel( + KData.getNDRDesc(), HostKernel, + nullptr, // Kernel + nullptr, // KernelBundle + std::move(CGData), std::move(KData).getArgs(), + *KData.getDeviceKernelInfoPtr(), std::move(StreamStorage), + std::move(AuxiliaryResources), detail::CGType::Kernel, + UR_KERNEL_CACHE_CONFIG_DEFAULT, + false, // KernelIsCooperative + false, // KernelUsesClusterLaunch + 0, // KernelWorkGroupMemorySize + CodeLoc)); + CommandGroup->MIsTopCodeLoc = IsTopCodeLoc; + + return detail::Scheduler::getInstance().addCG(std::move(CommandGroup), + *this, true); + }; + + return submit_direct(CallerNeedsEvent, SubmitKernelFunc); +} + +template +detail::EventImplPtr +queue_impl::submit_direct(bool CallerNeedsEvent, + SubmitCommandFuncType &SubmitCommandFunc) { + detail::CG::StorageInitHelper CGData; + std::unique_lock Lock(MMutex); + + // Graphs are not supported yet for the no-handler path + assert(!hasCommandGraph()); + + // Set the No Last Event Mode to false, since the no-handler path + // does not support it yet. + MNoLastEventMode.store(false, std::memory_order_relaxed); + + // Used by queue_empty() and getLastEvent() + MEmpty.store(false, std::memory_order_release); + + // Sync with an external event + std::optional ExternalEvent = popExternalEvent(); + if (ExternalEvent) { + CGData.MEvents.push_back(getSyclObjImpl(*ExternalEvent)); + } + + // Sync with the last event for in order queue + EventImplPtr &LastEvent = MDefaultGraphDeps.LastEventPtr; + if (isInOrder() && LastEvent) { + CGData.MEvents.push_back(LastEvent); + } + + // Barrier and un-enqueued commands synchronization for out or order queue + if (!isInOrder()) { + MMissedCleanupRequests.unset( + [&](MissedCleanupRequestsType &MissedCleanupRequests) { + for (auto &UpdatedGraph : MissedCleanupRequests) + doUnenqueuedCommandCleanup(UpdatedGraph); + MissedCleanupRequests.clear(); + }); + + if (MDefaultGraphDeps.LastBarrier && + !MDefaultGraphDeps.LastBarrier->isEnqueued()) { + CGData.MEvents.push_back(MDefaultGraphDeps.LastBarrier); + } + } + + EventImplPtr EventImpl = SubmitCommandFunc(CGData); + + // Sync with the last event for in order queue + if (isInOrder() && !EventImpl->isDiscarded()) { + LastEvent = EventImpl; + } + + // Barrier and un-enqueued commands synchronization for out or order queue + if (!isInOrder() && !EventImpl->isEnqueued()) { + MDefaultGraphDeps.UnenqueuedCmdEvents.push_back(EventImpl); + } + + return CallerNeedsEvent ? EventImpl : nullptr; +} + template event queue_impl::submitWithHandler(const std::vector &DepEvents, bool CallerNeedsEvent, diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 2b1d8f637b05d..c3d6748695423 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -359,6 +359,28 @@ class queue_impl : public std::enable_shared_from_this { return createSyclObjFromImpl(ResEvent); } + template + event submit_kernel_direct_with_event( + const nd_range &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc) { + detail::EventImplPtr EventImpl = + submit_kernel_direct_impl(NDRDescT{Range}, HostKernel, DeviceKernelInfo, + true, CodeLoc, IsTopCodeLoc); + return createSyclObjFromImpl(EventImpl); + } + + template + void submit_kernel_direct_without_event( + const nd_range &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc) { + submit_kernel_direct_impl(NDRDescT{Range}, HostKernel, DeviceKernelInfo, + false, CodeLoc, IsTopCodeLoc); + } + void submit_without_event(const detail::type_erased_cgfo_ty &CGF, const v1::SubmissionInfo &SubmitInfo, const detail::code_location &Loc, @@ -870,6 +892,28 @@ class queue_impl : public std::enable_shared_from_this { bool IsTopCodeLoc, const v1::SubmissionInfo &SubmitInfo); + /// Performs kernel submission to the queue. + /// + /// \param NDRDesc is an NDRange descriptor + /// \param HostKernel stores the kernel lambda instance + /// \param DeviceKernelInfo is a structure aggregating kernel related data + /// \param CallerNeedsEvent is a boolean indicating whether the event is + /// required by the user after the call. + /// \param CodeLoc is the code location of the submit call + /// \param IsTopCodeLoc Used to determine if the object is in a local + /// scope or in the top level scope. + /// + /// \return a SYCL event representing submitted command group or nullptr. + detail::EventImplPtr submit_kernel_direct_impl( + const NDRDescT &NDRDesc, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, bool CallerNeedsEvent, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + + template + detail::EventImplPtr submit_direct(bool CallerNeedsEvent, + SubmitCommandFuncType &SubmitCommandFunc); + /// Helper function for submitting a memory operation with a handler. /// \param DepEvents is a vector of dependencies of the operation. /// \param HandlerFunc is a function that submits the operation with a diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index b73c24091d4ed..ea64c80668958 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -480,6 +480,62 @@ void queue::ext_oneapi_set_external_event(const event &external_event) { const property_list &queue::getPropList() const { return impl->getPropList(); } +template +event submit_kernel_direct_with_event_impl( + const queue &Queue, const nd_range &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc) { + return getSyclObjImpl(Queue)->submit_kernel_direct_with_event( + Range, HostKernel, DeviceKernelInfo, CodeLoc, IsTopCodeLoc); +} + +template event __SYCL_EXPORT submit_kernel_direct_with_event_impl<1>( + const queue &Queue, const nd_range<1> &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + +template event __SYCL_EXPORT submit_kernel_direct_with_event_impl<2>( + const queue &Queue, const nd_range<2> &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + +template event __SYCL_EXPORT submit_kernel_direct_with_event_impl<3>( + const queue &Queue, const nd_range<3> &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + +template +void submit_kernel_direct_without_event_impl( + const queue &Queue, const nd_range &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc) { + getSyclObjImpl(Queue)->submit_kernel_direct_without_event( + Range, HostKernel, DeviceKernelInfo, CodeLoc, IsTopCodeLoc); +} + +template void __SYCL_EXPORT submit_kernel_direct_without_event_impl<1>( + const queue &Queue, const nd_range<1> &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + +template void __SYCL_EXPORT submit_kernel_direct_without_event_impl<2>( + const queue &Queue, const nd_range<2> &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + +template void __SYCL_EXPORT submit_kernel_direct_without_event_impl<3>( + const queue &Queue, const nd_range<3> &Range, + std::shared_ptr &HostKernel, + detail::DeviceKernelInfo *DeviceKernelInfo, + const detail::code_location &CodeLoc, bool IsTopCodeLoc); + } // namespace _V1 } // namespace sycl diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 0481c5b393302..ec2a21ef34424 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -2985,6 +2985,12 @@ _ZN4sycl3_V121__isgreaterequal_implEdd _ZN4sycl3_V121__isgreaterequal_implEff _ZN4sycl3_V122accelerator_selector_vERKNS0_6deviceE _ZN4sycl3_V128verifyUSMAllocatorPropertiesERKNS0_13property_listE +_ZN4sycl3_V136submit_kernel_direct_with_event_implILi1EEENS0_5eventERKNS0_5queueERKNS0_8nd_rangeIXT_EEERSt10shared_ptrINS0_6detail14HostKernelBaseEEPNSB_16DeviceKernelInfoERKNSB_13code_locationEb +_ZN4sycl3_V136submit_kernel_direct_with_event_implILi2EEENS0_5eventERKNS0_5queueERKNS0_8nd_rangeIXT_EEERSt10shared_ptrINS0_6detail14HostKernelBaseEEPNSB_16DeviceKernelInfoERKNSB_13code_locationEb +_ZN4sycl3_V136submit_kernel_direct_with_event_implILi3EEENS0_5eventERKNS0_5queueERKNS0_8nd_rangeIXT_EEERSt10shared_ptrINS0_6detail14HostKernelBaseEEPNSB_16DeviceKernelInfoERKNSB_13code_locationEb +_ZN4sycl3_V139submit_kernel_direct_without_event_implILi1EEEvRKNS0_5queueERKNS0_8nd_rangeIXT_EEERSt10shared_ptrINS0_6detail14HostKernelBaseEEPNSA_16DeviceKernelInfoERKNSA_13code_locationEb +_ZN4sycl3_V139submit_kernel_direct_without_event_implILi2EEEvRKNS0_5queueERKNS0_8nd_rangeIXT_EEERSt10shared_ptrINS0_6detail14HostKernelBaseEEPNSA_16DeviceKernelInfoERKNSA_13code_locationEb +_ZN4sycl3_V139submit_kernel_direct_without_event_implILi3EEEvRKNS0_5queueERKNS0_8nd_rangeIXT_EEERSt10shared_ptrINS0_6detail14HostKernelBaseEEPNSA_16DeviceKernelInfoERKNSA_13code_locationEb _ZN4sycl3_V13ext5intel12experimental9pipe_base13get_pipe_nameB5cxx11EPKv _ZN4sycl3_V13ext5intel12experimental9pipe_base17wait_non_blockingERKNS0_5eventE _ZN4sycl3_V13ext5intel12experimental9pipe_base18get_pipe_name_implEPKv diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 2c6be6c1684bb..8eed8b8dba437 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -286,6 +286,12 @@ ??$is_image_handle_supported@Usampled_image_handle@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA_NAEBUimage_descriptor@01234@W4image_memory_handle_type@01234@AEBVqueue@34@@Z ??$is_image_handle_supported@Uunsampled_image_handle@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA_NAEBUimage_descriptor@01234@W4image_memory_handle_type@01234@AEBVdevice@34@AEBVcontext@34@@Z ??$is_image_handle_supported@Uunsampled_image_handle@experimental@oneapi@ext@_V1@sycl@@@experimental@oneapi@ext@_V1@sycl@@YA_NAEBUimage_descriptor@01234@W4image_memory_handle_type@01234@AEBVqueue@34@@Z +??$submit_kernel_direct_with_event_impl@$00@_V1@sycl@@YA?AVevent@01@AEBVqueue@01@AEBV?$nd_range@$00@01@AEAV?$shared_ptr@VHostKernelBase@detail@_V1@sycl@@@std@@PEAVDeviceKernelInfo@detail@01@AEBUcode_location@801@_N@Z +??$submit_kernel_direct_with_event_impl@$01@_V1@sycl@@YA?AVevent@01@AEBVqueue@01@AEBV?$nd_range@$01@01@AEAV?$shared_ptr@VHostKernelBase@detail@_V1@sycl@@@std@@PEAVDeviceKernelInfo@detail@01@AEBUcode_location@801@_N@Z +??$submit_kernel_direct_with_event_impl@$02@_V1@sycl@@YA?AVevent@01@AEBVqueue@01@AEBV?$nd_range@$02@01@AEAV?$shared_ptr@VHostKernelBase@detail@_V1@sycl@@@std@@PEAVDeviceKernelInfo@detail@01@AEBUcode_location@801@_N@Z +??$submit_kernel_direct_without_event_impl@$00@_V1@sycl@@YAXAEBVqueue@01@AEBV?$nd_range@$00@01@AEAV?$shared_ptr@VHostKernelBase@detail@_V1@sycl@@@std@@PEAVDeviceKernelInfo@detail@01@AEBUcode_location@701@_N@Z +??$submit_kernel_direct_without_event_impl@$01@_V1@sycl@@YAXAEBVqueue@01@AEBV?$nd_range@$01@01@AEAV?$shared_ptr@VHostKernelBase@detail@_V1@sycl@@@std@@PEAVDeviceKernelInfo@detail@01@AEBUcode_location@701@_N@Z +??$submit_kernel_direct_without_event_impl@$02@_V1@sycl@@YAXAEBVqueue@01@AEBV?$nd_range@$02@01@AEAV?$shared_ptr@VHostKernelBase@detail@_V1@sycl@@@std@@PEAVDeviceKernelInfo@detail@01@AEBUcode_location@701@_N@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 diff --git a/sycl/unittests/Extensions/CommandGraph/CommandGraph.cpp b/sycl/unittests/Extensions/CommandGraph/CommandGraph.cpp index dedd4ebbcb407..f8cb84900d4f8 100644 --- a/sycl/unittests/Extensions/CommandGraph/CommandGraph.cpp +++ b/sycl/unittests/Extensions/CommandGraph/CommandGraph.cpp @@ -626,6 +626,8 @@ TEST_F(CommandGraphTest, AccessorModeEdges) { // Tests the transitive queue recording behaviour with queue shortcuts. TEST_F(CommandGraphTest, TransitiveRecordingShortcuts) { +// Graphs not supported yet for the no-handler submit path +#ifndef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT device Dev; context Ctx{{Dev}}; queue Q1{Ctx, Dev}; @@ -669,6 +671,7 @@ TEST_F(CommandGraphTest, TransitiveRecordingShortcuts) { ext::oneapi::experimental::queue_state::executing); ASSERT_EQ(Q3.ext_oneapi_get_state(), ext::oneapi::experimental::queue_state::executing); +#endif } // Tests that dynamic_work_group_memory.get() will throw on the host side. diff --git a/sycl/unittests/Extensions/FreeFunctionCommands/FreeFunctionEventsHelpers.hpp b/sycl/unittests/Extensions/FreeFunctionCommands/FreeFunctionEventsHelpers.hpp index c45d72ea4c343..e0a5c9be50c15 100644 --- a/sycl/unittests/Extensions/FreeFunctionCommands/FreeFunctionEventsHelpers.hpp +++ b/sycl/unittests/Extensions/FreeFunctionCommands/FreeFunctionEventsHelpers.hpp @@ -26,40 +26,53 @@ inline ur_result_t after_urKernelGetInfo(void *pParams) { static thread_local size_t counter_urEnqueueKernelLaunch = 0; inline ur_result_t redefined_urEnqueueKernelLaunch(void *pParams) { ++counter_urEnqueueKernelLaunch; +// TODO The no-handler scheduler submission includes a fix for the event return, +// where the event is returned by the scheduler on every submission. This fix +// is not yet applied to the handler-based path. +#ifndef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT auto params = *static_cast(pParams); EXPECT_EQ(*params.pphEvent, nullptr); +#endif return UR_RESULT_SUCCESS; } static thread_local size_t counter_urUSMEnqueueMemcpy = 0; inline ur_result_t redefined_urUSMEnqueueMemcpy(void *pParams) { ++counter_urUSMEnqueueMemcpy; +#ifndef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT auto params = *static_cast(pParams); EXPECT_EQ(*params.pphEvent, nullptr); +#endif return UR_RESULT_SUCCESS; } static thread_local size_t counter_urUSMEnqueueFill = 0; inline ur_result_t redefined_urUSMEnqueueFill(void *pParams) { ++counter_urUSMEnqueueFill; +#ifndef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT auto params = *static_cast(pParams); EXPECT_EQ(*params.pphEvent, nullptr); +#endif return UR_RESULT_SUCCESS; } static thread_local size_t counter_urUSMEnqueuePrefetch = 0; inline ur_result_t redefined_urUSMEnqueuePrefetch(void *pParams) { ++counter_urUSMEnqueuePrefetch; +#ifndef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT auto params = *static_cast(pParams); EXPECT_EQ(*params.pphEvent, nullptr); +#endif return UR_RESULT_SUCCESS; } static thread_local size_t counter_urUSMEnqueueMemAdvise = 0; inline ur_result_t redefined_urUSMEnqueueMemAdvise(void *pParams) { ++counter_urUSMEnqueueMemAdvise; +#ifndef __DPCPP_ENABLE_UNFINISHED_NO_CGH_SUBMIT auto params = *static_cast(pParams); EXPECT_EQ(*params.pphEvent, nullptr); +#endif return UR_RESULT_SUCCESS; } diff --git a/sycl/unittests/scheduler/InOrderQueueHostTaskDeps.cpp b/sycl/unittests/scheduler/InOrderQueueHostTaskDeps.cpp index 31a2914e2c803..7dae968013948 100644 --- a/sycl/unittests/scheduler/InOrderQueueHostTaskDeps.cpp +++ b/sycl/unittests/scheduler/InOrderQueueHostTaskDeps.cpp @@ -48,7 +48,7 @@ TEST_F(SchedulerTest, InOrderQueueHostTaskDeps) { EXPECT_EQ(GEventsWaitCounter, expectedCount); } -enum class CommandType { KERNEL = 1, MEMSET = 2 }; +enum class CommandType { KERNEL = 1, MEMSET = 2, HOST_TASK = 3 }; std::vector> ExecutedCommands; inline ur_result_t customEnqueueKernelLaunch(void *pParams) { @@ -162,3 +162,44 @@ TEST_F(SchedulerTest, InOrderQueueCrossDepsShortcutFuncs) { EXPECT_EQ(ExecutedCommands[1].first /*CommandType*/, CommandType::KERNEL); EXPECT_EQ(ExecutedCommands[1].second /*EventsCount*/, 0u); } + +TEST_F(SchedulerTest, InOrderQueueCrossDepsShortcutFuncsParallelFor) { + ExecutedCommands.clear(); + sycl::unittest::UrMock<> Mock; + mock::getCallbacks().set_before_callback("urEnqueueKernelLaunch", + &customEnqueueKernelLaunch); + + sycl::platform Plt = sycl::platform(); + + context Ctx{Plt}; + queue InOrderQueue{Ctx, default_selector_v, property::queue::in_order()}; + + std::mutex CvMutex; + std::condition_variable Cv; + bool ready = false; + + InOrderQueue.submit([&](sycl::handler &CGH) { + CGH.host_task([&] { + std::unique_lock lk(CvMutex); + Cv.wait(lk, [&ready] { return ready; }); + ExecutedCommands.push_back({CommandType::HOST_TASK, 0}); + }); + }); + + event Ev2 = InOrderQueue.parallel_for( + nd_range<1>{range{32}, range{32}}, [](nd_item<1>) {}); + + { + std::unique_lock lk(CvMutex); + ready = true; + } + Cv.notify_one(); + + InOrderQueue.wait(); + + ASSERT_EQ(ExecutedCommands.size(), 2u); + EXPECT_EQ(ExecutedCommands[0].first /*CommandType*/, CommandType::HOST_TASK); + EXPECT_EQ(ExecutedCommands[0].second /*EventsCount*/, 0u); + EXPECT_EQ(ExecutedCommands[1].first /*CommandType*/, CommandType::KERNEL); + EXPECT_EQ(ExecutedCommands[1].second /*EventsCount*/, 0u); +} diff --git a/sycl/unittests/xpti_trace/CMakeLists.txt b/sycl/unittests/xpti_trace/CMakeLists.txt index 44574d36a9aa4..0fbb3be4046fc 100644 --- a/sycl/unittests/xpti_trace/CMakeLists.txt +++ b/sycl/unittests/xpti_trace/CMakeLists.txt @@ -8,3 +8,4 @@ add_sycl_unittest(XptiTraceTests OBJECT ) target_link_libraries(XptiTraceTests_non_preview PRIVATE xpti xptitest_subscriber) target_link_libraries(XptiTraceTests_preview PRIVATE xpti xptitest_subscriber) +target_link_libraries(XptiTraceTests_no_cgh PRIVATE xpti xptitest_subscriber)