#include <stdio.h>
#include <cuda.h>
const char splitLine[] = "----------------------------------";
void output(const cudaDeviceProp devInfo) {
puts(splitLine);
printf("Device %s\n", devInfo.name);
puts(splitLine);
printf(" Device memory: \t%zu\n", devInfo.totalGlobalMem);
printf(" Memory per-block: \t%zu\n", devInfo.sharedMemPerBlock);
printf(" Register per-block: \t%d\n", devInfo.regsPerBlock);
printf(" Warp size: \t\t%d\n", devInfo.warpSize);
printf(" Memory pitch: \t\t%zu\n", devInfo.memPitch);
printf(" Constant Memory: \t%zu\n", devInfo.totalConstMem);
printf(" Max thread per-block: \t%d\n", devInfo.maxThreadsPerBlock);
printf(" Max thread dim: \t%d / %d / %d\n",
devInfo.maxThreadsDim[0], devInfo.maxThreadsDim[1], devInfo.maxThreadsDim[2]);
printf(" Max grid size: \t%d / %d / %d\n",
devInfo.maxGridSize[0], devInfo.maxGridSize[1], devInfo.maxGridSize[2]);
printf(" Ver: \t\t\t%d.%d\n", devInfo.major, devInfo.minor);
printf(" Clock: \t\t%d\n", devInfo.clockRate);
printf(" Texture Alignment: \t%zu\n", devInfo.textureAlignment);
}
int main() {
int cudaDeviceCnt = 0;
cudaGetDeviceCount(&cudaDeviceCnt);
printf("%d devices found supporting CUDA\n", cudaDeviceCnt);
if (cudaDeviceCnt == 0) {
printf("No supported GPU\n");
return 0;
}
for (int i = 0; i < cudaDeviceCnt; i++) {
cudaDeviceProp devInfo;
cudaGetDeviceProperties(&devInfo, i);
output(devInfo);
}
return 0;
}