1use crate::codegen::Compiler;
2use crate::compute::CubeTask;
3use cubecl_common::device::Device;
4use cubecl_ir::{StorageType, TargetProperties};
5use cubecl_runtime::{client::ComputeClient, server::ComputeServer};
6
7pub use cubecl_runtime::client;
8pub use cubecl_runtime::server;
9pub use cubecl_runtime::tune;
10
11const LOAD_WIDTH: usize = 128;
14
15pub trait Runtime: Send + Sync + 'static + core::fmt::Debug {
17 type Compiler: Compiler;
19 type Server: ComputeServer<Kernel = Box<dyn CubeTask<Self::Compiler>>>;
21 type Device: Device;
23
24 fn client(device: &Self::Device) -> ComputeClient<Self::Server>;
26
27 fn name(client: &ComputeClient<Self::Server>) -> &'static str;
29
30 fn require_array_lengths() -> bool {
32 false
33 }
34
35 fn supported_line_sizes() -> &'static [u8];
37
38 fn max_global_line_size() -> u8 {
40 u8::MAX
41 }
42
43 fn io_optimized_line_sizes(elem: &StorageType) -> impl Iterator<Item = u8> + Clone {
45 let max = (LOAD_WIDTH / elem.size_bits()) as u8;
46 let supported = Self::supported_line_sizes();
47 supported.iter().filter(move |v| **v <= max).cloned()
48 }
49
50 fn io_optimized_line_sizes_unchecked(size: usize) -> impl Iterator<Item = u8> + Clone {
54 let size_bits = size * 8;
55 let max = LOAD_WIDTH / size_bits;
56 let max = usize::min(Self::max_global_line_size() as usize, max);
57
58 let num_candidates = f32::log2(max as f32) as u32 + 1;
60
61 (0..num_candidates).map(|i| 2u8.pow(i)).rev()
62 }
63
64 fn max_cube_count() -> (u32, u32, u32);
66
67 fn can_read_tensor(shape: &[usize], strides: &[usize]) -> bool;
68
69 fn target_properties() -> TargetProperties;
71}