Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Send + Sync {
    // Required methods
    fn backend_type(&self) -> GpuBackend;
    fn initialize(&mut self) -> Result<(), BackendError>;
    fn device_count(&self) -> Result<u32, BackendError>;
    fn device_capabilities(
        &self,
        device_id: u32,
    ) -> Result<DeviceCapabilities, BackendError>;
    fn set_device(&mut self, device_id: u32) -> Result<(), BackendError>;
    fn allocate(&self, size: usize) -> Result<DeviceMemory, BackendError>;
    fn deallocate(&self, memory: DeviceMemory) -> Result<(), BackendError>;
    fn copy_to_device(
        &self,
        src: &[u8],
        dst: &DeviceMemory,
    ) -> Result<(), BackendError>;
    fn copy_to_host(
        &self,
        src: &DeviceMemory,
        dst: &mut [u8],
    ) -> Result<(), BackendError>;
    fn synchronize(&self) -> Result<(), BackendError>;
    fn launch_kernel(
        &self,
        kernel: &CompiledKernel,
        args: &[KernelArg],
    ) -> Result<(), BackendError>;
}
Expand description

Trait for GPU backend implementations

Required Methods§

Source

fn backend_type(&self) -> GpuBackend

Get backend type

Source

fn initialize(&mut self) -> Result<(), BackendError>

Initialize the backend

Source

fn device_count(&self) -> Result<u32, BackendError>

Get device count

Source

fn device_capabilities( &self, device_id: u32, ) -> Result<DeviceCapabilities, BackendError>

Get device capabilities

Source

fn set_device(&mut self, device_id: u32) -> Result<(), BackendError>

Set active device

Source

fn allocate(&self, size: usize) -> Result<DeviceMemory, BackendError>

Allocate memory on device

Source

fn deallocate(&self, memory: DeviceMemory) -> Result<(), BackendError>

Free device memory

Source

fn copy_to_device( &self, src: &[u8], dst: &DeviceMemory, ) -> Result<(), BackendError>

Copy memory from host to device

Source

fn copy_to_host( &self, src: &DeviceMemory, dst: &mut [u8], ) -> Result<(), BackendError>

Copy memory from device to host

Source

fn synchronize(&self) -> Result<(), BackendError>

Synchronize device

Source

fn launch_kernel( &self, kernel: &CompiledKernel, args: &[KernelArg], ) -> Result<(), BackendError>

Launch kernel

Implementors§