Bridge++  Version 1.5.4
 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 
19 //#include "configure.h"
20 //#include "bridge_defs.h"
22 #include "IO/bridgeIO.h"
23 
24 
26 
43  private:
44  static int m_Nthread;
46  static std::vector<double> m_darray_reduction;
47  static std::vector<float> m_darray_reductionF;
48 
49  // buffer size for global reduction
50 #ifdef REDUCTION_EACH_BUF_SIZE
51  static const int each_buf_size = REDUCTION_EACH_BUF_SIZE ;
52 #else
53  static const int each_buf_size = 8;
54 #endif
55 
56 #ifdef REDUCTION_EACH_BUF_SIZE_F
57  static const int each_buf_sizeF = REDUCTION_EACH_BUF_SIZE_F ;
58 #else
59  static const int each_buf_sizeF = 2*each_buf_size;
60 #endif
61 
62  private:
63  // non-copyable
66 
67  public:
68  static const std::string class_name;
69 
71  static void init(int Nthread);
72 
74  static void finalize();
75 
77  static int get_num_threads_available() { return m_Nthread; }
78 
80  static int get_num_threads();
81 
83  static int get_thread_id();
84 
86  static void wait();
87 
89  static void barrier(const int Nthread);
90 
92  static void sync_barrier_all();
93 
95  static void reduce_sum_global(double& value,
96  const int i_thread, const int Nthread);
97 
99  static void reduce_sum_global(double* value, const int num,
100  const int i_thread, const int Nthread);
101 
103  static void reduce_sum_global(float& value,
104  const int i_thread, const int Nthread);
105 
107  static void reduce_sum_global(float* value, const int num,
108  const int i_thread, const int Nthread);
109 
111  static void assert_single_thread(const std::string& class_name);
112 };
113 #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 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 const std::string class_name
static void barrier(const int Nthread)
barrier among threads inside a node.
static void reduce_sum_global(double &value, const int i_thread, const int Nthread)
global reduction with summation: value is assumed thread local.
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 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 &)