htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 8bbfa0c98da490deb069f0e3b7975f286f224f3e
parent 3ebedc84a5e49765f08437533696fd07d997bc75
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 28 Nov 2024 16:30:25 +0100

core: fix MPI lock when gathering image

If the number of tiles to render was not a multiple of the number of
processes performing the calculation, the remaining tiles were poorly
managed: they were all supposed to be calculated by the master process
and, more importantly, some of them were wrongly rejected. This commit
not only corrects the latter problem, but also makes a more smart
distribution of the remaining tiles by dividing them between all the
processes.

Diffstat:
Msrc/core/htrdr_draw_map.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/core/htrdr_draw_map.c b/src/core/htrdr_draw_map.c @@ -718,6 +718,7 @@ htrdr_draw_map size_t itile; struct proc_work work; size_t proc_ntiles_adjusted; + size_t remaining_tiles; double pix_sz[2]; ATOMIC probe_thieves = 1; @@ -752,9 +753,15 @@ htrdr_draw_map /* Define the initial number of tiles of the current process */ proc_ntiles_adjusted = ntiles_adjusted / (size_t)htrdr->mpi_nprocs; - if(htrdr->mpi_rank == 0) { /* Affect the remaining tiles to the master proc */ - proc_ntiles_adjusted += - ntiles_adjusted - proc_ntiles_adjusted*(size_t)htrdr->mpi_nprocs; + + remaining_tiles = + ntiles_adjusted - proc_ntiles_adjusted*(size_t)htrdr->mpi_nprocs; + + /* Distribute the remaining tiles among the processes. Each process whose + * rank is lower than the number of remaining tiles takes an additional + * tile */ + if((size_t)htrdr->mpi_rank < remaining_tiles) { + ++proc_ntiles_adjusted; } /* Define the initial list of tiles of the process */