-
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
[SYCL] Change adress space for global variables #2534
Conversation
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Looks like you are only changing the address space for string literals. Is that correct? PR title seems to be more general. |
The getStringLiteralAddressSpace() function is not being used for string literal only. |
But maybe I didn't write description exactly correct, now it should be more understandable. |
@@ -4012,7 +4012,7 @@ LangAS CodeGenModule::getStringLiteralAddressSpace() const { | |||
// const char *getLiteral() n{ | |||
// return "AB"; | |||
// } | |||
return LangAS::opencl_private; | |||
return LangAS::opencl_global; |
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 use opencl_global
here?
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 to generic
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.
Can you add tests for all the cases you're trying to support? The current test modifications only show address space change for string literals. I took a quick look at the code to see where Edit: Corrected Godbolt link. |
Is this the case you're trying to handle when you say global variables? I think I may have misunderstood what you meant by 'global variables'. In any case, please add a test. |
@elizabethandrews, I am not sure that it is needed to add tests because the fixed tests already show that I wanted to do. |
Please add a test that checks this for file-scope statics, static data members, and templated versions of both. I think these will be helpful. |
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
Signed-off-by: Aleksander Fadeev <[email protected]>
…_wrapper * upstream/sycl: (1021 commits) [SYCL] Enable async_work_group_copy for scalar and vector bool types (intel#2582) [SYCL] Fix element type in handler::copy (intel#2590) [NFC][SYCL] Remove unnecessary if condition (intel#2585) [SYCL][NFC] Fix SYCL lit test execution on a system w/o GPU (intel#2584) [SYCL] Add error handling for non-uniform work group size case (intel#2569) [SYCL][ESIMD] Preserve undef initializer for globals in ESIMDLowerVecArg pass (intel#2555) [SYCL] Make Level-Zero events visible on the host (intel#2576) [Driver][SYCL][NFC] Add help information for -Wno-sycl-strict (intel#2570) [SYCL] Relax test to work in Win32 environment. (intel#2580) [SYCL] Emit suppressed warnings from SYCL headers (intel#2575) [SYCL][NFC] Cover more classes with ABI tests (intel#2577) [SYCL][ESIMD] Update ESIMD tests and add raw send support. (intel#2482) [SYCL] Make ESIMD on-device tests require linux,gpu,opencl. (intel#2560) [SYCL] Release commands with no dependencies after they're enqueued (intel#2492) [SYCL] Add multi-device and multi-platform support for SYCL_DEVICE_ALLOWLIST (intel#2483) [SYCL] Try to enqueue host command depencies (intel#2561) [SYCL][ESIMD][NFC] Align namespace name with the spec guidelines (intel#2573) [SYCL][NFC] Add class layout ABI tests for memory objects (intel#2559) [SYCL] Change adress space for global variables (intel#2534) [NFC][SYCL] Fix comment. (intel#2541) ...
…global [DeviceMSAN] Fix gpu crashed on device global variable
[DeviceMSAN] Fix gpu crashed on device global variable
GlobalVariables shouldn't have private address space.
This PR change usage of private address space to global for global variables.
Private address space maps to Function StorageClass in llvm-spirv translator, but global declarations shouldn't have Function Storage Class due to SPIRV spec (https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html).
Signed-off-by: Aleksander Fadeev [email protected]