From ba2c91d8804fad5cdabf7ffaee697e39fd968f39 Mon Sep 17 00:00:00 2001 From: WickedJack99 Date: Sun, 29 Jun 2025 22:32:11 +0200 Subject: [PATCH] . --- lab12/exc4/jacobi.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lab12/exc4/jacobi.cpp b/lab12/exc4/jacobi.cpp index 52f47a8..df40e6f 100644 --- a/lab12/exc4/jacobi.cpp +++ b/lab12/exc4/jacobi.cpp @@ -239,12 +239,16 @@ Jacobi::Result Jacobi::run(const Matrix &init, double eps, int maxNumIter) int t0 = 0; // array index of current timestep int t1 = 1; // array index of next timestep + +#pragma omp parallel firstprivate(t0, t1) lastprivate(nIter) while (dist > eps && nIter < maxNumIter) { dist = 0; +#pragma omp single exchangeHaloLayers(phi[t0]); +#pragma omp for reduction(max : dist) schedule(static, numRows / 6) for (int i = 1; i < numRows - 1; ++i) { for (int j = 1; j < numCols - 1; ++j) @@ -257,6 +261,7 @@ Jacobi::Result Jacobi::run(const Matrix &init, double eps, int maxNumIter) } } +#pragma omp single MPI_Allreduce(MPI_IN_PLACE, &dist, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); nIter++;