-
Notifications
You must be signed in to change notification settings - Fork 15.7k
[libclc] Add OpenCL atomic_*_explicit builtins #168318
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 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5965c4b
[libclc] Add OpenCL atomic_*_explicit builtins
wenju-he 857b795
change default order to __ATOMIC_RELAXED
wenju-he 5e2939e
Revert "change default order to __ATOMIC_RELAXED"
wenju-he e93e6ed
Merge branch 'main' into libclc-atomic-explicit
wenju-he 808f3d8
remove volatile from CLC functions
wenju-he e3799b2
add '-include opencl-c-base.h' to compile flag and remove duplicate d…
wenju-he 4df7138
Merge branch 'main' into libclc-atomic-explicit
wenju-he 8a631b8
fix merge conflicts
wenju-he 3068130
Merge branch 'main' into libclc-atomic-explicit
wenju-he 58ddca5
-Xclang -fdeclare-opencl-builtins -Xclang -finclude-default-header
wenju-he d0c21f4
don't add the flag for CLC library
wenju-he 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
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,48 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef __CLC_OPENCL_TYPES_H__ | ||
| #define __CLC_OPENCL_TYPES_H__ | ||
|
|
||
| // Copied from clang/lib/Headers/opencl-c-base.h | ||
|
|
||
| typedef enum memory_scope { | ||
| memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM, | ||
| memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP, | ||
| memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE, | ||
| #if defined(__opencl_c_atomic_scope_all_devices) | ||
| memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES, | ||
| #if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) | ||
| memory_scope_all_devices = memory_scope_all_svm_devices, | ||
| #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= | ||
| // 202100) | ||
| #endif // defined(__opencl_c_atomic_scope_all_devices) | ||
| /** | ||
| * Subgroups have different requirements on forward progress, so just test | ||
| * all the relevant macros. | ||
| * CL 3.0 sub-groups "they are not guaranteed to make independent forward | ||
| * progress" KHR subgroups "Subgroups within a workgroup are independent, make | ||
| * forward progress with respect to each other" | ||
| */ | ||
| #if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || \ | ||
| defined(__opencl_c_subgroups) | ||
| memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP | ||
| #endif | ||
| } memory_scope; | ||
|
|
||
| typedef enum memory_order { | ||
| memory_order_relaxed = __ATOMIC_RELAXED, | ||
| memory_order_acquire = __ATOMIC_ACQUIRE, | ||
| memory_order_release = __ATOMIC_RELEASE, | ||
| memory_order_acq_rel = __ATOMIC_ACQ_REL, | ||
| #if defined(__opencl_c_atomic_order_seq_cst) | ||
| memory_order_seq_cst = __ATOMIC_SEQ_CST | ||
| #endif | ||
| } memory_order; | ||
|
|
||
| #endif // __CLC_OPENCL_TYPES_H__ | ||
Oops, something went wrong.
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.
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.
This shouldn't need copying? Use the builtin included declarations?
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.
The copying is deleted. e3799b2 added
-include opencl-c-base.hto compile flags for .cl files. Some types and constants in libclc are not needed anymore.opencl-c-base.h only defines OpenCL types and constant, so it should be safe to use in libclc.
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.
I think we can also change OpenCL enum memory_scope to map 1:1 to Clang memory_scope like in following diff:
Then we don't need to include opencl-c-base.h for libclc. What do you think?
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.
sorry,
-include opencl-c-base.his still needed. The above mapping change can only eliminates helper function __opencl_get_clang_memory_scope.