pMR API Documentation
Public Member Functions | List of all members
AllReduce Class Reference

Global reduction operations.

#include <allreduce.hpp>

Public Member Functions

 AllReduce (Communicator const &communicator, size_type const sizeByte)
 Setup environment for global reduction. More...
 
template<class Iterator >
void insert (Iterator inputIt, size_type const count)
 Copy data to internal buffer. More...
 
template<class Iterator >
void extract (Iterator outputIt, size_type const count)
 Copy data from internal buffer. More...
 
template<typename T = void>
T * data ()
 Direct access to the internal buffer. More...
 
template<typename T = void>
T const * data () const
 Direct access to the internal buffer. More...
 
size_type size () const
 Get the size of the internal buffer, and hence the maximum message size, in Byte. More...
 
template<typename T = unsigned char>
size_type count () const
 Get the size of the internal buffer, and hence the maximum message size, in count of type T. More...
 
template<typename T >
void execute (Operation op, size_type const count)
 Execute the global reduction using the supplied reduce function. Afterwards all process have the result stored in their local internal buffers. More...
 
template<typename T >
void execute (void(*op)(T const *in, T *inout, size_type const count), size_type const count)
 Execute the global reduction using the user-defined reduce function. Afterwards all process have the result stored in their local internal buffers. More...
 
template<typename T >
void executeBit (Operation op, size_type const count)
 Execute the global reduction using the supplied reduce function. Afterwards all process have the result stored in their local internal buffers. Results are guaranteed to be bit identical. More...
 
template<typename T >
void executeBit (void(*op)(T const *in, T *inout, size_type const count), size_type const count)
 Execute the global reduction using the user-defined reduce function. Afterwards all process have the result stored in their local internal buffers. Results are guaranteed to be bit identical. More...
 

Constructor & Destructor Documentation

AllReduce ( Communicator const &  communicator,
size_type const  sizeByte 
)
Parameters
communicatorCommunicator used in global reduction.
sizeByteReduce message size.
Note
The size might be chosen greater than the actual message size to allow re-use of the same environment for various messages sizes.

Member Function Documentation

size_type count ( ) const
Returns
Actual size of the internal buffer in count of T.
T * data ( )
Returns
Returns pointer to the internal buffer.
T const * data ( ) const
Returns
Returns pointer to the internal buffer.
void execute ( Operation  op,
size_type const  count 
)
Parameters
opReduce function used in reduction operation.
countNumber of element of type T to be part of global reduction.
Warning
The size of all elements of type T to be part of global reduction might not exceed the size as returned by size().
The content of the internal buffer that was not required for the global reduction is undefined.
void execute ( void(*)(T const *in, T *inout, size_type const count op,
size_type const  count 
)
Parameters
opReduce function used in reduction operation.
countNumber of element of type T to be part of global reduction.
Note
Example op function:
void sum(float const *in, float *inout, pMR::size_type count)
{
for(auto i = decltype(count){0}; i != count; ++i)
{
inout[i] += in[i];
}
}
Warning
The size of all elements of type T to be part of global reduction might not exceed the size as returned by size().
The content of the internal buffer that was not required for the global reduction is undefined.
User-defined reduce functions might not be able to use best performing routines.
User-defined reduce functions are assumed to be associative and commutative.
void executeBit ( Operation  op,
size_type const  count 
)
Parameters
opReduce function used in reduction operation.
countNumber of element of type T to be part of global reduction.
Note
The bit identical reduction is in general slower. Only use when it is a requirement to have bit identical results.
Warning
The size of all elements of type T to be part of global reduction might not exceed the size as returned by size().
The content of the internal buffer that was not required for the global reduction is undefined.
void executeBit ( void(*)(T const *in, T *inout, size_type const count op,
size_type const  count 
)
Parameters
opReduce function used in reduction operation.
countNumber of element of type T to be part of global reduction.
Note
The bit identical reduction is in general slower. Only use when it is a requirement to have bit identical results.
Example op function:
void sum(float const *in, float *inout, pMR::size_type count)
{
for(auto i = decltype(count){0}; i != count; ++i)
{
inout[i] += in[i];
}
}
Warning
The size of all elements of type T to be part of global reduction might not exceed the size as returned by size().
The content of the internal buffer that was not required for the global reduction is undefined.
User-defined reduce functions might not be able to use best performing routines.
User-defined reduce functions are assumed to be associative and commutative.
void extract ( Iterator  outputIt,
size_type const  count 
)

Copies data from the internal buffer to the location specified by outputIt.

Parameters
outputItIterator to destination.
countNumber of elements to copy.
void insert ( Iterator  inputIt,
size_type const  count 
)

Copies data from storage - inputIt iterator points to - to internal buffer.

Parameters
inputItIterator to source.
countNumber of elements to copy.
size_type size ( ) const
Returns
Actual size of the internal buffer in Byte.