cuda::experimental::device
Defined in include/cuda/experimental/__device/device.cuh
-
class device : public cuda::experimental::device_ref
An immovable “owning” representation of a CUDA device.
Public Types
-
using attrs = detail::__device_attrs
-
template<::cudaDeviceAttr _Attr>
using attr_result_t = typename detail::__dev_attr<_Attr>::type For a given attribute, returns the type of the attribute value.
See also
device::attrs
- Example
using threads_per_block_t = device::attr_result_t<device::attrs::max_threads_per_block>; static_assert(std::is_same_v<threads_per_block_t, int>);
Public Functions
-
inline const arch_traits_t &arch_traits() const noexcept
-
inline CUcontext primary_context() const
-
inline ~device()
-
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_ref
s for equality.Note
Allows comparison with
int
due to implicit conversion todevice_ref
.- Parameters
__lhs – The first
device_ref
to compare__rhs – The second
device_ref
to compare
- Returns
true if
lhs
andrhs
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 ::std::vector<device_ref> get_peers() const
Retrieve a vector of
device_ref
s 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
-
using attrs = detail::__device_attrs