Examples ā
Each example is a standalone Zig program in the examples/ directory. Run any of them with:
sh
zig build run-all-examples # run every example sequentially
zig build example-device-info # run a single example by name| # | Name | What it demonstrates |
|---|---|---|
| 01 | Device Info | Enumerate GPUs and read hardware properties |
| 02 | Memory Transfer | H2D, D2H, async copies, timing |
| 03 | Kernel Launch | Load PTX, launch with grid/block config |
| 04 | Streams & Events | Async pipelines, event timing |
| 05 | Tensor Operations | Elementwise, reduction, matmul |
| 06 | Multi-GPU | Peer access, cross-device copy |
| 07 | CPU Fallback | Run on host without a GPU |
| 08 | Managed Memory | Unified Memory, prefetch, advise |
| 09 | NVRTC Compilation | Runtime PTX compilation and launch |
| 10 | Memory Pools & 2D Pitched | Stream-ordered pool allocations & 2D pitched memory |
| 11 | Occupancy & Profiler | Occupancy calculator, stream priority & profiler markers |
| 12 | CPU vs GPU Benchmark | O(N²) N-body simulation ā 40Ć+ GPU speedup measured |
| 13 | N-D Tensor Operations | Reshape, transpose, broadcast, axis reductions, batched matmul |