1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//! `CubeCL`: the language, the launch API, and the runtimes.
//!
//! A kernel library depends on this crate with no runtime feature on and
//! compiles against no runtime at all. A binary, a benchmark or a test suite
//! turns on the features for the runtimes it wants to link, and then a
//! [`Device`] hands back the [`Client`](client::Client) to launch on —
//! [`Device::default`] for the most capable runtime in the build, or a named
//! variant for a particular one.
//!
//! ```no_run
//! # #[cfg(feature = "wgpu")]
//! # fn main() {
//! let client = cubecl::Device::default().client();
//! # }
//! # #[cfg(not(feature = "wgpu"))]
//! # fn main() {}
//! ```
extern crate alloc;
pub use *;
pub use features;
pub use config;
pub use MemoryAllocationMode;
/// Ship pre-warmed autotune and compilation caches with an application.
///
/// Run the application once so its caches are warm, then save the active
/// environment to a file and ship it. On the target machine either
/// [`environment::load`] mounts the file in place, or [`import`] copies it
/// into the local environment, after which the file can be deleted.
///
/// The exporting binary must be built against the same cubecl version as the
/// consuming one. The version is part of every cache namespace, so a bundle
/// built elsewhere installs cleanly and is then ignored, with a warning as the
/// only signal. Calling this from your own crate is what keeps the two in
/// step.
///
/// ```no_run
/// use cubecl::bundle::BundleFormat;
///
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// // ... run the work you want tuned and compiled, then:
/// let manifest = cubecl::environment::bundle().save("h100.bundle", BundleFormat::Sqlite)?;
/// println!("exported {}", manifest.name);
/// # Ok(())
/// # }
/// ```
///
/// Merging several roots or restricting the namespaces goes through
/// [`export`] directly.
///
/// [`export`]: cubecl_environment::bundle::export
/// [`import`]: cubecl_environment::bundle::import
/// [`environment::load`]: cubecl_environment::environment::load
pub use bundle;
/// Which named environment caches are warmed into, and where it lives.
pub use environment;
/// What an environment remembers of how it was built: sessions, marks, and
/// the records its tunes and compilations leave.
pub use records;
/// Running a workload for the compilation and tuning it provokes, without
/// running the workload itself.
///
/// This is what makes producing a [`bundle`] affordable: inside a
/// [`DryRun`](dry_run::DryRun) every launch is compiled, cached and tuned
/// without also being executed. Buffers are left as they were, so it only suits
/// a pass driven by the *shapes* it produces.
///
/// ```no_run
/// # fn warm_up() {}
/// let _dry_run = cubecl::dry_run::DryRun::new();
/// warm_up();
/// ```
pub use dry_run;
/// The kernels a workload launches, collected while it replays: what an
/// environment shipped for it has to keep.
pub use launched;
/// Watching what the runtime runs: the launch observer, and the profiling
/// logger's levels.
///
/// Re-exported because a caller attributing kernels to its own work reaches for
/// [`LaunchObservation`](cubecl_runtime::logging::LaunchObservation) and has no
/// other reason to depend on `cubecl-runtime` directly.
pub use logging;
/// A device of any runtime, and the runtime it belongs to.
pub use ;
pub use cubecl_std as std;
pub use cubecl_wgpu as wgpu;
pub use cubecl_cuda as cuda;
pub use cubecl_hip as hip;
pub use cubecl_cpu as cpu;
pub use cubecl_metal as metal;
/// The runtime this build tests on.
pub type TestRuntime = WgpuRuntime;
/// The runtime this build tests on.
pub type TestRuntime = WgpuRuntime;
/// The runtime this build tests on.
pub type TestRuntime = CpuRuntime;
/// The runtime this build tests on.
pub type TestRuntime = CudaRuntime;
/// The runtime this build tests on.
pub type TestRuntime = HipRuntime;
/// The runtime this build tests on.
pub type TestRuntime = MetalRuntime;
/// The client of [`test_device`], for the test that only wants one.
///
/// ```no_run
/// let client = cubecl::test_client();
/// ```
/// The [`Device`] of [`TestRuntime`], the runtime this build tests on.
///
/// A test reaches its client through [`Device::client`] like any other caller,
/// which is what keeps it from naming a runtime to get one.
///
/// ```no_run
/// let client = cubecl::test_device().client();
/// ```
/// The [`Device`] of [`TestRuntime`], the runtime this build tests on.
/// The [`Device`] of [`TestRuntime`], the runtime this build tests on.
/// The [`Device`] of [`TestRuntime`], the runtime this build tests on.
/// The [`Device`] of [`TestRuntime`], the runtime this build tests on.