This is an archive of the discontinued LLVM Phabricator instance.

[C++4OpenCL] Add clang extension for non-portable kernel parameters
ClosedPublic

Authored by olestrohm on Apr 23 2021, 8:13 AM.

Details

Reviewers
Anastasia
svenvh
Summary

This feature allows using non-portable types as kernel parameters. This allows bypassing the portability guarantees from the restrictions specified
in C++ for OpenCL v1.0 s2.4.

Currently this only disables the restrictions related to layout, as a programmer using the same compiler for host and device should get the same representation.
This could be extended to other things (like size_t) if desired in the future, but I think it's unlikely that someone would want that.

Previous discussion about the extension in https://bugs.llvm.org/show_bug.cgi?id=50081

Diff Detail

Event Timeline

olestrohm created this revision.Apr 23 2021, 8:13 AM
olestrohm requested review of this revision.Apr 23 2021, 8:13 AM
Anastasia added inline comments.Apr 26 2021, 5:53 AM
clang/docs/LanguageExtensions.rst
1816

How about __cl_clang_unsafe_kernel_parameters to match the other extension naming scheme? Or we could use __cl_clang_non_portable_kernel_parameters, __cl_clang_non_portable_kernel_parameter_types to be more specific regarding the kind of safety that we allow to break?

1819
1824
1825
1826
1835

Let's add declarations of such types along in the example.

clang/lib/Sema/SemaDecl.cpp
8652

I would rather add an assert for this because we should not ever reach this function for the dependent types?

olestrohm added inline comments.Apr 27 2021, 3:27 AM
clang/lib/Sema/SemaDecl.cpp
8652

The function is actually called on dependent types

olestrohm updated this revision to Diff 340796.Apr 27 2021, 4:39 AM

Improved the description and example per the feedback.

The check for dependent type is needed. If it is not included the diagnostic will get triggered when the extension is disabled, but not when it's enabled.

olestrohm retitled this revision from [C++4OpenCL] Add clang extension for unsafe kernel parameters to [C++4OpenCL] Add clang extension for non-portable kernel parameters.Apr 27 2021, 4:40 AM
Anastasia added inline comments.Apr 29 2021, 7:07 AM
clang/docs/LanguageExtensions.rst
1820

Let's add references to relevant OpenCL C and C++ for OpenCL sections with restrictions.

1830
1836
1836

Let's add . at the end of every sentance. :)

1837
1844
olestrohm updated this revision to Diff 341526.Apr 29 2021, 8:28 AM
olestrohm set the repository for this revision to rG LLVM Github Monorepo.

Added a link to the C++ for OpenCL specification and cleaned up the text according to the requests.

olestrohm updated this revision to Diff 341831.Apr 30 2021, 3:43 AM

Fixed merge error

Anastasia accepted this revision.Apr 30 2021, 4:38 AM

LGTM! Thanks!

This revision is now accepted and ready to land.Apr 30 2021, 4:38 AM