Trait Compiler

Source
pub trait Compiler {
    type Buffer;
    type Program;

    // Required methods
    fn store<T: Scalar>(
        &mut self,
        iter: impl IntoIterator<Item = T>,
    ) -> Result<Self::Buffer, ZyxError>;
    fn load<T: Scalar>(
        &mut self,
        buffer: &Self::Buffer,
        numel: usize,
    ) -> Result<Vec<T>, ZyxError>;
    fn drop_buffer(&mut self, buffer: &mut Self::Buffer) -> Result<(), ZyxError>;
    fn drop_program(
        &mut self,
        program: &mut Self::Program,
    ) -> Result<(), ZyxError>;
    fn launch(
        &mut self,
        program: &Self::Program,
        args: &[&Self::Buffer],
        flop: usize,
        bytes: usize,
    ) -> Result<Self::Buffer, ZyxError>;
    fn compile(&mut self, ir: &IR) -> Result<Self::Program, ZyxError>;
}
Expand description

Implement this trait for compiled backends

Required Associated Types§

Source

type Buffer

Buffer holds actual values in memory

Source

type Program

Program is kernel executable on the device, can be compiled at runtime

Required Methods§

Source

fn store<T: Scalar>( &mut self, iter: impl IntoIterator<Item = T>, ) -> Result<Self::Buffer, ZyxError>

Store iter into buffer

Source

fn load<T: Scalar>( &mut self, buffer: &Self::Buffer, numel: usize, ) -> Result<Vec<T>, ZyxError>

Load buffer into vec

Source

fn drop_buffer(&mut self, buffer: &mut Self::Buffer) -> Result<(), ZyxError>

Drop Buffer

Source

fn drop_program(&mut self, program: &mut Self::Program) -> Result<(), ZyxError>

Drop Program

Source

fn launch( &mut self, program: &Self::Program, args: &[&Self::Buffer], flop: usize, bytes: usize, ) -> Result<Self::Buffer, ZyxError>

Launch program with args

Source

fn compile(&mut self, ir: &IR) -> Result<Self::Program, ZyxError>

Compile ast into program

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§