/////////////////////////////////////////////////////////////////////////// Program main ///////////////////////////////////////////////////////////////////////////
| 64 | // Program main |
| 65 | //////////////////////////////////////////////////////////////////////////////// |
| 66 | int main(int argc, char **argv) |
| 67 | { |
| 68 | pArgc = &argc; |
| 69 | pArgv = argv; |
| 70 | |
| 71 | printf("%s Starting...\n\n", argv[0]); |
| 72 | printf(" CUDA Device Query (Runtime API) version (CUDART static linking)\n\n"); |
| 73 | |
| 74 | int deviceCount = 0; |
| 75 | cudaError_t error_id = cudaGetDeviceCount(&deviceCount); |
| 76 | |
| 77 | if (error_id != cudaSuccess) { |
| 78 | printf("cudaGetDeviceCount returned %d\n-> %s\n", static_cast<int>(error_id), cudaGetErrorString(error_id)); |
| 79 | printf("Result = FAIL\n"); |
| 80 | exit(EXIT_FAILURE); |
| 81 | } |
| 82 | |
| 83 | // This function call returns 0 if there are no CUDA capable devices. |
| 84 | if (deviceCount == 0) { |
| 85 | printf("There are no available device(s) that support CUDA\n"); |
| 86 | } |
| 87 | else { |
| 88 | printf("Detected %d CUDA Capable device(s)\n", deviceCount); |
| 89 | } |
| 90 | |
| 91 | int dev, driverVersion = 0, runtimeVersion = 0; |
| 92 | |
| 93 | for (dev = 0; dev < deviceCount; ++dev) { |
| 94 | cudaSetDevice(dev); |
| 95 | cudaDeviceProp deviceProp; |
| 96 | cudaGetDeviceProperties(&deviceProp, dev); |
| 97 | |
| 98 | printf("\nDevice %d: \"%s\"\n", dev, deviceProp.name); |
| 99 | |
| 100 | // Console log |
| 101 | cudaDriverGetVersion(&driverVersion); |
| 102 | cudaRuntimeGetVersion(&runtimeVersion); |
| 103 | printf(" CUDA Driver Version / Runtime Version %d.%d / %d.%d\n", |
| 104 | driverVersion / 1000, |
| 105 | (driverVersion % 100) / 10, |
| 106 | runtimeVersion / 1000, |
| 107 | (runtimeVersion % 100) / 10); |
| 108 | printf(" CUDA Capability Major/Minor version number: %d.%d\n", deviceProp.major, deviceProp.minor); |
| 109 | |
| 110 | char msg[256]; |
| 111 | #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) |
| 112 | sprintf_s(msg, |
| 113 | sizeof(msg), |
| 114 | " Total amount of global memory: %.0f MBytes " |
| 115 | "(%llu bytes)\n", |
| 116 | static_cast<float>(deviceProp.totalGlobalMem / 1048576.0f), |
| 117 | (unsigned long long)deviceProp.totalGlobalMem); |
| 118 | #else |
| 119 | snprintf(msg, |
| 120 | sizeof(msg), |
| 121 | " Total amount of global memory: %.0f MBytes " |
| 122 | "(%llu bytes)\n", |
| 123 | static_cast<float>(deviceProp.totalGlobalMem / 1048576.0f), |
nothing calls this directly
no test coverage detected