Bridge++  Ver. 2.0.2
threadManager.h
Go to the documentation of this file.
1 
14 #ifndef THREADMANAGER_INCLUDED
15 #define THREADMANAGER_INCLUDED
16 
17 #include <string>
18 
20 #include "IO/bridgeIO.h"
21 
22 
24 
45  private:
46  static int m_Nthread;
48  static std::vector<dcomplex> m_darray_reductionDC;
49  static std::vector<double> m_darray_reduction;
50  static std::vector<float> m_darray_reductionF;
51 
52  // buffer size for global reduction
53 #ifdef REDUCTION_EACH_BUF_SIZE_DC
54  static const int each_buf_size = REDUCTION_EACH_BUF_SIZE_DC;
55 #else
56  static const int each_buf_sizeDC = 16;
57 #endif
58 
59 #ifdef REDUCTION_EACH_BUF_SIZE
60  static const int each_buf_size = REDUCTION_EACH_BUF_SIZE;
61 #else
62  static const int each_buf_size = 8;
63 #endif
64 
65 #ifdef REDUCTION_EACH_BUF_SIZE_F
66  static const int each_buf_sizeF = REDUCTION_EACH_BUF_SIZE_F;
67 #else
68  static const int each_buf_sizeF = 2 * each_buf_size;
69 #endif
70 
71  private:
72  // non-copyable
75 
76  public:
77  static const std::string class_name;
78 
80  static void init(int Nthread);
81 
83  static void finalize();
84 
86  static int get_num_threads_available() { return m_Nthread; }
87 
89  static int get_num_threads();
90 
92  static int get_thread_id();
93 
95  static void wait();
96 
98  static void barrier(const int Nthread);
99 
101  static void sync_barrier_all();
102 
104  static void reduce_sum_global(dcomplex& value,
105  const int i_thread, const int Nthread);
106 
108  static void reduce_sum_global(dcomplex *value, const int num,
109  const int i_thread, const int Nthread);
110 
112  static void reduce_sum_global(double& value,
113  const int i_thread, const int Nthread);
114 
116  static void reduce_sum_global(double *value, const int num,
117  const int i_thread, const int Nthread);
118 
120  static void reduce_sum_global(float& value,
121  const int i_thread, const int Nthread);
122 
124  static void reduce_sum_global(float *value, const int num,
125  const int i_thread, const int Nthread);
126 
128  static void reduce_max_global(double *value, const int num,
129  const int i_thread, const int Nthread);
130 
132  static void reduce_max_global(double& value,
133  const int i_thread, const int Nthread);
134 
136  static void assert_single_thread(const std::string& class_name);
137 };
138 
139 
140 //typedef ThreadManager_OpenMP ThreadManager;
142 
143 
144 #endif //THREADMANAGER_INCLUDED
bridgeIO.h
ThreadManager::each_buf_size
static const int each_buf_size
reduction buffer size for each thread (double)
Definition: threadManager.h:62
ThreadManager::m_Nthread
static int m_Nthread
number of threads.
Definition: threadManager.h:46
ThreadManager::get_num_threads
static int get_num_threads()
returns available number of threads.
Definition: threadManager.cpp:246
ThreadManager::m_darray_reduction
static std::vector< double > m_darray_reduction
Definition: threadManager.h:49
ThreadManager::operator=
ThreadManager & operator=(const ThreadManager &)
ThreadManager::barrier
static void barrier(const int Nthread)
barrier among threads inside a node.
Definition: threadManager.cpp:269
ThreadManager::each_buf_sizeF
static const int each_buf_sizeF
reduction buffer size for each thread (float)
Definition: threadManager.h:68
ThreadManager::reduce_max_global
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.
Definition: threadManager.cpp:361
ThreadManager::sync_barrier_all
static void sync_barrier_all()
barrier among all the threads and nodes.
Definition: threadManager.cpp:276
ThreadManager::init
static void init(int Nthread)
setup: called in main only once.
Definition: threadManager.cpp:202
ThreadManager::m_vl
static Bridge::VerboseLevel m_vl
verbose level.
Definition: threadManager.h:47
ThreadManager::reduce_sum_global
static void reduce_sum_global(dcomplex &value, const int i_thread, const int Nthread)
global reduction with summation: dcomplex values are assumed thread local.
Definition: threadManager.cpp:288
ThreadManager::class_name
static const std::string class_name
Definition: threadManager.h:77
ThreadManager_OpenMP
ThreadManager ThreadManager_OpenMP
Definition: threadManager.h:141
ThreadManager::m_darray_reductionDC
static std::vector< dcomplex > m_darray_reductionDC
Definition: threadManager.h:48
ThreadManager::wait
static void wait()
barrier among threads inside a node.
Definition: threadManager.cpp:260
ThreadManager::m_darray_reductionF
static std::vector< float > m_darray_reductionF
Definition: threadManager.h:50
ThreadManager::get_num_threads_available
static int get_num_threads_available()
returns number of threads (works outside of parallel region).
Definition: threadManager.h:86
ThreadManager::finalize
static void finalize()
finalization.
Definition: threadManager.cpp:239
commonParameters.h
ThreadManager::get_thread_id
static int get_thread_id()
returns thread id.
Definition: threadManager.cpp:253
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
ThreadManager
Thread manager with OpenMP.
Definition: threadManager.h:44
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
ThreadManager::ThreadManager
ThreadManager(const ThreadManager &)
ThreadManager::each_buf_sizeDC
static const int each_buf_sizeDC
reduction buffer size for each thread (dcomplex)
Definition: threadManager.h:56