Created
September 15, 2013 18:42
-
-
Save allanmac/6573317 to your computer and use it in GitHub Desktop.
Test all device pairings for peer-to-peer memory access support.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiled with:
nvcc peer.cu cuda.lib -o peer