33 #ifndef __H__PCL__pcl_process_communicator_impl__
34 #define __H__PCL__pcl_process_communicator_impl__
41 template<
class TValue>
43 gatherv(std::vector<TValue>& recBufOut,
44 std::vector<TValue>& sendBuf,
int root,
45 std::vector<int>* pSizesOut, std::vector<int>* pOffsetsOut)
const
52 std::vector<int> sizes(this->
size(), 0);
53 std::vector<int> offsets(this->
size(), 0);
57 int localSize = (int)sendBuf.size() *
sizeof(TValue);
62 for(
size_t i = 0; i < sizes.size(); ++i){
63 offsets[i] = totalSize;
64 totalSize += sizes[i];
68 recBufOut.resize(totalSize /
sizeof(TValue));
83 std::vector<int>& sizesOut = *pSizesOut;
84 sizesOut.resize(sizes.size());
85 for(
size_t i = 0; i < sizes.size(); ++i)
86 sizesOut[i] = sizes[i] /
sizeof(TValue);
90 std::vector<int>& offsetsOut = *pOffsetsOut;
91 offsetsOut.resize(offsets.size());
92 for(
size_t i = 0; i < offsets.size(); ++i)
93 offsetsOut[i] = offsets[i] /
sizeof(TValue);
97 template<
class TValue>
100 std::vector<TValue>& sendBuf,
101 std::vector<int>* pSizesOut,
102 std::vector<int>* pOffsetsOut)
const
105 recBufOut.resize (sendBuf.size());
106 for(
size_t i = 0; i < sendBuf.size(); ++i){
107 recBufOut[i] = sendBuf[i];
110 pSizesOut->resize (1);
111 pSizesOut->at(0) = sendBuf.size();
114 pOffsetsOut->resize (1);
115 pOffsetsOut->at(0) = 0;
123 std::vector<int> sizes(this->
size(), 0);
124 std::vector<int> offsets(this->
size(), 0);
128 int localSize = (int)sendBuf.size() *
sizeof(TValue);
133 for(
size_t i = 0; i < sizes.size(); ++i){
134 offsets[i] = totalSize;
135 totalSize += sizes[i];
141 pSizesOut->resize (0);
143 pOffsetsOut->resize (0);
148 recBufOut.resize(totalSize /
sizeof(TValue));
158 std::vector<int>& sizesOut = *pSizesOut;
159 sizesOut.resize(sizes.size());
160 for(
size_t i = 0; i < sizes.size(); ++i)
161 sizesOut[i] = sizes[i] /
sizeof(TValue);
165 std::vector<int>& offsetsOut = *pOffsetsOut;
166 offsetsOut.resize(offsets.size());
167 for(
size_t i = 0; i < offsets.size(); ++i)
168 offsetsOut[i] = offsets[i] /
sizeof(TValue);
184 reduce(
const T *pSendBuff, T *pReceiveBuff,
size_t count,
193 reduce(
const std::vector<T> &send, std::vector<T> &receive,
197 receive.resize(send.size());
198 reduce(&send[0], &receive[0], send.size(), op, rootProc);
222 allreduce(
const std::vector<T> &send, std::vector<T> &receive,
226 receive.resize(send.size());
227 allreduce(&send[0], &receive[0], send.size(), op);
Definition: pcl_datatype.h:63
Definition: pcl_datatype.h:64
Definition: pcl_datatype.h:68
bool is_local() const
return true if the communicator is local, simulating current proc is the only proc
Definition: pcl_process_communicator.h:83
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.
Definition: pcl_process_communicator.cpp:296
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.
Definition: pcl_process_communicator.cpp:339
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.
Definition: pcl_process_communicator.cpp:406
void allreduce(const void *sendBuf, void *recBuf, int count, DataType type, ReduceOperation op) const
performs MPI_Allreduce on the processes of the communicator.
Definition: pcl_process_communicator.cpp:318
size_t size() const
returns the size of the communicator
Definition: pcl_process_communicator.cpp:71
void broadcast(void *v, size_t size, DataType type, int root=0) const
Definition: pcl_process_communicator.cpp:685
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.
Definition: pcl_process_communicator.cpp:443
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.
Definition: pcl_process_communicator.cpp:421
A Buffer for binary data.
Definition: binary_buffer.h:56
int ProcRank()
returns the rank of the process
Definition: pcl_base.cpp:83
MPI_Op ReduceOperation
Definition: pcl_methods.h:74
#define PCL_DT_BYTE
Definition: pcl_datatype.h:47
#define PCL_DT_INT
Definition: pcl_datatype.h:51
T * GetDataPtr(std::vector< T > &v)
Returns a pointer to the array which is managed by the std::vector.
Definition: vector_util.h:51
Definition: parallel_grid_layout.h:46
void Deserialize(TIStream &buf, ParallelVector< T > &v)
Deerialize for ParallelVector<T>
Definition: restart_bridge.cpp:112
void Serialize(TOStream &buf, const ParallelVector< T > &v)
Serialize for ParallelVector<T>
Definition: restart_bridge.cpp:103