-
Notifications
You must be signed in to change notification settings - Fork 797
[SYCL] Implement a builtin to mark a sycl kernel #3894
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 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c2b0991
[SYCL] implement a builtin to mark a sycl kernel
ddb3ae7
Fix the clang-format I'm willing to do
0962bf6
Document kernel_desc.hpp use of this builtin
e6c5f14
Fix a lang-extensions comment, update the diagnostics, add tests
6669b37
Fixes suggested by aaron, clarify language-extensions document
e9aa506
Change tests as Elizabeth requested
234bd2e
Add regression test requested by AlexeySachkov
7f61ef1
Update tests as @elizabethandrews requested in review
4e94a62
Accept @bader 's suggestion toremove sycldevice
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,17 @@ | ||
// RUN: %clang_cc1 -triple x86_64-linux-pc -fsycl-is-host -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s | ||
|
||
erichkeane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
erichkeane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int main() { | ||
auto lambda1 = [](){}; | ||
auto lambda2 = [](){}; | ||
|
||
(void)__builtin_sycl_unique_stable_name(decltype(lambda1)); | ||
// CHECK: [17 x i8] c"_ZTSZ4mainEUlvE_\00" | ||
|
||
// Should change the unique-stable-name of the lambda. | ||
(void)__builtin_sycl_mark_kernel_name(decltype(lambda2)); | ||
(void)__builtin_sycl_unique_stable_name(decltype(lambda2)); | ||
// CHECK: [22 x i8] c"_ZTSZ4mainEUlvE10000_\00" | ||
} | ||
|
||
|
||
erichkeane marked this conversation as resolved.
Show resolved
Hide resolved
|
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,50 @@ | ||
// RUN: %clang_cc1 %s -std=c++17 -triple x86_64-linux-gnu -Wno-sycl-2020-compat -fsycl-is-device -verify -fsyntax-only -Wno-unused | ||
erichkeane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
template <typename KernelName, typename KernelType> | ||
erichkeane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[[clang::sycl_kernel]] void kernel_single_task(KernelType kernelFunc) { // #kernelSingleTask | ||
erichkeane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kernelFunc(); | ||
} | ||
|
||
template <typename KN> | ||
erichkeane marked this conversation as resolved.
Show resolved
Hide resolved
|
||
struct KernelInfo { | ||
static constexpr const char *c = __builtin_sycl_unique_stable_name(KN); // #KI_USN | ||
}; | ||
|
||
template <typename KN> | ||
struct FixedKernelInfo { | ||
static constexpr bool b = __builtin_sycl_mark_kernel_name(KN); | ||
// making 'c' dependent on 'b' is necessary to ensure 'b' gets called first. | ||
static constexpr const char *c = b | ||
? __builtin_sycl_unique_stable_name(KN) | ||
: nullptr; | ||
}; | ||
|
||
template <template <typename> class KI, | ||
typename KernelName, | ||
typename KernelType> | ||
void wrapper(KernelType KernelFunc) { | ||
(void)KI<KernelName>::c; | ||
kernel_single_task<KernelName>(KernelFunc); // #SingleTaskInst | ||
} | ||
|
||
int main() { | ||
[]() { | ||
class KernelName1; | ||
constexpr const char *C = __builtin_sycl_unique_stable_name(KernelName1); | ||
// expected-error@+2 {{kernel naming changes the result of an evaluated '__builtin_sycl_unique_stable_name'}} | ||
// expected-note@-2 {{'__builtin_sycl_unique_stable_name' evaluated here}} | ||
__builtin_sycl_mark_kernel_name(KernelName1); | ||
}(); | ||
|
||
[]() { | ||
// expected-error@#kernelSingleTask {{kernel instantiation changes the result of an evaluated '__builtin_sycl_unique_stable_name'}} | ||
// expected-note@#SingleTaskInst {{in instantiation of function template}} | ||
// expected-note@+2 {{in instantiation of function template}} | ||
// expected-note@#KI_USN {{'__builtin_sycl_unique_stable_name' evaluated here}} | ||
wrapper<KernelInfo, class KernelName2>([]() {}); | ||
}(); | ||
|
||
[]() { | ||
wrapper<FixedKernelInfo, class KernelName3>([]() {}); | ||
}(); | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.