Compile Rust into PTX
nvptx command for manging nvptx-toolchain for Rust can be installed from crate.io
cargo install nvptx
And then, you can install nvptx-toolchain (including rustc
, rust-std
for nvptx64-nvidia-cuda
target):
nvptx install
This installs accel-nvptx
toolchain to rustup
like:
$ rustup toolchain list
stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
accel-nvptx
This toolchain is built from - rust-accel/rust - rust-accel/libc
You can build your crate using accel-nvptx
toolchain into a PTX file
nvptx build
This consists of following three steps:
cargo +accel-nvptx build --target nvptx64-nvidia-cuda
llvm-link
llc
You can load the PTX file into your stdout using
nvptx build --load
or
nvptx load