Skip to content

Commit

Permalink
Extended Subgroups (KhronosGroup#529)
Browse files Browse the repository at this point in the history
* initial version for publication

* add version information

* clarify undefined behavior for non-uniform broadcast and inverse ballot
document supported types for subgroup mask built-ins

* update version information

* Apply suggestions from code review
  • Loading branch information
bashbaug authored Dec 18, 2020
1 parent be5003d commit 2b26248
Show file tree
Hide file tree
Showing 4 changed files with 1,238 additions and 3 deletions.
2 changes: 2 additions & 0 deletions OpenCL_Ext.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ include::ext/cl_khr_async_work_group_copy_fence.asciidoc[]
include::ext/cl_khr_device_uuid.asciidoc[]
include::ext/cl_khr_extended_versioning.asciidoc[]

include::ext/cl_khr_subgroup_extensions.asciidoc[]

// NOTE: To keep meaningful section numbers, new
// extension documents should be added above here!

Expand Down
133 changes: 133 additions & 0 deletions env/extensions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,139 @@ If the OpenCL environment supports the extension `cl_khr_spirv_no_integer_wrap_d

If the OpenCL environment supports the extension `cl_khr_spirv_no_integer_wrap_decoration` and use of the SPIR-V extension `SPV_KHR_no_integer_wrap_decoration` is declared in the module via *OpExtension*, then the environment must accept modules that include the *NoSignedWrap* or *NoUnsignedWrap* decorations.

==== `cl_khr_subgroup_extended_types`

If the OpenCL environment supports the extension `cl_khr_subgroup_extended_types`, then additional types are valid for the following for *Groups* instructions with _Scope_ for _Execution_ equal to *Subgroup*:

* *OpGroupBroadcast*
* *OpGroupIAdd*, *OpGroupFAdd*
* *OpGroupSMin*, *OpGroupUMin*, *OpGroupFMin*
* *OpGroupSMax*, *OpGroupUMax*, *OpGroupFMax*

For these instructions, valid types for _Value_ are:

* Scalars of supported types:
** *OpTypeInt* (equivalent to `char`, `uchar`, `short`, `ushort`, `int`, `uint`, `long`, and `ulong`)
** *OpTypeFloat* (equivalent to `half`, `float`, and `double`)

Additionally, for *OpGroupBroadcast*, valid types for _Value_ are:

* *OpTypeVectors* with 2, 3, 4, 8, or 16 _Component Count_ components of supported types:
** *OpTypeInt* (equivalent to `char__n__`, `uchar__n__`, `short__n__`, `ushort__n__`, `int__n__`, `uint__n__`, `long__n__`, and `ulong__n__`)
** *OpTypeFloat* (equivalent to `half__n__`, `float__n__`, and `double__n__`)

==== `cl_khr_subgroup_non_uniform_vote`

If the OpenCL environment supports the extension `cl_khr_subgroup_non_uniform_vote`, then the environment must accept SPIR-V modules that declare the following SPIR-V capabilities:

* *GroupNonUniform*
* *GroupNonUniformVote*

For instructions requiring these capabilities, _Scope_ for _Execution_ may be:

* *Subgroup*

For the instruction *OpGroupNonUniformAllEqual*, valid types for _Value_ are:

* Scalars of supported types:
** *OpTypeInt* (equivalent to `char`, `uchar`, `short`, `ushort`, `int`, `uint`, `long`, and `ulong`)
** *OpTypeFloat* (equivalent to `half`, `float`, and `double`)

==== `cl_khr_subgroup_ballot`

If the OpenCL environment supports the extension `cl_khr_subgroup_ballot`, then the environment must accept SPIR-V modules that declare the following SPIR-V capabilities:

* *GroupNonUniformBallot*

For instructions requiring these capabilities, _Scope_ for _Execution_ may be:

* *Subgroup*

For the non-uniform broadcast instruction *OpGroupNonUniformBroadcast*, valid types for _Value_ are:

* Scalars of supported types:
** *OpTypeInt* (equivalent to `char`, `uchar`, `short`, `ushort`, `int`, `uint`, `long`, and `ulong`)
** *OpTypeFloat* (equivalent to `half`, `float`, and `double`)
* *OpTypeVectors* with 2, 3, 4, 8, or 16 _Component Count_ components of supported types:
** *OpTypeInt* (equivalent to `char__n__`, `uchar__n__`, `short__n__`, `ushort__n__`, `int__n__`, `uint__n__`, `long__n__`, and `ulong__n__`)
** *OpTypeFloat* (equivalent to `half__n__`, `float__n__`, and `double__n__`)

For the instruction *OpGroupNonUniformBroadcastFirst*, valid types for _Value_ are:

* Scalars of supported types:
** *OpTypeInt* (equivalent to `char`, `uchar`, `short`, `ushort`, `int`, `uint`, `long`, and `ulong`)
** *OpTypeFloat* (equivalent to `half`, `float`, and `double`)

For the instruction *OpGroupNonUniformBallot*, the valid _Result Type_ is an *OpTypeVector* with four _Component Count_ components of *OpTypeInt*, with _Width_ equal to 32 and _Signedness_ equal to 0 (equivalent to `uint4`).

For the instructions *OpGroupNonUniformInverseBallot*, *OpGroupNonUniformBallotBitExtract*, *OpGroupNonUniformBallotBitCount*, *OpGroupNonUniformBallotFindLSB*, and *OpGroupNonUniformBallotFindMSB*, the valid type for _Value_ is an *OpTypeVector* with four _Component Count_ components of *OpTypeInt*, with _Width_ equal to 32 and _Signedness_ equal to 0 (equivalent to `uint4`).

For built-in variables decorated with *SubgroupEqMask*, *SubgroupGeMask*, *SubgroupGtMask*, *SubgroupLeMask*, or *SubgroupLtMask*, the supported variable type is an *OpTypeVector* with four _Component Count_ components of *OpTypeInt*, with _Width_ equal to 32 and _Signedness_ equal to 0 (equivalent to `uint4`).

==== `cl_khr_subgroup_non_uniform_arithmetic`

If the OpenCL environment supports the extension `cl_khr_subgroup_non_uniform_arithmetic`, then the environment must accept SPIR-V modules that declare the following SPIR-V capabilities:

* *GroupNonUniformArithmetic*

For instructions requiring these capabilities, _Scope_ for _Execution_ may be:

* *Subgroup*

For the instructions *OpGroupNonUniformLogicalAnd*, *OpGroupNonUniformLogicalOr*, and *OpGroupNonUniformLogicalXor*, the valid type for _Value_ is *OpTypeBool*.

Otherwise, for the *GroupNonUniformArithmetic* scan and reduction instructions, valid types for _Value_ are:

* Scalars of supported types:
** *OpTypeInt* (equivalent to `char`, `uchar`, `short`, `ushort`, `int`, `uint`, `long`, and `ulong`)
** *OpTypeFloat* (equivalent to `half`, `float`, and `double`)

For the *GroupNonUniformArithmetic* scan and reduction instructions, the optional _ClusterSize_ operand must not be present.

==== `cl_khr_subgroup_shuffle`

If the OpenCL environment supports the extension `cl_khr_subgroup_shuffle`, then the environment must accept SPIR-V modules that declare the following SPIR-V capabilities:

* *GroupNonUniformShuffle*

For instructions requiring these capabilities, _Scope_ for _Execution_ may be:

* *Subgroup*

For the instructions *OpGroupNonUniformShuffle* and *OpGroupNonUniformShuffleXor* requiring these capabilities, valid types for _Value_ are:

* Scalars of supported types:
** *OpTypeInt* (equivalent to `char`, `uchar`, `short`, `ushort`, `int`, `uint`, `long`, and `ulong`)
** *OpTypeFloat* (equivalent to `half`, `float`, and `double`)

==== `cl_khr_subgroup_shuffle_relative`

If the OpenCL environment supports the extension `cl_khr_subgroup_shuffle_relative`, then the environment must accept SPIR-V modules that declare the following SPIR-V capabilities:

* *GroupNonUniformShuffleRelative*

For instructions requiring these capabilities, _Scope_ for _Execution_ may be:

* *Subgroup*

For the *GroupNonUniformShuffleRelative* instructions, valid types for _Value_ are:

* Scalars of supported types:
** *OpTypeInt* (equivalent to `char`, `uchar`, `short`, `ushort`, `int`, `uint`, `long`, and `ulong`)
** *OpTypeFloat* (equivalent to `half`, `float`, and `double`)

==== `cl_khr_subgroup_clustered_reduce`

If the OpenCL environment supports the extension `cl_khr_subgroup_clustered_reduce`, then the environment must accept SPIR-V modules that declare the following SPIR-V capabilities:

* *GroupNonUniformClustered*

For instructions requiring these capabilities, _Scope_ for _Execution_ may be:

* *Subgroup*

When the *GroupNonUniformClustered* capability is declared, the *GroupNonUniformArithmetic* scan and reduction instructions may include the optional _ClusterSize_ operand.

=== Embedded Profile Extensions

==== `cles_khr_int64`
Expand Down
Loading

0 comments on commit 2b26248

Please sign in to comment.