How davinchy/macuda works
macuda is a research CUDA compatibility stack for running llama.cpp and stable-diffusion.cpp CUDA workloads on an NVIDIA GPU attached to an Apple Silicon Mac. The main path is application calls through the CUDA runtime and cuBLAS shims into libtinynv, which boots and manages the GPU and submits kernels across a PCI/DriverKit transport. The README documents this layering; excerpts show key runtime-to-driver calls and driver responsibilities. Unsampled modules are represented only where the README or source index supports their role; profiling and experimental tools are not expanded into unsupported runtime flows.
Main entry points: tinynv.h Driver interface · cudart.c Launch ABI · tinynv.c Device lifecycle · exec.c Kernel execution
Components 18
CUDA compatibility
- Launch ABI
cuda-shim/libtinycudart/cudart.c - Runtime API
cuda-shim/libtinycudart/cudart_api.c - CUDA graphs
cuda-shim/libtinycudart/graph.c - Fatbin handling
cuda-shim/libtinycudart/fatbin.c - Pinned host memory
cuda-shim/libtinycudart/hostpool.c - cuBLAS shim
cuda-shim/libtinycublas/cublas.c
GPU driver
- Driver interface
cuda-shim/include/tinynv.h - Device lifecycle
cuda-shim/libtinynv/src/tinynv.c - Firmware boot
cuda-shim/libtinynv/src/gsp.c - GPU memory
cuda-shim/libtinynv/src/mmu.c
Hardware transport
- PCI boundary
cuda-shim/libtinynv/include/tinynv_pci.h - TinyGPU service
GPU execution
- NVIDIA GPU
- Kernel execution
cuda-shim/libtinynv/src/exec.c - Queue submission
cuda-shim/libtinynv/src/submit.c - Launch descriptors
cuda-shim/libtinynv/src/qmd.c - Cubin loading
cuda-shim/libtinynv/src/cubin.c
Other components
- CUDA workloads
Connections 21
- CUDA workloads → Launch ABI: calls launches
- CUDA workloads → Runtime API: calls runtime
- CUDA workloads → cuBLAS shim: calls GEMM
- Launch ABI → Driver interface: uses driver
cuda-shim/libtinycudart/cudart.c - Runtime API → Driver interface: uses driver
cuda-shim/libtinycudart/cudart_api.c - Launch ABI → Pinned host memory: initializes pool
cuda-shim/libtinycudart/cudart.c - Launch ABI → Cubin loading: loads kernels
cuda-shim/libtinycudart/cudart.c - cuBLAS shim → Driver interface: allocates and launches
cuda-shim/libtinycublas/cublas.c - CUDA graphs → Driver interface: records launches
cuda-shim/libtinycudart/graph.c - Driver interface → Device lifecycle: implements API
cuda-shim/libtinynv/src/tinynv.c - Device lifecycle → PCI boundary: opens device
cuda-shim/libtinynv/src/tinynv.c - PCI boundary → TinyGPU service: uses socket backend
cuda-shim/libtinynv/include/tinynv_pci.h - PCI boundary → NVIDIA GPU: accesses hardware
- Device lifecycle → Firmware boot: boots firmware
- Device lifecycle → GPU memory: manages MMU
- Driver interface → Kernel execution: runs work
- Kernel execution → Launch descriptors: builds launches
- Kernel execution → Queue submission: submits batches
cuda-shim/libtinynv/src/exec.c - Queue submission → NVIDIA GPU: rings queues
- Kernel execution → Cubin loading: executes kernels
- GPU memory → NVIDIA GPU: maps memory