redbluegreen wiki

The floor

What the kernel compute device asks of a program that has no GPU userspace under it.

our program, unit 1 fd 1: /dev/kfd GET_VERSION 0x01 RUNTIME_ENABLE 0x25 ACQUIRE_VM 0x15 ALLOC 0x16, MAP 0x18 CREATE_QUEUE 0x02 mmap: doorbells, event page fd 2: /dev/dri/renderD128 this fd goes to ACQUIRE_VM mmap: buffer host views no DRM ioctl after that the kfd fd answers ENODEV for a buffer host view calls maps kernel: the amdgpu and kfd driver programs GPU, AMD Strix Halo APU the ioctl request number, 32 bits: 31 29 15 7 dir size of the struct 'K' nr 2 bits 14 bits 8 bits 8 bits a wrong struct size gives a wrong request number, and the kernel answers EINVAL our code driver and hardware
Unit 1 holds two file descriptors: every ioctl goes to /dev/kfd, and the render node only gives the fd for ACQUIRE_VM and the host views of buffers.

The "floor" is the lowest level interface for accessing compute. On this machine, it is the kernel character device /dev/kfd.

A userspace runtime sits above /dev/kfd, hiding it.

redbluegreen starts below that runtime in order to optimize model training for the constraints of this box.

This unit does four things in order:

  1. It reads gpu_id from the sysfs topology. It skips each node with gpu_id 0.
  2. It opens both device nodes.
  3. It calls GET_VERSION.
  4. It calls ACQUIRE_VM with the render fd and the gpu_id.

The compute device takes every ioctl and serves the doorbells and event page.

The render node gives the fd ACQUIRE_VM needs and carries the host view of each buffer.

RUNTIME_ENABLE is called once per process, before any queue. The kernel comment says that MES uses this call to clear a stale process context.

Even though redbluegreen is trying to minimize dependencies, it cannot avoid three:

  1. The driver header defines every struct.
  2. An assembler builds gfx1151 machine code.
  3. libc supplies ioctl and mmap.

Sources