forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 3
SYCL Graph emulation mode #56
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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,67 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
#include <CL/sycl.hpp> | ||
#include <iostream> | ||
|
||
#include <sycl/ext/oneapi/experimental/graph.hpp> | ||
|
||
int main() { | ||
|
||
sycl::property_list properties{ | ||
sycl::property::queue::in_order{}, | ||
sycl::ext::oneapi::property::queue::lazy_execution{}}; | ||
|
||
sycl::queue q{sycl::gpu_selector_v, properties}; | ||
|
||
sycl::ext::oneapi::experimental::command_graph g; | ||
|
||
const size_t n = 10; | ||
float *arr = sycl::malloc_shared<float>(n, q); | ||
for (int i = 0; i < n; i++) { | ||
arr[i] = 0; | ||
} | ||
|
||
g.add([&](sycl::handler &h) { | ||
h.parallel_for(sycl::range<1>{n}, [=](sycl::id<1> idx) { | ||
size_t i = idx; | ||
arr[i] += 1; | ||
}); | ||
}); | ||
|
||
bool check = true; | ||
for (int i = 0; i < n; i++) { | ||
if (arr[i] != 0) | ||
check = false; | ||
} | ||
|
||
auto executable_graph = g.finalize(q.get_context()); | ||
|
||
for (int i = 0; i < n; i++) { | ||
if (arr[i] != 0) | ||
check = false; | ||
} | ||
|
||
q.submit([&](sycl::handler &h) { h.exec_graph(executable_graph); }); | ||
|
||
for (int i = 0; i < n; i++) { | ||
if (arr[i] != 1) | ||
check = false; | ||
} | ||
|
||
q.submit([&](sycl::handler &h) { h.exec_graph(executable_graph); }); | ||
|
||
for (int i = 0; i < n; i++) { | ||
if (arr[i] != 2) | ||
check = false; | ||
} | ||
|
||
if (check) | ||
std::cout << "Repeated execution of an explicit graph test passed." | ||
<< std::endl; | ||
else | ||
std::cout << "Repeated execution of an explicit graph test failed." | ||
<< std::endl; | ||
|
||
sycl::free(arr, q); | ||
|
||
return 0; | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this emulation mode to be most useful, in my mind it wouldn't live in a separate branch that we would need to keep up-to-date with the PoC branch, but live in the PoC branch itself.
Rather than removing this code, have you considered making emulation mode an environment variable users can set to ON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Ewan. The idea of using a separate branch and removing the PI implementation was to ease the review and merging of the code into the mainline. My understanding of the proposed three-step merge process is to provide the Graph API in the emulation mode and extend it with plugin implementations. Thus, SYCL Graph codes could be compiled for all runtimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, that makes sense as the first part of the 3 stage approach. I'm a bit wary of us trying to maintain a lot of branches, so I think we should sync up on our call later about how soon we want to open that stage 1 PR. If it's ASAP then using
sycl-graph-poc-emulation
to do that I think is good. However, if it's more delayed and more changes start getting merged into the PoC branch, then maintainingsycl-graph-poc-emulation
will be an overhead, and it might just be better to have the path in the PoC branch guarded by a preprocessor macro. Then, once we want to open a DPC++ PR with just stage 1, we can easily remove the macro and just keep the emulation path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the 3-step merge process referred to in the comment on the POC PR is for a future final implementation and not for the POC (which this code is based on). Unless we are planning to close that open PR and resubmit this as the first step, I agree with the idea of having this be optional functionality in the POC guarded by a macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will close this in favor of a version that is guarded by the SYCL Graph macro as discussed. I will further split the testing part of this PR into a separate PR.