Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Modules/CMakeCompilerCUDAArch.h
5015 views
1
#include <cstdio>
2
3
#include <cuda_runtime.h>
4
5
static bool cmakeCompilerCUDAArch()
6
{
7
int count = 0;
8
if (cudaGetDeviceCount(&count) != cudaSuccess || count == 0) {
9
std::fprintf(stderr, "No CUDA devices found.\n");
10
return -1;
11
}
12
13
bool found = false;
14
char const* sep = "";
15
for (int device = 0; device < count; ++device) {
16
cudaDeviceProp prop;
17
if (cudaGetDeviceProperties(&prop, device) == cudaSuccess) {
18
std::printf("%s%d%d", sep, prop.major, prop.minor);
19
sep = ";";
20
found = true;
21
}
22
}
23
24
if (!found) {
25
std::fprintf(stderr, "No CUDA architecture detected from any devices.\n");
26
}
27
28
return found;
29
}
30
31