cubecl_runtime/
runtime.rs1use alloc::boxed::Box;
2use alloc::vec::Vec;
3use cubecl_common::device::{Device, DeviceId};
4use cubecl_ir::TargetProperties;
5use cubecl_zspace::{Shape, Strides};
6
7use crate::{
8 client::ComputeClient,
9 compiler::{Compiler, CubeTask},
10 server::ComputeServer,
11};
12
13pub trait Runtime: Sized + Send + Sync + 'static + core::fmt::Debug + Clone {
15 type Compiler: Compiler;
17 type Server: ComputeServer<Kernel = Box<dyn CubeTask<Self::Compiler>>>;
19 type Device: Device;
21
22 fn client(device: &Self::Device) -> ComputeClient<Self>;
24
25 fn name(client: &ComputeClient<Self>) -> &'static str;
27
28 fn require_array_lengths() -> bool {
30 false
31 }
32
33 fn max_cube_count() -> (u32, u32, u32);
35
36 fn can_read_tensor(shape: &Shape, strides: &Strides) -> bool;
39
40 fn target_properties() -> TargetProperties;
42
43 fn enumerate_devices(
45 type_id: u16,
46 info: &<Self::Server as ComputeServer>::Info,
47 ) -> Vec<DeviceId>;
48 fn enumerate_all_devices(info: &<Self::Server as ComputeServer>::Info) -> Vec<DeviceId> {
50 Self::enumerate_devices(0, info)
51 }
52}