MADNESS 0.10.1
madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM > Class Template Reference

#include <exchangeoperator.h>

Collaboration diagram for madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >:

Classes

class  MacroTaskExchangeRow
class  MacroTaskExchangeSimple

Public Types

typedef Exchange< T, NDIM >::ExchangeAlgorithm Algorithm

Public Member Functions

 ExchangeImpl (World &world, const double lo, const double thresh)
 default ctor
 ExchangeImpl (World &world, const Nemo *nemo, const int ispin)
 ctor with a nemo calculation
 ExchangeImpl (World &world, const Nemo *nemo, const std::vector< Function< double, NDIM > > &R2mo, const int ispin)
 ctor with a nemo calculation whose bra R^2 F is already at hand; neither bra nor ket is copied
 ExchangeImpl (World &world, const SCF *calc, const int ispin)
 ctor with a conventional calculation
nlohmann::json gather_statistics () const
 return some statistics about the current settings
nlohmann::json gather_timings (World &world) const
nlohmann::json get_statistics () const
std::shared_ptr< MacroTaskQ > get_taskq () const
World & get_world () const
std::string info () const
bool is_symmetric () const
vecfuncT operator() (const vecfuncT &vket) const
 apply the exchange operator on a vector of functions
void print_timer (World &world) const
ExchangeImpl & set_accumulation_mode (const int mode)
ExchangeImpl & set_algorithm (const Algorithm &alg)
ExchangeImpl & set_batch_granularity (const long level)
void set_bra_and_ket (const vecfuncT &bra, const vecfuncT &ket)
 set the bra and ket orbital spaces, and the occupation
ExchangeImpl & set_cost_aware_assignment (const bool flag)
ExchangeImpl & set_macro_task_info (const MacroTaskInfo &info)
ExchangeImpl & set_macro_task_info (const std::vector< std::string > &info)
ExchangeImpl & set_printlevel (const long &level)
ExchangeImpl & set_taskq (std::shared_ptr< MacroTaskQ > taskq1)
ExchangeImpl & symmetric (const bool flag)

Static Public Member Functions

static auto set_poisson (World &world, const double lo, const double econv=FunctionDefaults< 3 >::get_thresh())

Public Attributes

Algorithm algorithm_ = multiworld_efficient_row
MacroTaskInfo macro_task_info = MacroTaskInfo::preset("default")

Private Types

typedef Function< T, NDIM > functionT
typedef std::vector< functionT > vecfuncT

Private Member Functions

vecfuncT K_large_memory (const vecfuncT &vket, const double mul_tol=0.0) const
 computing the upper triangle of the double sum (over vket and the K orbitals)
vecfuncT K_macrotask_efficient (const vecfuncT &vket, const double mul_tol=0.0) const
 exchange using macrotasks, i.e. apply K on a function in individual worlds
vecfuncT K_macrotask_efficient_row (const vecfuncT &vket, const double mul_tol=0.0) const
 exchange using macrotasks, i.e. apply K on a function in individual worlds row-wise
vecfuncT K_small_memory (const vecfuncT &vket, const double mul_tol=0.0) const
 computing the full square of the double sum (over vket and the K orbitals)
bool printdebug () const
bool printprogress () const
bool printtimings () const
bool printtimings_detail () const

Static Private Member Functions

static vecfuncT compute_K_tile (World &world, const vecfuncT &mo_bra, const vecfuncT &mo_ket, const vecfuncT &vket, std::shared_ptr< real_convolution_3d > poisson, const bool symmetric, const double mul_tol=0.0)
 computing the upper triangle of the double sum (over vket and the K orbitals)
static void reset_timer ()

Private Attributes

int accumulation_mode_ = 2
long batch_granularity_ = 1
bool cost_aware_assign_ = true
double lo = 1.e-4
vecfuncT mo_bra
 is the exchange matrix symmetric? K phi_i = \sum_k \phi_k \int \phi_k \phi_i
vecfuncT mo_ket
 MOs for bra and ket.
double mul_tol = FunctionDefaults<NDIM>::get_thresh()*0.1
long printlevel = 0
nlohmann::json statistics
 statistics of the Cloud (timings, memory) and of the parameters of this run
bool symmetric_ = false
std::shared_ptr< MacroTaskQ > taskq
double thresh = FunctionDefaults<NDIM>::get_thresh()
World & world

Static Private Attributes

static std::atomic< long > apply_timer
static double elapsed_time
static std::atomic< long > mul1_timer
 timing
static std::atomic< long > mul2_timer

Member Typedef Documentation

◆ Algorithm

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
typedef Exchange<T,NDIM>::ExchangeAlgorithm madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::Algorithm

◆ functionT

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
typedef Function<T, NDIM> madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::functionT
private

◆ vecfuncT

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
typedef std::vector<functionT> madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::vecfuncT
private

Constructor & Destructor Documentation

◆ ExchangeImpl() [1/4]

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::ExchangeImpl ( World & world,
const double lo,
const double thresh )
inline

◆ ExchangeImpl() [2/4]

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::ExchangeImpl ( World & world,
const SCF * calc,
const int ispin )

◆ ExchangeImpl() [3/4]

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::ExchangeImpl ( World & world,
const Nemo * nemo,
const int ispin )

◆ ExchangeImpl() [4/4]

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::ExchangeImpl ( World & world,
const Nemo * nemo,
const std::vector< Function< double, NDIM > > & R2mo,
const int ispin )

ctor with a nemo calculation whose bra R^2 F is already at hand; neither bra nor ket is copied

References ExchangeImpl(), madness::convert(), MADNESS_CHECK_THROW, mo_bra, mo_ket, and world.

Member Function Documentation

◆ compute_K_tile()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::vector< Function< T, NDIM > > madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::compute_K_tile ( World & world,
const vecfuncT & mo_bra,
const vecfuncT & mo_ket,
const vecfuncT & vket,
std::shared_ptr< real_convolution_3d > poisson,
const bool symmetric,
const double mul_tol = 0.0 )
staticprivate

◆ gather_statistics()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
nlohmann::json madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::gather_statistics ( ) const
inline

return some statistics about the current settings

References algorithm_, gather_timings(), lo, macro_task_info, mul_tol, printlevel, symmetric_, thresh, madness::Exchange< T, NDIM >::to_string(), and world.

Referenced by operator()().

◆ gather_timings()

◆ get_statistics()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
nlohmann::json madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::get_statistics ( ) const
inline

References statistics.

◆ get_taskq()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::shared_ptr< MacroTaskQ > madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::get_taskq ( ) const
inline

References taskq.

◆ get_world()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
World & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::get_world ( ) const
inline

References world.

◆ info()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::string madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::info ( ) const
inline

◆ is_symmetric()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
bool madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::is_symmetric ( ) const
inline

References symmetric_.

◆ K_large_memory()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::vector< Function< T, NDIM > > madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::K_large_memory ( const vecfuncT & vket,
const double mul_tol = 0.0 ) const
private

computing the upper triangle of the double sum (over vket and the K orbitals)

References compute_K_tile(), madness::Exchange< T, NDIM >::is_symmetric(), lo, mo_bra, mo_ket, mul_tol, set_poisson(), madness::truncate(), and world.

Referenced by operator()().

◆ K_macrotask_efficient()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::vector< Function< T, NDIM > > madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::K_macrotask_efficient ( const vecfuncT & vf,
const double mul_tol = 0.0 ) const
private

exchange using macrotasks, i.e. apply K on a function in individual worlds

apply the exchange operator by tiling the exchange matrix

compute the matrix N_{ik} = N \phi_i \phi_k by tiles, with i,k \in batches A,B, do a local reduce within the tiles: K_{iB} = \sum_{k \in batch B} \phi_k N_{ik} and a universe-wide reduce of the tiles: K\phi_i = \sum_{batches B} K_{iB} saving up to half of the cpu time compared to the naive algorithm

Template Parameters
Tnumber type
NDIMphysical dimension of the argument vket
Parameters
vfargument of the exchange operator
mul_tolcutoff parameter for sparse multiplication
Returns
the exchange operator applied on vket

References accumulation_mode_, batch_granularity_, cost_aware_assign_, madness::exch_force_general_path(), madness::exchange_batch_salt(), madness::exchange_same_operands(), madness::Exchange< T, NDIM >::is_symmetric(), lo, mo_bra, mo_ket, mul_tol, madness::print(), printdebug(), printlevel, symmetric(), and world.

Referenced by operator()().

◆ K_macrotask_efficient_row()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::vector< Function< T, NDIM > > madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::K_macrotask_efficient_row ( const vecfuncT & vket,
const double mul_tol = 0.0 ) const
private

exchange using macrotasks, i.e. apply K on a function in individual worlds row-wise

compute each row of the exchange matrix in different subworlds

References mul_tol.

Referenced by operator()().

◆ K_small_memory()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::vector< Function< T, NDIM > > madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::K_small_memory ( const vecfuncT & vket,
const double mul_tol = 0.0 ) const
private

computing the full square of the double sum (over vket and the K orbitals)

was vtol

was vtol

References madness::apply(), madness::gaxpy(), lo, mo_bra, mo_ket, madness::mul_sparse(), mul_tol, set_poisson(), madness::truncate(), world, and madness::zero_functions_compressed().

Referenced by operator()().

◆ operator()()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::vector< Function< T, NDIM > > madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::operator() ( const vecfuncT & vket) const

◆ print_timer()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
void madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::print_timer ( World & world) const
inline

References gather_timings(), and world.

Referenced by operator()().

◆ printdebug()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
bool madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::printdebug ( ) const
inlineprivate

◆ printprogress()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
bool madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::printprogress ( ) const
inlineprivate

References printdebug(), and printlevel.

◆ printtimings()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
bool madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::printtimings ( ) const
inlineprivate

References printlevel.

◆ printtimings_detail()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
bool madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::printtimings_detail ( ) const
inlineprivate

References printlevel.

Referenced by operator()().

◆ reset_timer()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
void madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::reset_timer ( )
inlinestaticprivate

◆ set_accumulation_mode()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_accumulation_mode ( const int mode)
inline

◆ set_algorithm()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_algorithm ( const Algorithm & alg)
inline

References ExchangeImpl(), and algorithm_.

◆ set_batch_granularity()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_batch_granularity ( const long level)
inline

◆ set_bra_and_ket()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
void madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_bra_and_ket ( const vecfuncT & bra,
const vecfuncT & ket )
inline

set the bra and ket orbital spaces, and the occupation

Parameters
[in]brabra space, must be provided as complex conjugate
[in]ketket space

References madness::copy(), mo_bra, mo_ket, and world.

◆ set_cost_aware_assignment()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_cost_aware_assignment ( const bool flag)
inline

◆ set_macro_task_info() [1/2]

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_macro_task_info ( const MacroTaskInfo & info)
inline

◆ set_macro_task_info() [2/2]

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_macro_task_info ( const std::vector< std::string > & info)
inline

◆ set_poisson()

◆ set_printlevel()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_printlevel ( const long & level)
inline

References ExchangeImpl(), and printlevel.

◆ set_taskq()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::set_taskq ( std::shared_ptr< MacroTaskQ > taskq1)
inline

References ExchangeImpl(), and taskq.

◆ symmetric()

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
ExchangeImpl & madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::symmetric ( const bool flag)
inline

References ExchangeImpl(), and symmetric_.

Referenced by compute_K_tile(), and K_macrotask_efficient().

Member Data Documentation

◆ accumulation_mode_

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
int madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::accumulation_mode_ = 2
private

how the tile results are gathered: 1 = subworld buffer then universe, 2 = also reduce within a node first (default; degrades to 1 on a single node)

Referenced by K_macrotask_efficient(), and set_accumulation_mode().

◆ algorithm_

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
Algorithm madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::algorithm_ = multiworld_efficient_row

◆ apply_timer

◆ batch_granularity_

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
long madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::batch_granularity_ = 1
private

batches per rank in the owner-pinned symmetric partition; 1 is the coarsest split and the one with the lowest peak memory

Referenced by K_macrotask_efficient(), and set_batch_granularity().

◆ cost_aware_assign_

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
bool madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::cost_aware_assign_ = true
private

place tasks by measured cost instead of by counting them; the first two applications still count, having no representative reference to measure against

Referenced by K_macrotask_efficient(), and set_cost_aware_assignment().

◆ elapsed_time

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
double madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::elapsed_time
inlinestaticprivate

◆ lo

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
double madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::lo = 1.e-4
private

◆ macro_task_info

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
MacroTaskInfo madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::macro_task_info = MacroTaskInfo::preset("default")

◆ mo_bra

◆ mo_ket

◆ mul1_timer

◆ mul2_timer

◆ mul_tol

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
double madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::mul_tol = FunctionDefaults<NDIM>::get_thresh()*0.1
private

◆ printlevel

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
long madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::printlevel = 0
private

◆ statistics

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
nlohmann::json madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::statistics
mutableprivate

statistics of the Cloud (timings, memory) and of the parameters of this run

Referenced by get_statistics(), and operator()().

◆ symmetric_

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
bool madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::symmetric_ = false
private

◆ taskq

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
std::shared_ptr<MacroTaskQ> madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::taskq
private

Referenced by get_taskq(), and set_taskq().

◆ thresh

template<typename T, std::size_t NDIM>
template<typename T, std::size_t NDIM>
double madness::Exchange< T, NDIM >::ExchangeImpl< T, NDIM >::thresh = FunctionDefaults<NDIM>::get_thresh()
private

Referenced by ExchangeImpl(), and gather_statistics().

◆ world


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