Skip to content

cl_khr_subgroups support #602

Open
Open

Description

@sjw36

We would like to enable the cl_khr_subgroups extension for the following functions:

These functions will map to Builtin constants:

  • get_sub_group_size - SubgroupSize
  • get_max_sub_group_size - SubgroupMaxSize
  • get_num_sub_groups - NumSubgroups
  • get_sub_group_id - SubgroupId
  • get_sub_group_local_id - SubgroupLocalInvocationId

And these functions will map to spv::Op's accordingly:

  • sub_group_all - OpGroupNonUniformAll
  • sub_group_any - OpGroupNonUniformAny
  • sub_group_broadcast - OpGroupNonUniformBroadcast
  • sub_group_barrier - OpControlBarrier

And the reduction functions as follows:

  • sub_group_<group_operation>_add
    • INT: OpGroupNonUniformIAdd
    • FLOAT: OpGroupNonUniformFAdd
  • sub_group_<group_operation>_min
    • INT: OpGroupNonUniformSMin
    • UINT: OpGroupNonUniformUMin
    • FLOAT: OpGroupNonUniformFMin
  • sub_group_<group_operation>_max
    • INT: OpGroupNonUniformSMax
    • UINT: OpGroupNonUniformUMax
    • FLOAT: OpGroupNonUniformFMax
      With <group_operation> correspondingly:
  • reduce - GroupOperationReduce
  • scan_exclusive - GroupOperationExclusiveScan
  • scan_inclusive - GroupOperationInclusiveScan

Adding the cl_khr_subgroups extension support requires OpenCL 2.0 or greater (clang front-end already supports with -cl-std=CL2.0) and also requires SPIR-V 1.3 or greater support. A command line switch will be required to specify the -spirv-std for the output version.

Setting -spirv-std=1.4 or greater requires updating the EntryPointInterface with all GlobalVariable IDs.

All tests should be run with -spirv-std=1.5 to test conformance.

Activity

  1. sjw36 commented on Jul 1, 2020

    @sjw36
    ContributorAuthor

    The remainder of cl_khr_subgroups functions that should be implemented for full support:

    • get_enqueued_num_subroups
    • sub_group_reserve_read_pipe
    • sub_group_reserve_write_pipe
    • sub_group_commit_read_pipe
    • sub_group_commit_write_pipe
    • get_kernel_sub_group_count_for_ndrange
    • get_kernel_max_sub_group_size_for_ndrange
  2. added a commit that references this issue on Jul 1, 2020
  3. added a commit that references this issue on Jul 10, 2020
  4. added a commit that references this issue on Jul 15, 2020
  5. alan-baker commented on Jul 20, 2020

    @alan-baker
    Collaborator

    #610 added sub_group_barrier support.

  6. dokipen3d commented on Feb 24, 2021

    @dokipen3d

    Are there any plans to introduce support for the intel extension 'cl_intel_subgroups' which includes subgroup functions sub_group_shuffle function etc...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions