Skip to main content

ComputeBackend

Trait ComputeBackend 

Source
pub trait ComputeBackend {
    // Required methods
    fn name(&self) -> &str;
    fn create_buffer(&self, size: usize) -> BufferHandle;
    fn write_buffer(&self, handle: BufferHandle, data: &[f64]);
    fn read_buffer(&self, handle: BufferHandle) -> Vec<f64>;
    fn dispatch(&self, kernel: &dyn ComputeKernel, work_size: usize);
}
Expand description

Trait for a compute backend (GPU or CPU fallback).

Required Methods§

Source

fn name(&self) -> &str

Human-readable name of this backend.

Source

fn create_buffer(&self, size: usize) -> BufferHandle

Allocate a buffer that can hold size f64 elements.

Source

fn write_buffer(&self, handle: BufferHandle, data: &[f64])

Write data into the buffer referenced by handle.

Source

fn read_buffer(&self, handle: BufferHandle) -> Vec<f64>

Read the full contents of the buffer referenced by handle.

Source

fn dispatch(&self, kernel: &dyn ComputeKernel, work_size: usize)

Dispatch a compute kernel over work_size work items.

Implementors§