-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL][NATIVECPU] Implement events on Native CPU #15926
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 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8a4d4d7
Update UR tag
PietroGhg ef12409
Merge branch 'sycl' into pietro/events_rr
PietroGhg 0dd0586
Merge branch 'sycl' into pietro/events_rr
PietroGhg 7e09faf
Merge branch 'sycl' into pietro/events_rr
PietroGhg bc11b08
Check for vector types in scalar args test
PietroGhg f23a060
Merge branch 'sycl' into pietro/events_rr
PietroGhg 5baeac6
Bump UR tag
callumfare d2f7246
Merge branch 'sycl' into pietro/events_rr
callumfare 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| # commit fa8cc8ec16c1a2cf0926cc64026edc6a254ff0c2 | ||
| # Merge: 3d58884b 1984ceb1 | ||
| # Author: aarongreig <[email protected]> | ||
| # Date: Fri Nov 1 10:03:37 2024 +0000 | ||
| # Merge pull request #1833 from ayylol/old-opencl-check | ||
| # [OpenCL] Add OpenCL version check for independent forward progress query | ||
| set(UNIFIED_RUNTIME_TAG fa8cc8ec16c1a2cf0926cc64026edc6a254ff0c2) | ||
| # Date: Thu Oct 31 14:05:55 2024 +0000 | ||
| # Merge pull request #2228 from nrspruit/copy_engine_refactor | ||
| # [L0] Refactor Copy Engine Usage checks for Performance | ||
| set(UNIFIED_RUNTIME_TAG pietro/events_rr) |
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 |
|---|---|---|
|
|
@@ -12,39 +12,62 @@ const size_t N = 10; | |
|
|
||
| template <typename T> class init_a; | ||
|
|
||
| template <typename T> bool test(queue myQueue) { | ||
| { | ||
| buffer<float, 1> a(range<1>{N}); | ||
| const T test = rand() % 10; | ||
|
|
||
| myQueue.submit([&](handler &cgh) { | ||
| auto A = a.get_access<access::mode::write>(cgh); | ||
| cgh.parallel_for<init_a<T>>(range<1>{N}, | ||
| [=](id<1> index) { A[index] = test; }); | ||
| }); | ||
|
|
||
| auto A = a.get_access<access::mode::read>(); | ||
| std::cout << "Result:" << std::endl; | ||
| for (size_t i = 0; i < N; i++) { | ||
| if (A[i] != test) { | ||
| std::cout << "ERROR at pos " << i << " expected " << test << ", got " | ||
| << A[i] << "\n"; | ||
| return false; | ||
| } | ||
| } | ||
| template <typename T, int M> | ||
| bool compare(const sycl::vec<T, M> a, const sycl::vec<T, M> truth) { | ||
| bool res = true; | ||
| for (int i = 0; i < M; i++) { | ||
| res &= a[i] == truth[i]; | ||
| } | ||
| return res; | ||
| } | ||
|
|
||
| std::cout << "Good computation!" << std::endl; | ||
| template <typename T> bool compare(const T a, const T truth) { | ||
| return a == truth; | ||
| } | ||
|
|
||
| template <typename T> bool check(buffer<T, 1> &result, const T truth) { | ||
| auto A = result.get_host_access(); | ||
| for (size_t i = 0; i < N; i++) { | ||
| if (!compare(A[i], truth)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| template <typename T> bool test(queue myQueue) { | ||
| buffer<T, 1> a(range<1>{N}); | ||
| const T test{42}; | ||
|
|
||
| myQueue.submit([&](handler &cgh) { | ||
| auto A = a.template get_access<access::mode::write>(cgh); | ||
| cgh.parallel_for<init_a<T>>(range<1>{N}, | ||
| [=](id<1> index) { A[index] = test; }); | ||
| }); | ||
|
|
||
| return check(a, test); | ||
| } | ||
|
|
||
| int main() { | ||
| queue q; | ||
| int res1 = test<int>(q); | ||
| int res2 = test<unsigned>(q); | ||
| int res3 = test<float>(q); | ||
| int res4 = test<double>(q); | ||
| if (!(res1 && res2 && res3 && res4)) { | ||
|
|
||
| std::vector<bool> res; | ||
| res.push_back(test<int>(q)); | ||
| res.push_back(test<unsigned>(q)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Performance. Using a vector here likely causes allocations and there's the overhead of iterating over the vector. |
||
| res.push_back(test<float>(q)); | ||
| res.push_back(test<double>(q)); | ||
| res.push_back(test<sycl::vec<int, 2>>(q)); | ||
| res.push_back(test<sycl::vec<int, 3>>(q)); | ||
| res.push_back(test<sycl::vec<int, 4>>(q)); | ||
| res.push_back(test<sycl::vec<int, 8>>(q)); | ||
| res.push_back(test<sycl::vec<int, 16>>(q)); | ||
| res.push_back(test<sycl::vec<double, 2>>(q)); | ||
| res.push_back(test<sycl::vec<double, 3>>(q)); | ||
| res.push_back(test<sycl::vec<double, 4>>(q)); | ||
| res.push_back(test<sycl::vec<double, 8>>(q)); | ||
| res.push_back(test<sycl::vec<double, 16>>(q)); | ||
|
|
||
| if (std::any_of(res.begin(), res.end(), [](bool b) { return !b; })) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
|
|
||
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.
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.
It might be worth replicating this test also for
access::mode::read_writeto see if timing/events handling is correct for different access modes.