Bridge++  Version 1.6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
threadManager_OpenMP.h
Go to the documentation of this file.
1 
14 #ifndef THREADMANAGER_OPENMP_INCLUDED
15 #define THREADMANAGER_OPENMP_INCLUDED
16 
17 #include <string>
18 
20 #include "IO/bridgeIO.h"
21 
22 
24 
43  private:
44  static int m_Nthread;
46  static std::vector<dcomplex> m_darray_reductionDC;
47  static std::vector<double> m_darray_reduction;
48  static std::vector<float> m_darray_reductionF;
49 
50  // buffer size for global reduction
51 #ifdef REDUCTION_EACH_BUF_SIZE_DC
52  static const int each_buf_size = REDUCTION_EACH_BUF_SIZE_DC;
53 #else
54  static const int each_buf_sizeDC = 16;
55 #endif
56 
57 #ifdef REDUCTION_EACH_BUF_SIZE
58  static const int each_buf_size = REDUCTION_EACH_BUF_SIZE;
59 #else
60  static const int each_buf_size = 8;
61 #endif
62 
63 #ifdef REDUCTION_EACH_BUF_SIZE_F
64  static const int each_buf_sizeF = REDUCTION_EACH_BUF_SIZE_F;
65 #else
66  static const int each_buf_sizeF = 2 * each_buf_size;
67 #endif
68 
69  private:
70  // non-copyable
73 
74  public:
75  static const std::string class_name;
76 
78  static void init(int Nthread);
79 
81  static void finalize();
82 
84  static int get_num_threads_available() { return m_Nthread; }
85 
87  static int get_num_threads();
88 
90  static int get_thread_id();
91 
93  static void wait();
94 
96  static void barrier(const int Nthread);
97 
99  static void sync_barrier_all();
100 
102  static void reduce_sum_global(dcomplex& value,
103  const int i_thread, const int Nthread);
104 
106  static void reduce_sum_global(dcomplex *value, const int num,
107  const int i_thread, const int Nthread);
108 
110  static void reduce_sum_global(double& value,
111  const int i_thread, const int Nthread);
112 
114  static void reduce_sum_global(double *value, const int num,
115  const int i_thread, const int Nthread);
116 
118  static void reduce_sum_global(float& value,
119  const int i_thread, const int Nthread);
120 
122  static void reduce_sum_global(float *value, const int num,
123  const int i_thread, const int Nthread);
124 
126  static void assert_single_thread(const std::string& class_name);
127 };
128 #endif //THREADMANAGER_OPENMP_INCLUDED
static int m_Nthread
number of threads.
static const int each_buf_size
reduction buffer size for each thread (double)
static int get_num_threads()
returns available number of threads.
static const int each_buf_sizeDC
reduction buffer size for each thread (dcomplex)
static std::vector< float > m_darray_reductionF
static void wait()
barrier among threads inside a node.
ThreadManager_OpenMP & operator=(const ThreadManager_OpenMP &)
static int get_thread_id()
returns thread id.
static void init(int Nthread)
setup: called in main only once.
static std::vector< dcomplex > m_darray_reductionDC
static const std::string class_name
static void barrier(const int Nthread)
barrier among threads inside a node.
static void sync_barrier_all()
barrier among all the threads and nodes.
static void finalize()
finalization.
static int get_num_threads_available()
returns number of threads (works outside of parallel region).
static const int each_buf_sizeF
reduction buffer size for each thread (float)
static void reduce_sum_global(dcomplex &value, const int i_thread, const int Nthread)
global reduction with summation: dcomplex values are assumed thread local.
static Bridge::VerboseLevel m_vl
verbose level.
static std::vector< double > m_darray_reduction
VerboseLevel
Definition: bridgeIO.h:42
Thread manager with OpenMP.
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
ThreadManager_OpenMP(const ThreadManager_OpenMP &)