AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Aqua::CalcServer::MPISync Class Reference

Synchronize arrays between processes. More...

#include <MPISync.hpp>

Inheritance diagram for Aqua::CalcServer::MPISync:
Collaboration diagram for Aqua::CalcServer::MPISync:

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 ()
virtual void execute ()
 Execute the tool measuring the elapsed time.
virtual Toolnext_tool ()
Toolprev_tool () const
void prev_tool (Tool *tool)
size_t allocatedMemory () const
unsigned int used_times () const
void addElapsedTime (float elapsed_time)
 Add new data to the average and squared elapsed times.
float elapsedTime (bool averaged=true) const
float elapsedTimeVariance () const
float elapsedTimeDeviation () const
virtual int scope_modifier () const
std::vector< InputOutput::Variable * > getInputDependencies () const
 Get the input depedencies of the tool.
std::vector< InputOutput::Variable * > getOutputDependencies () const
 Get the output depedencies of the tool.
std::tuple< std::vector< InputOutput::Variable * >, std::vector< InputOutput::Variable * > > getDependencies () const
 Get the depedencies of the tool.
cl_event getEvent () const
 Get the tool event.
void parent (Tool *tool)
 Set the tool parent.
Toolparent ()
 Get the tool parent.
Public Member Functions inherited from Aqua::CalcServer::Named
 Named (const std::string name)
 ~Named ()
void name (const std::string tool_name)
const std::string name () const
 Get the name.
Public Member Functions inherited from Aqua::CalcServer::Profiler
 Profiler ()
 ~Profiler ()
std::vector< Profile * > substages () const
 Get the substages.

Protected Member Functions

cl_event _execute (const std::vector< cl_event > events)
Protected Member Functions inherited from Aqua::CalcServer::Tool
int id_in_pipeline () const
std::string varPrefix () const
 Produce a variable name prefix.
void next_tool (Tool *tool)
void allocatedMemory (size_t mem_size)
virtual cl_event _execute (const UNUSED_PARAM std::vector< cl_event > events)
void setDependencies (std::vector< std::string > inputs, std::vector< std::string > outputs)
 Set the depedencies of the tool.
void setDependencies (std::vector< InputOutput::Variable * > inputs, std::vector< InputOutput::Variable * > outputs)
 Set the depedencies of the tool.
void setDependencies (std::vector< std::string > vars)
 Set the depedencies of the tool.
void setInputDependencies (std::vector< std::string > vars)
 Set the reading depedencies of the tool.
void setInputDependencies (std::vector< InputOutput::Variable * > vars)
 Set the reading depedencies of the tool.
void setOutputDependencies (std::vector< std::string > vars)
 Set the writing depedencies of the tool.
void setOutputDependencies (std::vector< InputOutput::Variable * > vars)
 Set the writing depedencies of the tool.
void setDependencies (std::vector< InputOutput::Variable * > vars)
 Set the depedencies of the tool.
const std::vector< cl_event > getEvents (dep_events which=dep_events::all) const
 Get the list of events that this tool shall wait for.
Protected Member Functions inherited from Aqua::CalcServer::Profiler
void substages (std::vector< Profile * > instances)
 Set the tool substages.

Additional Inherited Members

Protected Types inherited from Aqua::CalcServer::Tool
enum  dep_events { in = 0x01 , out = 0x02 , all = 0x03 }
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.

Detailed Description

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. That would take some time, depending of course 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, OVERWRITING 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.

Note
Since the mask array shall be sorted, arrays with a power of 2 length are required.

Constructor & Destructor Documentation

◆ MPISync()

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

Parameters
nameTool name
maskMask 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
fieldsFields to be synchronized between processes
procsProcesses 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
onceRun this tool just once. Useful to make initializations
Warning
The used mask will be overwritten
Here is the call graph for this function:

◆ ~MPISync()

Aqua::CalcServer::MPISync::~MPISync ( )

Destructor.

Member Function Documentation

◆ _execute()

cl_event Aqua::CalcServer::MPISync::_execute ( const std::vector< cl_event > events)
protected

Execute the tool

Parameters
eventsList of events that shall be waited before safe execution
Returns
OpenCL event to be waited before accessing the dependencies

◆ setup()

void Aqua::CalcServer::MPISync::setup ( )
virtual

Initialize the tool.

Reimplemented from Aqua::CalcServer::Tool.


The documentation for this class was generated from the following file: