CUDA 测试GPU是否支持P2P通信
用于测试NVIDIA GPU是否支持P2P通信的代码
·
NVIDIA GPU 只有在相同的PCIE根上 才能支持P2P通信
测试代码如下:
int can_access_peer;
cudaDeviceProp prop[64];
/* check device count */
CHECK(cudaGetDeviceCount(&dpar.ngpus));
if (mpar.myid==0)
{
warn(" > CUDA-capable device count: %i", dpar.ngpus);
}
for (int i=0; i < dpar.ngpus; i++)
{
CHECK(cudaGetDeviceProperties(&prop[i], i));
}
// Show all the combinations of supported P2P GPUs
if (mpar.myid==0)
{
for (int i = 0; i < dpar.ngpus; i++)
{
for (int j = 0; j < dpar.ngpus; j++)
{
if (i == j)
{
continue;
}
CHECK(cudaDeviceCanAccessPeer(&can_access_peer, i, j));
warn(" > Peer access from %s (GPU%d) -> %s (GPU%d) : %s", prop[i].name, i,
prop[j].name, j, can_access_peer ? "Yes" : "No");
}
}
}
更多推荐
所有评论(0)