MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / get_attribute

Method get_attribute

crates/cust/src/device.rs:345–357  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 2

from_descriptorMethod · 0.45
newMethod · 0.45

Calls 1

to_resultMethod · 0.45

Tested by

no test coverage detected