HILA
Loading...
Searching...
No Matches
Reduction< T > Class Template Reference

Special reduction class: enables delayed and non-blocking reductions, which are not possible with the standard reduction. See user guide for details. More...

#include <reduction.h>

Public Member Functions

 Reduction ()
 
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0>
 Reduction (const S &v)
 
 Reduction (const Reduction< T > &r)=delete
 
 ~Reduction ()
 Destructor cleans up communications if they are in progress.
 
Reductionallreduce (bool b=true)
 allreduce(bool) turns allreduce on or off. By default on.
 
Reductionnonblocking (bool b=true)
 nonblocking(bool) turns allreduce on or off. By default on.
 
Reductiondelayed (bool b=true)
 deferred(bool) turns deferred on or off. By default turns on.
 
const T value ()
 Return value of the reduction variable. Wait for the comms if needed.
 
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0>
void set (const S &rhs)
 Method set is the same as assignment, but without return value.
 
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0>
operator= (const S &rhs)
 Assignment is used only outside site loops - drop comms if on, no need to wait.
 
template<typename S , std::enable_if_t< hila::is_assignable< T &, hila::type_plus< T, S > >::value, int > = 0>
void operator+= (const S &rhs)
 
void start_reduce ()
 For delayed reduction, start_reduce starts or completes the reduction operation.
 
void reduce ()
 Complete the reduction - start if not done, and wait if ongoing.
 

Detailed Description

template<typename T>
class Reduction< T >

Special reduction class: enables delayed and non-blocking reductions, which are not possible with the standard reduction. See user guide for details.

Definition at line 14 of file reduction.h.

Constructor & Destructor Documentation

◆ Reduction() [1/3]

template<typename T >
Reduction< T >::Reduction ( )
inline

Initialize to zero by default (? exception to other variables) allreduce = true by default

Definition at line 102 of file reduction.h.

◆ Reduction() [2/3]

template<typename T >
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0>
Reduction< T >::Reduction ( const S &  v)
inline

Initialize to value only on rank 0 - ensures expected result for delayed reduction

Definition at line 109 of file reduction.h.

◆ Reduction() [3/3]

template<typename T >
Reduction< T >::Reduction ( const Reduction< T > &  r)
delete

Delete copy construct from another reduction just in case don't make Reduction temporaries

Member Function Documentation

◆ operator+=()

template<typename T >
template<typename S , std::enable_if_t< hila::is_assignable< T &, hila::type_plus< T, S > >::value, int > = 0>
void Reduction< T >::operator+= ( const S &  rhs)
inline

Compound operator += is used in reduction but can be used outside onsites too. returns void, unconventionally: these are used within site loops but their value is not well-defined. Thus a = (r += b); is disallowed

Definition at line 193 of file reduction.h.

◆ start_reduce()

template<typename T >
void Reduction< T >::start_reduce ( )
inline

For delayed reduction, start_reduce starts or completes the reduction operation.

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 260 of file reduction.h.


The documentation for this class was generated from the following file: