Skip to main content

Device

Struct Device 

Source
pub struct Device(/* private fields */);
Expand description

A CUDA device (a physical GPU, or a logical slice of one under MIG).

Cheap Copy type — it’s just an ordinal.

Implementations§

Source§

impl Device

Source

pub fn count() -> Result<u32>

Number of CUDA devices visible to the process.

Source

pub fn get(ordinal: u32) -> Result<Self>

Retrieve the device with the given ordinal.

Source

pub fn all() -> Result<Vec<Self>>

All visible devices, in ordinal order.

Source

pub fn ordinal(&self) -> i32

Raw ordinal (0, 1, …).

Source

pub fn name(&self) -> Result<String>

Human-readable name, e.g. "NVIDIA GeForce RTX 4090".

Source

pub fn total_memory(&self) -> Result<u64>

Total global memory on this device, in bytes.

Source

pub fn compute_capability(&self) -> Result<(u32, u32)>

Compute capability as (major, minor), e.g. (9, 0) for Hopper.

Source

pub fn multiprocessor_count(&self) -> Result<u32>

Multiprocessor count (SM count).

Source

pub fn warp_size(&self) -> Result<u32>

Warp size in threads (almost always 32).

Source

pub fn attribute(&self, attr: i32) -> Result<i32>

Query an arbitrary CUdevice_attribute. See baracuda_cuda_sys::types::CUdevice_attribute for the full list.

Source

pub fn as_raw(&self) -> CUdevice

The raw CUdevice handle. Use with care.

Source

pub fn uuid(&self) -> Result<[u8; 16]>

Return the device’s 16-byte UUID.

Source

pub fn luid(&self) -> Result<([u8; 8], u32)>

Return the device’s Windows LUID and 32-bit device-node mask (Windows only; Linux returns zeros).

Source

pub fn p2p_attribute(&self, peer: &Device, attr: i32) -> Result<i32>

Query a peer-to-peer attribute between self (as source) and peer (as destination). Pass a constant from baracuda_cuda_sys::types::CUdevice_P2PAttribute.

Source

pub fn exec_affinity_support(&self, affinity_type: i32) -> Result<bool>

Query whether this device supports a given exec-affinity type (e.g. SM-count partitioning at context-creation time).

Source

pub fn can_access_peer(&self, peer: &Device) -> Result<bool>

true if this device can directly access allocations on peer. Peer access still requires a matching Context::enable_peer_access on the accessing side before kernels can dereference peer pointers.

Source

pub fn primary_ctx_state(&self) -> Result<(u32, bool)>

Query the primary-context state for this device. Returns (flags, active)flags is the same bitmask crate::Context::with_flags takes, active is true if some caller currently holds a retained primary-context reference.

Source

pub fn set_primary_ctx_flags(&self, flags: u32) -> Result<()>

Set the flags used when the primary context is later created. Returns CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE if the primary context already exists; reset with Context::reset_primary first.

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Device

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Device

Source§

fn cmp(&self, other: &Device) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Device

Source§

fn eq(&self, other: &Device) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Device

Source§

fn partial_cmp(&self, other: &Device) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Device

Source§

impl Eq for Device

Source§

impl StructuralPartialEq for Device

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.