Skip to content

Make feature macro undefs conditional on -cl-ext input #426

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 1 commit into from
May 16, 2023

Conversation

AGindinson
Copy link

@AGindinson AGindinson commented May 15, 2023

Commits d6563b0, de262c9 and d5a2638 have provided a resolution for opencl-c-base.h defining OCL C 3.0 feature macros unconditionally, which interfered with Compute Runtime's platform-dependent definitions of extension lists.

An issue with this approach is that opencl-c-base.h provides additional defines based on __opencl_c_atomic_scope_all_devices being set:

#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)

(from https://github.com/llvm/llvm-project/blob/release/16.x/clang/lib/Headers/opencl-c-base.h#L387-L392)

Simply erasing the macro definition from opencl-c-base.h leads to memory scope values' erasure, as the command line definitions aren't available at that moment due to headers' inclusion order. Original commit d6563b0 did mention an alternative approach, which accounts for the above issue:

Once https://reviews.llvm.org/D141297 (LLVM 16) is integrated,
an alternative approach could be to pass -D__undef_<feature_macro>
<...> at the OCL Clang's level (upon detecting the lack of
extension-defining inputs to -cl-ext).

Implement just that in scope of the current commit. Said LLORG patch simply needs to be applied for CClang 14-15 instead of the original "unconditional undef" one.

@AGindinson AGindinson force-pushed the clang-14-feature-macro branch from 7466a0a to 9afea85 Compare May 15, 2023 10:22
@AGindinson
Copy link
Author

AGindinson commented May 15, 2023

@hewj03, @haonanya, @JablonskiMateusz, could you please take a look?

@AGindinson AGindinson force-pushed the clang-14-feature-macro branch from 9afea85 to dd96996 Compare May 15, 2023 14:44
Commits d6563b0, de262c9 and d5a2638 have provided a resolution for
`opencl-c-base.h` defining OCL C 3.0 feature macros unconditionally, which
interfered with Compute Runtime's platform-dependent definitions of extension
lists.

An issue with this approach is that `opencl-c-base.h` provides additional
defines based on `__opencl_c_atomic_scope_all_devices` being set:
```
  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
  memory_scope_all_devices = memory_scope_all_svm_devices,
```
(from https://github.com/llvm/llvm-project/blob/release/16.x/clang/lib/Headers/opencl-c-base.h#L387-L392)

Simply erasing the macro definition from `opencl-c-base.h` leads to memory
scope values' erasure, as the command line definitions aren't available at that
moment due to headers' inclusion order. Original commit d6563b0 did mention an
alternative approach, which accounts for the above issue:
> Once https://reviews.llvm.org/D141297 (LLVM 16) is integrated,
  an alternative approach could be to pass `-D__undef_<feature_macro>`
  <...> at the OCL Clang's level (upon detecting the lack of
  extension-defining inputs to `-cl-ext`).

Implement just that in scope of the current commit. Said LLORG patch simply
needs to be applied for CClang 14-15 instead of the original "unconditional
undef" one.

Signed-off-by: Artem Gindinson <[email protected]>
@AGindinson AGindinson force-pushed the clang-14-feature-macro branch from dd96996 to 671e123 Compare May 15, 2023 14:55
Copy link
Contributor

@wenju-he wenju-he left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@wenju-he
Copy link
Contributor

would you also add the patch to 15/16 branches?

@AGindinson
Copy link
Author

would you also add the patch to 15/16 branches?

Sure, I'll be creating porting CPs soon. For 16, we'd just need the compile_options.cpp changes.

@wenju-he wenju-he merged commit 78c5e3f into intel:ocl-open-140 May 16, 2023
@AGindinson AGindinson deleted the clang-14-feature-macro branch May 16, 2023 05:09
AGindinson pushed a commit to AGindinson/opencl-clang that referenced this pull request May 16, 2023
Cherry-pick commit 78c5e3f from `ocl-open-140` branch.

Signed-off-by: Artem Gindinson <[email protected]>
@AGindinson
Copy link
Author

Porting PRs: #434, #435, #436

haonanya pushed a commit that referenced this pull request May 17, 2023
Cherry-pick commit 78c5e3f from `ocl-open-140` branch.

Signed-off-by: Artem Gindinson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants