pansk
pansk

Reputation: 11

What's the difference between cuDeviceCanAccessPeer(...) and cuDeviceGetP2PAttribute(..., CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED, ...)?

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 of 1 if contexts on dev are capable of directly accessing memory from contexts on peerDev and 0 otherwise. If direct access of peerDev from dev 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 attribute attrib of the link between srcDevice and dstDevice. 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

Answers (1)

talonmies
talonmies

Reputation: 72349

I don't believe they are the same.

  • cuDeviceCanAccessPeer returns whether P2P access is possible between two devices or not.
  • cuDeviceGetP2PAttributereturns 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

Related Questions