/////////////////////////////////////////////////////////////////////////// Program main ///////////////////////////////////////////////////////////////////////////
| 40 | // Program main |
| 41 | //////////////////////////////////////////////////////////////////////////////// |
| 42 | int main(int argc, char **argv) |
| 43 | { |
| 44 | CUdevice dev; |
| 45 | int major = 0, minor = 0; |
| 46 | int deviceCount = 0; |
| 47 | char deviceName[256]; |
| 48 | |
| 49 | printf("%s Starting...\n\n", argv[0]); |
| 50 | |
| 51 | // note your project will need to link with cuda.lib files on windows |
| 52 | printf("CUDA Device Query (Driver API) statically linked version \n"); |
| 53 | |
| 54 | checkCudaErrors(cuInit(0)); |
| 55 | |
| 56 | checkCudaErrors(cuDeviceGetCount(&deviceCount)); |
| 57 | |
| 58 | // This function call returns 0 if there are no CUDA capable devices. |
| 59 | if (deviceCount == 0) { |
| 60 | printf("There are no available device(s) that support CUDA\n"); |
| 61 | } |
| 62 | else { |
| 63 | printf("Detected %d CUDA Capable device(s)\n", deviceCount); |
| 64 | } |
| 65 | |
| 66 | for (dev = 0; dev < deviceCount; ++dev) { |
| 67 | checkCudaErrors(cuDeviceGetAttribute(&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, dev)); |
| 68 | checkCudaErrors(cuDeviceGetAttribute(&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, dev)); |
| 69 | |
| 70 | checkCudaErrors(cuDeviceGetName(deviceName, 256, dev)); |
| 71 | |
| 72 | printf("\nDevice %d: \"%s\"\n", dev, deviceName); |
| 73 | |
| 74 | int driverVersion = 0; |
| 75 | checkCudaErrors(cuDriverGetVersion(&driverVersion)); |
| 76 | printf(" CUDA Driver Version: %d.%d\n", |
| 77 | driverVersion / 1000, |
| 78 | (driverVersion % 100) / 10); |
| 79 | printf(" CUDA Capability Major/Minor version number: %d.%d\n", major, minor); |
| 80 | |
| 81 | size_t totalGlobalMem; |
| 82 | checkCudaErrors(cuDeviceTotalMem(&totalGlobalMem, dev)); |
| 83 | |
| 84 | char msg[256]; |
| 85 | SPRINTF(msg, |
| 86 | " Total amount of global memory: %.0f MBytes " |
| 87 | "(%llu bytes)\n", |
| 88 | (float)totalGlobalMem / 1048576.0f, |
| 89 | (unsigned long long)totalGlobalMem); |
| 90 | printf("%s", msg); |
| 91 | |
| 92 | int multiProcessorCount; |
| 93 | getCudaAttribute<int>(&multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, dev); |
| 94 | |
| 95 | printf(" (%2d) Multiprocessors, (%3d) CUDA Cores/MP: %d CUDA Cores\n", |
| 96 | multiProcessorCount, |
| 97 | _ConvertSMVer2CoresDRV(major, minor), |
| 98 | _ConvertSMVer2CoresDRV(major, minor) * multiProcessorCount); |
| 99 |
nothing calls this directly
no test coverage detected