Reputation: 11
I don't have access to a multi-gpu system to test this, but in cuda.h I found two things that seems quite similar. The first is the function
CUresult CUDAAPI cuDeviceCanAccessPeer(int *canAccessPeer, CUdevice dev, CUdevice peerDev);
Described as
Returns in
*canAccessPeer
a value of1
if contexts ondev
are capable of directly accessing memory from contexts onpeerDev
and0
otherwise. If direct access ofpeerDev
fromdev
is possible, then access may be enabled on two specific contexts by calling::cuCtxEnablePeerAccess()
.
And the second one is
CUresult CUDAAPI cuDeviceGetP2PAttribute(int* value, CUdevice_P2PAttribute attrib, CUdevice srcDevice, CUdevice dstDevice);
Described as
Returns in
*value the
value of the requested attributeattrib
of the link betweensrcDevice
anddstDevice
. The supported attributes are:
::CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK
: A relative value indicating the performance of the link between two devices.
::CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED
P2:
1` if P2P Access is enable.
::CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED: 1
if Atomic operations over the link are supported.
The name CU_DEVICE_ATTRUBUTE_ACCESS_SUPPORTED
would suggest that a call to cuDeviceCanAccessPeer
is the same as using cuDeviceGetP2PAttribute
with attrib
set to ::CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED P2P
, but the description "1
if P2P Access is enable" confuses me.
Are they really the same, or the second one is supposed to test if the link has been activated?
Upvotes: 1
Views: 346
Reputation: 72349
I don't believe they are the same.
cuDeviceCanAccessPeer
returns whether P2P access is possible between two devices or not.cuDeviceGetP2PAttribute
returns whether P2P access is enabled between two devices.Without a prior successful call to cuCtxEnablePeerAccess
, cuDeviceGetP2PAttribute
should return false when queried for the CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED
attribute, even if cuDeviceCanAccessPeer
returns true.
Note that I also don't presently have access to a P2P enabled system to check this.
Upvotes: 2