-
Notifications
You must be signed in to change notification settings - Fork 808
[SYCL] Change adress space for global variables #2534
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
Changes from 5 commits
5c5d0ae
8b70645
878f996
d5d7290
9b50de7
52eeb92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4012,7 +4012,13 @@ LangAS CodeGenModule::getStringLiteralAddressSpace() const { | |
| // const char *getLiteral() n{ | ||
| // return "AB"; | ||
| // } | ||
| return LangAS::opencl_private; | ||
| // because there is a addressspacecast to generic address space in IR, | ||
| // but adressspacecast from constant to generic forbitten because of | ||
| // constant address space is not part of generic address space. | ||
| // The private adress space doesn't suit here because a IR is translated | ||
| // in SPIRV in SYCLIsDevice mode, and all global Value shouldn't | ||
| // be private in IR for rigth translation to SPIRV. | ||
| return LangAS::opencl_global; | ||
|
Contributor
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. To me,
Contributor
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. There are too many constraints on OpenCL
Contributor
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. In this case though, there is a comment just above the differences that says:
Contributor
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. Yes but it does not explains why it becomes illegal.
Contributor
Author
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. There is a addressspacecast to generic address space in IR, but adressspacecast from constant to generic forbitten because of constant address space is not part of generic address space. @keryell, should I write it in source code comments?
Contributor
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. Yes please, add a lot of comments useful to understand the big picture. Thanks. |
||
| if (auto AS = getTarget().getConstantAddressSpace()) | ||
| return AS.getValue(); | ||
| return LangAS::Default; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
|
|
||
bader marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s | ||
|
|
||
| struct C { | ||
| static int c; | ||
| }; | ||
|
|
||
| template <typename T> | ||
| struct D { | ||
| static T d; | ||
| }; | ||
|
|
||
| template <typename T> | ||
| void test() { | ||
| // CHECK: @_ZZ4testIiEvvE1a = linkonce_odr addrspace(1) constant i32 0, comdat, align 4 | ||
| static const int a = 0; | ||
| // CHECK: @_ZZ4testIiEvvE1b = linkonce_odr addrspace(1) constant i32 0, comdat, align 4 | ||
| static const T b = T(0); | ||
| // CHECK: @_ZN1C1cE = external addrspace(1) global i32, align 4 | ||
| C::c = 10; | ||
| const C struct_c; | ||
| // CHECK: @_ZN1DIiE1dE = external addrspace(1) global i32, align 4 | ||
| D<int>::d = 11; | ||
| const D<int> struct_d; | ||
| } | ||
|
|
||
| template <typename name, typename Func> | ||
| __attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) { | ||
| kernelFunc(); | ||
| } | ||
bader marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| int main() { | ||
| kernel_single_task<class fake_kernel>([]() { test<int>(); }); | ||
| return 0; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.