Trait BackendTrait

Source
pub trait BackendTrait: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn capabilities(&self) -> &BackendCapabilities;
    fn initialize<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn compile_kernel<'life0, 'life1, 'async_trait>(
        &'life0 self,
        source: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn launch_kernel<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        kernel: &'life1 [u8],
        grid: (u32, u32, u32),
        block: (u32, u32, u32),
        args: &'life2 [*const u8],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn allocate_memory(&self, size: usize) -> Result<*mut u8>;
    fn free_memory(&self, ptr: *mut u8) -> Result<()>;
    fn copy_memory(
        &self,
        dst: *mut u8,
        src: *const u8,
        size: usize,
        kind: MemcpyKind,
    ) -> Result<()>;
    fn synchronize(&self) -> Result<()>;
}
Expand description

Common interface for all backends

Required Methods§

Source

fn name(&self) -> &str

Get backend name

Source

fn capabilities(&self) -> &BackendCapabilities

Get backend capabilities

Source

fn initialize<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize the backend

Source

fn compile_kernel<'life0, 'life1, 'async_trait>( &'life0 self, source: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Compile a kernel

Source

fn launch_kernel<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, kernel: &'life1 [u8], grid: (u32, u32, u32), block: (u32, u32, u32), args: &'life2 [*const u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Launch a kernel

Source

fn allocate_memory(&self, size: usize) -> Result<*mut u8>

Allocate device memory

Source

fn free_memory(&self, ptr: *mut u8) -> Result<()>

Free device memory

Source

fn copy_memory( &self, dst: *mut u8, src: *const u8, size: usize, kind: MemcpyKind, ) -> Result<()>

Copy memory

Source

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

Synchronize device

Implementors§