Skip to main content

Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

Core builder to setup the bindings options

Implementations§

Source§

impl Builder

Source

pub fn set_compute_cap(&mut self, cap: usize)

Force to use a given compute capability

Source

pub fn get_compute_cap(&self) -> Option<usize>

Returns the detected CUDA compute capability, if available.

Source

pub fn kernel_paths<P: Into<PathBuf>>(self, paths: Vec<P>) -> Self

Setup the kernel paths. All path must be set at once and be valid files.

let builder = bindgen_cuda::Builder::default().kernel_paths(vec!["src/mykernel.cu"]);
Source

pub fn watch<T, P>(self, paths: T) -> Self
where T: IntoIterator<Item = P>, P: Into<PathBuf>,

Setup the paths that the lib depend on but does not need to build

let builder =
bindgen_cuda::Builder::default().watch(vec!["kernels/"]);
Source

pub fn include_paths<P: Into<PathBuf>>(self, paths: Vec<P>) -> Self

Setup the kernel paths. All path must be set at once and be valid files.

let builder = bindgen_cuda::Builder::default().include_paths(vec!["src/mykernel.cuh"]);
Source

pub fn kernel_paths_glob(self, glob: &str) -> Self

Setup the kernels with a glob.

let builder = bindgen_cuda::Builder::default().kernel_paths_glob("src/**/*.cu");
Source

pub fn include_paths_glob(self, glob: &str) -> Self

Setup the include files with a glob.

let builder = bindgen_cuda::Builder::default().kernel_paths_glob("src/**/*.cuh");
Source

pub fn out_dir<P: Into<PathBuf>>(self, out_dir: P) -> Self

Modifies the output directory. By default this is OUT_DIR

let builder = bindgen_cuda::Builder::default().out_dir("out/");
Source

pub fn arg(self, arg: &'static str) -> Self

Sets up extra nvcc compile arguments.

let builder = bindgen_cuda::Builder::default().arg("--expt-relaxed-constexpr");
Source

pub fn cuda_root<P>(&mut self, path: P)
where P: Into<PathBuf>,

Forces the cuda root to a specific directory. By default all standard directories will be visited.

let builder = bindgen_cuda::Builder::default().cuda_root("/usr/local/cuda");
Source

pub fn build_lib<P>(&self, out_file: P)
where P: Into<PathBuf>,

Consumes the builder and create a lib in the out_dir. It then needs to be linked against in your build.rs

let builder = bindgen_cuda::Builder::default().build_lib("libflash.a");
println!("cargo:rustc-link-lib=flash");
Source

pub fn build_ptx(&self) -> Result<Bindings, Error>

Consumes the builder and outputs 1 ptx file for each kernels found. This function returns Bindings which can then be unused to create a rust source file that will include those kernels.

let bindings = bindgen_cuda::Builder::default().build_ptx().unwrap();
bindings.write("src/lib.rs").unwrap();

Trait Implementations§

Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Builder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.