Julius Koskela
668293d956
- Make the crate a lib - Move main to examples as mat_mul_4x4.rs - Correctly track elapsed time of compute task Signed-off-by: Julius Koskela <julius.koskela@unikie.com> |
||
---|---|---|
examples | ||
src | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
default.nix | ||
flake.lock | ||
flake.nix | ||
LICENSE | ||
README.md |
Rust wGPU Matrix Multiplication Shader Test
Overview
This project demonstrates a matrix multiplication operation using compute shaders in Rust with the wGPU library. The primary goal is to showcase how to perform a simple matrix multiplication on the GPU, leveraging the power of parallel computation provided by shaders.
Features
- Matrix multiplication using a compute shader.
- Implementation using Rust and the wGPU library.
- Efficient GPU-based computation for matrix operations.
Prerequisites
- Rust programming language.
- wGPU library for Rust.
- GPU that supports WebGPU.
Getting Started
Installation
-
Clone the repository:
git clone https://github.com/your-repository/rust-wgpu-matrix-multiplication.git cd rust-wgpu-matrix-multiplication
-
Ensure you have the latest version of Rust installed:
rustup update
Build and Run
-
Build the project using Cargo, Rust's package manager and build system:
cargo build --release
-
Run the compiled binary:
cargo run --release
Project Structure
src/main.rs
: The main entry point for the application.src/ppu.rs
: Contains thePPU
struct for handling GPU tasks.shaders/
: Folder containing WGSL shader files.
Shader
The matrix multiplication logic is implemented in a WGSL shader. The shader takes two input matrices (matrixA
and matrixB
) and outputs the product (matrixC
).
How It Works
- The compute shader (
main
) is dispatched with a workgroup size of 4x4. - Each work item calculates one element of the product matrix.
- The result is written back to a buffer that is read by the Rust application.
Contributing
Contributions to this project are welcome. Please open an issue or pull request on the GitHub repository.
License
This project is open-source and available under the MIT License.