33 #ifndef __H__PCL_UTIL__
34 #define __H__PCL_UTIL__
47 #ifdef PCL_DEBUG_BARRIER_ENABLED
52 #define PCL_DEBUG_BARRIER(communicator) communicator.barrier()
53 #define PCL_DEBUG_BARRIER_ALL() {pcl::ProcessCommunicator com; com.barrier();}
56 #define PCL_DEBUG_BARRIER(communicator)
57 #define PCL_DEBUG_BARRIER_ALL()
75 bool AllProcsTrue(
bool bFlag, ProcessCommunicator comm = ProcessCommunicator());
79 bool OneProcTrue(
bool bFlag, ProcessCommunicator comm = ProcessCommunicator());
99 const std::vector<int>& vSendToRanks,
100 const ProcessCommunicator& procComm
101 = ProcessCommunicator());
116 template <
class TLayout,
class TSelector>
128 typedef typename TLayout::Interface Interface;
129 typedef typename TLayout::iterator InterfaceIter;
130 typedef typename Interface::Element Elem;
131 typedef typename Interface::iterator ElemIter;
134 for(
size_t level = 0; level < layout.num_levels(); ++level)
137 for(InterfaceIter iiter = layout.begin(level);
138 iiter != layout.end(level);)
140 bool interfaceChanged =
false;
141 Interface&
interface = layout.interface(iiter);
144 Interface tInterface;
146 for(ElemIter iter = interface.begin();
147 iter != interface.end(); ++iter)
149 Elem& e = interface.get_element(iter);
150 if(sel.is_selected(e))
151 tInterface.push_back(e);
153 interfaceChanged =
true;
157 if(interfaceChanged){
158 interface.swap(tInterface);
162 if(interface.size() == 0){
163 iiter = layout.erase(iiter, level);
194 template <
class TType,
class TLayoutMap,
class TSelector>
197 typedef typename TLayoutMap::template Types<TType>::Map::iterator iterator;
198 typedef typename TLayoutMap::template Types<TType>::Layout Layout;
201 for(iterator iter = lm.template layouts_begin<TType>();
202 iter != lm.template layouts_end<TType>();)
205 Layout& layout = iter->second;
211 iter = lm.template erase_layout<TType>(iter);
236 template <
class TLayout,
class TSelectorIn,
class TSelectorOut>
253 for(
typename Interface::iterator iter = interface.begin();
254 iter != interface.end(); ++iter)
256 if(
m_selIn.is_selected(interface.get_element(iter)))
257 buff.
write(&one,
sizeof(
char));
259 buff.
write(&zero,
sizeof(
char));
270 for(
typename Interface::iterator iter = interface.begin();
271 iter != interface.end(); ++iter)
273 buff.
read(&tmp,
sizeof(
char));
275 m_selOut.deselect(interface.get_element(iter));
277 m_selOut.select(interface.get_element(iter));
294 const std::vector<int>& sendTo,
307 bool SendRecvBuffersMatch(
const std::vector<int>& recvFrom,
const std::vector<int>& recvBufSizes,
308 const std::vector<int>& sendTo,
const std::vector<int>& sendBufSizes,
313 template<
typename TLayout>
314 void AddLayout(TLayout &destLayout,
const TLayout &sourceLayout)
316 for(
typename TLayout::const_iterator iter = sourceLayout.begin(); iter != sourceLayout.end(); ++iter)
318 const typename TLayout::Interface &source_interface = sourceLayout.interface(iter);
319 typename TLayout::Interface &dest_interface = destLayout.interface(sourceLayout.proc_id(iter));
320 for(
typename TLayout::Interface::const_iterator iter2 = source_interface.begin(); iter2 != source_interface.end(); ++iter2)
321 dest_interface.push_back(source_interface.get_element(iter2));
354 template <
typename TKey,
typename TValue,
typename Compare>
specializations are responsible to pack and unpack interface data during communication.
Definition: pcl_communication_structs.h:790
Layout::Interface Interface
Definition: pcl_communication_structs.h:793
Definition: pcl_process_communicator.h:70
communicates selection-status of interface elements
Definition: pcl_util.h:238
ICommunicationPolicy< TLayout >::Interface Interface
Definition: pcl_util.h:240
TSelectorIn & m_selIn
Definition: pcl_util.h:284
virtual bool extract(ug::BinaryBuffer &buff, Interface &interface)
iterates over the interface entries. selects for 1, deselects for 0.
Definition: pcl_util.h:267
virtual bool collect(ug::BinaryBuffer &buff, Interface &interface)
iterates over the interface entries. Writes 1 for selected, 0 for unselected.
Definition: pcl_util.h:248
SelectionCommPol(TSelectorIn &selIn, TSelectorOut &selOut)
Definition: pcl_util.h:243
TSelectorOut & m_selOut
Definition: pcl_util.h:285
A Buffer for binary data.
Definition: binary_buffer.h:56
void read(char *buf, size_t size)
reads data of the given size (in bytes)
Definition: binary_buffer_impl.h:58
void write(const char *buf, size_t size)
writes data of the given size (in bytes)
Definition: binary_buffer_impl.h:71
void SynchronizeProcesses()
Definition: pcl_util.cpp:48
void MinimalKeyValuePairAcrossAllProcs(TKey &keyInOut, TValue &valInOut, const Compare &cmp=Compare())
Find minimal key/value pair across processes This function will receive one key/value pair from each ...
Definition: pcl_util_impl.h:40
bool SendRecvListsMatch(const std::vector< int > &recvFromTmp, const std::vector< int > &sendTo, const ProcessCommunicator &involvedProcs)
checks whether proc-entries in send- and recv-lists on participating processes match
Definition: pcl_util.cpp:167
bool OneProcTrue(bool bFlag, ProcessCommunicator comm)
Definition: pcl_util.cpp:74
void AddLayout(TLayout &destLayout, const TLayout &sourceLayout)
Definition: pcl_util.h:314
bool AllProcsTrue(bool bFlag, ProcessCommunicator comm)
Definition: pcl_util.cpp:54
bool RemoveUnselectedInterfaceEntries(TLayout &layout, TSelector &sel)
Definition: pcl_util.h:117
bool SendRecvBuffersMatch(const std::vector< int > &recvFrom, const std::vector< int > &recvBufSizes, const std::vector< int > &sendTo, const std::vector< int > &sendBufSizes, const ProcessCommunicator &involvedProcs)
checks whether matching buffers in send- and recv-lists have the same size
Definition: pcl_util.cpp:230
void CommunicateInvolvedProcesses(std::vector< int > &vReceiveFromRanksOut, const std::vector< int > &vSendToRanks, const ProcessCommunicator &procComm)
exchanges information about which process wants to communicate with which other process.
Definition: pcl_util.cpp:94
Definition: parallel_grid_layout.h:46
bool ParallelReadFile(string &filename, vector< char > &file, bool bText, bool bDistributedLoad, const ProcessCommunicator &pc)
Definition: pcl_util.cpp:301