Skip to content

Commit

Permalink
cuda: add device information to minimal.cu
Browse files Browse the repository at this point in the history
  • Loading branch information
danbev committed Oct 10, 2024
1 parent a942f49 commit e81bd57
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gpu/cuda/src/minimal.cu
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ int main() {
}
}

// Get and print information for each device
for (int i = 0; i < count; i++) {
cudaDeviceProp prop;
err = cudaGetDeviceProperties(&prop, i);
if (err != cudaSuccess) {
printf("cudaGetDeviceProperties failed for device %d: %s\n", i, cudaGetErrorString(err));
continue;
}

printf("\nDevice %d:\n", i);
printf(" Name: %s\n", prop.name);
printf(" Compute Capability: %d.%d\n", prop.major, prop.minor);
printf(" Multiprocessors: %d\n", prop.multiProcessorCount);
printf(" Clock Rate: %.0f MHz\n", prop.clockRate * 1e-3f);
printf(" Total Global Memory: %.2f GB\n", prop.totalGlobalMem / (1024.0 * 1024.0 * 1024.0));
printf(" L2 Cache Size: %.2f MB\n", prop.l2CacheSize / (1024.0 * 1024.0));
}


myKernel<<<1,1>>>();
err = cudaGetLastError();
if (err != cudaSuccess) {
Expand Down

0 comments on commit e81bd57

Please sign in to comment.