cubecl_core/
id.rs

1use cubecl_runtime::{client::ComputeClient, id::DeviceId};
2
3/// ID used to identify a Just-in-Time environment.
4#[derive(Hash, PartialEq, Eq, Debug, Clone)]
5pub struct CubeTuneId {
6    device: DeviceId,
7    name: &'static str,
8}
9
10impl CubeTuneId {
11    /// Create a new ID.
12    pub fn new<R: crate::Runtime>(
13        client: &ComputeClient<R::Server, R::Channel>,
14        device: &R::Device,
15    ) -> Self {
16        Self {
17            device: R::device_id(device),
18            name: R::name(client),
19        }
20    }
21}
22
23impl core::fmt::Display for CubeTuneId {
24    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25        f.write_fmt(format_args!(
26            "device-{}-{}-{}",
27            self.device.type_id, self.device.index_id, self.name
28        ))
29    }
30}