This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Fix optional image types
ClosedPublic

Authored by Anastasia on Apr 21 2021, 11:27 AM.

Details

Summary

This change allows the use of identifiers for image types from cl_khr_gl_msaa_sharing freely in the kernel code if the extension is not supported since they are not in the list of the reserved identifiers:
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#keywords

This change also removed the need for pragma for the types in the extensions since the spec doesn't require the pragma uses. For example, there is the following wording for 3d image writes:

The behavior of write_imagef, write_imagei and write_imageui for image objects with image_channel_data_type values not specified in the description above or with (x, y, z) coordinate values that are not in the range [0, image width-1], [0, image height-1], and [0, image depth-1], respectively, is undefined.

Requires support for OpenCL C 2.0, or OpenCL C 3.0 or newer and the __opencl_c_3d_image_writes feature, or the cl_khr_3d_image_writes extension.

Diff Detail

Event Timeline

Anastasia created this revision.Apr 21 2021, 11:27 AM
Anastasia requested review of this revision.Apr 21 2021, 11:27 AM
azabaznov accepted this revision.Apr 27 2021, 4:34 AM

Generally looks good to me, but maybe a test needed, see a comment. Thanks! But I'm still not sure about completely removing pragmas for type declarations (see https://reviews.llvm.org/D100980#2719196).

clang/include/clang/Basic/OpenCLImageTypes.def
68

Maybe we should add a test to check that` image3d_t` is reserved?

This revision is now accepted and ready to land.Apr 27 2021, 4:34 AM
Anastasia added inline comments.Apr 27 2021, 6:37 AM
clang/include/clang/Basic/OpenCLImageTypes.def
68

Do you mean something like:

typedef int image3d_t;

And then check that this gives an error?

azabaznov added inline comments.Apr 28 2021, 3:05 AM
clang/include/clang/Basic/OpenCLImageTypes.def
68

Yes, exactly. But currently there is already an expected behaviour: https://godbolt.org/z/4afjf5brn. I don't think that your patch changes that, but still, it's good to add a test since you are removing cl_khr_3d_image_writes from image descriptions.

Anastasia updated this revision to Diff 341835.Apr 30 2021, 4:00 AM

Test all image types as identifiers

Anastasia added inline comments.Apr 30 2021, 4:06 AM
clang/include/clang/Basic/OpenCLImageTypes.def
68

Improving testing is always desirable. I have added testing for all image types that are implemented in clang now.

I don't think that your patch changes that, but still, it's good to add a test since you are removing cl_khr_3d_image_writes from image descriptions.

Technically I am moving it elsewhere so it is no longer needed here. :)

Anastasia updated this revision to Diff 341842.Apr 30 2021, 4:26 AM

Improved negative testing for cl_khr_gl_msaa_sharing

azabaznov accepted this revision.May 4 2021, 9:57 AM

LGTM. Thanks!

This revision was landed with ongoing or failed builds.May 7 2021, 5:31 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2021, 5:31 AM
Herald added a subscriber: ldrumm. · View Herald Transcript