Files
karl/include/simulation/cpu_synchronizer.h
T
2024-12-04 17:15:04 +01:00

92 lines
4.0 KiB
C++
Executable File

#ifndef CPU_SYNCHRONIZER_H
#define CPU_SYNCHRONIZER_H
#include <map>
#include <memory>
#include <string>
#include "blitz/array.h"
// defined in "simulation/density_field.h"
class DynamicDensityField;
// defined in "simulation/timer.h"
class Timer;
// defined in "simulation/current_collector.h"
class CurrentCollector;
// defined in "simulation/logger.h"
class DeletionLogger;
// defined in "simulation/species.h"
namespace species {
class TrackedSpecie;
};
// class to synchronize states between mpi-processes
class CpuSynchronizer {
public:
// CpuSynchronizer();
// function to handle synchronization of the map of TrackedSpecie
// synchronizes the timer, all CurrentCollectors, DynamicDensityFields and DeletionLoggers
void synchronize(
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
tracked_species);
// function to synchronize a DynamicDensityField;
// last_sync_field includes the state of the DynamicDensityField after the last
// synchronization, neccessary to calculate changes that have to be communicated
// after the synchronization both field and last_sync_field contain the same data
// but are different objects
void synchronize(DynamicDensityField* field,
DynamicDensityField* last_sync_field);
// function to synchronize a CurrentCollector;
// last_sync_collector includes the state of the CurrentCollector after the last
// synchronization, neccessary to calculate changes that have to be communicated
// after the synchronization both collector and last_sync_collector contain the same data
// but are different objects
void synchronize(CurrentCollector* collector,
CurrentCollector* last_sync_collector);
// function to synchronize a DeletionLogger;
// last_sync_logger includes the state of the DeletionLogger after the last
// synchronization, neccessary to calculate changes that have to be communicated
// after the synchronization both logger and last_sync_logger contain the same data
// but are different objects
void synchronize(DeletionLogger* logger,
DeletionLogger* last_sync_logger);
// function to synchronize a Timer;
// last_sync_timer includes the state of the Timer after the last
// synchronization, neccessary to calculate changes that have to be communicated
// after the synchronization both timer and last_sync_timer contain the same data
// but are different objects
void synchronize(Timer* timer, Timer* last_sync_timer);
// calculates delta = array - last_sync_array, then collects all deltas of all
// mpi-processes and adds them to last_sync_array (i.e. array does not get modified)
void sumToAll(blitz::Array<double, 4>& array,
blitz::Array<double, 4>& last_sync_array);
// calculates delta = array - last_sync_array, then collects all deltas of all
// mpi-processes and adds them to last_sync_array so that
// afterwards last_sync_array has the same values on each mpi-process
// (i.e. array does not get modified)
void sumToAll(blitz::Array<double, 3>& array,
blitz::Array<double, 3>& last_sync_array);
// calculates delta = array - last_sync_array, then collects all deltas of all
// mpi-processes and adds them to last_sync_array so that
// afterwards last_sync_array has the same values on each mpi-process
// (i.e. array does not get modified)
void sumToAll(blitz::Array<long int, 4>& array,
blitz::Array<long int, 4>& last_sync_array);
// calculates delta = value - last_sync_value, then collects all deltas of all
// mpi-processes and adds them to last_sync_value so that
// afterwards last_sync_value has the same value on each mpi-process
// (i.e. array does not get modified)
void sumToAll(double& value, double& last_sync_value);
// calculates delta = array - last_sync_array, then collects all deltas of all
// mpi-processes and adds them to last_sync_value so that
// afterwards last_sync_value has the same value on each mpi-process
// (i.e. array does not get modified)
void sumToAll(long int& value, long int& last_sync_value);
};
#endif /* CPU_SYNCHRONIZER_H */