redbluegreen wiki

Memory

How one Buffer gets one virtual address that the CPU and the GPU both use.

one virtual address range: va to va + size 1 reserve va mmap PROT_NONE MAP_ANONYMOUS passes va 2 ALLOC nr 0x16, 40 B va_addr = va returns handle 3 MAP to GPU nr 0x18 gpu_ids array returns offset 4 host view mmap MAP_FIXED render fd, offset after step 4 the CPU and the GPU use the same address Drop, in reverse FREE UNMAP munmap unmaps frees our code kfd driver
One Buffer takes four steps over one virtual address range, and a Drop runs the same three driver steps backwards.

Our buffer carries one address for both consumers so every pointer or kernel argument needs no translation step.

One buffer takes four steps:

  1. Get an address: reserve the range with an anonymous PROT_NONE mmap.
  2. Allocate memory: ALLOC (nr 0x16, a 40 byte argument) takes that address and returns a handle and mmap_offset.
  3. Map it to the GPU: MAP (nr 0x18) takes the handle and an array of gpu_ids.
  4. The host view is an mmap with MAP_SHARED and MAP_FIXED on the render fd at mmap_offset.

A Drop runs the reverse: munmap, UNMAP, FREE.

FlagBitMeaning
GTT1<<1place it in the GTT pool
WRITABLE1<<31 the GPU may store to it
EXECUTABLE1<<30 it may hold kernel code
COHERENT1<<26 fine grained, the CP sees CPU writes

Every buffer the command processor touches carries COHERENT: the ring, the two pointers, the kernel object, the kernarg buffer, and the signal.

Data that only the kernels read and write stays coarse. Streaming loads measure 222 GB/s fine and 225 GB/s coarse.

Sources