-
Notifications
You must be signed in to change notification settings - Fork 803
[SYCL] Record aspect names when computing device requirements #13974
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
5 commits
Select commit
Hold shift + click to select a range
377ddfd
[SYCL] Record aspect names when computing device requirements
jzc 0485adb
Update sycl_used_aspects in multi-filtered-outputs.ll
jzc 7c1c25a
Cleanup multiple-filtered-outputs.ll
jzc 337ef91
Add E2E tests
jzc edf3edd
Merge remote-tracking branch 'intel/sycl' into add-aspect-names-2
jzc 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // This test ensures that a program that has a kernel | ||
| // using fp64 can be compiled AOT. | ||
|
|
||
| // REQUIRES: ocloc | ||
| // RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_tgllp -o %t.tgllp.out %s | ||
| // RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc -o %t.pvc.out %s | ||
| // RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_cfl -o %t.cfl.out %s | ||
|
|
||
| #include <sycl/detail/core.hpp> | ||
|
|
||
| using namespace sycl; | ||
|
|
||
| int main() { | ||
| queue q; | ||
| if (q.get_device().has(aspect::fp64)) { | ||
| double d = 2.5; | ||
| { | ||
| buffer<double, 1> buf(&d, 1); | ||
| q.submit([&](handler &cgh) { | ||
| accessor acc{buf, cgh}; | ||
| cgh.single_task([=] { acc[0] *= 2; }); | ||
| }); | ||
| } | ||
| std::cout << d << "\n"; | ||
| } | ||
| } |
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,74 @@ | ||
| // This test ensures that a program that has a kernel | ||
| // using various required sub-group sizes can be compiled AOT. | ||
|
|
||
| // REQUIRES: ocloc | ||
| // RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_tgllp -o %t.tgllp.out %s | ||
| // RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc -o %t.pvc.out %s | ||
| // RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_cfl -o %t.cfl.out %s | ||
|
|
||
| #include <cstdio> | ||
| #include <iostream> | ||
|
|
||
| #include <sycl/detail/core.hpp> | ||
|
|
||
| using namespace sycl; | ||
|
|
||
| template <int N> class kernel_name; | ||
|
|
||
| template <size_t... Ns> struct SubgroupDispatcher { | ||
| std::vector<std::pair<size_t, size_t>> fails; | ||
| SubgroupDispatcher(queue &q) : q(q) {} | ||
|
|
||
| void operator()(const std::vector<size_t> &v) { | ||
| for (auto i : v) | ||
| (*this)(i); | ||
| } | ||
|
|
||
| void operator()(size_t n) { (dispatch<Ns>(n), ...); } | ||
|
|
||
| private: | ||
| queue &q; | ||
|
|
||
| template <size_t size> void dispatch(size_t n) { | ||
| if (n == size) { | ||
| size_t res = 0; | ||
| { | ||
| buffer<size_t, 1> buf(&res, 1); | ||
| q.submit([&](handler &cgh) { | ||
| accessor acc{buf, cgh}; | ||
| cgh.parallel_for<kernel_name<size>>( | ||
| nd_range<1>(1, 1), | ||
| [=](auto item) [[intel::reqd_sub_group_size(size)]] { | ||
| acc[0] = item.get_sub_group().get_max_local_range()[0]; | ||
| }); | ||
| }); | ||
| } | ||
| if (res != size) | ||
| fails.push_back({res, size}); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| int main() { | ||
| queue q; | ||
| auto ctx = q.get_context(); | ||
| auto dev = q.get_device(); | ||
| auto sizes = dev.get_info<sycl::info::device::sub_group_sizes>(); | ||
| std::cout << " sub-group sizes supported by the device: " << sizes[0]; | ||
| for (int i = 1; i < sizes.size(); ++i) { | ||
| std::cout << ", " << sizes[i]; | ||
| } | ||
| std::cout << '\n'; | ||
|
|
||
| using dispatcher_t = SubgroupDispatcher<4, 8, 16, 32, 64, 128>; | ||
| dispatcher_t dispatcher(q); | ||
| dispatcher(sizes); | ||
| if (dispatcher.fails.size() > 0) { | ||
| for (auto [actual, expected] : dispatcher.fails) { | ||
| std::cout << "actual: " << actual << "\n" | ||
| << "expected: " << expected << "\n"; | ||
| } | ||
| } else { | ||
| std::cout << "pass\n"; | ||
| } | ||
| } |
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.
Just for my understanding: we could have a non-pair value in case of an internal aspect with a negative value and no name, right? Plus, it should serve as path for backwards compatibility if we link object files produced by an older toolchain, right?
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.
Yep, those are both correct.