From b2e4f2f4ff8a24614584c54aef9cae095e6351b8 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 19 Jul 2019 15:27:44 +0200 Subject: [PATCH] Fixed Bug in splitting up the number of calculations on each CPUs leading to deadlock. --- src/mc_electron/simulation.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mc_electron/simulation.cpp b/src/mc_electron/simulation.cpp index 8b8f8ea..d8391e7 100644 --- a/src/mc_electron/simulation.cpp +++ b/src/mc_electron/simulation.cpp @@ -115,13 +115,13 @@ void Simulation::create_out_dir(std::string dirname) { void Simulation::doit() { long int decays_this_cpu = numberTotalDecays/mpi_size; - int overflow = numberTotalDecays/mpi_size; - if (overflow < mpi_rank) { // Split overflows equaly to left over CPUs. - decays_this_cpu += 1; - } - int num_cycles = decays_this_cpu/simulationStepWidth; + int overflow = numberTotalDecays%mpi_size; + + int num_cycles = decays_this_cpu/simulationStepWidth; // Must be same for all CPUs else deadlock! int num_remaining = decays_this_cpu%simulationStepWidth; - + if (mpi_rank < overflow) { // Split overflows equaly to left over CPUs. + num_remaining += 1; + } std::cout <