Page MenuHomePhabricator

[OpenCL] Add support for missing sub_group functions.
ClosedPublic

Authored by joey on Jun 6 2017, 9:12 AM.

Details

Reviewers
bader
Anastasia
Summary

This adds get_kernel_max_sub_group_size_for_ndrange and get_kernel_sub_group_count_for_ndrange.

Note this also changes err_opencl_requires_extension to print the name of the function that the diagnostic is warning about.

Diff Detail

Event Timeline

joey created this revision.Jun 6 2017, 9:12 AM
joey added a reviewer: bader.Jun 19 2017, 2:38 AM
bader requested changes to this revision.Jun 19 2017, 4:09 AM

Please, split this patch into two parts:

  1. Improve diagnostics on extension enabling.
  2. Add missing sub_group_* built-in functions.
Sema/SemaChecking.cpp
1091–1092

I suggest leaving SemaBuiltinReserveRWPipe as is (i.e. two parameter) and modify the check for sub_group_* functions only:

if (checkOpenCLSubgroupExt(S, TheCall) || SemaBuiltinReserveRWPipe(*this, TheCall))
  return ExprError();

It think it's more readable than looking at SemaBuiltinReserveRWPipe declaration or leaving the comment like this:

if (SemaBuiltinReserveRWPipe(*this, TheCall, false /*isSubgroup*/))

Please, apply the same approach to SemaBuiltinCommitRWPipe.

In addition to that, it makes sense to set the TheCall type inside the SemaBuiltinReserveRWPipe to avoid code duplication.

SemaOpenCL/cl20-device-side-enqueue.cl
219

Please, add a test case(s) on invalid block parameters to cover the checks you added for new sub_group_ built-ins..

SemaOpenCL/sub-group-bifs.cl
1 ↗(On Diff #101576)

I don't think it makes sense to add this test. This test look like a duplicate of test cases added to SemaOpenCL/cl20-device-side-enqueue.cl.

clang/Basic/Builtins.def
1402–1403

This built-in functions should return unsigned integers: "i." -> "Ui.".
Please, fix get_kernel_work_group_size and get_kernel_preferred_work_group_size_multiple too.

clang/Basic/DiagnosticSemaKinds.td
8423–8424 ↗(On Diff #101576)

Since, this message is not specific to enqueue_kernel anymore, I suggest either rename it or better re-use existing diagnostics if possible. I think there are already message to report argument mismatch + probably additional note diagnostics that hints correct argument type.

This revision now requires changes to proceed.Jun 19 2017, 4:09 AM
joey updated this revision to Diff 108452.Jul 27 2017, 6:02 AM
joey edited edge metadata.

Updated all the comments you made and rebased.

Sorry for the long delay.

bader accepted this revision.Jul 27 2017, 7:07 AM

Thanks!
Overall the patch looks good, but I would suggest splitting it into three commits (as they seems to be independent):

  1. [OpenCL] Check that cl_khr_subgroups pragma is enabled if respective extension is used.
  2. [OpenCL] Add support for missing sub_group functions.
  3. [OpenCL] Fix return type for reserve pipe built-ins.

Please, add a regression test for the part #3.

You might also review this patch with @Anastasia (OpenCL code owner).

Sema/SemaChecking.cpp
685–689

This change is not covered with regression tests.

This revision is now accepted and ready to land.Jul 27 2017, 7:07 AM
Anastasia accepted this revision.Jul 27 2017, 9:14 AM

LGTM! Thanks!

joey closed this revision.Aug 9 2017, 8:23 AM

I committed all the parts separately: r309567 (with r309571 to fix a test), r309678 and r310477.