-
Notifications
You must be signed in to change notification settings - Fork 803
[SYCL] Fix sync of host task vs kernel for in-order queue #5551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fa6c774
Fix sync of host task vs kernel for in-order queue
KseniyaTikhomirova ecf2fdb
Tiny code fixes: comments and extra header removal
KseniyaTikhomirova b3f0555
Redesign test to verify single finalizeHandler function
KseniyaTikhomirova 968c8b0
Add comment for queue change
KseniyaTikhomirova e14e03e
Code-review: fix test header and namespace
KseniyaTikhomirova e05636a
Code-review: fix grammar in comments
KseniyaTikhomirova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| //==---------- InOrderQueueSyncCheck.cpp --- Scheduler unit tests ----------==// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "SchedulerTest.hpp" | ||
| #include "SchedulerTestUtils.hpp" | ||
| #include <CL/sycl.hpp> | ||
| #include <detail/queue_impl.hpp> | ||
| #include <detail/scheduler/commands.hpp> | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| using namespace sycl; | ||
|
|
||
| // Define type with the only methods called by finalizeHandler | ||
| class LimitedHandler { | ||
| public: | ||
| virtual void depends_on(sycl::event){}; | ||
|
|
||
| virtual event finalize() { | ||
| cl::sycl::detail::EventImplPtr NewEvent = | ||
| std::make_shared<detail::event_impl>(); | ||
| return sycl::detail::createSyclObjFromImpl<sycl::event>(NewEvent); | ||
| }; | ||
| }; | ||
|
|
||
| // Needed to use EXPECT_CALL to verify depends_on that originally appends lst | ||
| // event as dependency to the new CG | ||
| class LimitedHandlerSimulation : public LimitedHandler { | ||
| public: | ||
| MOCK_METHOD1(depends_on, void(sycl::event)); | ||
| }; | ||
|
|
||
| class MockQueueImpl : public sycl::detail::queue_impl { | ||
| public: | ||
| MockQueueImpl(const sycl::detail::DeviceImplPtr &Device, | ||
| const sycl::async_handler &AsyncHandler, | ||
| const sycl::property_list &PropList) | ||
| : sycl::detail::queue_impl(Device, AsyncHandler, PropList) {} | ||
| using sycl::detail::queue_impl::finalizeHandler; | ||
| }; | ||
|
|
||
| // Only check events dependency in queue_impl::finalizeHandler | ||
| TEST_F(SchedulerTest, InOrderQueueSyncCheck) { | ||
| sycl::platform Plt{sycl::default_selector()}; | ||
| if (Plt.is_host() || Plt.get_backend() == sycl::backend::ext_oneapi_cuda || | ||
| Plt.get_backend() == sycl::backend::ext_oneapi_hip) { | ||
| std::cerr << "Test is not supported on " | ||
| << Plt.get_info<sycl::info::platform::name>() << ", skipping\n"; | ||
| GTEST_SKIP(); // test is not supported on selected platform. | ||
| } | ||
|
|
||
| const sycl::device Dev = Plt.get_devices()[0]; | ||
| auto Queue = std::make_shared<MockQueueImpl>( | ||
| sycl::detail::getSyclObjImpl(Dev), sycl::async_handler{}, | ||
| sycl::property::queue::in_order()); | ||
|
|
||
| // What we are testing here: | ||
| // Task type | Must depend on | ||
| // host | yes - always, separate sync management | ||
| // host | yes - always, separate sync management | ||
| // kernel | yes - change of sync approach | ||
| // kernel | no - sync between pi calls must be done by backend | ||
| // host | yes - always, separate sync management | ||
|
|
||
| sycl::event Event; | ||
| // host task | ||
| { | ||
| LimitedHandlerSimulation MockCGH; | ||
| EXPECT_CALL(MockCGH, depends_on).Times(1); | ||
| Queue->finalizeHandler<LimitedHandlerSimulation>( | ||
| MockCGH, detail::CG::CGTYPE::CodeplayHostTask, Event); | ||
| } | ||
| // host task | ||
| { | ||
| LimitedHandlerSimulation MockCGH; | ||
| EXPECT_CALL(MockCGH, depends_on).Times(1); | ||
| Queue->finalizeHandler<LimitedHandlerSimulation>( | ||
| MockCGH, detail::CG::CGTYPE::CodeplayHostTask, Event); | ||
| } | ||
| // kernel task | ||
| { | ||
| LimitedHandlerSimulation MockCGH; | ||
| EXPECT_CALL(MockCGH, depends_on).Times(1); | ||
| Queue->finalizeHandler<LimitedHandlerSimulation>( | ||
| MockCGH, detail::CG::CGTYPE::Kernel, Event); | ||
| } | ||
| // kernel task | ||
| { | ||
| LimitedHandlerSimulation MockCGH; | ||
| EXPECT_CALL(MockCGH, depends_on).Times(0); | ||
| Queue->finalizeHandler<LimitedHandlerSimulation>( | ||
| MockCGH, detail::CG::CGTYPE::Kernel, Event); | ||
| } | ||
| // host task | ||
| { | ||
| LimitedHandlerSimulation MockCGH; | ||
| EXPECT_CALL(MockCGH, depends_on).Times(1); | ||
| Queue->finalizeHandler<LimitedHandlerSimulation>( | ||
| MockCGH, detail::CG::CGTYPE::CodeplayHostTask, Event); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.