pub struct Device { /* private fields */ }
Expand description
Opaque handle to a CUDA device.
Implementations
sourceimpl Device
impl Device
sourcepub fn num_devices() -> CudaResult<u32>
pub fn num_devices() -> CudaResult<u32>
Get the number of CUDA-capable devices.
Returns the number of devices with compute-capability 2.0 or greater which are available for execution.
Example
use cust::device::Device;
let num_devices = Device::num_devices()?;
println!("Number of devices: {}", num_devices);
sourcepub fn get_device(ordinal: u32) -> CudaResult<Device>
pub fn get_device(ordinal: u32) -> CudaResult<Device>
Get a handle to the ordinal
’th CUDA device.
Ordinal must be in the range 0..num_devices()
. If not, an error will be returned.
Example
use cust::device::Device;
let device = Device::get_device(0)?;
println!("Device Name: {}", device.name()?);
sourcepub fn devices() -> CudaResult<Devices>
pub fn devices() -> CudaResult<Devices>
Return an iterator over all CUDA devices.
Example
use cust::device::Device;
for device in Device::devices()? {
let device = device?;
println!("Device Name: {}", device.name()?);
}
sourcepub fn total_memory(self) -> CudaResult<usize>
pub fn total_memory(self) -> CudaResult<usize>
Returns the total amount of memory available on the device in bytes.
Example
use cust::device::Device;
let device = Device::get_device(0)?;
println!("Device Memory: {}", device.total_memory()?);
sourcepub fn name(self) -> CudaResult<String>
pub fn name(self) -> CudaResult<String>
Returns the name of this device.
Example
use cust::device::Device;
let device = Device::get_device(0)?;
println!("Device Name: {}", device.name()?);
sourcepub fn get_attribute(self, attr: DeviceAttribute) -> CudaResult<i32>
pub fn get_attribute(self, attr: DeviceAttribute) -> CudaResult<i32>
Returns information about this device.
Example
use cust::device::{Device, DeviceAttribute};
let device = Device::get_device(0)?;
println!("Max Threads Per Block: {}",
device.get_attribute(DeviceAttribute::MaxThreadsPerBlock).unwrap());
Trait Implementations
impl Copy for Device
impl Eq for Device
impl StructuralEq for Device
impl StructuralPartialEq for Device
Auto Trait Implementations
impl RefUnwindSafe for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnwindSafe for Device
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more