DiSMEC++
dismec::parallel::NUMAReplicator< T > Class Template Reference

Helper class to ensure that each NUMA node has its own copy of some immutable data. More...

#include <numa.h>

Inheritance diagram for dismec::parallel::NUMAReplicator< T >:
dismec::parallel::NUMAReplicatorBase

Public Member Functions

 NUMAReplicator (std::shared_ptr< const T > data)
 Initializes the NUMAReplicator and distributes the data to all NUMA nodes. More...
 
std::shared_ptr< const T > get_local () const
 
- Public Member Functions inherited from dismec::parallel::NUMAReplicatorBase
bool has_numa () const
 this returns true if NUMA is available. Otherwise, there will be no replication. More...
 
int num_numa () const
 This returns the number of NUMA nodes. More...
 

Private Types

using ptr_t = std::shared_ptr< const T >
 

Private Member Functions

std::any get_clone () const override
 This function needs to be implemented by a derived class. More...
 

Private Attributes

ptr_t m_Data
 

Additional Inherited Members

- Protected Member Functions inherited from dismec::parallel::NUMAReplicatorBase
 NUMAReplicatorBase ()
 
virtual ~NUMAReplicatorBase ()=default
 
void make_copies ()
 Uses the get_clone() function of the implementing class to generate NUMA-local copies for each NUMA node. More...
 
const std::any & access_local () const
 

Detailed Description

template<class T>
class dismec::parallel::NUMAReplicator< T >

Helper class to ensure that each NUMA node has its own copy of some immutable data.

Template Parameters
TThe type of the data to be duplicated among NUMA nodes. Must be copyable.

We assume that we have the data available as std::shared_ptr<T>, and that T is copyable. The class provides one function, get_local() which returns a shared_ptr to the data on the NUMA node of the calling process.

Most of the implementation of this class is independent of the contained type, and provided by NUMAReplicatorBase.

Definition at line 72 of file numa.h.

Member Typedef Documentation

◆ ptr_t

template<class T >
using dismec::parallel::NUMAReplicator< T >::ptr_t = std::shared_ptr<const T>
private

Definition at line 73 of file numa.h.

Constructor & Destructor Documentation

◆ NUMAReplicator()

template<class T >
dismec::parallel::NUMAReplicator< T >::NUMAReplicator ( std::shared_ptr< const T >  data)
inlineexplicit

Initializes the NUMAReplicator and distributes the data to all NUMA nodes.

Definition at line 76 of file numa.h.

References dismec::parallel::NUMAReplicatorBase::make_copies().

Member Function Documentation

◆ get_clone()

template<class T >
std::any dismec::parallel::NUMAReplicator< T >::get_clone ( ) const
inlineoverrideprivatevirtual

This function needs to be implemented by a derived class.

Implements dismec::parallel::NUMAReplicatorBase.

Definition at line 92 of file numa.h.

References dismec::parallel::NUMAReplicator< T >::m_Data.

◆ get_local()

template<class T >
std::shared_ptr<const T> dismec::parallel::NUMAReplicator< T >::get_local ( ) const
inline

Gets the local copy of the data. The calling thread should cache this value, to prevent the overhead of doing this lookup.

Definition at line 82 of file numa.h.

References dismec::parallel::NUMAReplicatorBase::access_local(), and dismec::parallel::NUMAReplicator< T >::m_Data.

Referenced by dismec::init::ConstantInitializationStrategy::make_initializer().

Member Data Documentation

◆ m_Data


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