Contributors
-
Ben Ashbaugh, Intel
-
Jianhui Li, Intel
-
Victor Mustya, Intel
-
Andrzej Ratajewski, Intel
-
Whitney Tsang, Intel
Dependencies
This extension is written against the SPIR-V Specification, Version 1.6 Revision 8.
This extension requires SPIR-V 1.0.
This extension extends the SPV_EXT_shader_atomic_float_add and SPV_EXT_shader_atomic_float_min_max extensions, which provide the floating-point atomic operations used by this extension.
This extension depends on the SPV_KHR_bfloat16 extension, which adds the
bfloat16 floating-point type used by this extension.
Overview
This extension extends the atomic support in SPIR-V to support atomic operations
on 16-bit integers in memory, and to support atomic load, store, and exchange as
well as floating-point atomic addition, minimum, and maximum on 16-bit bfloat16
floating-point numbers in memory.
Extension Name
To use this extension within a SPIR-V module, the following OpExtension must be present in the module:
OpExtension "SPV_INTEL_16bit_atomics"
Modifications to the SPIR-V Specification, Version 1.6
Modify Section 3.2.30, "Capability", adding to the Capability table:
| Capability | Implicitly Declares | |
|---|---|---|
6260 |
AtomicInt16CompareExchangeINTEL |
Int16 |
6261 |
Int16AtomicsINTEL |
AtomicInt16CompareExchangeINTEL |
6262 |
AtomicBFloat16LoadStoreINTEL |
BFloat16TypeKHR |
6255 |
AtomicBFloat16AddINTEL |
BFloat16TypeKHR |
6256 |
AtomicBFloat16MinMaxINTEL |
BFloat16TypeKHR |
Add the AtomicBFloat16AddINTEL capability to the OpAtomicFAddEXT instruction added by SPV_EXT_shader_atomic_float_add:
Add the AtomicBFloat16MinMaxINTEL capability to the OpAtomicFMinEXT and OpAtomicFMaxEXT instructions added by SPV_EXT_shader_atomic_float_min_max:
Validation Rules
-
For all atomic instructions, the Result Type may be a 16-bit integer type, and the type of Value may be a 16-bit integer type.
-
If the Result Type for OpAtomicLoad, OpAtomicExchange, OpAtomicCompareExchange, or OpAtomicCompareExchangeWeak is a 16-bit integer type, then the AtomicInt16CompareExchangeINTEL capability must be declared.
-
If the type of Value for OpAtomicStore is a 16-bit integer type, then the AtomicInt16CompareExchangeINTEL capability must be declared.
-
For all other atomic instructions, if the Result Type is a 16-bit integer type or the type of Value is a 16-bit integer type, then the Int16AtomicsINTEL capability must be declared.
-
-
For the instructions OpAtomicLoad, OpAtomicStore, OpAtomicExchange, OpAtomicFAddEXT, OpAtomicFMinEXT, or OpAtomicFMaxEXT, the Result Type may be a 16-bit floating-point type with the BFloat16KHR encoding, and the type of Value may be a 16-bit floating-point type with the BFloat16KHR encoding.
-
If the Result Type for OpAtomicLoad or OpAtomicExchange is a 16-bit floating-point type with the BFloat16KHR encoding, then the AtomicBFloat16LoadStoreINTEL capability must be declared.
-
If the type of Value for OpAtomicStore is a 16-bit floating-point type with the BFloat16KHR encoding, then the AtomicBFloat16LoadStoreINTEL capability must be declared.
-
If the Result Type for OpAtomicFAddEXT is a 16-bit floating-point type with the BFloat16KHR encoding, then the AtomicBFloat16AddINTEL capability must be declared.
-
If the Result Type for OpAtomicFMinEXT or OpAtomicFMaxEXT is a 16-bit floating-point type with the BFloat16KHR encoding, then the AtomicBFloat16MinMaxINTEL capability must be declared.
-
Issues
-
Do we need to support the case where
bfloat16values are represented as 16-bit integers where the bit pattern represents abfloat16value?RESOLVED: No, we will only support the case with a real
bfloat16type, specifically a 16-bit floating-point type with the BFloat16KHR encoding. This means that this extension has a dependency on SPV_KHR_bfloat16. -
Do we need a separate capability for an
int16atomic load and store?RESOLVED: No, this is not necessary. The AtomicInt16CompareExchangeINTEL capability will also enable support for 16-bit integer atomic loads, stores, and exchanges.