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
Usevec_width=4 to process 4 elements per thread with float4 instructions:
vec_width is handled by the compiler.
Benchmarking
See also
- First Kernel — walkthrough of this example
- Execution Model — grid and thread index details
- Parallel Reduction — more complex pattern
