Skip to content

Commit 72f3fce

Browse files
committed
[AMDGPU] Document meaning of alignment of buffer fat pointers, intrinsics
This commit adds documentation clarifying the meaning of `align` on ptr addrpsace(7) (buffer fat pointer) and ptr addrspace(9) (bufferef structured pointer) operations (specifying that both the base and the offset need to be aligned) and documents the meaning of the `align` attribute when used as an argument on *.buffer.ptr.* intrinsics.
1 parent a314b3b commit 72f3fce

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

llvm/docs/AMDGPUUsage.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,15 @@ supported for the ``amdgcn`` target.
10161016
`ptr addrspace(7)` directly, which produces a buffer fat pointer with an initial
10171017
offset of 0 and prevents the address space cast from being rewritten away.
10181018

1019+
The `align` attribute on operations from buffer fat pointers is deemed to apply
1020+
to all componenents of the pointer - that is, an `align 4` load is expected to
1021+
both have the offset be a multiple of 4 and to have a base pointer whose an
1022+
alignment of 4.
1023+
1024+
(This componentwise definition of alignment is needed to allow for promotion of
1025+
aligned loads to `s_buffer_load`, which requires that both the base pointer and
1026+
offset be appropriately aligned.)
1027+
10191028
**Buffer Resource**
10201029
The buffer resource pointer, in address space 8, is the newer form
10211030
for representing buffer descriptors in AMDGPU IR, replacing their
@@ -1039,6 +1048,18 @@ supported for the ``amdgcn`` target.
10391048
(bits `127:96`). The specific interpretation of these fields varies by the
10401049
target architecture and is detailed in the ISA descriptions.
10411050

1051+
When buffer resourcess are passed to buffer intrinsics such as `raw.ptr.buffer.load`
1052+
or `struct.ptr.buffer.store`, the `align` attribute on the pointer is assumed to
1053+
apply to both the offset and the base pointer value. That is, `align 8` means that
1054+
both the base address within the `ptr addrspace(8)` and the `offset` argument
1055+
have their three lowesst bits set to 0. If the stride of the resource is nonzero,
1056+
the stride must be a multiple of the given alignment.
1057+
1058+
In other words, the `align` attribute specifies the alignemnt of the effective
1059+
address being loaded from/stored to *and* acts as a guuarantee that this is
1060+
not achieved from adding lower-alignment parts (as hardware may not always
1061+
allow for such an addition).
1062+
10421063
**Buffer Strided Pointer**
10431064
The buffer index pointer is an experimental address space. It represents
10441065
a 128-bit buffer descriptor and a 32-bit offset, like the **Buffer Fat
@@ -1057,6 +1078,12 @@ supported for the ``amdgcn`` target.
10571078
index and offset values are both 0. This prevents the address space cast from
10581079
being rewritten away.
10591080

1081+
As with buffer fat pointers, alignment of a buffer strided pointer applies to
1082+
both the base pointer address and the offset. In addition, the alignment also
1083+
constrains the stride of the pointer. That is, if you do an `align 4` load from
1084+
a buffer strided pointer, this means that the base pointer is `align(4)`, that
1085+
the offset is a multiple of 4 bytes, and that the stride is a multiple of 4.
1086+
10601087
**Streamout Registers**
10611088
Dedicated registers used by the GS NGG Streamout Instructions. The register
10621089
file is modelled as a memory in a distinct address space because it is indexed

0 commit comments

Comments
 (0)