#pragma once
#include "ParaIdType.hxx"
+#include "MEDCouplingMemArray.hxx"
#include <mpi.h>
MPI_Op op, int root, MPI_Comm comm) const { return MPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm); }
int allReduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) const { return MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm); }
public:
+
+ /*!
+ * \a counts is expected to be an array of array length. This method returns an array of split array.
+ */
+ static std::unique_ptr<mcIdType[]> SplitArrayOfLength(const std::unique_ptr<mcIdType[]>& counts, std::size_t countsSz, int rk, int size)
+ {
+ std::unique_ptr<mcIdType[]> ret(new mcIdType[countsSz]);
+ for(std::size_t i=0;i<countsSz;++i)
+ {
+ mcIdType a,b;
+ DataArray::GetSlice(0,counts[i],1,rk,size,a,b);
+ ret[i] = b-a;
+ }
+ return ret;
+ }
+
+ /*!
+ * Helper of alltoallv and allgatherv
+ */
template<class T>
static std::unique_ptr<int []> ToIntArray(const std::unique_ptr<T []>& arr, std::size_t size)
{
std::copy(arr.get(),arr.get()+size,ret.get());
return ret;
}
+
+ /*!
+ * Helper of alltoallv and allgatherv
+ */
static std::unique_ptr<int []> ComputeOffset(const std::unique_ptr<int []>& counts, std::size_t sizeOfCounts)
{
std::unique_ptr<int []> ret(new int[sizeOfCounts]);