cubecl_runtime/device/
cuda.rs1use cubecl_common::device::{Device, DeviceId};
2
3#[derive(new, Clone, PartialEq, Eq, Default, Hash)]
5pub struct CudaDevice {
6 pub index: usize,
8}
9
10impl core::fmt::Debug for CudaDevice {
11 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
12 write!(f, "Cuda({})", self.index)
13 }
14}
15
16impl Device for CudaDevice {
17 fn from_id(device_id: DeviceId) -> Self {
18 Self {
19 index: device_id.index_id as usize,
20 }
21 }
22
23 fn to_id(&self) -> DeviceId {
24 DeviceId {
25 type_id: 0,
26 index_id: super::index_id(self.index),
27 }
28 }
29}