Fixed Bug in splitting up the number of calculations on each CPUs leading to deadlock.

This commit is contained in:
Christian
2019-07-19 15:27:44 +02:00
parent 3adefc7c8b
commit b2e4f2f4ff
+6 -6
View File
@@ -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 <<mpi_rank<<": "<<decays_this_cpu<<"\n";
for (int i = 0; i<(num_cycles-1); i++) {
do_decays(simulationStepWidth);