13 #include "spdlog/spdlog.h"
57 [[nodiscard]]
virtual std::any
get_clone()
const = 0;
73 using ptr_t = std::shared_ptr<const T>;
84 if(data.has_value()) {
85 return std::any_cast<ptr_t>(data);
93 return std::make_shared<const T>(*
m_Data);
Base class for NUMAReplicator.
bool m_HasNUMA
Whether NUMA functions are available.
void make_copies()
Uses the get_clone() function of the implementing class to generate NUMA-local copies for each NUMA n...
virtual std::any get_clone() const =0
This function needs to be implemented by a derived class.
std::vector< std::any > m_Copies
This vector contains one copy of data for each NUMA node.
int num_numa() const
This returns the number of NUMA nodes.
bool has_numa() const
this returns true if NUMA is available. Otherwise, there will be no replication.
virtual ~NUMAReplicatorBase()=default
const std::any & access_local() const
Helper class to ensure that each NUMA node has its own copy of some immutable data.
std::shared_ptr< const T > get_local() const
std::any get_clone() const override
This function needs to be implemented by a derived class.
std::shared_ptr< const T > ptr_t
NUMAReplicator(std::shared_ptr< const T > data)
Initializes the NUMAReplicator and distributes the data to all NUMA nodes.
This class helps with distributing threads to the different CPU cores.
void pin_this_thread(thread_id_t thread_id)
std::vector< cpu_id_t > m_TargetCPUs
List of CPUs to which the threads will be assigned.
ThreadDistributor(long num_threads, std::shared_ptr< spdlog::logger >={})
std::shared_ptr< spdlog::logger > m_Logger
Strong typedef for an int to signify a thread id.
void pin_to_data(const void *data)
Pint the calling thread to the NUMA node on which data resides.