HILA
|
#include <reductionvector.h>
Public Member Functions | |
ReductionVector ()=default | |
~ReductionVector () | |
Destructor cleans up communications if they are in progress. | |
T & | operator[] (const int i) |
And access operators - these do in practice everything already! | |
ReductionVector & | allreduce (bool b=true) |
allreduce(bool) turns allreduce on or off. By default on. | |
ReductionVector & | nonblocking (bool b=true) |
nonblocking(bool) turns allreduce on or off. By default on. | |
ReductionVector & | delayed (bool b=true) |
deferred(bool) turns deferred on or off. By default turns on. | |
template<typename S , std::enable_if_t< std::is_assignable< T &, S >::value, int > = 0> | |
void | operator= (const S &rhs) |
void | operator= (std::nullptr_t np) |
Assignment from 0. | |
void | init_sum () |
Init is to be called before every site loop. | |
void | init_product () |
Init is to be called before every site loop. | |
void | reduce_sum () |
void | reduce_product () |
void | wait () |
Wait for MPI to complete, if it is currently going on. | |
void | start_reduce () |
For delayed reduction, reduce starts or completes the reduction operation. | |
void | reduce () |
Complete non-blocking or delayed reduction. | |
T * | data () |
data() returns ptr to the raw storage | |
size_t | size () const |
methods from std::vector: | |
Special reduction class for arrays: declare a reduction array as ReductionVector<T> a(size);
This can be used within site loops as onsites(ALL ) { int i = ... a[i] += ... }
or outside site loops as usual. Reductions: += *= sum or product reduction NOTE: size of the reduction vector must be same on all nodes! By default reduction is "allreduce", i.e. all nodes get the same result.
Reduction can be customized by using methods: a.size() : return the size of the array a.resize(new_size) : change size of array (all nodes must use same size!) a[i] : get/set element i
a.allreduce(bool) : turn allreduce on/off (default=true) a.nonblocking(bool) : turn non-blocking reduction on/off a.delayed(bool) : turn delayed reduction on/off
a.wait() : for non-blocking reduction, wait() has to be called after the loop to complete the reduction a.reduce() : for delayed reduction starts/completes the reduction
a.is_allreduce() : queries the reduction status is_nonblocking() is_delayed()
a.push_back(element) : add one element to The same reduction variable can be used again
Definition at line 44 of file reductionvector.h.
|
explicitdefault |
Initialize to zero by default (? exception to other variables) allreduce = true by default
|
inline |
Assignment is used only outside site loops - wait for comms if needed Make this return void, hard to imagine it is used for anything useful
Definition at line 184 of file reductionvector.h.
|
inline |
Product reduction – currently works only for scalar data types. For Complex, Matrix and Vector data product is not element-wise. TODO: Array or std::array ? TODO: implement using custom MPI ops (if needed)
Definition at line 233 of file reductionvector.h.
|
inline |
Start sum reduction – works only if the type T addition == element-wise addition. This is true for all hila predefined data types
Definition at line 217 of file reductionvector.h.