8 #ifndef CUDA_API_WRAPPERS_PEER_TO_PEER_HPP_ 9 #define CUDA_API_WRAPPERS_PEER_TO_PEER_HPP_ 21 namespace peer_to_peer {
35 #if CUDA_VERSION >= 10000 36 constexpr
const attribute_t array_access_support = CU_DEVICE_P2P_ATTRIBUTE_CUDA_ARRAY_ACCESS_SUPPORTED;
56 auto status = cuDeviceGetP2PAttribute(&value, attribute, source, destination);
57 throw_if_error_lazy(status,
"Failed obtaining peer-to-peer device attribute for device pair (" 58 + ::std::to_string(source) +
", " + ::std::to_string(destination) +
')');
73 auto status = cuDeviceCanAccessPeer(&result, accessor, peer);
74 throw_if_error_lazy(status,
"Failed determining whether " + device::detail_::identify(accessor)
75 +
" can access " + device::detail_::identify(peer));
89 namespace peer_to_peer {
96 void enable_access_to(
const context_t &peer_context);
103 void disable_access_to(
const context_t &peer_context);
113 namespace peer_to_peer {
119 enum :
unsigned {fixed_flags = 0 };
121 auto status = cuCtxEnablePeerAccess(peer_context, fixed_flags);
122 throw_if_error_lazy(status,
"Failed enabling access to peer " + context::detail_::identify(peer_context));
127 auto status = cuCtxDisablePeerAccess(peer_context);
128 throw_if_error_lazy(status,
"Failed disabling access to peer " + context::detail_::identify(peer_context));
133 context::current::detail_::scoped_override_t set_context_for_this_context(accessor);
134 enable_access_to(peer);
139 context::current::detail_::scoped_override_t set_context_for_this_context(accessor);
140 disable_access_to(peer);
181 namespace peer_to_peer {
245 #endif // CUDA_API_WRAPPERS_PEER_TO_PEER_HPP_ int attribute_value_t
All CUDA device attributes (cuda::device::attribute_t) have a value of this type. ...
Definition: types.hpp:860
Wrapper class for a CUDA context.
Definition: context.hpp:244
bool can_access_each_other(const device_t &first, const device_t &second)
Determine whether two CUDA devices can currently access each other.
Definition: device.hpp:88
Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
bool can_access(const device_t &accessor, const device_t &peer)
Determine whether one CUDA device can access the global memory of another CUDA device.
Definition: device.hpp:68
CUcontext handle_t
Raw CUDA driver handle for a context; see {context_t}.
Definition: types.hpp:878
attribute_value_t get_attribute(attribute_t attribute, const device_t &first, const device_t &second)
Get one of the numeric attributes for a(n ordered) pair of devices, relating to their interaction...
Definition: device.hpp:113
CUdevice id_t
Numeric ID of a CUDA device used by the CUDA Runtime API.
Definition: types.hpp:850
constexpr const attribute_t access_support
1 if access is supported, 0 otherwise
Definition: peer_to_peer.hpp:30
constexpr const attribute_t link_performance_rank
Aliases for CUDA driver GPU attribute codes.
Definition: peer_to_peer.hpp:27
constexpr const attribute_t native_atomics_support
1 if the first device can perform native atomic operations on the second device, 0 otherwise ...
Definition: peer_to_peer.hpp:33
CUdevice_P2PAttribute attribute_t
While Individual CUDA devices have individual "attributes" (attribute_t), there are also attributes c...
Definition: types.hpp:869
#define throw_if_error_lazy(status__,...)
A macro for only throwing an error if we've failed - which also ensures no string is constructed unle...
Definition: error.hpp:316
void disable_access(const device_t &accessor, const device_t &peer)
Disable access by one CUDA device to the global memory of another.
Definition: device.hpp:78
void enable_access(const device_t &accessor, const device_t &peer)
Enable access by one CUDA device to the global memory of another.
Definition: device.hpp:73
void enable_bidirectional_access(const device_t &first, const device_t &second)
Enable access both by the first to the second device and the other way around.
Definition: device.hpp:93
Wrapper class for a CUDA device.
Definition: device.hpp:135
void disable_bidirectional_access(const device_t &first, const device_t &second)
Disable access both by the first to the second device and the other way around.
Definition: device.hpp:103