averaging instead of summation in syncronization;

changed deleted_particles from long to double
This commit is contained in:
2024-02-06 13:41:25 +01:00
parent 331e887f04
commit 4dd84ff5fc
4 changed files with 20 additions and 8 deletions
+13
View File
@@ -5,34 +5,47 @@
#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) {