cubecl_ir/
runtime_properties.rs

1use crate::{MatrixLayout, TypeHash};
2
3/// Hacky solution for getting comptime properties into the scope.
4/// Allows querying certain target-specific properties at compile time, rather than at runtime.
5/// Review on how to better solve this and delegate to the compiler if possible.
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[derive(Debug, Clone, PartialEq, Eq, TypeHash, Default)]
8pub struct TargetProperties {
9    pub mma: MmaProperties,
10}
11
12#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
13#[derive(Debug, Clone, PartialEq, Eq, TypeHash)]
14pub struct MmaProperties {
15    /// Size of registers in bits, used to calculate line size
16    pub register_size_bits: u32,
17    /// Constant size of planes, for calculating lane indices in a matrix
18    pub const_plane_size: u32,
19    /// Layout of registers in Matrix A
20    pub register_layout_a: MatrixLayout,
21    /// Layout of registers in Matrix B
22    pub register_layout_b: MatrixLayout,
23    /// Layout of registers in Matrix C/D
24    pub register_layout_acc: MatrixLayout,
25
26    /// How many copies of each piece of data exist for matrix A
27    pub register_duplication_a: u32,
28    /// How many copies of each piece of data exist for matrix B
29    pub register_duplication_b: u32,
30    /// How many copies of each piece of data exist for matrix C/D
31    pub register_duplication_acc: u32,
32}
33
34impl Default for MmaProperties {
35    fn default() -> Self {
36        Self {
37            register_size_bits: 32,
38            const_plane_size: 32,
39            register_layout_a: MatrixLayout::RowMajor,
40            register_layout_b: MatrixLayout::ColMajor,
41            register_layout_acc: MatrixLayout::RowMajor,
42            register_duplication_a: 1,
43            register_duplication_b: 1,
44            register_duplication_acc: 1,
45        }
46    }
47}