ug4
pcl::ProcessCommunicator Class Reference

#include <pcl_process_communicator.h>

Classes

struct  CommWrapper
 holds an mpi-communicator. More...
 

Public Member Functions

void allgather (const void *sendBuf, int sendCount, DataType sendType, void *recBuf, int recCount, DataType recType) const
 performs MPI_Allgather on the processes of the communicator. More...
 
void allgather (ug::BinaryBuffer &buf) const
 
void allgatherv (const void *sendBuf, int sendCount, DataType sendType, void *recBuf, int *recCounts, int *displs, DataType recType) const
 performs MPI_Allgatherv on the processes of the communicator. More...
 
template<class TValue >
void allgatherv (std::vector< TValue > &recBufOut, std::vector< TValue > &sendBuf, std::vector< int > *pSizesOut=NULL, std::vector< int > *pOffsetsOut=NULL) const
 gathers variable arrays on all processes. More...
 
size_t allreduce (const size_t &t, pcl::ReduceOperation op) const
 overload for size_t More...
 
template<typename T >
void allreduce (const std::vector< T > &send, std::vector< T > &receive, pcl::ReduceOperation op) const
 
template<typename T >
allreduce (const T &t, pcl::ReduceOperation op) const
 
template<typename T >
void allreduce (const T *pSendBuff, T *pReceiveBuff, size_t count, pcl::ReduceOperation op) const
 
void allreduce (const void *sendBuf, void *recBuf, int count, DataType type, ReduceOperation op) const
 performs MPI_Allreduce on the processes of the communicator. More...
 
void alltoall (const void *sendBuf, int sendCount, DataType sendType, void *recBuf, int recCount, DataType recType)
 performs MPI_Alltoall on the processes of the communicator. More...
 
void barrier () const
 this method will not return until all processes in the communicator have called it. More...
 
void broadcast (size_t &s, int root=0) const
 overload for size_t More...
 
template<typename T >
void broadcast (T &t, int root, DataTypeDirectlySupported d) const
 broadcast function for directly supported types More...
 
template<typename T >
void broadcast (T &t, int root, DataTypeIndirectlySupported d) const
 broadcast function for indirectly supported types (using Serialize/Deserialize) More...
 
template<typename T >
void broadcast (T &t, int root=0) const
 
template<typename T >
void broadcast (T *p, size_t size=1, int root=0) const
 
void broadcast (ug::BinaryBuffer &buf, int root=0) const
 
void broadcast (void *v, size_t size, DataType type, int root=0) const
 
ProcessCommunicator create_sub_communicator (bool participate) const
 creates a new communicator containing a subset of the current communicator More...
 
ProcessCommunicator create_sub_communicator (std::vector< int > &newProcs) const
 
void distribute_data (ug::BinaryBuffer &recvBufOut, int *segSizesOut, int *recvFromRanks, int numRecvFroms, void *sendBuf, int *sendSegSizes, int *sendToRanks, int numSendTos, int tag=1) const
 sends and receives data to/from multiple processes More...
 
void distribute_data (ug::BinaryBuffer *recvBufs, int *recvFromRanks, int numRecvs, ug::BinaryBuffer *sendBufs, int *sendToRanks, int numSendTos, int tag=1) const
 sends and receives data to/from multiple processes More...
 
void distribute_data (void *pBufferOut, int *pBufferOutSegSizes, int *pSenderProcMap, int numSenderProcs, void *pBuffer, int *pBufferSegSizes, int *pRecvProcMap, int numRecvProcs, int tag=1) const
 sends and receives data to / from multiple processes. More...
 
bool empty () const
 returns true if the communicator is empty, false if not. More...
 
void gather (const void *sendBuf, int sendCount, DataType sendType, void *recBuf, int recCount, DataType recType, int root) const
 performs MPI_Gather on the processes of the communicator. More...
 
void gather (ug::BinaryBuffer &buf, int root=0) const
 
void gatherv (const void *sendBuf, int sendCount, DataType sendType, void *recBuf, int *recCounts, int *displs, DataType recType, int root) const
 performs MPI_Gatherv on the processes of the communicator. More...
 
template<class TValue >
void gatherv (std::vector< TValue > &recBufOut, std::vector< TValue > &sendBuf, int root, std::vector< int > *pSizesOut=NULL, std::vector< int > *pOffsetsOut=NULL) const
 gathers variable arrays on one process. More...
 
int get_local_proc_id (int globalProcID=pcl::ProcRank()) const
 returns the proc-id relative to this communicator More...
 
MPI_Comm get_mpi_communicator () const
 returns the mpi-communicator, in case someone needs it More...
 
int get_proc_id (size_t index) const
 returns the i-th process in the communicator More...
 
bool is_local () const
 return true if the communicator is local, simulating current proc is the only proc More...
 
bool is_proc_id (size_t index) const
 returns true if we are the i-th process in the communicator More...
 
bool is_world () const
 return true if the communicator is PCD_WORLD More...
 
 ProcessCommunicator (ProcessCommunicatorDefaults pcd=PCD_WORLD)
 creates a communicator. More...
 
void receive_data (void *pBuffOut, int bufferSize, int srcProc, int tag) const
 receives data from srcPrc with the specified tag. More...
 
size_t reduce (const size_t &t, pcl::ReduceOperation op, int rootProc) const
 overload for size_t More...
 
template<typename T >
void reduce (const std::vector< T > &send, std::vector< T > &receive, pcl::ReduceOperation op, int rootProc) const
 
template<typename T >
reduce (const T &t, pcl::ReduceOperation op, int rootProc) const
 
template<typename T >
void reduce (const T *pSendBuff, T *pReceiveBuff, size_t count, pcl::ReduceOperation op, int rootProc) const
 
void reduce (const void *sendBuf, void *recBuf, int count, DataType type, ReduceOperation op, int rootProc) const
 performs MPI_Reduce on the processes of the communicator. More...
 
void scatter (const void *sendBuf, int sendCount, DataType sendType, void *recBuf, int recCount, DataType recType, int root) const
 performs MPI_Scatter on the processes of the communicator More...
 
void send_data (void *pBuffer, int *pBufferSegSizes, int *pRecProcMap, int numRecProcs, int tag) const
 sends data in different blocks of pBuffer to the processes in pRecProcMap. More...
 
void send_data (void *pBuffer, int bufferSize, int destProc, int tag) const
 sends data with the given tag to the specified process. More...
 
size_t size () const
 returns the size of the communicator More...
 

Static Public Member Functions

static ProcessCommunicator create_communicator (std::vector< int > &newGlobalProcs)
 
static ProcessCommunicator create_communicator (size_t first, size_t num)
 

Private Types

typedef SmartPtr< CommWrapperSPCommWrapper
 Smart-pointer that encapsulates a CommWrapper. More...
 

Private Attributes

SPCommWrapper m_comm
 smart-pointer to an instance of a CommWrapper. More...
 

Detailed Description

A ProcessCommunicator is a very lightweight object that can be passed by value. Creation using the constructor is a lightweight operation too. Creating a new communicator using create_sub_communicator however requires communication and thus shouldn't be unnecessarily called.

Please note that ProcessCommunicators created on different processes via create_sub_communicator(...) should be deleted at the same time - even if the creating processes are not part of the communicator.

Member Typedef Documentation

◆ SPCommWrapper

Smart-pointer that encapsulates a CommWrapper.

Constructor & Destructor Documentation

◆ ProcessCommunicator()

pcl::ProcessCommunicator::ProcessCommunicator ( ProcessCommunicatorDefaults  pcd = PCD_WORLD)

creates a communicator.

By default a communicator for all processes is generated.

References pcl::PCD_EMPTY, pcl::PCD_LOCAL, pcl::PCD_WORLD, and PCL_COMM_WORLD.

Member Function Documentation

◆ allgather() [1/2]

void pcl::ProcessCommunicator::allgather ( const void *  sendBuf,
int  sendCount,
DataType  sendType,
void *  recBuf,
int  recCount,
DataType  recType 
) const

performs MPI_Allgather on the processes of the communicator.

This method synchronises involved processes.

Parameters
sendBufstarting address of send buffer (choice)
sendCountnumber of elements in send buffer (integer)
sendTypedata type of send buffer elements (handle)
recBufstarting address of receive buffer (choice)
recCountnumber of elements received from any process (integer)
recTypedata type of receive buffer elements (handle)

References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.

Referenced by ug::AllGatherGrid(), allgatherv(), pcl::CommunicateInvolvedProcesses(), and ug::ConstructParallelDualGraphMGLevel().

◆ allgather() [2/2]

void pcl::ProcessCommunicator::allgather ( ug::BinaryBuffer buf) const

allgather of BinaryBuffers

Parameters
bufBinary buffer in/out
rootroot processor

◆ allgatherv() [1/2]

void pcl::ProcessCommunicator::allgatherv ( const void *  sendBuf,
int  sendCount,
DataType  sendType,
void *  recBuf,
int *  recCounts,
int *  displs,
DataType  recType 
) const

performs MPI_Allgatherv on the processes of the communicator.

This method synchronises involved processes.

Parameters
sendBufstarting address of send buffer (choice)
sendCountnumber of elements in send buffer (integer)
sendTypedata type of send buffer elements (handle)
recCountsinteger array (of length group size) containing the number of elements that are received from each process
recBufstarting address of receive buffer (choice)
displsinteger array (of length group size). Entry i specifies the displacement (relative to recvbuf ) at which to place the incoming data from process i
recTypedata type of receive buffer elements (handle)

References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.

Referenced by allgatherv(), pcl::CommunicateInvolvedProcesses(), ug::PrimalSubassembledMatrixInverse< TAlgebra >::init(), and pcl::MultiGroupCommunicator::reinit().

◆ allgatherv() [2/2]

template<class TValue >
void pcl::ProcessCommunicator::allgatherv ( std::vector< TValue > &  recBufOut,
std::vector< TValue > &  sendBuf,
std::vector< int > *  pSizesOut = NULL,
std::vector< int > *  pOffsetsOut = NULL 
) const

gathers variable arrays on all processes.

The arrays specified in sendBuf will be copied to all processes in the ProcessCommunicator. The order of the arrays in recBufOut is the same as the order of the sending processes in this ProcessCommnicator. You can optionally specify an array pSizesOut, which will be filled with the size of the array that was received from each process and an array in which the offsets of each array are stored - that means the first index of each array - again in the order of processes in this ProcessCommunicator.

Note that recBufOut, pSizesOut and pOffsetsOut will be resized as required.

Please note that this method communicates twice.

References allgather(), allgatherv(), ug::GetDataPtr(), is_local(), PCL_DT_BYTE, PCL_DT_INT, and size().

◆ allreduce() [1/5]

size_t pcl::ProcessCommunicator::allreduce ( const size_t &  t,
pcl::ReduceOperation  op 
) const

overload for size_t

References PCL_DT_UNSIGNED_LONG_LONG.

◆ allreduce() [2/5]

template<typename T >
void pcl::ProcessCommunicator::allreduce ( const std::vector< T > &  send,
std::vector< T > &  receive,
pcl::ReduceOperation  op 
) const

simplified allreduce for std::vector. The receive-buffer is automatically resized as required.

References allreduce().

◆ allreduce() [3/5]

template<typename T >
T pcl::ProcessCommunicator::allreduce ( const T &  t,
pcl::ReduceOperation  op 
) const

simplified allreduce for size=1. calls allreduce for parameter t, and then returns the result.

Parameters
tthe input parameter
opthe Reduce Operation
Returns
the reduced result

References allreduce().

◆ allreduce() [4/5]

template<typename T >
void pcl::ProcessCommunicator::allreduce ( const T *  pSendBuff,
T *  pReceiveBuff,
size_t  count,
pcl::ReduceOperation  op 
) const

simplified allreduce for buffers.

Parameters
pSendBuffthe input buffer
pReceiveBuffthe output buffer
countnumber of elements in the input/output buffers
opthe Reduce Operation

References allreduce().

◆ allreduce() [5/5]

void pcl::ProcessCommunicator::allreduce ( const void *  sendBuf,
void *  recBuf,
int  count,
DataType  type,
ReduceOperation  op 
) const

performs MPI_Allreduce on the processes of the communicator.

This method synchronises involved processes.

References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.

Referenced by pcl::AllProcsTrue(), allreduce(), ug::ApplySmoothManifoldPosToTopLevelButterflyScheme(), ug::ApplySmoothManifoldPosToTopLevelLoopScheme(), ug::ApplySmoothSubdivisionSurfacesToTopLevel(), ug::ApplySmoothSubdivisionVolumesToTopLevel(), ug::Partitioner_DynamicBisection< TElem, dim >::bisect_elements(), ug::Partitioner_DynamicBisection< TElem, dim >::calculate_global_dimensions(), ug::CalculateNumManifoldEdgesVertexAttachmentInParentLevel(), ug::CalculateSmoothCreaseManifoldPosInParentLevelLoopScheme(), ug::CalculateSmoothManifoldPosInParentLevelButterflyScheme(), ug::CalculateSmoothManifoldPosInParentLevelLoopScheme(), ug::CheckGFValuesWithinBounds(), ug::MemInfo::communicate_process_values(), ug::ComputeAvg(), ug::ComputeMinMax(), ug::ParallelHangingNodeRefiner_MultiGrid::contains_edges(), ug::ParallelHangingNodeRefiner_MultiGrid::contains_faces(), ug::ParallelHangingNodeRefiner_MultiGrid::contains_volumes(), ug::GridFunctionComponentSpace< TGridFunction >::distance2(), ug::LoadBalancer::estimate_distribution_quality(), ug::LoadBalancer::estimate_distribution_quality_impl(), ug::bridge::Evaluate::NumberValuedUserDataEvaluator< TDomain, TAlgebra >::evaluate(), ug::bridge::Evaluate::VectorValuedUserDataEvaluator< TDomain, TAlgebra >::evaluate(), ug::GlobalGridFunctionNumberData< TGridFunction, elemDim >::evaluate_global(), ug::GetMaxEdgeLength(), ug::Partitioner_DynamicBisection< TElem, dim >::improve_split_values(), ug::Integral(), ug::IntegralNormalComponentOnManifoldSubsets(), ug::IntegrateDiscFlux(), ug::IntegrateNormalComponentOnManifold(), ug::IntegrateNormalGradientOnManifold(), ug::IntegrateSubsets(), ug::ExpectedErrorMarkingStrategy< TDomain >::mark(), ug::MeanValueMarking< TDomain >::mark(), ug::AbsoluteMarking< TDomain >::mark(), ug::VarianceMarking< TDomain >::mark(), ug::VarianceMarkingEta< TDomain >::mark(), ug::MaximumMarking< TDomain >::mark(), ug::APosterioriCoarsening< TDomain >::mark(), ug::MarkElements(), ug::MarkElementsAbsolute(), ug::MarkElementsForCoarsening(), ug::MarkElementsForRefinement(), ug::MarkForAdaption_GradientAverage(), ug::MarkForAdaption_GradientJump(), ug::MarkForAdaption_L2ErrorExact(), ug::MarkForAdaption_ResidualErrorP1Absolute(), ug::MarkForAdaption_ResidualErrorP1Relative(), ug::MarkOutOfRangeElems(), ug::MaxElementDiameter(), ug::MinElementDiameter(), ug::CompositeConvCheck< TVector, TDomain >::norm(), ug::GridFunctionComponentSpace< TGridFunction >::norm2(), ug::IRefiner::num_marked_edges(), ug::IRefiner::num_marked_elements(), ug::IRefiner::num_marked_faces(), ug::IRefiner::num_marked_volumes(), pcl::OneProcTrue(), ug::bridge::ParallelMax(), ug::bridge::ParallelMin(), ug::bridge::ParallelSum(), ug::bridge::ParallelVecMax(), ug::bridge::ParallelVecMin(), ug::bridge::ParallelVecSum(), ug::Partitioner_DynamicBisection< TElem, dim >::partition(), ug::Partitioner_DynamicBisection< TElem, dim >::perform_bisection(), ug::LocalSchurComplement< TAlgebra >::print_statistic_of_inner_solver(), ug::PrimalSubassembledMatrixInverse< TAlgebra >::print_statistic_of_inner_solver(), ug::PrintElementEdgeRatios(), ug::ProjectHierarchyToSubdivisionLimit(), ug::SurfaceView::refresh_surface_states(), ug::DoFCount::sum_values_over_procs(), ug::SumGFValuesAt(), ug::SynchronizeAttachedGlobalAttachments(), ug::GlobalAttachments::SynchronizeDeclaredGlobalAttachments(), and ug::TestGridLayoutMap().

◆ alltoall()

void pcl::ProcessCommunicator::alltoall ( const void *  sendBuf,
int  sendCount,
DataType  sendType,
void *  recBuf,
int  recCount,
DataType  recType 
)

performs MPI_Alltoall on the processes of the communicator.

All processes send (the same amount of) data to all processes. The receive buffer needs to have the appropriate size.

Parameters
sendBufstarting address of send buffer (choice)
sendCountnumber of elements to send to each process (integer)
sendTypedata type of send buffer elements (handle)
recBufstarting address of receive buffer (choice)
recCountnumber of elements to receive from each process (integer)
recTypedata type of receive buffer elements (handle)

References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.

◆ barrier()

void pcl::ProcessCommunicator::barrier ( ) const

this method will not return until all processes in the communicator have called it.

References PCL_PROFILE.

Referenced by pcl::SynchronizeProcesses().

◆ broadcast() [1/7]

void pcl::ProcessCommunicator::broadcast ( size_t &  s,
int  root = 0 
) const

overload for size_t

References s.

◆ broadcast() [2/7]

template<typename T >
void pcl::ProcessCommunicator::broadcast ( T &  t,
int  root,
DataTypeDirectlySupported  d 
) const
inline

broadcast function for directly supported types

References broadcast().

◆ broadcast() [3/7]

template<typename T >
void pcl::ProcessCommunicator::broadcast ( T &  t,
int  root,
DataTypeIndirectlySupported  d 
) const

broadcast function for indirectly supported types (using Serialize/Deserialize)

References broadcast(), ug::Deserialize(), pcl::ProcRank(), and ug::Serialize().

◆ broadcast() [4/7]

template<typename T >
void pcl::ProcessCommunicator::broadcast ( T &  t,
int  root = 0 
) const
inline

Bcast for objects

Parameters
vobject to be broadcasted (uses Serialize/Deserialize)
rootprocess that distributes data (default 0)
See also
Serialize, Deserialize

References broadcast().

◆ broadcast() [5/7]

template<typename T >
void pcl::ProcessCommunicator::broadcast ( T *  p,
size_t  size = 1,
int  root = 0 
) const
inline

simplified broadcast for supported datatypes compiler error for unsupported datatypes you can cast to unsigned char to broadcast arbitrary fixed data

Parameters
ppointer to data
sizenumber of T elements the pointer p is pointing to. default 1
rootprocess that distributes data (default 0)

References broadcast(), p, and size().

◆ broadcast() [6/7]

void pcl::ProcessCommunicator::broadcast ( ug::BinaryBuffer buf,
int  root = 0 
) const

broadcast of BinaryBuffers

Parameters
bufBinary buffer in/out
rootroot processor

References ug::BinaryBuffer::buffer(), PCL_DT_CHAR, PCL_DT_LONG, pcl::ProcRank(), ug::BinaryBuffer::reserve(), ug::BinaryBuffer::set_write_pos(), and ug::BinaryBuffer::write_pos().

◆ broadcast() [7/7]

void pcl::ProcessCommunicator::broadcast ( void *  v,
size_t  size,
DataType  type,
int  root = 0 
) const

◆ create_communicator() [1/2]

ProcessCommunicator pcl::ProcessCommunicator::create_communicator ( size_t  first,
size_t  num 
)
static

Make sure that all processes call this method with the same parameters!

References m_comm, pcl::PCD_EMPTY, pcl::PCD_WORLD, and PCL_COMM_WORLD.

◆ create_communicator() [2/2]

ProcessCommunicator pcl::ProcessCommunicator::create_communicator ( std::vector< int > &  newGlobalProcs)
static

Make sure that all processes call this method with the same parameters!

References m_comm, pcl::PCD_EMPTY, pcl::PCD_WORLD, and PCL_COMM_WORLD.

Referenced by ug::ProcessHierarchy::add_hierarchy_level(), and ug::Deserialize().

◆ create_sub_communicator() [1/2]

ProcessCommunicator pcl::ProcessCommunicator::create_sub_communicator ( bool  participate) const

creates a new communicator containing a subset of the current communicator

Note that this method has to be called by all processes in the current communicator - even if they don't want to participate in the new one.

References pcl::PCD_EMPTY, PCL_DEBUG_BARRIER, PCL_DT_INT, PCL_PROFILE, PCL_RO_MAX, and UG_COND_THROW.

Referenced by ug::FetiLayouts< TAlgebra >::create_layouts(), ug::ParallelDualGraph< TGeomBaseObj, TIndexType, TConnectingObj >::generate_graph(), ug::PartitionMultiGridLevel_ParmetisKway(), and ug::DoFDistribution::reinit_layouts_and_communicator().

◆ create_sub_communicator() [2/2]

ProcessCommunicator pcl::ProcessCommunicator::create_sub_communicator ( std::vector< int > &  newProcs) const

Make sure that all processes which participate in the current communicator call this method with the same parameters! Process indices are to be specified relative to the current communicator.

note: ranks in newProcs are ranks in the (group!) communicator m_comm->m_mpiComm

See also
create_communicator

References m_comm, pcl::NumProcs(), pcl::PCD_EMPTY, pcl::PCD_WORLD, PCL_COMM_WORLD, PCL_PROFILE, PCL_PROFILE_END, and UG_COND_THROW.

◆ distribute_data() [1/3]

void pcl::ProcessCommunicator::distribute_data ( ug::BinaryBuffer recvBufOut,
int *  segSizesOut,
int *  recvFromRanks,
int  numRecvFroms,
void *  sendBuf,
int *  sendSegSizes,
int *  sendToRanks,
int  numSendTos,
int  tag = 1 
) const

sends and receives data to/from multiple processes

This method automatically determines the size of the distributed data and writes it to a binary stream. Note that it has to communicate twice, since the buffer-sizes also have to be communicated.

Parameters
recvBufOutReceived data will be written to this buffer.
segSizesOutArray to which the block-sizes received from each process will be written. Has to have size numRecvFroms.
recvFromRanksArray containing the ranks which send data to this process. Has to have size numRecvFroms.
numRecvFromsSpecifies from how many processes this process will receive data.
sendBufContains the data which will be send to other processes. Make sure that it is big enough (sum of all sendSegSizes).
sendSegSizesThe i-th entry corresponds to the block-size which will be send to the i-th process in sendToRanks. Has to have size numSendTos.
sendToRanksAn array of process ids, which defines to where data shall be sent. Has to have size numSendTos.
numSendTosSpecifies to how many processes data will be sent.

References ug::BinaryBuffer::buffer(), ug::GetDataPtr(), PCL_PROFILE, ug::BinaryBuffer::reserve(), and ug::BinaryBuffer::set_write_pos().

◆ distribute_data() [2/3]

void pcl::ProcessCommunicator::distribute_data ( ug::BinaryBuffer recvBufs,
int *  recvFromRanks,
int  numRecvs,
ug::BinaryBuffer sendBufs,
int *  sendToRanks,
int  numSendTos,
int  tag = 1 
) const

sends and receives data to/from multiple processes

Note that it has to communicate twice, since the buffer-sizes also have to be communicated.

Parameters
recvBufsReceived data will be written to this buffers. This array has to be of the size numRecvs
recvFromRanksArray containing the ranks from which data shall be received. Has to have size numRecvs.
numRecvsSpecifies from how many processes this process will receive data.
sendBufsArray of buffers whose data will be send to other processes. Has to be of size numSends
sendToRanksAn array of process ids, which defines to where data shall be sent. Has to have size numSends.
numSendTosSpecifies to how many processes data will be sent.

References ug::BinaryBuffer::clear(), ug::GetDataPtr(), PCL_PROFILE, ug::BinaryBuffer::reserve(), and pcl::Waitall().

◆ distribute_data() [3/3]

void pcl::ProcessCommunicator::distribute_data ( void *  pBufferOut,
int *  pBufferOutSegSizes,
int *  pSenderProcMap,
int  numSenderProcs,
void *  pBuffer,
int *  pBufferSegSizes,
int *  pRecvProcMap,
int  numRecvProcs,
int  tag = 1 
) const

sends and receives data to / from multiple processes.

Parameters
pBufferOutReceived data is written to this buffer. Make sure that this buffer is big enough (sum of all seg-sizes).
pBufferOutSegSizesi-th entry corresponds to the size of the i-th segment of pBufferOut.
pSenderProcMapThe processes from which data is received.
numSenderProcsThe number of processes from which data is received. Has to be the same as the size of pBufferOutSegSizes and pSenderProcMap.
pBufferHolds the data that is to be send to other processes.
pBufferSegSizesi-th entry corresponds to the size of the i-th segment in pBuffer.
pRecvProcMapranks of processes to which data will be send.
numRecvProcsNumber of processes in pRecvProcMap. Also corresponds to the size of pBufferSegSizes and to the number of segments in pBuffer.
tagThis tag will be used to identify send and received messages. Default: 1

References PCL_PROFILE, UG_COND_THROW, and pcl::Waitall().

Referenced by ug::DistributeGrid().

◆ empty()

◆ gather() [1/2]

void pcl::ProcessCommunicator::gather ( const void *  sendBuf,
int  sendCount,
DataType  sendType,
void *  recBuf,
int  recCount,
DataType  recType,
int  root 
) const

performs MPI_Gather on the processes of the communicator.

This method synchronises involved processes.

Parameters
sendBufstarting address of send buffer (choice)
sendCountnumber of elements in send buffer (integer)
sendTypedata type of send buffer elements (handle)
recBufonly significant for root process. All gathered data is written here.
recCountnumber of elements received from each process (integer)
recTypedata type of receive buffer elements (handle)
rootThe rank of the process that receives all the data.

References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.

Referenced by ug::BuildOneToManyLayout(), ug::GatherGrid(), gatherv(), ug::GenerateGlobalConsecutiveIndices(), pcl::MinimalKeyValuePairAcrossAllProcs(), pcl::SendRecvBuffersMatch(), and pcl::SendRecvListsMatch().

◆ gather() [2/2]

void pcl::ProcessCommunicator::gather ( ug::BinaryBuffer buf,
int  root = 0 
) const

gather of BinaryBuffers

Parameters
bufBinary buffer in/out
rootroot processor

References ug::BinaryBuffer::buffer(), PCL_DT_CHAR, PCL_DT_INT, pcl::ProcRank(), ug::BinaryBuffer::reserve(), ug::BinaryBuffer::set_write_pos(), and ug::BinaryBuffer::write_pos().

◆ gatherv() [1/2]

void pcl::ProcessCommunicator::gatherv ( const void *  sendBuf,
int  sendCount,
DataType  sendType,
void *  recBuf,
int *  recCounts,
int *  displs,
DataType  recType,
int  root 
) const

performs MPI_Gatherv on the processes of the communicator.

This method synchronises involved processes.

Parameters
sendBufstarting address of send buffer (choice)
sendCountnumber of elements in send buffer (integer)
sendTypedata type of send buffer elements (handle)
recCountsinteger array (of length group size) containing the number of elements that are received from each process. (Only significant at root)
recBufstarting address of receive buffer (choice) (Only significant at root)
displsinteger array (of length group size). Entry i specifies the displacement (relative to recvbuf ) at which to place the incoming data from process i. (Only significant at root)
recTypedata type of receive buffer elements (handle). (Only significant at root)
rootThe rank of the process that receives all the data.

References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.

Referenced by ug::BuildOneToManyLayout(), gatherv(), and ug::ExpectedErrorMarkingStrategy< TDomain >::mark().

◆ gatherv() [2/2]

template<class TValue >
void pcl::ProcessCommunicator::gatherv ( std::vector< TValue > &  recBufOut,
std::vector< TValue > &  sendBuf,
int  root,
std::vector< int > *  pSizesOut = NULL,
std::vector< int > *  pOffsetsOut = NULL 
) const

gathers variable arrays on one process.

The arrays specified in sendBuf will be copied to recBufOut on root. recBufOut is thus only important on root. The order of the arrays is the same as the order of the sending processes in this ProcessCommnicator. You can optionally specify an array pSizesOut, which will be filled with the size of the array that was received from each process (only relevant on root) and an array in which the offsets of each array are stored - that means the first index of each array - again in the order of processes in this ProcessCommunicator (only relevant on root, too).

Note that recBufOut, pSizesOut and pOffsetsOut will be resized as required.

Please note that this method communicates twice.

References gather(), gatherv(), ug::GetDataPtr(), is_local(), PCL_DT_BYTE, PCL_DT_INT, and size().

◆ get_local_proc_id()

int pcl::ProcessCommunicator::get_local_proc_id ( int  globalProcID = pcl::ProcRank()) const

◆ get_mpi_communicator()

MPI_Comm pcl::ProcessCommunicator::get_mpi_communicator ( ) const
inline

◆ get_proc_id()

◆ is_local()

bool pcl::ProcessCommunicator::is_local ( ) const
inline

return true if the communicator is local, simulating current proc is the only proc

References m_comm, and SmartPtr< T, FreePolicy >::valid().

Referenced by allgatherv(), pcl::AllProcsTrue(), empty(), gatherv(), is_world(), pcl::OneProcTrue(), and pcl::operator<<().

◆ is_proc_id()

bool pcl::ProcessCommunicator::is_proc_id ( size_t  index) const
inline

returns true if we are the i-th process in the communicator

References get_proc_id(), and pcl::ProcRank().

◆ is_world()

bool pcl::ProcessCommunicator::is_world ( ) const
inline

return true if the communicator is PCD_WORLD

References is_local(), m_comm, pcl::ProcessCommunicator::CommWrapper::m_mpiComm, and PCL_COMM_WORLD.

Referenced by ug::Deserialize(), pcl::operator<<(), ug::Serialize(), and pcl::ToString().

◆ receive_data()

void pcl::ProcessCommunicator::receive_data ( void *  pBuffOut,
int  bufferSize,
int  srcProc,
int  tag 
) const

receives data from srcPrc with the specified tag.

This method waits until the data has been received

References pcl::MPI_Wait(), PCL_PROFILE, and UG_COND_THROW.

Referenced by ug::BGLParallelMatrix< T >::refresh().

◆ reduce() [1/5]

size_t pcl::ProcessCommunicator::reduce ( const size_t &  t,
pcl::ReduceOperation  op,
int  rootProc 
) const

overload for size_t

References PCL_DT_UNSIGNED_LONG_LONG.

◆ reduce() [2/5]

template<typename T >
void pcl::ProcessCommunicator::reduce ( const std::vector< T > &  send,
std::vector< T > &  receive,
pcl::ReduceOperation  op,
int  rootProc 
) const

simplified reduce for std::vector. The receive-buffer is automatically resized as required.

References reduce().

◆ reduce() [3/5]

template<typename T >
T pcl::ProcessCommunicator::reduce ( const T &  t,
pcl::ReduceOperation  op,
int  rootProc 
) const

simplified reduce for size=1. calls reduce for parameter t, and then returns the result compiler error for unsupported datatypes

Parameters
tthe input parameter
opthe Reduce Operation
rootProcthe process onto which the result will be reduced.
Returns
the reduced result

References reduce().

◆ reduce() [4/5]

template<typename T >
void pcl::ProcessCommunicator::reduce ( const T *  pSendBuff,
T *  pReceiveBuff,
size_t  count,
pcl::ReduceOperation  op,
int  rootProc 
) const

simplified reduce for buffers.

Parameters
pSendBuffthe input buffer
pReceiveBuffthe output buffer
countnumber of elements in the input/output buffers
opthe Reduce Operation
rootProcthe process onto which the result will be reduced.

References reduce().

◆ reduce() [5/5]

void pcl::ProcessCommunicator::reduce ( const void *  sendBuf,
void *  recBuf,
int  count,
DataType  type,
ReduceOperation  op,
int  rootProc 
) const

performs MPI_Reduce on the processes of the communicator.

This method synchronises involved processes.

References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.

Referenced by reduce(), and ug::DoFCount::sum_values_over_procs().

◆ scatter()

void pcl::ProcessCommunicator::scatter ( const void *  sendBuf,
int  sendCount,
DataType  sendType,
void *  recBuf,
int  recCount,
DataType  recType,
int  root 
) const

performs MPI_Scatter on the processes of the communicator

Parameters
sendBufstarting address of send buffer (choice)
sendCountnumber of elements in send buffer (integer)
sendTypedata type of send buffer elements (handle)
recBufonly significant for root process. All gathered data is written here.
recCountnumber of elements received from each process (integer)
recTypedata type of receive buffer elements (handle)
rootThe rank of the process that receives all the data.

References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.

Referenced by ug::GenerateGlobalConsecutiveIndices(), and ug::ExpectedErrorMarkingStrategy< TDomain >::mark().

◆ send_data() [1/2]

void pcl::ProcessCommunicator::send_data ( void *  pBuffer,
int *  pBufferSegSizes,
int *  pRecProcMap,
int  numRecProcs,
int  tag 
) const

sends data in different blocks of pBuffer to the processes in pRecProcMap.

This method synchronises involved processes. Call receive_data on the processes in pRecProcMap to receive the sent data.

Parameters
pBufferBlocks of data. The i-th block is send to the i-th process of pRecProcMap.
pBufferSegSizesThe i-th entry holds the size of the i-th block in pBuffer.
pRecProcMapThe i-th entry holds the process-rank to which the i-th block shall be send.
numRecProcsThe number of processes to which data shall be send. Note that pBufferSegSizes and pRecProcMap have to have numRecProcs entries.
tagA tag that tags the message. Use the same tag in receive_data.

References PCL_PROFILE, UG_COND_THROW, and pcl::Waitall().

◆ send_data() [2/2]

void pcl::ProcessCommunicator::send_data ( void *  pBuffer,
int  bufferSize,
int  destProc,
int  tag 
) const

sends data with the given tag to the specified process.

This method waits until the data has been sent.

References pcl::MPI_Wait(), PCL_PROFILE, and UG_COND_THROW.

Referenced by ug::BGLParallelMatrix< T >::refresh().

◆ size()

Member Data Documentation

◆ m_comm

SPCommWrapper pcl::ProcessCommunicator::m_comm
private

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