This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Adjust diagnostic for subgroup support.
ClosedPublic

Authored by azabaznov on Feb 4 2022, 7:32 AM.

Details

Summary

OpenCL C 3.0 __opencl_c_subgroups feature is slightly different
then other equivalent features and extensions (fp64 and 3d image writes):
OpenCL C 3.0 device can support the extension but not the feature.
cl_khr_subgroups requires subgroup independent forward progress.

This patch adjusts the check which is used when translating language
builtins to check either the extension or feature is supported.

Diff Detail

Event Timeline

azabaznov created this revision.Feb 4 2022, 7:32 AM
azabaznov requested review of this revision.Feb 4 2022, 7:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2022, 7:32 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Btw can you point us to the spec reference please, I can't seem to find anything related to this: https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#subgroup-functions.

It would be nice to add the reference in the code comment too.

clang/lib/Sema/SemaChecking.cpp
1055

Ideally we should reduce the number of separate diagnostics, so could we just print something like:
"cl_khr_subgroups extension or __opencl_c_subgroups OpenCL C 3.0 feature"
when using diag::err_opencl_requires_extension?

It seems hard to find a direct mention in the spec, but in the API spec:

CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: Is CL_TRUE if this device supports independent forward progress of sub-groups, CL_FALSE otherwise. This query must return CL_TRUE for devices that support the cl_khr_subgroups extension, and must return CL_FALSE for devices that do not support subgroups.

It seems hard to find a direct mention in the spec, but in the API spec:

CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: Is CL_TRUE if this device supports independent forward progress of sub-groups, CL_FALSE otherwise. This query must return CL_TRUE for devices that support the cl_khr_subgroups extension, and must return CL_FALSE for devices that do not support subgroups.

Ok, I would agree that the wording doesn't seem identical since the extension explicitly details forward progress behavior but the feature doesn't:
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_subgroups

But I think it would make sense to add wording of it in the feature spec too otherwise it appears unspecified?

Anyway, at present, since they are not identical having separate handling of these teo seems reasonable.

azabaznov updated this revision to Diff 407856.Feb 11 2022, 5:52 AM

Use existing diagnostics; add the comment that device can support extension but not the feature. Will follow up if we need explicit mention in the language spec.

Anastasia accepted this revision.Feb 11 2022, 6:38 AM

LGTM! Thanks

This revision is now accepted and ready to land.Feb 11 2022, 6:38 AM
This revision was automatically updated to reflect the committed changes.