Bridge++  Ver. 2.0.2
ThreadManager Class Reference

Thread manager with OpenMP. More...

#include <threadManager.h>

Static Public Member Functions

static void init (int Nthread)
 setup: called in main only once. More...
 
static void finalize ()
 finalization. More...
 
static int get_num_threads_available ()
 returns number of threads (works outside of parallel region). More...
 
static int get_num_threads ()
 returns available number of threads. More...
 
static int get_thread_id ()
 returns thread id. More...
 
static void wait ()
 barrier among threads inside a node. More...
 
static void barrier (const int Nthread)
 barrier among threads inside a node. More...
 
static void sync_barrier_all ()
 barrier among all the threads and nodes. More...
 
static void reduce_sum_global (dcomplex &value, const int i_thread, const int Nthread)
 global reduction with summation: dcomplex values are assumed thread local. More...
 
static void reduce_sum_global (dcomplex *value, const int num, const int i_thread, const int Nthread)
 global reduction with summation for an array: dcomplex values are assumed thread local. More...
 
static void reduce_sum_global (double &value, const int i_thread, const int Nthread)
 global reduction with summation: double values are assumed thread local. More...
 
static void reduce_sum_global (double *value, const int num, const int i_thread, const int Nthread)
 global reduction with summation for an array: double values are assumed thread local. More...
 
static void reduce_sum_global (float &value, const int i_thread, const int Nthread)
 global reduction with summation: float values are assumed thread local. More...
 
static void reduce_sum_global (float *value, const int num, const int i_thread, const int Nthread)
 global reduction with summation for an array: float values are assumed thread local. More...
 
static void reduce_max_global (double *value, const int num, const int i_thread, const int Nthread)
 global reduction with max for an array: double values are assumed thread local. More...
 
static void reduce_max_global (double &value, const int i_thread, const int Nthread)
 global reduction with max: double value is assumed thread local. More...
 
static void assert_single_thread (const std::string &class_name)
 assert currently running on single thread. More...
 

Static Public Attributes

static const std::string class_name = "ThreadManager"
 

Private Member Functions

 ThreadManager (const ThreadManager &)
 
ThreadManageroperator= (const ThreadManager &)
 

Static Private Attributes

static int m_Nthread = 0
 number of threads. More...
 
static Bridge::VerboseLevel m_vl = Bridge::CRUCIAL
 verbose level. More...
 
static std::vector< dcomplex > m_darray_reductionDC
 
static std::vector< double > m_darray_reduction
 
static std::vector< float > m_darray_reductionF
 
static const int each_buf_sizeDC = 16
 reduction buffer size for each thread (dcomplex) More...
 
static const int each_buf_size = 8
 reduction buffer size for each thread (double) More...
 
static const int each_buf_sizeF = 2 * each_buf_size
 reduction buffer size for each thread (float) More...
 

Detailed Description

Thread manager with OpenMP.

This class wraps OpenMP API functions. The number of available threads is specified as an argument of init() function, which is to be called at the begining of main, soon after Communicator and CommonParameter are initialized. If the specified number of threads (nthread) is not the same as that of OMP_NUM_THREADS environment variable, the number of threads is set to the specified one. If Nthread = 0 is specified, the number of threads is set to OMP_NUM_THREADS or maximum number of platform. [29 Aug 2013 H.Matsufuru]

Added reduce_sum_global for array [30 Sep 2019 I.Kanamori] Add complex args [08 Aug 2020 Y.Namekawa] Renamed: ThreadManager_OpenMP -> ThreadManager [27 Aug 2022 H.Matsufuru]

Definition at line 44 of file threadManager.h.

Constructor & Destructor Documentation

◆ ThreadManager()

ThreadManager::ThreadManager ( const ThreadManager )
private

Member Function Documentation

◆ assert_single_thread()

void ThreadManager::assert_single_thread ( const std::string &  class_name)
static

assert currently running on single thread.

Definition at line 372 of file threadManager.cpp.

◆ barrier()

void ThreadManager::barrier ( const int  Nthread)
static

barrier among threads inside a node.

Definition at line 269 of file threadManager.cpp.

◆ finalize()

void ThreadManager::finalize ( )
static

finalization.

Definition at line 239 of file threadManager.cpp.

◆ get_num_threads()

int ThreadManager::get_num_threads ( )
static

returns available number of threads.

Definition at line 246 of file threadManager.cpp.

◆ get_num_threads_available()

static int ThreadManager::get_num_threads_available ( )
inlinestatic

returns number of threads (works outside of parallel region).

Definition at line 86 of file threadManager.h.

◆ get_thread_id()

int ThreadManager::get_thread_id ( )
static

returns thread id.

Definition at line 253 of file threadManager.cpp.

◆ init()

void ThreadManager::init ( int  Nthread)
static

setup: called in main only once.

Definition at line 202 of file threadManager.cpp.

◆ operator=()

ThreadManager& ThreadManager::operator= ( const ThreadManager )
private

◆ reduce_max_global() [1/2]

void ThreadManager::reduce_max_global ( double &  value,
const int  i_thread,
const int  Nthread 
)
static

global reduction with max: double value is assumed thread local.

Definition at line 351 of file threadManager.cpp.

◆ reduce_max_global() [2/2]

void ThreadManager::reduce_max_global ( double *  value,
const int  num,
const int  i_thread,
const int  Nthread 
)
static

global reduction with max for an array: double values are assumed thread local.

Definition at line 361 of file threadManager.cpp.

◆ reduce_sum_global() [1/6]

void ThreadManager::reduce_sum_global ( dcomplex &  value,
const int  i_thread,
const int  Nthread 
)
static

global reduction with summation: dcomplex values are assumed thread local.

Definition at line 288 of file threadManager.cpp.

◆ reduce_sum_global() [2/6]

void ThreadManager::reduce_sum_global ( dcomplex *  value,
const int  num,
const int  i_thread,
const int  Nthread 
)
static

global reduction with summation for an array: dcomplex values are assumed thread local.

Definition at line 298 of file threadManager.cpp.

◆ reduce_sum_global() [3/6]

void ThreadManager::reduce_sum_global ( double &  value,
const int  i_thread,
const int  Nthread 
)
static

global reduction with summation: double values are assumed thread local.

Definition at line 309 of file threadManager.cpp.

◆ reduce_sum_global() [4/6]

void ThreadManager::reduce_sum_global ( double *  value,
const int  num,
const int  i_thread,
const int  Nthread 
)
static

global reduction with summation for an array: double values are assumed thread local.

Definition at line 319 of file threadManager.cpp.

◆ reduce_sum_global() [5/6]

void ThreadManager::reduce_sum_global ( float &  value,
const int  i_thread,
const int  Nthread 
)
static

global reduction with summation: float values are assumed thread local.

Definition at line 330 of file threadManager.cpp.

◆ reduce_sum_global() [6/6]

void ThreadManager::reduce_sum_global ( float *  value,
const int  num,
const int  i_thread,
const int  Nthread 
)
static

global reduction with summation for an array: float values are assumed thread local.

Definition at line 340 of file threadManager.cpp.

◆ sync_barrier_all()

void ThreadManager::sync_barrier_all ( )
static

barrier among all the threads and nodes.

Definition at line 276 of file threadManager.cpp.

◆ wait()

void ThreadManager::wait ( )
static

barrier among threads inside a node.

Definition at line 260 of file threadManager.cpp.

Member Data Documentation

◆ class_name

const std::string ThreadManager::class_name = "ThreadManager"
static

Definition at line 77 of file threadManager.h.

◆ each_buf_size

const int ThreadManager::each_buf_size = 8
staticprivate

reduction buffer size for each thread (double)

Definition at line 62 of file threadManager.h.

◆ each_buf_sizeDC

const int ThreadManager::each_buf_sizeDC = 16
staticprivate

reduction buffer size for each thread (dcomplex)

Definition at line 56 of file threadManager.h.

◆ each_buf_sizeF

const int ThreadManager::each_buf_sizeF = 2 * each_buf_size
staticprivate

reduction buffer size for each thread (float)

Definition at line 68 of file threadManager.h.

◆ m_darray_reduction

std::vector< double > ThreadManager::m_darray_reduction
staticprivate

Definition at line 49 of file threadManager.h.

◆ m_darray_reductionDC

std::vector< dcomplex > ThreadManager::m_darray_reductionDC
staticprivate

Definition at line 48 of file threadManager.h.

◆ m_darray_reductionF

std::vector< float > ThreadManager::m_darray_reductionF
staticprivate

Definition at line 50 of file threadManager.h.

◆ m_Nthread

int ThreadManager::m_Nthread = 0
staticprivate

number of threads.

Definition at line 46 of file threadManager.h.

◆ m_vl

Bridge::VerboseLevel ThreadManager::m_vl = Bridge::CRUCIAL
staticprivate

verbose level.

Definition at line 47 of file threadManager.h.


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