Files
CMake/Tests/Cuda/WithC/cuda.cu
T
Brad King 8d75d8dc72 Tests: Add case for CUDA with C but not C++
An executable using CUDA and C should link as CUDA.
2017-02-14 10:34:06 -05:00

17 lines
381 B
Plaintext

#include <cuda.h>
#include <iostream>
extern "C" int use_cuda(void)
{
int nDevices = 0;
cudaError_t err = cudaGetDeviceCount(&nDevices);
if (err != cudaSuccess) {
std::cerr << "Failed to retrieve the number of CUDA enabled devices"
<< std::endl;
return 1;
}
std::cout << "Found " << nDevices << " CUDA enabled devices" << std::endl;
return 0;
}