Skip to main content
Elementwise addition is the hello-world of GPU programming. This example covers the full dispatch path.

Complete code

What happens at each step

Compilation

enigma.compile(vector_add) traces the Python function body once with symbolic IRValue placeholders. The result is Metal source like:

Dispatch parameters

Vectorized variant

Use vec_width=4 to process 4 elements per thread with float4 instructions:
The kernel body is unchanged — vec_width is handled by the compiler.

Benchmarking

See also