From 2a5d4dece04b38b9c5c1b1eb2d5b402bf76f4134 Mon Sep 17 00:00:00 2001 From: fredrikr79 Date: Mon, 6 Oct 2025 15:48:38 +0200 Subject: [PATCH] task 1 --- exercise4/wave_2d_parallel.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/exercise4/wave_2d_parallel.c b/exercise4/wave_2d_parallel.c index ca0c692..bffb5ef 100644 --- a/exercise4/wave_2d_parallel.c +++ b/exercise4/wave_2d_parallel.c @@ -14,7 +14,7 @@ // TASK: T1a // Include the MPI headerfile // BEGIN: T1 -; +#include // END: T1a // Convert 'struct timeval' into seconds in double prec. floating point @@ -34,6 +34,11 @@ real_t #define U_prv(i, j) buffers[0][((i) + 1) * (N + 2) + (j) + 1] #define U(i, j) buffers[1][((i) + 1) * (N + 2) + (j) + 1] #define U_nxt(i, j) buffers[2][((i) + 1) * (N + 2) + (j) + 1] + +int world_size; +int world_rank; + +#define ROOT 0 // END: T1b // Simulation parameters: size, step count, and how often to save the state @@ -243,7 +248,9 @@ int main(int argc, char **argv) { // TASK: T1c // Initialise MPI // BEGIN: T1c - ; + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); // END: T1c // TASK: T3 @@ -278,7 +285,7 @@ int main(int argc, char **argv) { // TASK: T1d // Finalise MPI // BEGIN: T1d - ; + MPI_Finalize(); // END: T1d exit(EXIT_SUCCESS);