-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL][clang] Emit default template arguments in integration header #16005
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
sommerlukas
merged 10 commits into
intel:sycl
from
Fznamznon:default-template-args-int-header
Nov 18, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c3cdacb
[SYCL][clang] Emit default template arguments in integration header
Fznamznon da51a19
Groom TypePrinter.cpp
Fznamznon 6ba5063
Force namespace printing
Fznamznon 3e0e4bb
[WIP] Add test
Fznamznon 4f091c0
Fix nns printing and add a couple of tests
Fznamznon 7e2272f
Add more tests, clean SemaSYCL
Fznamznon e206684
Fix format
Fznamznon aded78e
Fix format again
Fznamznon 30ff224
Try to clarify comments with an example
Fznamznon e2779e8
Merge branch 'sycl' into default-template-args-int-header
Fznamznon 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
100 changes: 100 additions & 0 deletions
100
clang/test/CodeGenSYCL/free_function_default_template_arguments.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,100 @@ | ||
| // RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -sycl-std=2020 -fsycl-int-header=%t.h %s | ||
| // RUN: FileCheck -input-file=%t.h %s | ||
|
|
||
| // This test checks integration header contents for free functions kernels with | ||
| // parameter types that have default template arguments. | ||
|
|
||
| #include "mock_properties.hpp" | ||
| #include "sycl.hpp" | ||
|
|
||
| namespace ns { | ||
|
|
||
| struct notatuple { | ||
| int a; | ||
| }; | ||
|
|
||
| namespace ns1 { | ||
| template <typename A = notatuple> | ||
| class hasDefaultArg { | ||
|
|
||
| }; | ||
| } | ||
|
|
||
| template <typename T, typename = int, int a = 12, typename = notatuple, typename ...TS> struct Arg { | ||
| T val; | ||
| }; | ||
|
|
||
| [[__sycl_detail__::add_ir_attributes_function("sycl-single-task-kernel", | ||
| 2)]] void | ||
| simple(Arg<char>){ | ||
| } | ||
|
|
||
| } | ||
|
|
||
| [[__sycl_detail__::add_ir_attributes_function("sycl-single-task-kernel", | ||
| 2)]] void | ||
| simple1(ns::Arg<ns::ns1::hasDefaultArg<>>){ | ||
| } | ||
|
|
||
|
|
||
| template <typename T> | ||
| [[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] void | ||
| templated(ns::Arg<T, float, 3>, T end) { | ||
| } | ||
|
|
||
| template void templated(ns::Arg<int, float, 3>, int); | ||
|
|
||
| using namespace ns; | ||
|
|
||
| template <typename T> | ||
| [[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] void | ||
| templated2(Arg<T, notatuple>, T end) { | ||
| } | ||
|
|
||
| template void templated2(Arg<int, notatuple>, int); | ||
|
|
||
| template <typename T, int a = 3> | ||
| [[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] void | ||
| templated3(Arg<T, notatuple, a, ns1::hasDefaultArg<>, int, int>, T end) { | ||
| } | ||
|
|
||
| template void templated3(Arg<int, notatuple, 3, ns1::hasDefaultArg<>, int, int>, int); | ||
|
|
||
| // CHECK: Forward declarations of kernel and its argument types: | ||
| // CHECK-NEXT: namespace ns { | ||
| // CHECK-NEXT: struct notatuple; | ||
| // CHECK-NEXT: } | ||
| // CHECK-NEXT: namespace ns { | ||
| // CHECK-NEXT: template <typename T, typename, int a, typename, typename ...TS> struct Arg; | ||
| // CHECK-NEXT: } | ||
|
|
||
| // CHECK: void ns::simple(ns::Arg<char, int, 12, ns::notatuple>); | ||
| // CHECK-NEXT: static constexpr auto __sycl_shim1() { | ||
| // CHECK-NEXT: return (void (*)(struct ns::Arg<char, int, 12, struct ns::notatuple>))simple; | ||
| // CHECK-NEXT: } | ||
|
|
||
| // CHECK: Forward declarations of kernel and its argument types: | ||
| // CHECK: namespace ns { | ||
| // CHECK: namespace ns1 { | ||
| // CHECK-NEXT: template <typename A> class hasDefaultArg; | ||
| // CHECK-NEXT: } | ||
|
|
||
| // CHECK: void simple1(ns::Arg<ns::ns1::hasDefaultArg<ns::notatuple>, int, 12, ns::notatuple>); | ||
| // CHECK-NEXT: static constexpr auto __sycl_shim2() { | ||
| // CHECK-NEXT: return (void (*)(struct ns::Arg<class ns::ns1::hasDefaultArg<struct ns::notatuple>, int, 12, struct ns::notatuple>))simple1; | ||
| // CHECK-NEXT: } | ||
|
|
||
| // CHECK: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple>, T end); | ||
| // CHECK-NEXT: static constexpr auto __sycl_shim3() { | ||
| // CHECK-NEXT: return (void (*)(struct ns::Arg<int, float, 3, struct ns::notatuple>, int))templated<int>; | ||
| // CHECK-NEXT: } | ||
|
|
||
| // CHECK: template <typename T> void templated2(ns::Arg<T, ns::notatuple, 12, ns::notatuple>, T end); | ||
| // CHECK-NEXT: static constexpr auto __sycl_shim4() { | ||
| // CHECK-NEXT: return (void (*)(struct ns::Arg<int, struct ns::notatuple, 12, struct ns::notatuple>, int))templated2<int>; | ||
| // CHECK-NEXT: } | ||
|
|
||
| // CHECK: template <typename T, int a> void templated3(ns::Arg<T, ns::notatuple, a, ns::ns1::hasDefaultArg<ns::notatuple>, int, int>, T end); | ||
| // CHECK-NEXT: static constexpr auto __sycl_shim5() { | ||
| // CHECK-NEXT: return (void (*)(struct ns::Arg<int, struct ns::notatuple, 3, class ns::ns1::hasDefaultArg<struct ns::notatuple>, int, int>, int))templated3<int, 3>; | ||
| // CHECK-NEXT: } |
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.
I think an example in the comments would be helpful here. Probably the same one in PR description. Just reading these is very confusing without context.
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.
Added, thanks!