Returns information about this device. # Example ``` # use cust::*; # use std::error::Error; # fn main() -> Result<(), Box > { # init(CudaFlags::empty())?; use cust::device::{Device, DeviceAttribute}; let device = Device::get_device(0)?; println!("Max Threads Per Block: {}", device.get_attribute(DeviceAttribute::MaxThreadsPerBlock).unwrap()); # Ok(()) # } ```
(self, attr: DeviceAttribute)
| 343 | /// # } |
| 344 | /// ``` |
| 345 | pub fn get_attribute(self, attr: DeviceAttribute) -> CudaResult<i32> { |
| 346 | unsafe { |
| 347 | let mut val = 0i32; |
| 348 | cuDeviceGetAttribute( |
| 349 | &mut val as *mut i32, |
| 350 | // This should be safe, as the repr and values of DeviceAttribute should match. |
| 351 | ::std::mem::transmute(attr), |
| 352 | self.device, |
| 353 | ) |
| 354 | .to_result()?; |
| 355 | Ok(val) |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | /// Returns a raw handle to this device, not handing over ownership, meaning that dropping |
| 360 | /// this device will try to drop the underlying device. |
no test coverage detected