use cubecl_environment::sync::{Arc, LazyLock, Mutex};
pub use cubecl_environment::config::RuntimeConfig;
static CUBEK_GLOBAL_CONFIG: Mutex<Option<Arc<CubekConfig>>> = Mutex::new(None);
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
#[serde(default)]
pub struct CubekConfig {
pub matmul: MatmulConfig,
}
#[derive(Clone, Copy, Debug, serde::Serialize, serde::Deserialize)]
#[serde(default)]
pub struct MatmulConfig {
pub allow_tf32: bool,
}
impl Default for MatmulConfig {
fn default() -> Self {
Self { allow_tf32: true }
}
}
impl MatmulConfig {
pub fn get() -> &'static Self {
static CONFIG: LazyLock<MatmulConfig> = LazyLock::new(|| CubekConfig::get().matmul);
&CONFIG
}
}
impl RuntimeConfig for CubekConfig {
fn storage() -> &'static Mutex<Option<Arc<Self>>> {
&CUBEK_GLOBAL_CONFIG
}
fn file_names() -> &'static [&'static str] {
&["cubek.toml", "CubeK.toml"]
}
fn section_file_names() -> &'static [(&'static str, &'static str)] {
&[("burn.toml", "cubek"), ("Burn.toml", "cubek")]
}
}