Skip to content

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
#NameWhat it demonstrates
01Device InfoEnumerate GPUs and read hardware properties
02Memory TransferH2D, D2H, async copies, timing
03Kernel LaunchLoad PTX, launch with grid/block config
04Streams & EventsAsync pipelines, event timing
05Tensor OperationsElementwise, reduction, matmul
06Multi-GPUPeer access, cross-device copy
07CPU FallbackRun on host without a GPU
08Managed MemoryUnified Memory, prefetch, advise
09NVRTC CompilationRuntime PTX compilation and launch
10Memory Pools & 2D PitchedStream-ordered pool allocations & 2D pitched memory
11Occupancy & ProfilerOccupancy calculator, stream priority & profiler markers
12CPU vs GPU BenchmarkO(N²) N-body simulation — 40Ɨ+ GPU speedup measured
13N-D Tensor OperationsReshape, transpose, broadcast, axis reductions, batched matmul

Released under the MIT License.