cuda::experimental::device_ref

Defined in include/cuda/experimental/__device/device_ref.cuh

class device_ref

A non-owning representation of a CUDA device.

Subclassed by cuda::experimental::device

Public Functions

inline constexpr device_ref(int __id) noexcept

Create a device_ref object from a native device ordinal.

inline constexpr int get() const noexcept

Retrieve the native ordinal of the device_ref

Returns

int The native device ordinal held by the device_ref object

inline constexpr bool operator==(device_ref __lhs, device_ref __rhs) noexcept

Compares two device_refs for equality.

Note

Allows comparison with int due to implicit conversion to device_ref.

Parameters
Returns

true if lhs and rhs refer to the same device ordinal

template<typename _Attr>
inline auto attr(_Attr __attr) const

Retrieve the specified attribute for the device.

See also

device::attrs

Parameters

__attr – The attribute to query. See device::attrs for the available attributes.

Throws

cuda_error – if the attribute query fails

template<::cudaDeviceAttr _Attr>
inline auto attr() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

inline ::std::string get_name() const
inline bool has_peer_access_to(device_ref __other_dev) const

Queries if its possible for this device to directly access specified device’s memory.

If this function returns true, device supplied to this call can be passed into enable_peer_access on memory resource or pool that manages memory on this device. It will make allocations from that pool accessible by this device.

Parameters

__other_dev – Device to query the peer access

Returns

true if its possible for this device to access the specified device’s memory

inline const arch_traits_t &arch_traits() const
inline ::std::vector<device_ref> get_peers() const

Retrieve a vector of device_refs that are peers of this device.

The device on which this API is called is not included in the vector, if a full group of peer devices is needed, it needs to be pushed_back separately.

Throws

cuda_error – if any peer access query fails