33 #ifndef __H__LIB_ALGEBRA__PARALLELIZATION__PARALLELIZATION_UTIL__
34 #define __H__LIB_ALGEBRA__PARALLELIZATION__PARALLELIZATION_UTIL__
46 #define PROFILE_PARALLELIZATION_UTIL
47 #ifdef PROFILE_PARALLELIZATION_UTIL
48 #define PU_PROFILE_FUNC() PROFILE_FUNC()
49 #define PU_PROFILE_BEGIN(name) PROFILE_BEGIN(name)
50 #define PU_PROFILE_END(name) PROFILE_END_(name)
52 #define PU_PROFILE_FUNC()
53 #define PU_PROFILE_BEGIN(name)
54 #define PU_PROFILE_END(name)
80 template <
class TLayout>
82 std::vector<AlgebraID>& idsOut,
84 const TLayout& masterLayout,
85 const TLayout& slaveLayout)
89 idsOut.resize(numIDs);
91 for(
size_t i = 0; i < numIDs; ++i)
97 communicator.
send_data(masterLayout, copyPol);
105 template <
typename TMatrix>
110 vector<AlgebraID> globalIDs;
111 const IndexLayout& masters = mat.layouts()->master();
112 const IndexLayout& slaves = mat.layouts()->slave();
125 template <
typename TMatrix>
130 vector<AlgebraID> globalIDs;
131 const IndexLayout& masters = mat.layouts()->master();
132 const IndexLayout& slaves = mat.layouts()->slave();
159 template <
typename TVector>
203 template <
typename TVector>
227 template <
typename TVector>
260 template <
typename TVector>
277 com.
send_data(slaveLayout, cpVecAddSetZero);
288 template <
typename TVector>
297 iter != interface.
end(); ++iter)
303 (*pVec)[index] = val;
314 template <
typename TVector>
325 for(; iter != end; ++iter)
332 iter != interface.end(); ++iter)
338 (*pVec)[index] = val;
349 template <
typename TVector>
360 for(; iter != end; ++iter)
367 iter != interface.end(); ++iter)
373 (*pVec)[index] *= scale;
387 template <
typename TVector>
405 template <
typename TVector>
422 com.
send_data(slaveLayout, cpVecSubtract);
429 com.
send_data(masterLayout, cpVecScaleCopy);
444 template <
typename TVector>
462 com.
send_data(slaveLayout, cpVecSubtractOOS);
481 template <
typename TVector>
528 std::vector<std::vector<int> >& connectionsToSubDomsOut,
555 std::vector<int>* pNewMasterIDsOut = NULL);
587 template <
typename TMatrix,
typename TVector>
589 const TMatrix* pMatrix,
597 for(; iter != end; ++iter)
603 iter != interface.end(); ++iter)
610 for(
size_t beta = 0; beta < (size_t)
GetCols(block); ++beta)
627 template <
typename TMatrix,
typename TVector>
629 const TVector* pDiagVector,
637 for(; iter != end; ++iter)
643 iter != interface.end(); ++iter)
650 for(
size_t beta = 0; beta < (size_t)
GetCols(block); ++beta)
669 template <
typename TAlgebra>
678 typename TAlgebra::vector_type vecDiag;
681 vecDiag.resize(pMat->num_rows());
707 template <
typename TVector>
708 void VecGather( TVector* pVecDest,
const TVector* pVecSrc,
741 template <
typename TVector>
758 com.
send_data(masterLayoutSrc, cpVecCopy);
773 template<
typename TLayout>
774 typename TLayout::iterator
find_pid(TLayout &layout,
int pid)
776 for(
typename TLayout::iterator it = layout.begin(); it != layout.end(); ++it)
777 if(layout.proc_id(it) == pid)
return it;
789 template <
class TIndVec>
791 const AlgebraLayouts& layouts);
800 template <
class TMatrix>
803 std::vector<AlgebraID>* algebraIDs = NULL,
location verbose
Definition: checkpoint_util.lua:128
Definition: smart_pointer.h:108
Definition: pcl_domain_decomposition.h:43
Performs communication between interfaces on different processes.
Definition: pcl_interface_communicator.h:68
bool communicate(int tag=749345)
sends and receives the collected data.
Definition: pcl_interface_communicator_impl.hpp:409
void send_data(int targetProc, const Interface &interface, ICommunicationPolicy< TLayout > &commPol)
collects data that will be send during communicate.
Definition: pcl_interface_communicator_impl.hpp:80
void receive_data(int srcProc, const Interface &interface, ICommunicationPolicy< TLayout > &commPol)
registers a communication-policy to receive data on communicate.
Definition: pcl_interface_communicator_impl.hpp:188
You may add elements to this interface and iterate over them.
Definition: pcl_communication_structs.h:207
iterator end()
Definition: pcl_communication_structs.h:293
iterator begin()
Definition: pcl_communication_structs.h:292
Element & get_element(iterator iter)
Definition: pcl_communication_structs.h:298
Definition: pcl_process_communicator.h:70
iterator end(size_t level=0)
returns the iterator to the last interface of the layout.
Definition: pcl_communication_structs.h:492
iterator begin(size_t level=0)
returns the iterator to the first interface of the layout.
Definition: pcl_communication_structs.h:486
InterfaceMap::const_iterator const_iterator
Definition: pcl_communication_structs.h:477
Communication Policy to copy slave couplings to master row.
Definition: communication_policies.h:1143
Communication Policy to copy couplings between interfaces.
Definition: communication_policies.h:1273
Communication Policy to add values of a vector.
Definition: communication_policies.h:319
Communication Policy to add values of a vector and reset value to zero on sending interface.
Definition: communication_policies.h:564
Communication Policy to copy values of a vector.
Definition: communication_policies.h:88
Communication Policy to copy scaled values of a vector.
Definition: communication_policies.h:204
Communication Policy to subtract values of a vector.
Definition: communication_policies.h:679
Communication Policy to subtract only one slave value per master of a vector.
Definition: communication_policies.h:881
Holds Interfaces and communicators for horizontal communication.
Definition: algebra_layouts.h:48
const pcl::ProcessCommunicator & proc_comm() const
returns process communicator
Definition: algebra_layouts.h:68
const IndexLayout & slave() const
Definition: algebra_layouts.h:63
const IndexLayout & master() const
Definition: algebra_layouts.h:61
pcl::InterfaceCommunicator< IndexLayout > & comm() const
returns (non-const !!!) communicator
Definition: algebra_layouts.h:78
void ScaleLayoutValues(TVector *pVec, const IndexLayout &layout, number scale)
scales the values of a vector by a given number only on the layout indices
Definition: parallelization_util.h:350
void ConsistentToUnique(TVector *pVec, const IndexLayout &slaveLayout)
changes parallel storage type from consistent to unique
Definition: parallelization_util.h:388
void GenerateGlobalAlgebraIDs(pcl::InterfaceCommunicator< TLayout > &communicator, std::vector< AlgebraID > &idsOut, size_t numIDs, const TLayout &masterLayout, const TLayout &slaveLayout)
Generates a set of unique global algebra ids.
Definition: parallelization_util.h:81
void SetLayoutValues(TVector *pVec, const IndexLayout &layout, typename TVector::value_type val)
sets the values of a vector to a given number only on the layout indices
Definition: parallelization_util.h:315
void MatAddSlaveRowsToMasterRowOverlap0(TMatrix &mat)
Generates a set of unique global algebra ids.
Definition: parallelization_util.h:106
void UniqueToConsistent(TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
changes parallel storage type from unique to consistent
Definition: parallelization_util.h:204
void MatMakeConsistentOverlap0(TMatrix &mat)
Generates a set of unique global algebra ids.
Definition: parallelization_util.h:126
void AdditiveToUnique(TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
changes parallel storage type from additive to unique
Definition: parallelization_util.h:261
void VecSubtractOnLayout(TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
subtracts values of slave layout from master layout and sets slave layouts to negative of difference
Definition: parallelization_util.h:406
void VecSubtractOneSlaveFromMaster(TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
subtracts values of only one slave dof per master on layout
Definition: parallelization_util.h:445
void SetInterfaceValues(TVector *pVec, const IndexLayout::Interface &interface, typename TVector::value_type val)
sets the values of a vector to a given number only on the interface indices
Definition: parallelization_util.h:289
void CopyValues(TVector *pVec, const IndexLayout &sourceLayout, const IndexLayout &targetLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
Copies values from the source to the target layout.
Definition: parallelization_util.h:228
void AdditiveToConsistent(TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
changes parallel storage type from additive to consistent
Definition: parallelization_util.h:160
pcl::SingleLevelLayout< pcl::OrderedInterface< size_t, std::vector > > IndexLayout
Definition: parallel_index_layout.h:53
int ProcRank()
returns the rank of the process
Definition: pcl_base.cpp:83
bool TestLayout(const pcl::ProcessCommunicator &processCommunicator, pcl::InterfaceCommunicator< TLayout > &com, const TLayout &masterLayout, const TLayout &slaveLayout, bool bPrint=false, boost::function< TValue(typename TLayout::Element)> cbToValue=TrivialToValue< typename TLayout::Element >, bool compareValues=false)
Checks whether the given layouts are consistent.
Definition: pcl_layout_tests.h:300
double number
Definition: types.h:124
void VecCopy(vector_target_t &target, const vector_source_t &source, typename vector_target_t::value_type fill)
Copy contents between vectors of possibly different types.
Definition: math_vector_functions_common_impl.hpp:56
#define PU_PROFILE_END(name)
Definition: parallelization_util.h:50
#define PU_PROFILE_BEGIN(name)
Definition: parallelization_util.h:49
Definition: smart_pointer.h:814
size_t GetCols(const T &t)
void GenerateGlobalConsecutiveIndices(TIndVec &indsOut, size_t numLocalInds, const AlgebraLayouts &layouts)
Generates a set of global consecutive indices.
Definition: parallelization_util_impl.h:44
int BuildOneToManyLayout(IndexLayout &masterLayoutOut, IndexLayout &slaveLayoutOut, int rootProcID, IndexLayout &masterLayout, IndexLayout &slaveLayout, pcl::ProcessCommunicator procComm, std::vector< int > *pNewMasterIDsOut)
Definition: parallelization_util.cpp:162
void BuildDomainDecompositionLayouts(IndexLayout &subdomMastersOut, IndexLayout &subdomSlavesOut, IndexLayout &processMastersOut, IndexLayout &processSlavesOut, IndexLayout &deltaNbrMastersOut, IndexLayout &deltaNbrSlavesOut, IndexLayout &crossPointMastersOut, IndexLayout &crossPointSlavesOut, const IndexLayout &standardMasters, const IndexLayout &standardSlaves, int highestReferencedIndex, IDomainDecompositionInfo &ddinfo)
Definition: parallelization_util.cpp:497
void TestHorizontalAlgebraLayouts(const TMatrix &mat, std::vector< AlgebraID > *algebraIDs=NULL, bool verbose=false)
Tests layouts by matching master and slave interfaces and by comparing global id's.
Definition: parallelization_util_impl.h:121
int GetHighestReferencedIndex(IndexLayout &layout)
Definition: parallelization_util.cpp:139
void MatAdditiveToConsistentOnDiag(typename TAlgebra::matrix_type *pMat, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
changes parallel storage type from additive to consistent on diagonal of a matrix
Definition: parallelization_util.h:670
void CommunicateConnections(vector< vector< int > > &connectionsToProcsOut, vector< vector< int > > &connectionsToSubDomsOut, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, int highestReferencedIndex, pcl::IDomainDecompositionInfo &ddinfo)
Definition: parallelization_util.cpp:70
TLayout::iterator find_pid(TLayout &layout, int pid)
Definition: parallelization_util.h:774
double & BlockRef(T &vec, size_t i)
Definition: blocks.h:66
void MatWriteDiagOnLayout(TMatrix *pMatrix, const TVector *pDiagVector, const IndexLayout &Layout)
writes diagonal of a matrix for interface indices
Definition: parallelization_util.h:628
void VecGather(TVector *pVecDest, const TVector *pVecSrc, const IndexLayout &masterLayoutDest, const IndexLayout &slaveLayoutSrc, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
gathers all values in master indices of a second vector
Definition: parallelization_util.h:708
void MatExtractDiagOnLayout(TVector *pDiagVector, const TMatrix *pMatrix, const IndexLayout &Layout)
extracts diagonal of a matrix for interface indices
Definition: parallelization_util.h:588
bool PrintLayouts(const HorizontalAlgebraLayouts &layout)
Definition: parallelization_util.h:763
SmartPtr< AlgebraLayouts > CreateLocalAlgebraLayouts()
Definition: parallelization_util.cpp:936
void VecBroadcast(TVector *pVecDest, const TVector *pVecSrc, const IndexLayout &slaveLayoutDest, const IndexLayout &masterLayoutSrc, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
broadcasts all values from master indices to slave values in a second vector
Definition: parallelization_util.h:742
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258
T value_type
Definition: sparsematrix_interface.h:2
this type is used to identify distributed objects.
Definition: algebra_id.h:46