Commit 5c94c402 authored by Peter Kovář's avatar Peter Kovář

Updated CUDA.c++

parent 9804613c
#include <cuda/cuda.h>
#include <cuda/cuda_runtime.h>
#include "helper_cuda.h"
#include <stdio.h>
#include <stdlib.h>
#define STRNCASECMP strncmp
#include <helper_cuda.h>
int
main (int argc, char **argv)
......@@ -12,28 +12,28 @@ main (int argc, char **argv)
cudaError_t error_id ;
int dev, driverVersion = 0, runtimeVersion = 0 ;
error_id = cudaGetDeviceCount (&deviceCount) ;
error_id = cudaGetDeviceCount (&deviceCount);
if (error_id != cudaSuccess)
{
printf ("cudaGetDeviceCount returned %d\n-> %s\n", (int) error_id, cudaGetErrorString (error_id)) ;
printf ("Result = FAIL\n") ;
exit (EXIT_FAILURE) ;
printf ("cudaGetDeviceCount returned %d\n-> %s\n", (int) error_id, cudaGetErrorString (error_id));
printf ("Result = FAIL\n");
exit (EXIT_FAILURE);
}
if (deviceCount == 0)
{
printf ("There are no available device(s) that support CUDA\n") ;
printf ("There are no available device(s) that support CUDA\n");
}
else
{
printf ("Detected %d CUDA Capable device(s)\n", deviceCount) ;
printf ("Detected %d CUDA Capable device(s)\n", deviceCount);
}
for (dev = 0 ; dev < deviceCount ; dev++)
{
cudaSetDevice (dev) ;
cudaSetDevice (dev);
cudaDeviceProp deviceProp ;
cudaGetDeviceProperties (&deviceProp, dev) ;
cudaGetDeviceProperties (&deviceProp, dev);
printf("\nDevice %d: \"%s\"\n", dev, deviceProp.name);
......@@ -143,19 +143,19 @@ main (int argc, char **argv)
for (int device = 0 ; device < deviceCount ; device++)
{
checkCudaErrors(cudaGetDeviceProperties(&prop[device], device));
checkCudaErrors(cudaGetDeviceProperties(&prop[device], device));
// Only boards based on Fermi or later can support P2P
if ((prop[device].major >= 2)
// Only boards based on Fermi or later can support P2P
if ((prop[device].major >= 2)
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
// on Windows (64-bit), the Tesla Compute Cluster driver for windows must be enabled to support this
&& prop[device].tccDriver
// on Windows (64-bit), the Tesla Compute Cluster driver for windows must be enabled to support this
&& prop[device].tccDriver
#endif
)
{
// This is an array of P2P capable GPUs
gpuid[gpu_p2p_count++] = device;
}
)
{
// This is an array of P2P capable GPUs
gpuid[gpu_p2p_count++] = device;
}
}
// Show all the combinations of support P2P GPUs
......@@ -163,32 +163,32 @@ main (int argc, char **argv)
if (gpu_p2p_count >= 2)
{
for (int i = 0 ; i < gpu_p2p_count-1 ; i++)
for (int i = 0 ; i < gpu_p2p_count-1 ; i++)
{
for (int j = 1 ; j < gpu_p2p_count ; j++)
{
for (int j = 1 ; j < gpu_p2p_count ; j++)
{
checkCudaErrors(cudaDeviceCanAccessPeer(&can_access_peer_0_1, gpuid[i], gpuid[j]));
printf("> Peer access from %s (GPU%d) -> %s (GPU%d) : %s\n", prop[gpuid[i]].name, gpuid[i],
prop[gpuid[j]].name, gpuid[j] ,
can_access_peer_0_1 ? "Yes" : "No");
}
checkCudaErrors(cudaDeviceCanAccessPeer(&can_access_peer_0_1, gpuid[i], gpuid[j]));
printf("> Peer access from %s (GPU%d) -> %s (GPU%d) : %s\n", prop[gpuid[i]].name, gpuid[i],
prop[gpuid[j]].name, gpuid[j] ,
can_access_peer_0_1 ? "Yes" : "No");
}
}
for (int j = 1 ; j < gpu_p2p_count ; j++)
for (int j = 1 ; j < gpu_p2p_count ; j++)
{
for (int i = 0 ; i < gpu_p2p_count-1 ; i++)
{
for (int i = 0 ; i < gpu_p2p_count-1 ; i++)
{
checkCudaErrors(cudaDeviceCanAccessPeer(&can_access_peer_1_0, gpuid[j], gpuid[i]));
printf("> Peer access from %s (GPU%d) -> %s (GPU%d) : %s\n", prop[gpuid[j]].name, gpuid[j],
prop[gpuid[i]].name, gpuid[i] ,
can_access_peer_1_0 ? "Yes" : "No");
}
checkCudaErrors(cudaDeviceCanAccessPeer(&can_access_peer_1_0, gpuid[j], gpuid[i]));
printf("> Peer access from %s (GPU%d) -> %s (GPU%d) : %s\n", prop[gpuid[j]].name, gpuid[j],
prop[gpuid[i]].name, gpuid[i] ,
can_access_peer_1_0 ? "Yes" : "No");
}
}
}
}
printf("\n");
cudaDeviceReset () ;
exit (EXIT_SUCCESS) ;
cudaDeviceReset ();
exit (EXIT_SUCCESS);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment