-
Notifications
You must be signed in to change notification settings - Fork 848
[SYCL][Graph] Support handler-based restricted host task with native recording #22746
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
Open
mmichel11
wants to merge
1
commit into
intel:sycl
Choose a base branch
from
adamfidel:matt/native_host_task_handler
base: sycl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+178
−13
Open
Changes from all commits
Commits
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
107 changes: 107 additions & 0 deletions
107
sycl/test-e2e/Graph/RecordReplay/Inputs/enqueue_func_host_task_event.cpp
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,107 @@ | ||
| // Tests that a restricted host task submitted through the | ||
| // handler path can be recorded into a SYCL Graph and | ||
| // participate in event-based dependencies. | ||
|
|
||
| #include "../../graph_common.hpp" | ||
|
|
||
| #include <sycl/ext/oneapi/experimental/enqueue_functions.hpp> | ||
| #include <sycl/properties/all_properties.hpp> | ||
|
|
||
| constexpr size_t N = 1024; | ||
|
|
||
| int main() { | ||
| device Dev; | ||
| context Ctx{Dev}; | ||
|
|
||
| queue Queue1{Ctx, Dev, {property::queue::in_order{}}}; | ||
| queue Queue2{Ctx, Dev, {property::queue::in_order{}}}; | ||
| queue Queue3{Ctx, Dev, {property::queue::in_order{}}}; | ||
|
|
||
| #ifdef GRAPH_E2E_NATIVE_RECORDING | ||
| exp_ext::command_graph Graph{ | ||
| Ctx, Dev, {exp_ext::property::graph::enable_native_recording{}}}; | ||
| #else | ||
| exp_ext::command_graph Graph{Ctx, Dev}; | ||
| #endif | ||
|
|
||
| uint32_t *Data = malloc_shared<uint32_t>(N, Queue1); | ||
| std::fill(Data, Data + N, 0); | ||
|
|
||
| QueueStateVerifier verifier(Queue1, Queue2, Queue3); | ||
| verifier.verify(EXECUTING, EXECUTING, EXECUTING); | ||
|
|
||
| Graph.begin_recording(Queue1); | ||
| verifier.verify(RECORDING, EXECUTING, EXECUTING); | ||
|
|
||
| exp_ext::submit_with_event(Queue1, [&](handler &CGH) { | ||
| exp_ext::host_task(CGH, [=] { | ||
| for (size_t i = 0; i < N; i++) | ||
| Data[i] += 5; | ||
| }); | ||
| }); | ||
|
|
||
| Queue1.submit([&](handler &CGH) { | ||
| CGH.parallel_for(range<1>{N}, [=](id<1> idx) { | ||
| Data[idx] += static_cast<uint32_t>(idx[0]) + 1; | ||
| }); | ||
| }); | ||
|
|
||
| // Fork: host task signals ForkEvent, consumed by Q2 and Q3. | ||
| auto ForkEvent = exp_ext::submit_with_event(Queue1, [&](handler &CGH) { | ||
| exp_ext::host_task(CGH, [=] { | ||
| for (size_t i = 0; i < N; i++) | ||
| Data[i] += 100; | ||
| }); | ||
| }); | ||
|
|
||
| // Q2 and Q3 run concurrently, so they operate on disjoint halves. | ||
| // Q2 fork: kernel on the first half. | ||
| auto Q2Event = exp_ext::submit_with_event(Queue2, [&](handler &CGH) { | ||
| CGH.depends_on(ForkEvent); | ||
| CGH.parallel_for(range<1>{N / 2}, [=](id<1> idx) { Data[idx] += 10; }); | ||
| }); | ||
| verifier.verify(RECORDING, RECORDING, EXECUTING); | ||
|
|
||
| // Q3 fork: host task on the second half. | ||
| auto Q3Event = exp_ext::submit_with_event(Queue3, [&](handler &CGH) { | ||
| CGH.depends_on(ForkEvent); | ||
| exp_ext::host_task(CGH, [=] { | ||
| for (size_t i = N / 2; i < N; i++) | ||
| Data[i] += 10; | ||
| }); | ||
| }); | ||
| verifier.verify(RECORDING, RECORDING, RECORDING); | ||
|
|
||
| // Join: host task waits on events from two distinct queues | ||
| Queue1.submit([&](handler &CGH) { | ||
| CGH.depends_on({Q2Event, Q3Event}); | ||
| exp_ext::host_task(CGH, [=] { | ||
| for (size_t i = 0; i < N; i++) | ||
| Data[i] += 1; | ||
| }); | ||
| }); | ||
|
|
||
| Graph.end_recording(); | ||
|
|
||
| auto ExecutableGraph = Graph.finalize(); | ||
|
|
||
| // Each replay adds 5 + (i + 1) + 100 + 10 + 1 = (i + 117) to every element. | ||
| Queue1.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecutableGraph); }); | ||
| Queue1.wait(); | ||
|
|
||
| for (size_t i = 0; i < N; i++) { | ||
| uint32_t Expected = static_cast<uint32_t>(i) + 117; | ||
| assert(check_value(i, Expected, Data[i], "Data")); | ||
| } | ||
|
|
||
| Queue1.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecutableGraph); }); | ||
| Queue1.wait(); | ||
|
|
||
| for (size_t i = 0; i < N; i++) { | ||
| uint32_t Expected = 2 * (static_cast<uint32_t>(i) + 117); | ||
| assert(check_value(i, Expected, Data[i], "Data")); | ||
| } | ||
|
|
||
| free(Data, Queue1); | ||
| return 0; | ||
| } |
17 changes: 17 additions & 0 deletions
17
sycl/test-e2e/Graph/RecordReplay/NativeRecording/enqueue_func_host_task_event.cpp
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,17 @@ | ||
| // REQUIRES: level_zero_v2_adapter && arch-intel_gpu_bmg_g21 | ||
| // REQUIRES: linux | ||
| // REQUIRES: aspect-usm_shared_allocations | ||
| // REQUIRES-INTEL-DRIVER: lin: 38146 | ||
|
|
||
| // TODO: Update windows driver once available with other tests. The current | ||
| // driver restriction aligns with get_graph_multi_queue.cpp | ||
|
|
||
| // RUN: %{build} -o %t.out | ||
| // RUN: %{run} %t.out | ||
| // RUN: %if level_zero %{%{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} | ||
|
|
||
| // Tests fork/join of a restricted host_task using the handler path. | ||
|
|
||
| #define GRAPH_E2E_NATIVE_RECORDING | ||
|
|
||
| #include "../Inputs/enqueue_func_host_task_event.cpp" |
Oops, something went wrong.
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.