Module Tolk.Gpu_target

Resolved GPU target descriptors for renderer construction.

This module owns CUDA/AMD target selection policy. Renderers consume these resolved targets and do not read environment variables themselves.

type cuda =
  1. | SM75
  2. | SM80
  3. | SM89
  4. | SM90

CUDA SM architecture tiers used by source generation.

type amd =
  1. | RDNA3
  2. | RDNA4
  3. | CDNA3
  4. | CDNA4

AMD GPU architecture families used by source generation.

type metal =
  1. | Apple of int
  2. | Mac of int

Metal GPU family used by source generation. Mirrors tinygrad's Metal target architecture string, e.g. "Apple7" or "Mac2".

type opencl = string

OpenCL target architecture string used by source generation. Mirrors tinygrad's comma-separated Target.arch, normally the device extension list such as "cl_khr_fp16,cl_khr_fp64".

type cpu =
  1. | X86_64
  2. | Arm64
  3. | Riscv64

CPU architecture family used by source generation. Mirrors tinygrad's normalized CPU target architecture prefix.

val cpu_of_machine : string -> cpu option

cpu_of_machine s normalizes host machine names such as "amd64" or "aarch64" to CPU renderer targets.

val host_cpu : unit -> cpu

host_cpu () is the CPU renderer target for the current host.

Raises Invalid_argument if the host architecture is unsupported.

val cuda_of_env : unit -> cuda option

cuda_of_env () resolves CUDA_ARCH or CUDA_SM to the nearest supported CUDA SM tier. Returns None when no supported tier is configured.

val amd_of_env : unit -> amd option

amd_of_env () resolves common AMD arch environment variables such as AMD_ARCH, HIP_ARCH, HCC_AMDGPU_TARGET, or HSA_OVERRIDE_GFX_VERSION. Returns None when no supported arch family is configured.

val parse_metal_arch : string -> metal option

parse_metal_arch s parses tinygrad-style Metal architecture names such as "Apple7" and "Mac2".