cubecl_runtime/config/environment.rs
1use alloc::string::{String, ToString};
2
3#[cfg(std_io)]
4use super::cache::CacheConfig;
5
6/// Which named environment the process warms into, and where environments are
7/// kept.
8///
9/// An environment is one local store holding every cached namespace: autotune
10/// results, compiled kernels, throughput measurements. Exactly one is active
11/// at a time, so naming them lets a single checkout keep several side by side.
12///
13/// ```toml
14/// [environment]
15/// name = "h100"
16/// path = "target"
17/// ```
18///
19/// `CUBECL_ENVIRONMENT` overrides the name.
20///
21/// `path` only exists where there is a file system to put environments on;
22/// elsewhere the name still selects one, it just isn't backed by a directory.
23#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
24pub struct EnvironmentConfig {
25 /// Name of the environment to activate when the configuration loads.
26 #[serde(default = "default_name")]
27 pub name: String,
28
29 /// Directory the environments live in.
30 #[cfg(std_io)]
31 #[serde(default)]
32 pub path: CacheConfig,
33}
34
35fn default_name() -> String {
36 cubecl_environment::environment::DEFAULT.to_string()
37}
38
39impl Default for EnvironmentConfig {
40 fn default() -> Self {
41 Self {
42 name: default_name(),
43 #[cfg(std_io)]
44 path: CacheConfig::default(),
45 }
46 }
47}