Crate ptx_builder
source ·Expand description
build.rs
helper crate for your CUDA experiments.
It helps to automatically build device crate in both single-source and separated-source projects.
Features the crate provide:
- Automatically notify Cargo about device crate sources, so it can reuild on changes,
- Provide output PTX assembly path to Rust via environment variable,
- Rich reporting of device crate errors,
- Hints and troubleshooting for missing tools.
Usage
Simply add the crate as build-dependency
:
[build-dependencies]
ptx-builder = "0.5"
And start using it in build.rs
script:
use ptx_builder::error::Result;
use ptx_builder::prelude::*;
fn main() -> Result<()> {
CargoAdapter::with_env_var("KERNEL_PTX_PATH").build(Builder::new(".")?);
}
Now, on the host-side, the PTX assembly can be loaded and used with your favorite CUDA driver crate:
ⓘ
use std::ffi::CString;
let ptx = CString::new(include_str!(env!("KERNEL_PTX_PATH")))?;
// use the assembly contents ...
Modules
Build helpers.
Error handling.
External executables that are needed to build CUDA crates.
Convenient re-exports of mostly used types.
Build reporting helpers.