MADNESS 0.10.1
Classes | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
madness::Displacements< NDIM > Class Template Reference

Holds displacements for applying operators to avoid replicating for all operators. More...

#include <displacements.h>

Collaboration diagram for madness::Displacements< NDIM >:
Collaboration graph
[legend]

Classes

struct  DispEntry
 
struct  PeriodicLists
 the displacements for kernels lattice-summed along one set of axes, per level, in the two orders consumers use More...
 

Public Member Functions

 Displacements ()
 
const std::vector< Key< NDIM > > & get_disp ()
 return the standard displacements appropriate for operators w/o lattice summation
 
const std::vector< Key< NDIM > > & get_disp (Level n, const array_of_bools< NDIM > &kernel_lattice_sum_axes)
 
const std::vector< Key< NDIM > > & get_disp_images (Level n, const array_of_bools< NDIM > &kernel_lattice_sum_axes)
 

Static Public Member Functions

static int bmax_default ()
 
static void make_disp (int bmax)
 
static void make_disp_images (PeriodicLists &lists)
 fills lists.by_image_distance (requires the lock)
 
static void make_disp_periodic (int bmax, Level n, PeriodicLists &lists)
 fills lists.by_distance[n] for lists.axes
 
static PeriodicLists & periodic (const array_of_bools< NDIM > &axes)
 the lists for kernels lattice-summed along axes, built on the first request
 
static void reset_periodic_axes (const array_of_bools< NDIM > &periodic_axes)
 builds the displacements for kernels lattice-summed along periodic_axes if they do not exist yet
 
static void set_width (const Tensor< double > &width)
 
static void sort_displacements (std::vector< Key< NDIM > > &d, const Tensor< double > &w)
 
static void sort_displacements_images (std::vector< Key< NDIM > > &d, const array_of_bools< NDIM > &paxes, const Tensor< double > &w)
 
static void sort_displacements_periodic (std::vector< Key< NDIM > > &d, const array_of_bools< NDIM > &paxes, const Tensor< double > &w)
 

Static Private Member Functions

static std::size_t axes_mask (const array_of_bools< NDIM > &axes)
 

Static Private Attributes

static std::vector< Key< NDIM > > disp = {}
 standard displacements to be used with standard kernels (range-unrestricted, no lattice sum)
 
static constexpr Level nlevels = 8 * sizeof(Translation) - 2
 levels for which lists are built
 
static std::array< std::atomic< PeriodicLists * >,(std::size_t(1)<< NDIM)> periodic_lists {}
 
static Mutex periodic_lists_mutex {}
 serializes building the lists and set_width()
 
static std::vector< std::unique_ptr< PeriodicLists > > periodic_lists_owner {}
 owns what periodic_lists points to
 
static Tensor< double > widths {NDIM}
 cell width, used to order displacements from least to most real space distance
 

Detailed Description

template<std::size_t NDIM>
class madness::Displacements< NDIM >

Holds displacements for applying operators to avoid replicating for all operators.

Constructor & Destructor Documentation

◆ Displacements()

template<std::size_t NDIM>
madness::Displacements< NDIM >::Displacements ( )
inline

The first call generates the standard displacements and, if the default boundary conditions have periodic axes, the displacements for kernels lattice-summed along those axes. Lists for any other set of lattice-summed axes are built on their first request (get_disp, get_disp_images), which SeparatedConvolution makes when it is constructed.

References madness::Displacements< NDIM >::bmax_default(), madness::Displacements< NDIM >::disp, e(), madness::FunctionDefaults< NDIM >::get_bc(), MADNESS_PRAGMA_CLANG, madness::Displacements< NDIM >::make_disp(), NDIM, madness::Tensor< T >::normf(), madness::Displacements< NDIM >::periodic(), madness::pop(), and madness::Displacements< NDIM >::widths.

Member Function Documentation

◆ axes_mask()

template<std::size_t NDIM>
static std::size_t madness::Displacements< NDIM >::axes_mask ( const array_of_bools< NDIM > &  axes)
inlinestaticprivate

References d, mask, and NDIM.

Referenced by madness::Displacements< NDIM >::periodic().

◆ bmax_default()

template<std::size_t NDIM>
static int madness::Displacements< NDIM >::bmax_default ( )
inlinestatic

◆ get_disp() [1/2]

template<std::size_t NDIM>
const std::vector< Key< NDIM > > & madness::Displacements< NDIM >::get_disp ( )
inline

return the standard displacements appropriate for operators w/o lattice summation

References madness::Displacements< NDIM >::disp, MADNESS_PRAGMA_CLANG, and madness::pop().

◆ get_disp() [2/2]

template<std::size_t NDIM>
const std::vector< Key< NDIM > > & madness::Displacements< NDIM >::get_disp ( Level  n,
const array_of_bools< NDIM > &  kernel_lattice_sum_axes 
)
inline

the displacements for a kernel lattice-summed along kernel_lattice_sum_axes (the standard displacements if none), ordered by the real-space distance to the source modulo the lattice (Key::real_distsq_bc), as FunctionImpl::do_apply screens a kernel that decays away from the source

References madness::array_of_bools< N >::any(), madness::Displacements< NDIM >::PeriodicLists::by_distance, madness::Displacements< NDIM >::disp, MADNESS_CHECK, MADNESS_PRAGMA_CLANG, madness::Displacements< NDIM >::nlevels, madness::Displacements< NDIM >::periodic(), and madness::pop().

Referenced by madness::FunctionImpl< T, NDIM >::do_apply_directed_screening(), and madness::SeparatedConvolution< Q, NDIM >::get_disp().

◆ get_disp_images()

template<std::size_t NDIM>
const std::vector< Key< NDIM > > & madness::Displacements< NDIM >::get_disp_images ( Level  n,
const array_of_bools< NDIM > &  kernel_lattice_sum_axes 
)
inline

◆ make_disp()

template<std::size_t NDIM>
static void madness::Displacements< NDIM >::make_disp ( int  bmax)
inlinestatic

◆ make_disp_images()

template<std::size_t NDIM>
static void madness::Displacements< NDIM >::make_disp_images ( PeriodicLists &  lists)
inlinestatic

◆ make_disp_periodic()

template<std::size_t NDIM>
static void madness::Displacements< NDIM >::make_disp_periodic ( int  bmax,
Level  n,
PeriodicLists &  lists 
)
inlinestatic

◆ periodic()

template<std::size_t NDIM>
static PeriodicLists & madness::Displacements< NDIM >::periodic ( const array_of_bools< NDIM > &  axes)
inlinestatic

◆ reset_periodic_axes()

template<std::size_t NDIM>
static void madness::Displacements< NDIM >::reset_periodic_axes ( const array_of_bools< NDIM > &  periodic_axes)
inlinestatic

builds the displacements for kernels lattice-summed along periodic_axes if they do not exist yet

Lists are built per set of lattice-summed axes on first request, so this is not needed for correctness; it moves the build (all levels, a few tens of milliseconds) out of the first apply.

Parameters
periodic_axesthe lattice-summed axes

References madness::array_of_bools< N >::any(), MADNESS_ASSERT, and madness::Displacements< NDIM >::periodic().

◆ set_width()

template<std::size_t NDIM>
static void madness::Displacements< NDIM >::set_width ( const Tensor< double > &  width)
inlinestatic

◆ sort_displacements()

template<std::size_t NDIM>
static void madness::Displacements< NDIM >::sort_displacements ( std::vector< Key< NDIM > > &  d,
const Tensor< double > &  w 
)
inlinestatic

◆ sort_displacements_images()

template<std::size_t NDIM>
static void madness::Displacements< NDIM >::sort_displacements_images ( std::vector< Key< NDIM > > &  d,
const array_of_bools< NDIM > &  paxes,
const Tensor< double > &  w 
)
inlinestatic

orders by the distance to the nearest non-home image: least distance between the boxes, then boxes, then the distance between the box centers. The last breaks the tie among the displacements one box from an image, which are all at least distance 0: the narrowest summed axis comes first, and its block is the operator's largest (SeparatedConvolution::norm_bound visits the leading image-adjacent run).

References d, k, and w().

Referenced by madness::Displacements< NDIM >::make_disp_images().

◆ sort_displacements_periodic()

template<std::size_t NDIM>
static void madness::Displacements< NDIM >::sort_displacements_periodic ( std::vector< Key< NDIM > > &  d,
const array_of_bools< NDIM > &  paxes,
const Tensor< double > &  w 
)
inlinestatic

Member Data Documentation

◆ disp

template<std::size_t NDIM>
std::vector< Key<NDIM> > madness::Displacements< NDIM >::disp = {}
inlinestaticprivate

◆ nlevels

template<std::size_t NDIM>
constexpr Level madness::Displacements< NDIM >::nlevels = 8 * sizeof(Translation) - 2
staticconstexprprivate

◆ periodic_lists

template<std::size_t NDIM>
std::array<std::atomic<PeriodicLists*>, (std::size_t(1) << NDIM)> madness::Displacements< NDIM >::periodic_lists {}
inlinestaticprivate

the lists for each set of lattice-summed axes, indexed by the axes' bitmask; a slot is filled on the first request for its axes (see periodic()) and published through the atomic once complete, so lookups take no lock. Sorting the lists with the metric of the axes they are requested for is what makes the shell-wise screening of FunctionImpl::do_apply sound: a list sorted for a superset of the kernel's axes would place a displacement wrapped along an axis the kernel does not sum next to the source, where for that kernel it is a cell away. A set holds every level's list in each order it was asked for (for NDIM = 3 up to (4 bmax + 1)^3 keys per level, some ten MB per order), so a process that uses operators summed along several different axis sets pays that per set; before, one set served them all.

Referenced by madness::Displacements< NDIM >::periodic().

◆ periodic_lists_mutex

template<std::size_t NDIM>
Mutex madness::Displacements< NDIM >::periodic_lists_mutex {}
inlinestaticprivate

◆ periodic_lists_owner

template<std::size_t NDIM>
std::vector<std::unique_ptr<PeriodicLists> > madness::Displacements< NDIM >::periodic_lists_owner {}
inlinestaticprivate

owns what periodic_lists points to

Referenced by madness::Displacements< NDIM >::periodic(), and madness::Displacements< NDIM >::set_width().

◆ widths

template<std::size_t NDIM>
Tensor<double> madness::Displacements< NDIM >::widths {NDIM}
inlinestaticprivate

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