triton.experimental.gluon.language.amd.cdna5.buffer.make_buffer_descriptor
- triton.experimental.gluon.language.amd.cdna5.buffer.make_buffer_descriptor(base, num_records, _semantic=None) buffer_descriptor
Make a buffer resource descriptor from the hardware fields the program controls.
Accesses through the descriptor address
base + soffset + offsets[i]. The hardware checks every access againstnum_records, countingsoffset: in bytes frombase, an access is in bounds only ifsoffset + offset + size <= num_records. Out-of-bounds loads return zero and out-of-bounds stores are dropped, sonum_records=0disables every access.The check applies per hardware access, not per element. An access that ends within
num_recordsis in bounds as a whole. One that crosses it is checked in 4-byte pieces, and a piece is in bounds only if it ends at least 4 bytes beforenum_records, so elements near the bound can be out of bounds even though they fit. How many elements an access holds is up to the compiler: it vectorizes based on the alignment ofbaseandoffsetsand on the mask, but not onnum_records. So near the bound, the result can depend on vectorization. For example, loadingoffsets = [0, 1, 2, ...](a store drops the same elements):int32 elements and
num_records = 20: with one element per access, elements 0 to 4 are loaded. With four per access (16 bytes), the access holding elements 4 to 7 crosses the bound, and element 4 reads zero too: its piece ends at byte 20, not 4 bytes before the bound.int8 elements and
num_records = 10: with one element per access, elements 0 to 9 are loaded. With sixteen per access, the access holding elements 0 to 15 crosses the bound, and only its first piece (elements 0 to 3) is in bounds.
To bound each element exactly, keep accesses from crossing
num_records: make it andsoffset(in bytes) multiples of 16 bytes, the widest access, or also mask the elements past the bound, e.g.mask=offsets < nwithnum_records = n * 4for int32 and nosoffset. The compiler only vectorizes an access as far as its mask allows, so no access the mask keeps crosses the bound.The descriptor is as aligned as
base: usemultiple_of()onbaseto let accesses through it vectorize when the compiler can’t prove the alignment.- Parameters:
base (pointer to scalar) – Global memory base pointer. Its pointee type is the element type of the descriptor; offsets count these elements.
num_records (int32 or uint32 scalar) – Bytes accessible from
base, read as an unsigned 32-bit value: up to 2**32 - 1.
- Returns:
the descriptor.
- Return type: