Skip to content
Snippets Groups Projects
Commit 001d2d06 authored by Markus Blatt's avatar Markus Blatt
Browse files

Added allgather.

[[Imported from SVN: r6489]]
parent 20d4d243
No related branches found
No related tags found
No related merge requests found
......@@ -180,6 +180,26 @@ namespace Dune
return 0;
}
/**
* @brief Gathers data from all tasks and distribute it to all.
*
* The block of data sent from the jth process is received by every
* process and placed in the jth block of the buffer recvbuf.
*
* @param[in] sbuf The buffer with the data to send. Has to be the same for
* each task.
* @param[in] count The number of elements to send by any process.
* @param[out] rbuf The receive buffer for the data. Has to be of size
* notasks*count, with notasks being the number of tasks in the communicator.
*/
template<typename T>
int allgather(T* sbuf, int count, T* rbuf) const
{
for(T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf)
*sbuf=*rbuf;
return 0;
}
/**
* @brief Compute something over all processes
* for each component of an array and return the result
......
......@@ -314,6 +314,15 @@ namespace Dune
return communicator;
}
//! @copydoc CollectiveCommunication::allgather()
template<typename T, typename T1>
int allgather(T* sbuf, int count, T1* rbuf) const
{
return MPI_Allgather(sbuf, count, MPITraits<T>::getType(),
rbuf, count, MPITraits<T1>::getType(),
communicator);
}
template<typename BinaryFunction, typename Type>
int allreduce(Type* inout, int len) const
{
......@@ -324,6 +333,7 @@ namespace Dune
return ret;
}
//! @copydoc CollectiveCommunication::allreduce()
template<typename BinaryFunction, typename Type>
int allreduce(Type* in, Type* out, int len) const
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment