JANA2
C++ framework for multi-threaded data processing
JCpuInfo Namespace Reference

Functions

size_t GetNumCpus ()
 
uint32_t GetCpuID ()
 
bool PinThreadToCpu (std::thread *thread, size_t cpu_id)
 

Detailed Description

The cache line size is useful for creating a buffer to make sure that a variable accessed by multiple threads does not share the cache line it is on. This is useful for variables that may be written-to by one of the threads, because the thread will acquire locked access to the entire cache line. This blocks other threads from operating on the other data stored on the cache line. Note that it is also important to align the shared data as well. See http://www.drdobbs.com/parallel/eliminate-false-sharing/217500206?pgno=4 for more details.

Function Documentation

◆ GetCpuID()

uint32_t JCpuInfo::GetCpuID ( )

Returns the current CPU the calling thread is running on. Note that unless the thread affinity has been set, this may change, even before returning from this call. The thread affinity of all threads may be fixed by setting the AFFINITY configuration parameter at program start up.

◆ GetNumCpus()

size_t JCpuInfo::GetNumCpus ( )

Returns the number of cores that are on the computer. The count will be full cores+hyperthreads (or equivalent)

Referenced by JApplication::Initialize().