Enum rust_gpu_tools::Program
source · [−]Expand description
Abstraction for running programs on CUDA or OpenCL.
Variants
Cuda(Program)
CUDA program.
Opencl(Program)
OpenCL program.
Implementations
sourceimpl Program
impl Program
sourcepub fn run<F1, F2, R, E, A>(&self, fun: (F1, F2), arg: A) -> Result<R, E> where
E: From<GPUError>,
F1: FnOnce(&Program, A) -> Result<R, E>,
F2: FnOnce(&Program, A) -> Result<R, E>,
pub fn run<F1, F2, R, E, A>(&self, fun: (F1, F2), arg: A) -> Result<R, E> where
E: From<GPUError>,
F1: FnOnce(&Program, A) -> Result<R, E>,
F2: FnOnce(&Program, A) -> Result<R, E>,
Run some code in the context of the program.
There is an implementation for OpenCL and for CUDA. Both use different Rust types, but
opencl::Program
and cuda::Program
implement the same API. This means that same
code code can be used to run on either of them. The only difference is the type of the
Program
.
You need to pass in two closures, one for OpenCL, one for CUDA, both get their
corresponding program type as parameter. For convenience there is the program_closures
macro defined, which can help reducing code duplication by creating two closures out of
a single one.
CUDA and OpenCL support can be enabled/disabled by the opencl
and cuda
features. If
one of them is disabled, you still need to pass in two closures. This way the API stays,
the same, but you can disable it things at compile-time.
The second parameter is a single arbitrary argument, which will be passed on into the closure. This is useful when you e.g. need to pass in a mutable reference. Such a reference cannot be shared between closures, hence we pass it on, so that the compiler knows that it is used at most once.
sourcepub fn device_name(&self) -> &str
pub fn device_name(&self) -> &str
Returns the name of the GPU, e.g. “GeForce RTX 3090”.
Auto Trait Implementations
impl RefUnwindSafe for Program
impl Send for Program
impl !Sync for Program
impl Unpin for Program
impl UnwindSafe for Program
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more