Skip to main content
Log in

Mojo function

make_buffer_resource

make_buffer_resource[type: DType](gds_ptr: UnsafePointer[SIMD[type, 1], address_space=address_space, alignment=alignment, mut=mut, origin=origin], num_records: Int = __init__[::Intable](SIMD(max_or_inf[::DType]()))) -> SIMD[uint32, 4]

Creates a 128-bit buffer resource descriptor for AMD GPU buffer operations.

This function constructs a 128-bit buffer resource descriptor used by AMD GPUs for buffer load/store operations. The descriptor contains information about the memory location, size, and access properties needed by the hardware to perform memory operations.

Notes:

- Only supported on AMD GPUs.
- The descriptor follows AMD's hardware-specific format:
- Bits 0-63: Base address
- Bits 64-95: Number of records (size)
- Bits 96-127: Flags controlling access properties
- Used with buffer_load and buffer_store operations.
- Performance-critical for optimized memory access patterns on AMD GPUs.
- Only supported on AMD GPUs.
- The descriptor follows AMD's hardware-specific format:
- Bits 0-63: Base address
- Bits 64-95: Number of records (size)
- Bits 96-127: Flags controlling access properties
- Used with buffer_load and buffer_store operations.
- Performance-critical for optimized memory access patterns on AMD GPUs.

Example:

```mojo
from gpu.intrinsics import make_buffer_resource

var ptr = UnsafePointer[Scalar[DType.float32]].alloc(1024)
var resource = make_buffer_resource[DType.float32](ptr, 1024)
# Use resource with buffer_load/buffer_store operations
```
.
```mojo
from gpu.intrinsics import make_buffer_resource

var ptr = UnsafePointer[Scalar[DType.float32]].alloc(1024)
var resource = make_buffer_resource[DType.float32](ptr, 1024)
# Use resource with buffer_load/buffer_store operations
```
.

Parameters:

  • type (DType): The data type of elements in the buffer.

Args:

  • gds_ptr (UnsafePointer[SIMD[type, 1], address_space=address_space, alignment=alignment, mut=mut, origin=origin]): Global memory base address pointer to the start of the buffer.
  • num_records (Int): Maximum number of records that can be accessed through this resource descriptor. Reads with offsets beyond this value return 0. Defaults to UInt32.MAX for maximum possible range.

Returns:

A 128-bit buffer resource descriptor as a SIMD[DType.uint32, 4].