From 0813765831ef0ad54c0fc5d806d8964e9dc3d595 Mon Sep 17 00:00:00 2001 From: fredrikr79 Date: Tue, 4 Nov 2025 13:11:12 +0100 Subject: [PATCH] ex7: start --- exercise7/wave_2d_parallel.cu | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/exercise7/wave_2d_parallel.cu b/exercise7/wave_2d_parallel.cu index ffdf273..156df50 100644 --- a/exercise7/wave_2d_parallel.cu +++ b/exercise7/wave_2d_parallel.cu @@ -1,3 +1,4 @@ +#include #include #include #include @@ -11,7 +12,8 @@ // TASK: T1 // Include the cooperative groups library // BEGIN: T1 -; +#include +namespace cg = cooperative_groups; // TODO // END: T1 // Convert 'struct timeval' into seconds in double prec. floating point @@ -172,6 +174,28 @@ void occupancy(void) { // Make sure at least one CUDA-capable device exists static bool init_cuda() { // BEGIN: T2 + int count; + if (cudaGetDeviceCount(&count) != cudaSuccess) + return false; + + printf("CUDA device count: %d\n", count); + + if (count > 0) { + cudaDeviceProp p; + if (cudaSetDevice(0) != cudaSuccess) + return false; + if (cudaGetDeviceProperties(&p, 0) != cudaSuccess) + return false; + + printf("CUDA device #0:\n"); + printf(" Name: %s\n", p.name); + printf(" Compute capability: %d.%d\n", p.major, p.minor); + printf(" Multiprocessors: %d\n", p.multiProcessorCount); + printf(" Warp size: %d\n", p.warpSize); + printf(" Global memory: %.1fGiB bytes\n", p.totalGlobalMem / (1024.0 * 1024.0 * 1024.0)); + printf(" Per-block shared memory: %.1fKiB\n", p.sharedMemPerBlock / 1024.0); + printf(" Per-block registers: %d\n", p.regsPerBlock); + } return true; // END: T2 }