Made for learning how to parallelize computations in the GPU using Apple's Metal, in Rust, via the metal crate.
The source code will contain documented examples of use, growing in complexity, aimed at a final objective of parallelize a Fast Fourier Transform algorithm.
- dotprod: learn the basics of Metal and metal-rs, implement a simple dot product between two vectors represented as uint arrays.
- matrixprod: a more complex example to learn about grid size and thread groups, implement a product between square matrices.
- memory: example to show how to shared memory between CPU and GPU. This example creates a vector to be modified from the GPU.
To run the examples, use the following command:
make example EXAMPLE={example}
To re-build all the necessary .metallib
files, you can use
make compile_metal EXAMPLE={example}
where {example}
is the name of the example to run in both commands.
- Apple's Metal documentation: we recommend to start with "Performing Calculations on a GPU". Note that these docs are in Swift/Obj-C.
- miniSTARK: A minimal STARK library built in Rust and gpu-accelerated with Metal.
- metal-rs examples