Name Strings

SPV_INTEL_masked_gather_scatter

Contact

To report problems with this extension, please open a new issue at:

Contributors

  • Dmitry Sidorov, Intel

  • Ben Ashbaugh, Intel

  • Arvind Sudarsanam, Intel

Notice

Copyright (c) 2023 Intel Corporation. All rights reserved.

Status

  • Shipping.

Version

Last Modified Date

2023-09-05

Revision

1

Dependencies

This extension is written against the SPIR-V Specification, Version 1.6 Revision 2.

This extension requires SPIR-V 1.0.

Overview

This extension allows OpTypeVector to have a physical pointer type Component Type and introduces gather/scatter instructions. These are important operations for many explicitly vectorized kernels.

Extension Name

To use this extension within a SPIR-V module, the appropriate OpExtension must be present in the module:

OpExtension "SPV_INTEL_masked_gather_scatter"

New Capabilities

This extension introduces new capabilities:

MaskedGatherScatterINTEL

New Instructions

Instructions added under the MaskedGatherScatterINTEL capability:

OpMaskedGatherINTEL
OpMaskedScatterINTEL

Token Number Assignments

MaskedGatherScatterINTEL

6427

OpMaskedGatherINTEL

6428

OpMaskedScatterINTEL

6429

Modifications to the SPIR-V Specification, Version 1.5

2.2.2. Types

Update the definition of Vector, adding pointers to the set of supported component types: An ordered homogeneous collection of two or more scalars or pointers of physical pointer type. Vector sizes are quite restrictive and dependent on the execution model.

2.16.1. Universal Validation Rules

Modify Data rules section, replacing following segment:

  • Vector types must be parameterized only with numerical types or the OpTypeBool type.

with:

  • Vector types must be parameterized only with numerical types or the OpTypeBool type. They can also be parameterized with physical pointer type types under MaskedGatherScatterINTEL capability.

Capabilities

Modify Section 3.31, Capability, adding rows to the Capability table:

Capability Implicitly Declares

6427

MaskedGatherScatterINTEL

Allow OpTypeVector to have a physical pointer type Component Type.

See also extension: SPV_INTEL_masked_gather_scatter

Addresses

3.42.6. Type-Declaration Instructions

Modify OpTypeVector, changing the description of Component Type to: Component Type is the type of each component in the resulting type. It must be a scalar type or physical pointer type.

3.42.7. Constant-Creation Instructions

Modify OpConstantNull, allowing Result Type to be a vector of physical pointer type.

3.42.8. Memory Instructions

Allow vector of physical pointer type to be used by OpVariable, OpAccessChain, OpInBoundsAccessChain, OpPtrAccessChain, OpInBoundsPtrAccessChain, OpPtrEqual, OpPtrNotEqual and OpPtrDiff instructions. When vector of physical pointer type is allowed for OpVariable it is implicitly possible to be used by OpStore and OpLoad which can store/load through a pointer to this vector.

Change the Overview of OpVariable as follows: Allocate an object or a vector of objects in memory, resulting in a pointer or appropriately a vector of pointers to it, which can be used with OpLoad and OpStore. Change the Result Type of OpVariable as follows: Result Type must be an OpTypePointer or a vector with physical pointer type Component Type. Its Type operand is the type of object or vector of objects in memory.

Modify OpAccessChain (implicitly modifies OpInBoundsAccessChain, OpPtrAccessChain and OpInBoundsPtrAccessChain instructions) Change the Base as follows: Base must be a pointer, pointing to the base of a composite object or a vector of physical pointer type.

Allow vector of physical pointer type to be the type of Operand 1 and Operand 2 of OpPtrEqual, OpPtrNotEqual and OpPtrDiff instructions. If operands are vectors of pointers, then the Result Type of OpPtrEqual and OpPtrNotEqual is a vector with boolean Component Type and Result Type of OpPtrDiff is a vector with integer Component Type.

Add the following new entries:

OpMaskedGatherINTEL

Reads values from a vector of pointers gathering them into one vector. Returns the gathered vector. Memory access is specified by a mask instruction parameter.

Result Type is a type of the gathered vector. Its Component Type must be the same as the base type of PtrVector.
PtrVector is a vector with physical pointer type Component Type, containing addresses from where the instruction reads.

Alignment is an unsigned 32-bit integer literal whose value is either 0 or a power of two. When the value is not 0, it is an assertion that each pointer value in PtrVector has this alignment. The behavior is undefined if any pointer value in PtrVector does not have this alignment.

Mask is a vector of boolean values with the same number of elements as the Result Type. It specifies which elements of PtrVector should be gathered.

FillEmpty is used to fill the masked-off lanes of the result. It must be of the same type as the Component Type of Result Type.

Capability:
MaskedGatherScatterINTEL

7

6428

<id>
Result Type

Result <id>

<id>
PtrVector

<literal>
Alignment

<id>
Mask

<id>
FillEmpty

OpMaskedScatterINTEL

Writes values from a vector to the corresponding memory address of the given vector of pointers. Memory access is specified by a mask instruction parameter.

InputVector is a vector of values to scatter.

PtrVector is a vector with physical pointer type Component Type, containing addresses where the instruction stores the scattered values.

Alignment is an unsigned 32-bit integer literal whose value is either 0 or a power of two. When the value is not 0, it is an assertion that each pointer value in PtrVector has this alignment. The behavior is undefined if any pointer value in PtrVector does not have this alignment.

Mask is a vector of boolean values with the same number of elements as the InputVector. It specifies which elements of InputVector should be scattered.

Capability:
MaskedGatherScatterINTEL

5

6429

<id>
InputVector

<id>
PtrVector

<literal>
Alignment

<id>
Mask

3.42.11. Conversion Instructions

Allow OpTypeVector to be Result Type and type of an input for OpConvertPtrToU, OpConvertUToPtr instructions: Change the Result Type of OpConvertPtrToU as follows: Result Type must be a scalar or vector of integer type, whose Signedness operand is 0.

Change the Pointer of OpConvertPtrToU as follows: Pointer must be a physical pointer type or a vector with physical pointer type Component Type. If the bit width of Pointer is smaller than that of Result Type, the conversion zero-extends Pointer. If the bit width of Pointer is larger than that of Result Type, the conversion truncates Pointer. For same bit width Pointer and Result Type, this is the same as OpBitcast.

Change the Result Type of OpConvertUToPtr as follows: Result Type must be a physical pointer type or a vector with physical pointer type Component Type.

Change the Integer Value of OpConvertUToPtr as follows: Integer Value must be a scalar or vector of integer type, whose Signedness operand is 0. If the bit width of Integer Value is smaller than that of Result Type, the conversion zero-extends Integer Value. If the bit width of Integer Value is larger than that of Result Type, the conversion truncates Integer Value. For same width Integer Value and Result Type, this is the same as OpBitcast.

Allow vector of physical pointer type to be Result Type and type of a Pointer for OpPtrCastToGeneric, OpGenericCastToPtr and OpGenericCastToPtrExplicit instructions.

Allow vector of physical pointer type to be Result Type and type of an Operand for OpBitcast instruction.

3.42.12. Composite Instructions

Most of the Composite Instructions that are supposed to work with vector type do not have any restrictions about Component Type. This extension allows these instructions to operate on vector of physical pointer type.

Allow physical pointer type to be a Result Type of OpVectorExtractDynamic.

Issues

None

Revision History

Rev Date Author Changes

1

2023-09-05

Dmitry Sidorov

Prepare to ship