Skip to content

Commit 46b94d4

Browse files
Merge branch 'master' of github.com:RDambrosio016/Rust-CUDA
2 parents 445fcfb + 45b334d commit 46b94d4

File tree

112 files changed

+12663
-5064
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+12663
-5064
lines changed

.github/workflows/build_guide.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: build mdbook for github pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Setup mdBook
15+
uses: peaceiris/actions-mdbook@v1
16+
with:
17+
mdbook-version: 'latest'
18+
19+
- run: mdbook build guide/ -d ../book
20+
21+
- name: Deploy
22+
uses: peaceiris/actions-gh-pages@v3
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
publish_dir: ./book

.github/workflows/rust.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Rust CI
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '**.md'
7+
push:
8+
paths-ignore:
9+
- '**.md'
10+
branches:
11+
- master
12+
13+
env:
14+
RUST_LOG: info
15+
RUST_BACKTRACE: 1
16+
17+
jobs:
18+
rust:
19+
name: Rust ${{ matrix.rust }} on ${{ matrix.os }}
20+
runs-on: ${{ matrix.os }}
21+
env:
22+
LLVM_LINK_STATIC: 1
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- os: ubuntu-20.04
28+
target: x86_64-unknown-linux-gnu
29+
- os: windows-latest
30+
target: x86_64-pc-windows-msvc
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v2
34+
35+
- name: Install CUDA
36+
uses: Jimver/[email protected]
37+
id: cuda-toolkit
38+
with:
39+
cuda: '11.2.2'
40+
41+
# random command that forces rustup to install stuff in rust-toolchain
42+
- name: Install rust-toolchain
43+
run: cargo version
44+
45+
- name: Add rustup components
46+
run: rustup component add rustfmt clippy
47+
48+
- name: Install LLVM 7
49+
if: contains(matrix.os, 'ubuntu')
50+
run: |
51+
sudo apt-get install llvm-7
52+
sudo ln -s /usr/bin/llvm-config-7 /usr/local/bin/llvm-config
53+
54+
- name: Load Rust Cache
55+
uses: Swatinem/rust-cache@v1
56+
57+
- name: Rustfmt
58+
if: contains(matrix.os, 'ubuntu')
59+
run: cargo fmt --all -- --check
60+
61+
- name: Build
62+
run: cargo build --workspace --exclude "optix" --exclude "optix_sys" --exclude "path_tracer" --exclude "denoiser" --exclude "add"
63+
64+
# Don't currently test because many tests rely on the system having a CUDA GPU
65+
# - name: Test
66+
# run: cargo test --workspace
67+
68+
- name: Clippy
69+
if: contains(matrix.os, 'ubuntu')
70+
env:
71+
RUSTFLAGS: -Dwarnings
72+
run: cargo clippy --workspace --exclude "optix" --exclude "optix_sys" --exclude "path_tracer" --exclude "denoiser" --exclude "add"
73+
74+
- name: Check documentation
75+
env:
76+
RUSTDOCFLAGS: -Dwarnings
77+
run: cargo doc --workspace --all-features --document-private-items --no-deps --exclude "optix" --exclude "optix_sys" --exclude "path_tracer" --exclude "denoiser" --exclude "add"

README.md

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,88 @@
1-
# Rust CUDA
1+
<div align="center">
2+
<h1>The Rust CUDA Project</h1>
3+
4+
<p>
5+
<strong>An ecosystem of libraries and tools for writing and executing extremely fast GPU code fully in
6+
<a href="https://www.rust-lang.org/">Rust</a></strong>
7+
</p>
8+
9+
<h3>
10+
<a href="guide">Guide</a>
11+
<span> | </span>
12+
<a href="guide/src/guide/getting_started.md">Getting Started</a>
13+
<span> | </span>
14+
<a href="guide/src/features.md">Features</a>
15+
</h3>
16+
<strong>⚠️ The project is still in early development, expect bugs, safety issues, and things that don't work ⚠️</strong>
17+
</div>
18+
19+
## Goal
20+
21+
The Rust CUDA Project is a project aimed at making Rust a tier-1 language for extremely fast GPU computing
22+
using the CUDA Toolkit. It provides tools for compiling Rust to extremely fast PTX code as well as libraries
23+
for using existing CUDA libraries with it.
24+
25+
## Background
26+
27+
Historically, general purpose high performance GPU computing has been done using the CUDA toolkit. The CUDA toolkit primarily
28+
provides a way to use Fortran/C/C++ code for GPU computing in tandem with CPU code with a single source. It also provides
29+
many libraries, tools, forums, and documentation to supplement the single-source CPU/GPU code.
30+
31+
CUDA is exclusively an NVIDIA-only toolkit. Many tools have been proposed for cross-platform GPU computing such as
32+
OpenCL, Vulkan Computing, and HIP. However, CUDA remains the most used toolkit for such tasks by far. This is why it is
33+
imperative to make Rust a viable option for use with the CUDA toolkit.
34+
35+
However, CUDA with Rust has been a historically very rocky road. The only viable option until now has been to use the LLVM PTX
36+
backend, however, the LLVM PTX backend does not always work and would generate invalid PTX for many common Rust operations, and
37+
in recent years it has been shown time and time again that a specialized solution is needed for Rust on the GPU with the advent
38+
of projects such as rust-gpu (for Rust -> SPIR-V).
39+
40+
Our hope is that with this project we can push the Rust GPU computing industry forward and make Rust an excellent language
41+
for such tasks. Rust offers plenty of benefits such as `__restrict__` performance benefits for every kernel, An excellent module/crate system,
42+
delimiting of unsafe areas of CPU/GPU code with `unsafe`, high level wrappers to low level CUDA libraries, etc.
43+
44+
## Structure
45+
46+
The scope of the Rust CUDA Project is quite broad, it spans the entirety of the CUDA ecosystem, with libraries and tools to make it
47+
usable using Rust. Therefore, the project contains many crates for all corners of the CUDA ecosystem.
48+
49+
The current line-up of libraries is the following:
50+
51+
- `rustc_codegen_nvvm` Which is a rustc backend that targets NVVM IR (a subset of LLVM IR) for the [libnvvm](https://docs.nvidia.com/cuda/nvvm-ir-spec/index.html) library.
52+
- Generates highly optimized PTX code which can be loaded by the CUDA Driver API to execute on the GPU.
53+
- For the near future it will be CUDA-only, but it may be used to target amdgpu in the future.
54+
- `cuda_std` for GPU-side functions and utilities, such as thread index queries, memory allocation, warp intrinsics, etc.
55+
- *Not* a low level library, provides many utility functions to make it easier to write cleaner and more reliable GPU kernels.
56+
- Closely tied to `rustc_codegen_nvvm` which exposes GPU features through it internally.
57+
- `cust` for CPU-side CUDA features such as launching GPU kernels, GPU memory allocation, device queries, etc.
58+
- High level with features such as RAII and Rust Results that make it easier and cleaner to manage the interface to the GPU.
59+
- A high level wrapper for the CUDA Driver API, the lower level version of the more common CUDA Runtime API used from C++.
60+
- Provides much more fine grained control over things like kernel concurrency and module loading than the C++ Runtime API.
61+
- `gpu_rand` for GPU-friendly random number generation, currently only implements xoroshiro RNGs from `rand_xoshiro`.
62+
- `optix` for CPU-side hardware raytracing and denoising using the CUDA OptiX library.
63+
64+
In addition to many "glue" crates for things such as high level wrappers for certain smaller CUDA libraries.
65+
66+
## Related Projects
67+
68+
Other projects related to using Rust on the GPU:
69+
- 2016: [glassful](https://github.com/kmcallister/glassful) Subset of Rust that compiles to GLSL.
70+
- 2017: [inspirv-rust](https://github.com/msiglreith/inspirv-rust) Experimental Rust MIR -> SPIR-V Compiler.
71+
- 2018: [nvptx](https://github.com/japaric-archived/nvptx) Rust to PTX compiler using the `nvptx` target for rustc (using the LLVM PTX backend).
72+
- 2020: [accel](https://github.com/termoshtt/accel) Higher level library that relied on the same mechanism that `nvptx` does.
73+
- 2020: [rlsl](https://github.com/MaikKlein/rlsl) Experimental Rust -> SPIR-V compiler (predecessor to rust-gpu)
74+
- 2020: [rust-gpu](https://github.com/EmbarkStudios/rust-gpu) Rustc codegen backend to compile Rust to SPIR-V for use in shaders, similar mechanism as our project.
75+
76+
## License
77+
78+
Licensed under either of
79+
80+
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
81+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
82+
83+
at your discretion.
84+
85+
### Contribution
86+
87+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
288

3-
TODO: the entire readme

crates/blastoff/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "blastoff"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["Riccardo D'Ambrosio <[email protected]>"]
6+
repository = "https://github.com/Rust-GPU/Rust-CUDA"
7+
8+
[dependencies]
9+
bitflags = "1.3.2"
10+
cublas_sys = { version = "0.1", path = "../cublas_sys" }
11+
cust = { version = "0.2", path = "../cust", features = ["num-complex"] }
12+
num-complex = "0.4.0"

0 commit comments

Comments
 (0)