-
Notifications
You must be signed in to change notification settings - Fork 788
[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
Merged
bader
merged 6 commits into
intel:sycl
from
fadeeval:private/fadeeval/adressSpace_changes
Sep 30, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5c5d0ae
Change adress space for global variables
fadeeval 8b70645
Add better solution
fadeeval 878f996
Change tests
fadeeval d5d7290
Add test and comments
fadeeval 9b50de7
Add formatting
fadeeval 52eeb92
Change comment and take single_task from sycl.hpp
fadeeval 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s | ||
#include "Inputs/sycl.hpp" | ||
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; | ||
} | ||
|
||
int main() { | ||
cl::sycl::kernel_single_task<class fake_kernel>([]() { test<int>(); }); | ||
return 0; | ||
} |
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.
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.
To me,
opencl_constant
looks like a right value to return. Could you explain why we useopencl_global
here?Uh oh!
There was an error while loading. Please reload this page.
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.
There are too many constraints on OpenCL
constant
address space: limited memory capacity, pointers that cannot be cast togeneric
address space...So even it seems like the obvious answer, it causes a lot of trouble.
But since you are asking: there is obviously a missing comment explaining the motivation in the code... :-(
Actually any question in a PR means at least 1 lacking comment in the code. ;-)
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.
In this case though, there is a comment just above the differences that says:
```
// If we keep a literal string in constant address space, the following code
// becomes illegal:
//
// const char *getLiteral() n{
// return "AB";
// }
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.
Yes but it does not explains why it becomes illegal.
The more comments, the happier I am. :-)
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.
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?
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.
Yes please, add a lot of comments useful to understand the big picture. Thanks.