AQUAgpusph 4.1.2
|
Synchronize arrays between processes. More...
#include <CalcServer/MPISync.h>
Data Structures | |
class | Exchanger |
Interprocess array synchronization base class. More... | |
class | Receiver |
Synchronize arrays between processes. More... | |
class | Sender |
Synchronize arrays between processes. More... | |
Public Member Functions | |
MPISync (const std::string name, const std::string mask, const std::vector< std::string > fields, const std::vector< unsigned int > procs, bool once=false) | |
~MPISync () | |
void | setup () |
Public Member Functions inherited from Aqua::CalcServer::Tool | |
Tool (const std::string tool_name, bool once=false) | |
virtual | ~Tool () |
void | name (const std::string tool_name) |
const std::string | name () |
virtual void | setup () |
virtual void | execute () |
Execute the tool measuring the elapsed time. | |
virtual Tool * | next_tool () |
size_t | allocatedMemory () const |
unsigned int | used_times () const |
float | elapsedTime (bool averaged=true) const |
float | elapsedTimeVariance () const |
float | elapsedTimeDeviation () const |
virtual const int | scope_modifier () |
Protected Member Functions | |
cl_event | _execute (const std::vector< cl_event > events) |
Protected Member Functions inherited from Aqua::CalcServer::Tool | |
int | id_in_pipeline () |
void | next_tool (Tool *tool) |
void | allocatedMemory (size_t mem_size) |
virtual cl_event | _execute (const std::vector< cl_event > events) |
void | addElapsedTime (float elapsed_time) |
Add new data to the average and squared elapsed times. | |
void | setDependencies (std::vector< std::string > var_names) |
Set the depedencies of the tool. | |
void | setDependencies (std::vector< InputOutput::Variable * > vars) |
Set the depedencies of the tool. | |
const std::vector< InputOutput::Variable * > | getDependencies () |
Get the depedencies of the tool. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Aqua::CalcServer::Tool | |
static std::vector< cl_kernel > | compile (const std::string source, const std::vector< std::string > names, const std::string flags="") |
Compile an OpenCL source code and generate the corresponding kernel. | |
static cl_kernel | compile_kernel (const std::string source, const std::string kernel_name, const std::string flags="") |
Compile an OpenCL source code and generate the corresponding kernel. | |
Synchronize arrays between processes.
When MPI is enabled, several instances/processes of AQUAgpusph can be simultaneously launched, letting each process compute a subset of the whole simulation, in such a way the global simulation computation can be accelerated.
The data synchronization is a quite expensive operation, both in computational and physical time, so it shall be thoroughly used.
First, the tool should dispose the data in a convenient way, which implies a sorting algorithm, as well as reduction operations to compute the amount of data to be sent to each process. After that, the data is sent by the network to the rest of processes, which would take some time, depending on the amount of data to send, and the network speed.
In parallel, the tool will prepare everything to download the data incoming from the other processes, INSIDE THE SAME ARRAYS.
To reduce the computational cost and avoid aside effects, it is strongly recommended to copy the actual data into helper arrays before synchronizing.
Aqua::CalcServer::MPISync::MPISync | ( | const std::string | name, |
const std::string | mask, | ||
const std::vector< std::string > | fields, | ||
const std::vector< unsigned int > | procs, | ||
bool | once = false |
||
) |
Constructor
name | Tool name |
mask | Mask of the data to be sent to each process. Numbers out of bounds (i.e. bigger or equal to the number of processes) will be ignored, and therefore not sent anywhere |
fields | Fields to be synchronized between processes |
procs | Processes to be considered to send information. If an empty list is provided, all the processes will be considered. Providing a list of processes is reducing the number of reductions to be carried out, and therefore the computational cost |
once | Run this tool just once. Useful to make initializations |
Aqua::CalcServer::MPISync::~MPISync | ( | ) |
Destructor.
|
protectedvirtual |
Execute the tool
events | List of events that shall be waited before safe execution |
Reimplemented from Aqua::CalcServer::Tool.
|
virtual |
Initialize the tool.
Reimplemented from Aqua::CalcServer::Tool.