BioDynaMo  v1.05.120-25dc9790
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
bdm::ThreadInfo Class Reference

This class stores information about each thread. (e.g. to which NUMA node it belongs to.) NB: Threads must be bound to CPUs using OMP_PROC_BIND=true. More...

#include <thread_info.h>

Public Member Functions

 ThreadInfo (const ThreadInfo &)=delete
 
ThreadInfooperator= (const ThreadInfo &)=delete
 
int GetMyThreadId () const
 
int GetMyNumaNode () const
 
int GetMyNumaThreadId () const
 Return the numa thread id of an openmp thread. More...
 
int GetNumaNodes () const
 Returns the number of NUMA nodes on this machine. More...
 
int GetNumaNode (int omp_thread_id) const
 Returns the numa node the given openmp thread is bound to. More...
 
int GetThreadsInNumaNode (int numa_node) const
 Returns the number of threads in a given NUMA node. More...
 
int GetNumaThreadId (int omp_thread_id) const
 Return the numa thread id of an openmp thread. More...
 
int GetMaxThreads () const
 Return the maximum number of threads. More...
 
uint64_t GetUniversalThreadId () const
 
uint64_t GetMaxUniversalThreadId () const
 
void Renew ()
 

Static Public Member Functions

static ThreadInfoGetInstance ()
 

Private Member Functions

 ThreadInfo ()
 

Private Attributes

int max_threads_
 Maximum number of threads for this simulation. More...
 
uint16_t numa_nodes_
 Number of NUMA nodes on this machine. More...
 
std::vector< int > thread_numa_mapping_
 
std::vector< int > numa_thread_id_
 
std::vector< int > threads_in_numa_
 

Static Private Attributes

static std::atomic< uint64_t > thread_counter_
 

Friends

std::ostream & operator<< (std::ostream &str, const ThreadInfo &ti)
 

Detailed Description

This class stores information about each thread. (e.g. to which NUMA node it belongs to.) NB: Threads must be bound to CPUs using OMP_PROC_BIND=true.

Definition at line 31 of file thread_info.h.

Constructor & Destructor Documentation

◆ ThreadInfo() [1/2]

bdm::ThreadInfo::ThreadInfo ( const ThreadInfo )
delete

◆ ThreadInfo() [2/2]

bdm::ThreadInfo::ThreadInfo ( )
inlineprivate

Definition at line 158 of file thread_info.h.

Member Function Documentation

◆ GetInstance()

ThreadInfo * bdm::ThreadInfo::GetInstance ( )
static

Definition at line 21 of file thread_info.cc.

◆ GetMaxThreads()

int bdm::ThreadInfo::GetMaxThreads ( ) const
inline

Return the maximum number of threads.

Definition at line 66 of file thread_info.h.

◆ GetMaxUniversalThreadId()

uint64_t bdm::ThreadInfo::GetMaxUniversalThreadId ( ) const
inline

Definition at line 72 of file thread_info.h.

◆ GetMyNumaNode()

int bdm::ThreadInfo::GetMyNumaNode ( ) const
inline

Definition at line 42 of file thread_info.h.

◆ GetMyNumaThreadId()

int bdm::ThreadInfo::GetMyNumaThreadId ( ) const
inline

Return the numa thread id of an openmp thread.

Definition at line 45 of file thread_info.h.

◆ GetMyThreadId()

int bdm::ThreadInfo::GetMyThreadId ( ) const
inline

Definition at line 39 of file thread_info.h.

◆ GetNumaNode()

int bdm::ThreadInfo::GetNumaNode ( int  omp_thread_id) const
inline

Returns the numa node the given openmp thread is bound to.

Definition at line 51 of file thread_info.h.

◆ GetNumaNodes()

int bdm::ThreadInfo::GetNumaNodes ( ) const
inline

Returns the number of NUMA nodes on this machine.

Definition at line 48 of file thread_info.h.

◆ GetNumaThreadId()

int bdm::ThreadInfo::GetNumaThreadId ( int  omp_thread_id) const
inline

Return the numa thread id of an openmp thread.

Definition at line 61 of file thread_info.h.

◆ GetThreadsInNumaNode()

int bdm::ThreadInfo::GetThreadsInNumaNode ( int  numa_node) const
inline

Returns the number of threads in a given NUMA node.

Definition at line 56 of file thread_info.h.

◆ GetUniversalThreadId()

uint64_t bdm::ThreadInfo::GetUniversalThreadId ( ) const

Returns a unique thread id even for parallel regions that don't use OpenMP.

Definition at line 26 of file thread_info.cc.

◆ operator=()

ThreadInfo& bdm::ThreadInfo::operator= ( const ThreadInfo )
delete

◆ Renew()

void bdm::ThreadInfo::Renew ( )
inline

Renews the metadata.
Whenever a thread is scheduled on a different cpu, e.g. using numa_run_on_node, Renew() must be called to update the thread metadata.

Definition at line 78 of file thread_info.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  str,
const ThreadInfo ti 
)
friend

Definition at line 112 of file thread_info.h.

Member Data Documentation

◆ max_threads_

int bdm::ThreadInfo::max_threads_
private

Maximum number of threads for this simulation.

Definition at line 138 of file thread_info.h.

◆ numa_nodes_

uint16_t bdm::ThreadInfo::numa_nodes_
private

Number of NUMA nodes on this machine.

Definition at line 140 of file thread_info.h.

◆ numa_thread_id_

std::vector<int> bdm::ThreadInfo::numa_thread_id_
private

Contains the mapping omp_thread_id -> numa thread id
each thread in a numa domain has a unique id in the range 0 to number
of threads in this numa domain

Definition at line 150 of file thread_info.h.

◆ thread_counter_

std::atomic< uint64_t > bdm::ThreadInfo::thread_counter_
staticprivate

Definition at line 135 of file thread_info.h.

◆ thread_numa_mapping_

std::vector<int> bdm::ThreadInfo::thread_numa_mapping_
private

Contains the mapping thread id -> numa node
vector position = omp_thread_id
vector value = numa node

Definition at line 145 of file thread_info.h.

◆ threads_in_numa_

std::vector<int> bdm::ThreadInfo::threads_in_numa_
private

Contains the mapping numa node -> total number of threads in this numa node
vector position: numa node
vector value number of threads

Definition at line 156 of file thread_info.h.


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