AsyncExecutor

Struct AsyncExecutor 

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

§AsyncExecutor

The AsyncExecutor is the central engine of this library. Its job is to simplify all the “dirty work” of OpenCL: finding the best graphics card, creating the context, managing command queues, and distributing work intelligently.

Think of it as an orchestra conductor that decides which musicians (GPUs) play each part.

Implementations§

Source§

impl AsyncExecutor

Source

pub fn new_best_platform() -> Result<Self, ClError>

Creates an executor by automatically selecting the best available platform.

It will search among all cards (NVIDIA, AMD, Intel) and choose the one with the most computing power and memory.

Source

pub fn new_best_platform_with_options( profiling_enabled: bool, ) -> Result<Self, ClError>

Creates an executor with the best platform, allowing profiling to be enabled.

If profiling_enabled is true, you can measure exactly how many nanoseconds each kernel takes to execute on the card.

Source

pub fn new_all_platforms() -> Result<Self, ClError>

Source

pub fn new_from_platforms(platforms: &[ClPlatform]) -> Result<Self, ClError>

Source

pub fn new_from_devices(devices: &[ClDevice]) -> Result<Self, ClError>

Source

pub fn new_from_devices_with_options( devices: &[ClDevice], profiling_enabled: bool, ) -> Result<Self, ClError>

Source

pub fn is_profiling_enabled(&self) -> bool

Source

pub fn get_context(&self) -> Arc<ClContext>

Source

pub fn get_device_versions(&self) -> &[OpenCLVersion]

Source

pub fn get_devices(&self) -> Result<Vec<ClDevice>, ClError>

Source

pub fn get_queues(&self) -> &[ClCommandQueue]

Source

pub fn create_task(&self, kernel: ClKernel) -> TaskBuilder<'_>

Creates a task to be executed.

This is the entry point for the declarative workflow. It receives a ClKernel (the function that will run on the GPU) and returns a TaskBuilder to configure the arguments and work size.

Source

pub fn build_program( &self, source: String, options: Option<&str>, ) -> Result<ClProgram<Builded>, ClError>

Compiles an OpenCL program from source code (C-like).

§Example
let source = "kernel void add(...) { ... }";
let program = executor.build_program(source.to_string(), None)?;
Source

pub fn compile_or_binary( &self, src_path: &str, binary_dest_folder: &str, options: Option<&str>, ) -> Result<ClProgram<Builded>, ClError>

Compiles the program or loads it from binary if available.

Checks if binaries exist in binary_dest_folder. If so, loads them. Otherwise, compiles from src_path and saves binaries to binary_dest_folder.

Source

pub fn create_kernel( &self, program: &ClProgram<Builded>, name: &str, ) -> Result<ClKernel, ClError>

Creates a Kernel from an already compiled program. The name must exactly match the name of the kernel function in your C code.

Source

pub fn create_buffer( &self, flags: &[MemoryFlags], size: usize, host_ptr: *mut c_void, ) -> Result<ClBuffer, ClError>

Creates a memory Buffer on the GPU.

Buffers are “boxes” of data that the GPU can read or write.

Source

pub fn create_image( &self, flags: &[MemoryFlags], format: &ClImageFormats, desc: &ClImageDesc, host_ptr: *mut c_void, ) -> Result<ClImage, ClError>

Creates an OpenCL Image (requires OpenCL 1.2+). Images are optimized for 2D/3D access and filtering.

Source

pub fn create_svm_buffer<T>( &self, flags: &[MemoryFlags], len: usize, ) -> Result<ClSvmBuffer<T>, ClError>

Creates an SVM Buffer (Shared Virtual Memory). (Requires OpenCL 2.0+). Allows sharing pointers directly between CPU and GPU without manual copies.

Source

pub async fn read_buffer<T: Sized>( &self, buffer: &ClBuffer, host_memory: &mut [T], ) -> Result<ClEvent, ClError>

Reads data from a buffer to host memory. Uses the most powerful GPU available to perform the copy.

Source

pub async fn write_buffer<T: Sized>( &self, buffer: &ClBuffer, host_memory: &mut [T], ) -> Result<ClEvent, ClError>

Writes data from host memory to a buffer. Uses the most powerful GPU available to perform the copy.

Source

pub async fn read_image<T: Sized>( &self, image: &ClImage, host_memory: &mut [T], origin: [usize; 3], region: [usize; 3], ) -> Result<ClEvent, ClError>

Reads data from an image to host memory.

Source

pub async fn write_image<T: Sized>( &self, image: &ClImage, host_memory: &mut [T], origin: [usize; 3], region: [usize; 3], ) -> Result<ClEvent, ClError>

Writes data from host memory to an image.

Trait Implementations§

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, 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.