cuda::experimental::device

Defined in /home/runner/work/cccl/cccl/cudax/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_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.