Module Tolk_cuda

CUDA GPU device backend.

Tolk_cuda provides a Tolk.Device.t that executes compiled kernels on NVIDIA GPUs through the CUDA driver API. Construct a device with create and interact with it through the Tolk.Device interface.

The CUDA driver (libcuda.so.1) and NVRTC (libnvrtc.so) libraries are loaded dynamically at device creation, so this library links on machines without a CUDA installation; create raises there instead.

Kernel compilation

Kernels are compiled to PTX with NVRTC for the device's compute-capability tier and JIT-compiled by the driver at module load. Compilation results are stored in the on-disk compile cache.

Environment variables

  • CUDA_ARCH / CUDA_SM — override the compute-capability tier used for source generation and PTX compilation (e.g. sm_80). Defaults to the tier resolved from the device's compute capability.
  • CUDA_PATH — CUDA toolkit root used for compile-time include paths. Defaults to the standard system locations.

Device

val create : string -> Tolk.Device.t

create name is a CUDA device identified by name.

The device ordinal is parsed from name ("CUDA:1" opens device 1; "CUDA" defaults to device 0). The device uses an LRU-cached allocator over CUDA device memory with pinned host staging for host-to-device and device-to-host copies, a CUDA renderer compiled through NVRTC, and a Tolk.Device.Graph capability that replays batched call sequences as CUDA execution graphs.

Raises Failure if no CUDA driver or GPU is available, and Invalid_argument if the suffix after ':' is not an integer.