-
Notifications
You must be signed in to change notification settings - Fork 770
[SYCL] Add clang support for device_global #5597
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 11 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
0251bfb
[SYCL] Add clang support for device_global
schittir 117de59
Remove unused lines i.e., Merge attribute method calls and SYCLUniqueID
schittir a96d57a
Address some comments, fix format, remove unused lines
schittir f2230af
Add Sema test; address more comments
schittir 0fb176d
Some fixes in order to pass CodeGen test
Fznamznon e4c15c4
Refactor isSyclGlobalVariableAllowedType
schittir af8a294
Fix some test cases; address some comments
schittir feb841b
Remove explicit attribute handling; change diagnostic message; add test
schittir df337a7
Add diagnostic to test
schittir 748e8ce
Address Mariya's comments
schittir d84428c
Fix typo; Refactor methods;
schittir 0343158
Fix quotes, update diag messages, report private members
Fznamznon 6d6d7dd
Change DeviceGlobalType checking call
schittir 679b5f0
Move isSyclGlobalType definition to header
schittir 5ecd545
Address latest comments
schittir e51530d
Merge remote-tracking branch 'intel_llvm_remote/sycl' into SYCL_devic…
schittir aef34f9
Add back attribute to CodeGenSYCL/Inputs/sycl.hpp after merge
schittir 4cac80e
Remove additional definition of SYCLDeviceGlobal
schittir 3f79c5e
Add test description; Remove unsupported test cases
schittir 2664869
Fix format
schittir 0469d18
clang-format again!
schittir d25c816
Fix lit tests; Address comments
schittir 19f62a5
Fix lint
schittir 0354ea5
Lint again :(
schittir b45159d
Fix build failure; Add comment; Fix indentation
schittir 3baff38
Fix lit test SemaSYCL/explicit-cast-to-generic.cpp
schittir 5bced1a
Emit generic addrspace in llvm.used and llvm.global_ctors
Fznamznon 505a4f2
Fix format
schittir 4905d70
Add comments; rename method; add separate AST test
schittir 3817bf0
Fix lint that git-clang-format didn't catch :(
schittir 1c53934
Add case where device_global attributes are applied to the wrong subject
schittir e489d50
Attribute doesn't apply to this type
schittir 0709448
Add comments in CodeGenModule.cpp
schittir d4647f6
Change comments
schittir ef0f5d0
Change "customer code" to "user code" in documentation
schittir 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
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,83 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -fsycl-unique-prefix=THE_PREFIX -std=c++17 -emit-llvm %s -o - | FileCheck %s | ||
#include "sycl.hpp" | ||
schittir marked this conversation as resolved.
Show resolved
Hide resolved
schittir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
namespace cl { | ||
namespace sycl { | ||
namespace ext { | ||
namespace oneapi { | ||
schittir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// decorated with only global_variable_allowed attribute | ||
template <typename T> | ||
class [[__sycl_detail__::global_variable_allowed]] only_global_var_allowed { | ||
public : | ||
const T & get() const noexcept { return *Data; } | ||
only_global_var_allowed() {} | ||
operator T&() noexcept { return *Data; } | ||
private: | ||
T *Data; | ||
}; | ||
} // namespace oneapi | ||
} // namespace ext | ||
} // namespace sycl | ||
} // namespace cl | ||
|
||
using namespace sycl::ext::oneapi; | ||
using namespace cl::sycl; | ||
queue q; | ||
|
||
device_global<int> A; | ||
static device_global<int> B; | ||
|
||
struct Foo { | ||
static device_global<int> C; | ||
}; | ||
device_global<int> Foo::C; | ||
// CHECK: @A = addrspace(1) global %"class.cl::sycl::ext::oneapi::device_global" zeroinitializer, align 8 #[[A_ATTRS:[0-9]+]] | ||
// CHECK: @_ZL1B = internal addrspace(1) global %"class.cl::sycl::ext::oneapi::device_global" zeroinitializer, align 8 #[[B_ATTRS:[0-9]+]] | ||
// CHECK: @_ZN3Foo1CE = addrspace(1) global %"class.cl::sycl::ext::oneapi::device_global" zeroinitializer, align 8 #[[C_ATTRS:[0-9]+]] | ||
|
||
device_global<int> same_name; | ||
namespace NS { | ||
device_global<int> same_name; | ||
} | ||
// CHECK: @same_name = addrspace(1) global %"class.cl::sycl::ext::oneapi::device_global" zeroinitializer, align 8 #[[SAME_NAME_ATTRS:[0-9]+]] | ||
// CHECK: @_ZN2NS9same_nameE = addrspace(1) global %"class.cl::sycl::ext::oneapi::device_global" zeroinitializer, align 8 #[[SAME_NAME_NS_ATTRS:[0-9]+]] | ||
|
||
// check that we don't generate `sycl-unique-id` IR attribute if class does not use | ||
// [[__sycl_detail__::device_global]] | ||
only_global_var_allowed<int> no_device_global; | ||
schittir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// CHECK: @no_device_global = addrspace(1) global %"class.cl::sycl::ext::oneapi::only_global_var_allowed" zeroinitializer, align 8{{$}} | ||
|
||
void foo() { | ||
q.submit([&](handler &h) { | ||
h.single_task<class kernel_name_1>([=]() { | ||
(void)A; | ||
(void)B; | ||
(void)Foo::C; | ||
(void)same_name; | ||
(void)NS::same_name; | ||
(void)no_device_global; | ||
}); | ||
}); | ||
} | ||
|
||
namespace { | ||
device_global<int> same_name; | ||
} | ||
// CHECK: @_ZN12_GLOBAL__N_19same_nameE = internal addrspace(1) global %"class.cl::sycl::ext::oneapi::device_global" zeroinitializer, align 8 #[[SAME_NAME_ANON_NS_ATTRS:[0-9]+]] | ||
|
||
namespace { | ||
void bar() { | ||
q.submit([&](handler &h) { | ||
h.single_task<class kernel_name>([=]() { int A = same_name; }); | ||
}); | ||
} | ||
|
||
} | ||
|
||
|
||
// CHECK: attributes #[[A_ATTRS]] = { "sycl-unique-id"="_Z1A" } | ||
// CHECK: attributes #[[B_ATTRS]] = { "sycl-unique-id"="THE_PREFIX____ZL1B" } | ||
schittir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// CHECK: attributes #[[C_ATTRS]] = { "sycl-unique-id"="_ZN3Foo1CE" } | ||
// CHECK: attributes #[[SAME_NAME_ATTRS]] = { "sycl-unique-id"="_Z9same_name" } | ||
// CHECK: attributes #[[SAME_NAME_NS_ATTRS]] = { "sycl-unique-id"="_ZN2NS9same_nameE" } | ||
// CHECK: attributes #[[SAME_NAME_ANON_NS_ATTRS]] = { "sycl-unique-id"="THE_PREFIX____ZN12_GLOBAL__N_19same_nameE" } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.