Skip to main content

ruda_kernel/dsl/
id.rs

1use ruda_core::device::{Device, DeviceId};
2use ruda::runtime::{client::ComputeClient, backend::Runtime};
3
4/// ID used to identify a Just-in-Time environment.
5#[derive(Hash, PartialEq, Eq, Debug, Clone)]
6pub struct RudaTuneId {
7    device: DeviceId,
8    name: &'static str,
9}
10
11impl RudaTuneId {
12    /// Create a new ID.
13    pub fn new<R: Runtime>(client: &ComputeClient<R>, device: &R::Device) -> Self {
14        Self {
15            device: device.to_id(),
16            name: R::name(client),
17        }
18    }
19}
20
21impl core::fmt::Display for RudaTuneId {
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}