Revert "averaging instead of summation in syncronization;"

This reverts commit 4dd84ff5fc.
This commit is contained in:
2024-02-06 15:44:30 +01:00
parent 4dd84ff5fc
commit 6456dab0c4
4 changed files with 8 additions and 20 deletions
-13
View File
@@ -5,47 +5,34 @@
#include "simulation/density_field.h"
#include "simulation/logger.h"
#include "simulation/species.h"
#include "simulation/mpi_communication.h"
/*
Note: changed from sum to average over all cpus (probs best to rename
the functions)
Highly likely that it does not work (correct or as intended) for
the cases of int/long communication
*/
void CpuSynchronizer::sumToAll(blitz::Array<double, 4>& array) {
int size = array.size();
MPI_Allreduce(MPI_IN_PLACE, array.data(), size, MPI_DOUBLE, MPI_SUM,
MPI_COMM_WORLD);
array /= MpiCommunication::mpi_size;
}
void CpuSynchronizer::sumToAll(blitz::Array<long int, 4>& array) {
int size = array.size();
MPI_Allreduce(MPI_IN_PLACE, array.data(), size, MPI_LONG, MPI_SUM,
MPI_COMM_WORLD);
array /= MpiCommunication::mpi_size;
}
void CpuSynchronizer::sumToAll(blitz::Array<double, 3>& array) {
int size = array.size();
MPI_Allreduce(MPI_IN_PLACE, array.data(), size, MPI_DOUBLE, MPI_SUM,
MPI_COMM_WORLD);
array /= MpiCommunication::mpi_size;
}
void CpuSynchronizer::sumToAll(double& value) {
int size = 1;
MPI_Allreduce(MPI_IN_PLACE, &value, size, MPI_DOUBLE, MPI_SUM,
MPI_COMM_WORLD);
value /= MpiCommunication::mpi_size;
}
void CpuSynchronizer::sumToAll(long int& value) {
int size = 1;
MPI_Allreduce(MPI_IN_PLACE, &value, size, MPI_LONG, MPI_SUM, MPI_COMM_WORLD);
value /= MpiCommunication::mpi_size;
}
void CpuSynchronizer::synchronize(Timer* timer) {