Skip to content

Instantly share code, notes, and snippets.

@allanmac
Created September 15, 2013 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allanmac/6573317 to your computer and use it in GitHub Desktop.
Save allanmac/6573317 to your computer and use it in GitHub Desktop.
Test all device pairings for peer-to-peer memory access support.
#include <stdio.h>
#include <cuda.h>
int main(int argc, char** argv)
{
cuInit(0);
int count;
cuDeviceGetCount(&count);
for (int ii=0; ii<count; ii++)
{
CUdevice dev0;
char devName0[16];
cuDeviceGet(&dev0,ii);
cuDeviceGetName(devName0,16,dev0);
for (int jj=0; jj<count; jj++)
{
if (jj == ii)
continue;
CUdevice dev1;
char devName1[16];
cuDeviceGet(&dev1,jj);
cuDeviceGetName(devName1,16,dev1);
int canAccess;
cuDeviceCanAccessPeer(&canAccess,dev0,dev1);
const char* const tf = (canAccess == 0) ? "FALSE" : "TRUE";
printf("%-16s <-- %-16s : %s\n",devName0,devName1,tf);
}
}
return 0;
}
@allanmac
Copy link
Author

Compiled with: nvcc peer.cu cuda.lib -o peer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment