KASKADE 7 development version
Public Types | Public Member Functions | List of all members
Kaskade::LocalVectors< Entry, SortedIdx, Vector > Class Template Reference

A structure for holding a sequence of several local vectors to be filled sequentially and to be scattered jointly. More...

#include <localVectors.hh>

Detailed Description

template<class Entry, class SortedIdx, class Vector>
class Kaskade::LocalVectors< Entry, SortedIdx, Vector >

A structure for holding a sequence of several local vectors to be filled sequentially and to be scattered jointly.

This realizes a container of vector, with the critical feature that the entries for all the vectors are stored in a contiguous memory block. This should improve locality of memory access during assembly and scattering of local vectors.

Template Parameters
Entrythe type of matrix entries
SortedIdxa range of indices (global idx, local idx) sorted ascendingly by global idx
Vectorthe type of the global Vector

Definition at line 94 of file localVectors.hh.

Public Types

using value_type = LocalVector< Entry, SortedIdx >
 

Public Member Functions

 LocalVectors (Vector &globalVector, std::vector< std::mutex > &scatterMutexes_, size_t maxStorage=256 *1024)
 
 LocalVectors ()
 Default constructor. More...
 
 ~LocalVectors ()
 Destructor. More...
 
void push_back (SortedIdx const &idx)
 Appends another (zero-initialized) local vector. More...
 
value_typeoperator[] (int n)
 A reference to the n-th local matrix. More...
 
value_type const & operator[] (int n) const
 
value_typeback ()
 A reference to the last pushed local matrix. More...
 
value_type const & back () const
 
size_t size () const
 The number of local vectors that are stored. More...
 
void scatter ()
 Scatters the local vectors into the global one and removes them from the local container. More...
 
void clear ()
 clears all the data, leaving an empty state More...
 
size_t storageSize () const
 reports the size of the local vectors storage in bytes More...
 

Member Typedef Documentation

◆ value_type

template<class Entry , class SortedIdx , class Vector >
using Kaskade::LocalVectors< Entry, SortedIdx, Vector >::value_type = LocalVector<Entry,SortedIdx>

Definition at line 97 of file localVectors.hh.

Constructor & Destructor Documentation

◆ LocalVectors() [1/2]

template<class Entry , class SortedIdx , class Vector >
Kaskade::LocalVectors< Entry, SortedIdx, Vector >::LocalVectors ( Vector &  globalVector,
std::vector< std::mutex > &  scatterMutexes_,
size_t  maxStorage = 256*1024 
)
inline
Parameters
globalVectorglobal vector where computed local vectors are to be scattered to.
scatterMutexes_several mutexes (associated with ranges in the global vector), required to lock ranges in the global vector during scattering. By the number of given mutexes it can be controlled into how many ranges the global vector is to be subdivided during scattering.
maxStoragethe desired size of the buffer for data of local vectors, in bytes.

Definition at line 105 of file localVectors.hh.

◆ LocalVectors() [2/2]

template<class Entry , class SortedIdx , class Vector >
Kaskade::LocalVectors< Entry, SortedIdx, Vector >::LocalVectors ( )
inline

Default constructor.

This creates an essentially useless empty local matrix buffer.

Definition at line 121 of file localVectors.hh.

◆ ~LocalVectors()

template<class Entry , class SortedIdx , class Vector >
Kaskade::LocalVectors< Entry, SortedIdx, Vector >::~LocalVectors ( )
inline

Destructor.

The destructor scatters all remaining local matrices into the global matrix.

Definition at line 129 of file localVectors.hh.

Member Function Documentation

◆ back() [1/2]

template<class Entry , class SortedIdx , class Vector >
value_type & Kaskade::LocalVectors< Entry, SortedIdx, Vector >::back ( )
inline

A reference to the last pushed local matrix.

Definition at line 167 of file localVectors.hh.

◆ back() [2/2]

template<class Entry , class SortedIdx , class Vector >
value_type const & Kaskade::LocalVectors< Entry, SortedIdx, Vector >::back ( ) const
inline

Definition at line 168 of file localVectors.hh.

◆ clear()

template<class Entry , class SortedIdx , class Vector >
void Kaskade::LocalVectors< Entry, SortedIdx, Vector >::clear ( )
inline

clears all the data, leaving an empty state

Definition at line 223 of file localVectors.hh.

Referenced by Kaskade::LocalVectors< Entry, SortedIdx, Vector >::scatter().

◆ operator[]() [1/2]

template<class Entry , class SortedIdx , class Vector >
value_type & Kaskade::LocalVectors< Entry, SortedIdx, Vector >::operator[] ( int  n)
inline

A reference to the n-th local matrix.

Definition at line 161 of file localVectors.hh.

◆ operator[]() [2/2]

template<class Entry , class SortedIdx , class Vector >
value_type const & Kaskade::LocalVectors< Entry, SortedIdx, Vector >::operator[] ( int  n) const
inline

Definition at line 162 of file localVectors.hh.

◆ push_back()

template<class Entry , class SortedIdx , class Vector >
void Kaskade::LocalVectors< Entry, SortedIdx, Vector >::push_back ( SortedIdx const &  idx)
inline

Appends another (zero-initialized) local vector.

In case that appending the new local vector exceeds the maximum storage size, the existing local vectors are scattered into the global vector before the new vector is created.

Parameters
idxa range of (global idx, local idx) pairs sorted by global index

Definition at line 142 of file localVectors.hh.

◆ scatter()

template<class Entry , class SortedIdx , class Vector >
void Kaskade::LocalVectors< Entry, SortedIdx, Vector >::scatter ( )
inline

Scatters the local vectors into the global one and removes them from the local container.

This is generally not necessary, as the LocalVectors class scatters automatically as soon as its buffer is filled, and also on destruction. Use this only if you need to control the specific time point at which scattering occurs.

Definition at line 182 of file localVectors.hh.

Referenced by Kaskade::LocalVectors< Entry, SortedIdx, Vector >::push_back(), and Kaskade::LocalVectors< Entry, SortedIdx, Vector >::~LocalVectors().

◆ size()

template<class Entry , class SortedIdx , class Vector >
size_t Kaskade::LocalVectors< Entry, SortedIdx, Vector >::size ( ) const
inline

The number of local vectors that are stored.

Definition at line 173 of file localVectors.hh.

Referenced by Kaskade::LocalVectors< Entry, SortedIdx, Vector >::push_back().

◆ storageSize()

template<class Entry , class SortedIdx , class Vector >
size_t Kaskade::LocalVectors< Entry, SortedIdx, Vector >::storageSize ( ) const
inline

reports the size of the local vectors storage in bytes

Definition at line 232 of file localVectors.hh.


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