#llvm #cuda #gpgpu #cli

bin+lib nvptx

Rust to PTX compiler using LLVM/NVPTX target

5 releases

Uses old Rust 2015

0.2.3 Aug 16, 2018
0.2.2 Jul 30, 2018
0.2.1 Jul 28, 2018
0.2.0 Jul 16, 2018
0.1.0 Jun 14, 2018

#51 in #gpgpu

MIT license

32KB
860 lines

nvptx toolchain

docs.rs CircleCI

Compile Rust into PTX/cubin

Install

nvptx command

nvptx is a CLI tool to

  • Build Rust crate into a PTX/cubin file
  • install accel-nvptx toolchain (for rustup)
cargo install nvptx

accel-nvptx toolchain

accel-nvptx is a toolchain name for rustup. It contains rustc and runtime libraries with 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

Build

You can build your crate using accel-nvptx toolchain into a PTX file

nvptx build

This consists of following three steps:

  • Compile Rust into LLVM bitcode. This step corresponds to the following command:
cargo +accel-nvptx build --target nvptx64-nvidia-cuda
  • Link rlib into a LLVM bitcode using llvm-link
  • Drop unused bitcode using opt
  • Compile LLVM bitcode into PTX using llc
  • (Optional) Convert PTX to cubin using nvcc

Dependencies

~4–14MB
~154K SLoC