Skip to main content

cubecl_core/
id.rs

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