pub enum Program {
    Cuda(Program),
    Opencl(Program),
}
Expand description

Abstraction for running programs on CUDA or OpenCL.

Variants

Cuda(Program)

CUDA program.

Opencl(Program)

OpenCL program.

Implementations

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.

Returns the name of the GPU, e.g. “GeForce RTX 3090”.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.