This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Fix parsing of opencl-c.h in CL 3.0
ClosedPublic

Authored by kpet on Mar 26 2021, 10:23 AM.

Details

Summary

Ensure that the cl_khr_3d_image_writes pragma is enabled by making
cl_khr_3d_image_writes an optional core feature in CL 3.0 in addition
to being an available extension in 1.0 onwards and a core feature in
CL 2.0.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>

Diff Detail

Event Timeline

kpet created this revision.Mar 26 2021, 10:23 AM
kpet requested review of this revision.Mar 26 2021, 10:23 AM
Anastasia accepted this revision.Mar 26 2021, 12:09 PM

LGTM! Thanks! I would like to hold off committing this for a day or two to see if there is any input from @azabaznov or anyone else.

This revision is now accepted and ready to land.Mar 26 2021, 12:09 PM
kpet added a comment.Mar 28 2021, 3:00 AM

Thanks! I'll wait for a couple of days before committing then.

Thanks for  the patch! Sorry for the delay

Can you please elaborate on what issue you are trying to resolve with this fix? You're trying to emit diagnostics for cl_khr_3d_image_writes for OpenCL C 3.0?

FYI cl_khr_3d_image_writes should have no effect in -cl-ext option for OpenCL C 3.0 as there exist __opencl_c_3d_image_writes,  I think it was discussed in some previous reviews

kpet added a comment.Mar 30 2021, 5:45 AM

@azabaznov Without this change, opencl-c.h cannot be parsed with -cl-std=CL3.0 as the write_only image3d_t type is not enabled. The type is currently enabled via cl_khr_3d_image_writes. See https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/OpenCLImageTypes.def#L68. It may be that we want to redesign this such that the type be enabled by the feature macro (or via another mechanism) and have the extension enable the feature macro internally but this would require more thinking and is probably best done as a follow-up IMHO (maybe as part of https://reviews.llvm.org/D92004 or a pre-requisite thereof?).

azabaznov accepted this revision.Mar 30 2021, 7:40 AM

Looks good to me. Thanks!

Without this change, opencl-c.h cannot be parsed with -cl-std=CL3.0 as the write_only image3d_t type is not enabled.

This should be fixed in the following up patches to check for __opencl_c_3d_image_writes feature or either for both: __opencl_c_3d_image_writes and cl_khr_3d_image_writes (in OpenCL C 3.0 mode). But I think it's OK to have this check for now.

kpet added a comment.Mar 30 2021, 7:51 AM

Thanks! I'll commit the change.