-
Notifications
You must be signed in to change notification settings - Fork 754
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
[WIP] [SYCL] Move static const variables to constant address space #158
Closed
Closed
Changes from all commits
Commits
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 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 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.
We use
sycl_*
address spaces in all other places and with this change we mix two potentially different mappings in the single program.I think we should first agree on using
opencl_*
address space map for SYCL device code and if so, replace all usages ofsycl_*
address spaces withopencl_*
and removesycl_*
address spaces from the map.@Naghasan, @keryell do you see any potential issues with using
opencl_*
address spaces?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.
TBH, I never fully understood the rational behind the introduction of the
sycl_*
address spaces. I think it was made to allow this c278543#diff-54e8e44f96ab947511166d795bad8022R477 but I find this suspicious as it is easy to trick the compiler (see #40).Apart from the constant address space, I don't see any particular issue in moving from
sycl_*
asp toopencl_*
asp.The device compiler needs to convert the outlined code into an OpenCL kernel, so reusing
LangAS::opencl_*
seems a rational choice to me as it will play better with existing code in clang (especially that it will need to obey to the same set of rules). For the library, the exposure of the address space is pushed to themulti_ptr
andaccessor
classes. You will probably have to do adjustments in the header files, but those classes are also there to handle the host/device boundary in a transparent way for the user.That being said, there is the question of handling the (OpenCL) constant address space. As you can't make it overlap with the generic address space, this becomes tricky. But that's an exception that can be approached in different ways.
Note on the patch itself
considering this code
this patch will tranform it into something like this opencl C 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.
Right, I noticed that as well. Please treat this patch as WIP for now.
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.
NOTE: even if we use
opencl_*
it doesn't mean we enforce OpenCL rules. A lot of OpenCL rules are enabled only for OpenCL language, which we can't use in for SYCL unfortunately.We might need to go over this checks that enable them for SYCL too by adding additional case or removing language check at all.
+@AnastasiaStulova
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.
Btw, I don't think it is correct to deduce const to __constant. Variables that are const qualified can be initialized at RT. But __constant required compile time constant initializers.
In a way it is a bit closer to constexpr.
I would prefer to remove OpenCL checks completely. They normally come from the old code anyway. I never understood why it was written like that. If we have OpenCL address spaces surely we are compiling OpenCL code (or may be SYCL device code now too!).
I was also thinking if it helps we could add some sort of common language mode (i.e. CLDevice) that we could use for common logic between OpenCL and SYCL. And then derive OpenCL and SYCL from CLDevice. Not sure how helpful it is though but it could be one options.