https://github.com/lambdaclass/metal_playground
A repo for learning how to parallelize computations in the GPU using Apple's Metal, in Rust.
https://github.com/lambdaclass/metal_playground
Last synced: 10 months ago
JSON representation
A repo for learning how to parallelize computations in the GPU using Apple's Metal, in Rust.
- Host: GitHub
- URL: https://github.com/lambdaclass/metal_playground
- Owner: lambdaclass
- License: apache-2.0
- Created: 2023-02-16T13:39:51.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-17T04:51:37.000Z (about 3 years ago)
- Last Synced: 2025-07-12T23:22:22.261Z (11 months ago)
- Language: Rust
- Size: 756 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Metal playground in rust
Made for learning how to parallelize computations in the GPU using Apple's Metal, in Rust, via the [metal](https://crates.io/crates/metal) crate.
## Overview
The source code will contain documented examples of use, growing in complexity, aimed at a final objective of parallelize a Fast Fourier Transform algorithm.
### Contents
1. **dotprod**: learn the basics of Metal and metal-rs, implement a simple dot product between two vectors represented as uint arrays.
2. **matrixprod**: a more complex example to learn about grid size and thread groups, implement a product between square matrices.
3. **memory**: example to show how to shared memory between CPU and GPU. This example creates a vector to be modified from the GPU.
## Pre-requisites
- [XCode](https://www.freecodecamp.org/news/how-to-download-and-install-xcode/)
- [Rust](https://www.rust-lang.org/es/tools/install)
## Running the examples
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.
## References
- [Apple's Metal documentation](https://developer.apple.com/documentation/metal): we recommend to start with "Performing Calculations on a GPU". Note that these docs are in Swift/Obj-C.
- [miniSTARK](https://github.com/andrewmilson/ministark): A minimal STARK library built in Rust and gpu-accelerated with Metal.
- [metal-rs examples](https://github.com/gfx-rs/metal-rs)