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