ug4
|
#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 > | |
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 > | |
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< CommWrapper > | SPCommWrapper |
Smart-pointer that encapsulates a CommWrapper. More... | |
Private Attributes | |
SPCommWrapper | m_comm |
smart-pointer to an instance of a CommWrapper. More... | |
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.
|
private |
Smart-pointer that encapsulates a CommWrapper.
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.
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.
sendBuf | starting address of send buffer (choice) |
sendCount | number of elements in send buffer (integer) |
sendType | data type of send buffer elements (handle) |
recBuf | starting address of receive buffer (choice) |
recCount | number of elements received from any process (integer) |
recType | data 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().
void pcl::ProcessCommunicator::allgather | ( | ug::BinaryBuffer & | buf | ) | const |
allgather of BinaryBuffers
buf | Binary buffer in/out |
root | root processor |
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.
sendBuf | starting address of send buffer (choice) |
sendCount | number of elements in send buffer (integer) |
sendType | data type of send buffer elements (handle) |
recCounts | integer array (of length group size) containing the number of elements that are received from each process |
recBuf | starting address of receive buffer (choice) |
displs | integer array (of length group size). Entry i specifies the displacement (relative to recvbuf ) at which to place the incoming data from process i |
recType | data 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().
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().
size_t pcl::ProcessCommunicator::allreduce | ( | const size_t & | t, |
pcl::ReduceOperation | op | ||
) | const |
overload for size_t
References PCL_DT_UNSIGNED_LONG_LONG.
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().
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.
t | the input parameter |
op | the Reduce Operation |
References allreduce().
void pcl::ProcessCommunicator::allreduce | ( | const T * | pSendBuff, |
T * | pReceiveBuff, | ||
size_t | count, | ||
pcl::ReduceOperation | op | ||
) | const |
simplified allreduce for buffers.
pSendBuff | the input buffer |
pReceiveBuff | the output buffer |
count | number of elements in the input/output buffers |
op | the Reduce Operation |
References allreduce().
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().
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.
sendBuf | starting address of send buffer (choice) |
sendCount | number of elements to send to each process (integer) |
sendType | data type of send buffer elements (handle) |
recBuf | starting address of receive buffer (choice) |
recCount | number of elements to receive from each process (integer) |
recType | data type of receive buffer elements (handle) |
References ug::GetSize(), PCL_PROFILE, and UG_COND_THROW.
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().
void pcl::ProcessCommunicator::broadcast | ( | size_t & | s, |
int | root = 0 |
||
) | const |
overload for size_t
References s.
|
inline |
broadcast function for directly supported types
References broadcast().
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().
|
inline |
Bcast for objects
v | object to be broadcasted (uses Serialize/Deserialize) |
root | process that distributes data (default 0) |
References broadcast().
|
inline |
simplified broadcast for supported datatypes compiler error for unsupported datatypes you can cast to unsigned char to broadcast arbitrary fixed data
p | pointer to data |
size | number of T elements the pointer p is pointing to. default 1 |
root | process that distributes data (default 0) |
References broadcast(), p, and size().
void pcl::ProcessCommunicator::broadcast | ( | ug::BinaryBuffer & | buf, |
int | root = 0 |
||
) | const |
broadcast of BinaryBuffers
buf | Binary buffer in/out |
root | root 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().
void pcl::ProcessCommunicator::broadcast | ( | void * | v, |
size_t | size, | ||
DataType | type, | ||
int | root = 0 |
||
) | const |
performs a MPI_Bcast
v | pointer to data |
size | size of data |
type | type of data |
root | root process, that distributes data |
References PCL_PROFILE.
Referenced by broadcast(), ug::IDomain< TGrid, TSubsetHandler >::broadcast_refinement_projector(), ug::BroadcastGrid(), ug::ExpectedErrorMarkingStrategy< TDomain >::mark(), pcl::MinimalKeyValuePairAcrossAllProcs(), pcl::ParallelReadFile(), ug::GlobalAttachments::SynchronizeDeclaredGlobalAttachments(), and ug::IDomain< TGrid, TSubsetHandler >::update_subset_infos().
|
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.
|
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().
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().
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
References m_comm, pcl::NumProcs(), pcl::PCD_EMPTY, pcl::PCD_WORLD, PCL_COMM_WORLD, PCL_PROFILE, PCL_PROFILE_END, and UG_COND_THROW.
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.
recvBufOut | Received data will be written to this buffer. |
segSizesOut | Array to which the block-sizes received from each process will be written. Has to have size numRecvFroms. |
recvFromRanks | Array containing the ranks which send data to this process. Has to have size numRecvFroms. |
numRecvFroms | Specifies from how many processes this process will receive data. |
sendBuf | Contains the data which will be send to other processes. Make sure that it is big enough (sum of all sendSegSizes). |
sendSegSizes | The i-th entry corresponds to the block-size which will be send to the i-th process in sendToRanks. Has to have size numSendTos. |
sendToRanks | An array of process ids, which defines to where data shall be sent. Has to have size numSendTos. |
numSendTos | Specifies 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().
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.
recvBufs | Received data will be written to this buffers. This array has to be of the size numRecvs |
recvFromRanks | Array containing the ranks from which data shall be received. Has to have size numRecvs. |
numRecvs | Specifies from how many processes this process will receive data. |
sendBufs | Array of buffers whose data will be send to other processes. Has to be of size numSends |
sendToRanks | An array of process ids, which defines to where data shall be sent. Has to have size numSends. |
numSendTos | Specifies to how many processes data will be sent. |
References ug::BinaryBuffer::clear(), ug::GetDataPtr(), PCL_PROFILE, ug::BinaryBuffer::reserve(), and pcl::Waitall().
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.
pBufferOut | Received data is written to this buffer. Make sure that this buffer is big enough (sum of all seg-sizes). |
pBufferOutSegSizes | i-th entry corresponds to the size of the i-th segment of pBufferOut. |
pSenderProcMap | The processes from which data is received. |
numSenderProcs | The number of processes from which data is received. Has to be the same as the size of pBufferOutSegSizes and pSenderProcMap. |
pBuffer | Holds the data that is to be send to other processes. |
pBufferSegSizes | i-th entry corresponds to the size of the i-th segment in pBuffer. |
pRecvProcMap | ranks of processes to which data will be send. |
numRecvProcs | Number of processes in pRecvProcMap. Also corresponds to the size of pBufferSegSizes and to the number of segments in pBuffer. |
tag | This 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().
|
inline |
returns true if the communicator is empty, false if not.
References is_local(), m_comm, and pcl::ProcessCommunicator::CommWrapper::m_mpiComm.
Referenced by pcl::AllProcsTrue(), ug::Deserialize(), pcl::OneProcTrue(), pcl::operator<<(), ug::PartitionMultiGridLevel_ParmetisKway(), ug::Partitioner_DynamicBisection< TElem, dim >::perform_bisection(), ug::DoFDistribution::reinit_layouts_and_communicator(), and pcl::ToString().
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.
sendBuf | starting address of send buffer (choice) |
sendCount | number of elements in send buffer (integer) |
sendType | data type of send buffer elements (handle) |
recBuf | only significant for root process. All gathered data is written here. |
recCount | number of elements received from each process (integer) |
recType | data type of receive buffer elements (handle) |
root | The 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().
void pcl::ProcessCommunicator::gather | ( | ug::BinaryBuffer & | buf, |
int | root = 0 |
||
) | const |
gather of BinaryBuffers
buf | Binary buffer in/out |
root | root 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().
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.
sendBuf | starting address of send buffer (choice) |
sendCount | number of elements in send buffer (integer) |
sendType | data type of send buffer elements (handle) |
recCounts | integer array (of length group size) containing the number of elements that are received from each process. (Only significant at root) |
recBuf | starting address of receive buffer (choice) (Only significant at root) |
displs | integer 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) |
recType | data type of receive buffer elements (handle). (Only significant at root) |
root | The 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().
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().
int pcl::ProcessCommunicator::get_local_proc_id | ( | int | globalProcID = pcl::ProcRank() | ) | const |
returns the proc-id relative to this communicator
This method has a worst time complexity of O(n)
References PCL_COMM_WORLD, pcl::ProcRank(), UG_ASSERT, and UG_LOG.
Referenced by pcl::MultiGroupCommunicator::allreduce(), ug::ConstructParallelDualGraphMGLevel(), ug::GatherGrid(), ug::GenerateGlobalConsecutiveIndices(), pcl::TestLayoutIsDoubleEnded(), and pcl::WriteParallelArchive().
|
inline |
returns the mpi-communicator, in case someone needs it
References m_comm, and pcl::ProcessCommunicator::CommWrapper::m_mpiComm.
Referenced by pcl::MultiGroupCommunicator::allreduce(), ug::PartitionMultiGridLevel_ParmetisKway(), pcl::ReadCombinedParallelFile(), pcl::WriteCombinedParallelFile(), and pcl::WriteParallelArchive().
int pcl::ProcessCommunicator::get_proc_id | ( | size_t | index | ) | const |
returns the i-th process in the communicator
References PCL_COMM_WORLD, and pcl::ProcRank().
Referenced by pcl::MultiGroupCommunicator::allreduce(), ug::BuildOneToManyLayout(), ug::CollectMatrixOnOneProc(), pcl::CommunicateInvolvedProcesses(), ug::ConnectionViewer::GetParallelName(), ug::PrimalSubassembledMatrixInverse< TAlgebra >::init(), is_proc_id(), pcl::operator<<(), pcl::ParallelReadFile(), pcl::PrintPC(), pcl::ReadCombinedParallelFile(), pcl::SendRecvBuffersMatch(), pcl::SendRecvListsMatch(), ug::Serialize(), pcl::TestLayoutIsDoubleEnded(), pcl::ToString(), pcl::WriteCombinedParallelFile(), ug::ConnectionViewer::WriteMatrixPar(), and pcl::WriteParallelArchive().
|
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<<().
|
inline |
returns true if we are the i-th process in the communicator
References get_proc_id(), and pcl::ProcRank().
|
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().
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().
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.
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().
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
t | the input parameter |
op | the Reduce Operation |
rootProc | the process onto which the result will be reduced. |
References reduce().
void pcl::ProcessCommunicator::reduce | ( | const T * | pSendBuff, |
T * | pReceiveBuff, | ||
size_t | count, | ||
pcl::ReduceOperation | op, | ||
int | rootProc | ||
) | const |
simplified reduce for buffers.
pSendBuff | the input buffer |
pReceiveBuff | the output buffer |
count | number of elements in the input/output buffers |
op | the Reduce Operation |
rootProc | the process onto which the result will be reduced. |
References reduce().
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().
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
sendBuf | starting address of send buffer (choice) |
sendCount | number of elements in send buffer (integer) |
sendType | data type of send buffer elements (handle) |
recBuf | only significant for root process. All gathered data is written here. |
recCount | number of elements received from each process (integer) |
recType | data type of receive buffer elements (handle) |
root | The 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().
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.
pBuffer | Blocks of data. The i-th block is send to the i-th process of pRecProcMap. |
pBufferSegSizes | The i-th entry holds the size of the i-th block in pBuffer. |
pRecProcMap | The i-th entry holds the process-rank to which the i-th block shall be send. |
numRecProcs | The number of processes to which data shall be send. Note that pBufferSegSizes and pRecProcMap have to have numRecProcs entries. |
tag | A tag that tags the message. Use the same tag in receive_data. |
References PCL_PROFILE, UG_COND_THROW, and pcl::Waitall().
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_t pcl::ProcessCommunicator::size | ( | ) | const |
returns the size of the communicator
References UG_LOG.
Referenced by ug::AllGatherGrid(), allgatherv(), broadcast(), ug::BuildOneToManyLayout(), ug::CollectMatrixOnOneProc(), pcl::CommunicateInvolvedProcesses(), ug::ConstructParallelDualGraphMGLevel(), ug::LoadBalancer::estimate_distribution_quality_impl(), ug::GatherGrid(), gatherv(), ug::GenerateGlobalConsecutiveIndices(), ug::ConnectionViewer::GetParallelName(), ug::PrimalSubassembledMatrixInverse< TAlgebra >::init(), pcl::operator<<(), ug::PartitionMultiGridLevel_ParmetisKway(), pcl::PrintPC(), pcl::ReadCombinedParallelFile(), pcl::MultiGroupCommunicator::reinit(), pcl::SendRecvBuffersMatch(), pcl::SendRecvListsMatch(), ug::Serialize(), pcl::TestLayoutIsDoubleEnded(), pcl::ToString(), pcl::WriteCombinedParallelFile(), ug::ConnectionViewer::WriteMatrixPar(), and pcl::WriteParallelArchive().
|
private |
smart-pointer to an instance of a CommWrapper.
Referenced by create_communicator(), create_sub_communicator(), empty(), get_mpi_communicator(), is_local(), and is_world().