File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -327,6 +327,29 @@ impl Device {
327
327
}
328
328
}
329
329
330
+ /// Returns the UUID of this device.
331
+ ///
332
+ /// # Example
333
+ /// ```
334
+ /// # use cust::*;
335
+ /// # use std::error::Error;
336
+ /// # fn main() -> Result<(), Box<dyn Error>> {
337
+ /// # init(CudaFlags::empty())?;
338
+ /// use cust::device::Device;
339
+ /// let device = Device::get_device(0)?;
340
+ /// println!("Device UUID: {:?}", device.uuid()?);
341
+ /// # Ok(())
342
+ /// # }
343
+ /// ```
344
+ pub fn uuid ( self ) -> CudaResult < [ u8 ; 16 ] > {
345
+ let mut cu_uuid = CUuuid { bytes : [ 0i8 ; 16 ] } ;
346
+ unsafe {
347
+ cuDeviceGetUuid ( & mut cu_uuid, self . device ) . to_result ( ) ?;
348
+ }
349
+ let uuid: [ u8 ; 16 ] = cu_uuid. bytes . map ( |byte| byte. to_ne_bytes ( ) [ 0 ] ) ;
350
+ Ok ( uuid)
351
+ }
352
+
330
353
/// Returns information about this device.
331
354
///
332
355
/// # Example
You can’t perform that action at this time.
0 commit comments