This commit is contained in:
2025-10-06 15:48:38 +02:00
parent f6c7cff8da
commit 2a5d4dece0

View File

@@ -14,7 +14,7 @@
// TASK: T1a
// Include the MPI headerfile
// BEGIN: T1
;
#include <mpi.h>
// 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);