-
Notifications
You must be signed in to change notification settings - Fork 808
[SYCL] Add implementation of sycl::intel::barrier #2198
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cdce6dd
[SYCL][Doc] Add barrier to GroupAlgorithms
Pennycook 4953438
[SYCL] Add implementation of sycl::intel::barrier
Pennycook 5c04e39
[SYCL] Add fence_scope argument and fix warnings
Pennycook 3a70070
[SYCL] Fix warnings
Pennycook ffe5ba0
[SYCL][Doc] Clarify relationship to SYCL 2020
Pennycook 6a34aac
[SYCL][Doc] Attempt to clarify group barrier fence
Pennycook 6f4424a
[SYCL] Guarantee memory scope is broad enough
Pennycook 69f0717
Merge remote-tracking branch 'origin/sycl' into group-barrier
Pennycook b2eabbb
[SYCL][Doc] Clarify behavior of scope argument
Pennycook 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // UNSUPPORTED: cuda | ||
| // | ||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
| // RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
|
||
| #include <CL/sycl.hpp> | ||
| #include <cassert> | ||
| using namespace sycl; | ||
| using namespace sycl::intel; | ||
|
|
||
| class barrier_kernel; | ||
|
|
||
| void test(queue q) { | ||
|
|
||
| constexpr size_t N = 32; | ||
| constexpr size_t L = 16; | ||
| std::array<int, N> out; | ||
| std::fill(out.begin(), out.end(), 0); | ||
| { | ||
| buffer<int> out_buf(out.data(), range<1>{N}); | ||
| q.submit([&](handler &cgh) { | ||
| auto tmp = | ||
| accessor<int, 1, access::mode::read_write, access::target::local>( | ||
| L, cgh); | ||
| auto out = out_buf.get_access<access::mode::read_write>(cgh); | ||
| cgh.parallel_for<class barrier_kernel>( | ||
| nd_range<1>(N, L), [=](nd_item<1> it) { | ||
| group<1> g = it.get_group(); | ||
| tmp[it.get_local_linear_id()] = it.get_global_linear_id() + 1; | ||
| barrier(g); | ||
| int result = 0; | ||
| for (int i = 0; i < L; ++i) { | ||
| result += tmp[i]; | ||
| } | ||
| out[it.get_global_linear_id()] = result; | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| // Each work-item should see writes from all other work-items in its group | ||
| for (int g = 0; g < N / L; ++g) { | ||
| int sum = 0; | ||
| for (int wi = 0; wi < L; ++wi) { | ||
| sum += g * L + wi + 1; | ||
| } | ||
| for (int wi = 0; wi < L; ++wi) { | ||
| assert(out[g * L + wi] == sum); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| int main() { | ||
| queue q; | ||
| test(q); | ||
| std::cout << "Test passed." << std::endl; | ||
| } |
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.