pub struct Generator { /* private fields */ }Expand description
Bindings generator.
This does:
- Compile Futhark code to C code for each target.
- Generate unsafe Rust bindings for each target.
- Generate a single safe wrapper around all targets.
- Compile and link generated C code.
§Usage
In your build.rs file:
use cargo_futhark::{Generator, Result, Target};
fn main() -> Result<()> {
Generator::new("src/lib.fut")
.with_target_if(Target::C, cfg!(feature = "c"))
.with_target_if(Target::MultiCore, cfg!(feature = "multicore"))
.with_target_if(Target::OpenCL, cfg!(feature = "opencl"))
.with_target_if(Target::Cuda, cfg!(feature = "cuda"))
.with_target_if(Target::ISPC, cfg!(feature = "ispc"))
.run()
}Implementations§
Source§impl Generator
impl Generator
Sourcepub fn new(source: impl Into<PathBuf>) -> Self
pub fn new(source: impl Into<PathBuf>) -> Self
Returns a new Generator with default settings.
The source should be the .fut file containing the entry functions.
The defaults are:
watch_sources = truetargets = EMPTY
You must add at least on Target before you call Generator::run.
Sourcepub fn watch_sources(&mut self, watch: bool) -> &mut Self
pub fn watch_sources(&mut self, watch: bool) -> &mut Self
Watch Futhark source file for changes.
Enabled by default.
Sourcepub fn with_cuda_home(
&mut self,
cuda_home: impl Into<PathBuf>,
) -> Result<&mut Self>
pub fn with_cuda_home( &mut self, cuda_home: impl Into<PathBuf>, ) -> Result<&mut Self>
Specify a custom CUDA home path.
This will add the following:
$cuda_home/includeto include path$cuda_home/lib64to link path
Sourcepub fn with_target(&mut self, target: Target) -> &mut Self
pub fn with_target(&mut self, target: Target) -> &mut Self
Enable the given Target.
Sourcepub fn with_target_if(&mut self, target: Target, condition: bool) -> &mut Self
pub fn with_target_if(&mut self, target: Target, condition: bool) -> &mut Self
Auto Trait Implementations§
impl Freeze for Generator
impl RefUnwindSafe for Generator
impl Send for Generator
impl Sync for Generator
impl Unpin for Generator
impl UnwindSafe for Generator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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