github ↗
docs menu

Module Rig_amd_abi

The bytes an AMD GPU shares with its driver and with compiled code, as values.

This library describes what an AMD GPU reads and writes: the code objects it runs, and the thread traces and counters a run records. Nothing here acts on a GPU. Each value describes bytes, and its caller writes them where the GPU reads them, or reads them where the GPU wrote them. A format whose bytes depend on the GPU takes a Gpu.t, the versions of the GPU's blocks and the number of its parts.

A code object (Code_object.t) is a program the GPU runs. A device loads its image into the GPU's memory and launches its kernels from there.

A device's driver declares what compiled code needs of the device as a Capability.t (declare): its GPU, its clock, what its compute queue reads and its trace buffers. Compiled code finds it under key.

Compiled code checks that a device d runs a code object co:

ocaml
let runs d co =
  match Rig.capability d key with
  | Some c -> Code_object.runs_on co c.gpu
  | None -> false

The modules below are in reading order.

Conventions

Misuse raises Invalid_argument, such as an integer outside the range its function states, or a register the GPU's GC does not have. A code object that is not one for AMD GPUs is Error msg, msg saying why.

The library has no state, and any domain may use any of its values.

References

GPUs

#module Gpu : sig ... end

AMD GPUs, as their formats depend on them.

Programs

#module Code_object : sig ... end

Code objects, the programs AMD GPUs run.

Records of runs

#module Thread_trace : sig ... end

Thread traces, which a GPU's shader engines record while they run waves.

#module Counter : sig ... end

Performance counters, which count events of a kernel's run.

Devices

#module Capability : sig ... end

What compiled code needs from an AMD device.

#val key : Capability.t Stdlib.Type.Id.t

key is the key of an AMD device's record. Compiled code finds the record of a device d with Rig.capability d key, which is None if d is not an AMD device.

declare c is c under key, as the facts of an AMD device carry it (Rig_edge.facts).