pub struct Device { /* private fields */ }
Expand description
Opaque handle to a CUDA device.
Implementations§
source§impl 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 rustacuda::device::Device;
let num_devices = Device::num_devices().unwrap();
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 rustacuda::device::Device;
let device = Device::get_device(0).unwrap();
println!("Device Name: {}", device.name().unwrap());
sourcepub fn devices() -> CudaResult<Devices>
pub fn devices() -> CudaResult<Devices>
Return an iterator over all CUDA devices.
Example:
use rustacuda::device::Device;
for device in Device::devices().unwrap() {
let device = device.unwrap();
println!("Device Name: {}", device.name().unwrap());
}
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 rustacuda::device::Device;
let device = Device::get_device(0).unwrap();
println!("Device Memory: {}", device.total_memory().unwrap());
sourcepub fn name(self) -> CudaResult<String>
pub fn name(self) -> CudaResult<String>
Returns the name of this device.
Example:
use rustacuda::device::Device;
let device = Device::get_device(0).unwrap();
println!("Device Name: {}", device.name().unwrap());
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 rustacuda::device::{Device, DeviceAttribute};
let device = Device::get_device(0).unwrap();
println!("Max Threads Per Block: {}",
device.get_attribute(DeviceAttribute::MaxThreadsPerBlock).unwrap());