Skip to main content

ruda_runtime/runtime/
compiler.rs

1use crate::runtime::{kernel::{CompiledKernel, KernelMetadata}, server::ExecutionMode};
2use ruda_core::ir::StorageType;
3pub use ruda_core::compiler::{CompilationError, Compiler};
4
5/// Kernel trait with the `ComputeShader` that will be compiled and cached based on the
6/// provided id.
7pub trait RudaTask<C: Compiler>: KernelMetadata + Send + Sync {
8    /// Export the shared IR when this task originates from a kernel definition.
9    /// Source-only tasks do not have an IR representation.
10    fn kernel_definition(&self) -> Option<ruda_core::kernel::KernelDefinition> {
11        None
12    }
13
14    /// Compile a kernel and return the compiled form with an optional non-text representation
15    fn compile(
16        &self,
17        compiler: &mut C,
18        compilation_options: &C::CompilationOptions,
19        mode: ExecutionMode,
20        address_type: StorageType,
21    ) -> Result<CompiledKernel<C>, CompilationError>;
22}