Bridge++  Version 1.6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
threadManager_OpenMP.cpp
Go to the documentation of this file.
1 
15 
17 #include "IO/bridgeIO.h"
18 using Bridge::vout;
19 
20 // These are stub routine when OpenMP is not used.
21 // [11 Mar 2014 H.Matsufuru]
22 //====================================================================
23 // initialization of static member variables.
24 
27 std::vector<double> ThreadManager_OpenMP::m_darray_reduction(0);
28 std::vector<float> ThreadManager_OpenMP::m_darray_reductionF(0);
29 
30 //====================================================================
31 void ThreadManager_OpenMP::init(int Nthread)
32 {
34 
35  m_Nthread = 1;
36 
37  vout.general(m_vl, "ThreadManager_OpenMP being setup.\n");
38  vout.general(m_vl, " Number of thread = %d\n", m_Nthread);
39  vout.general(m_vl, " OpenMP is not used: stub implementation.\n");
40 }
41 
42 
43 //====================================================================
45 {
46  vout.paranoiac(m_vl, "Thread manager says good-bye.\n");
47 }
48 
49 
50 //====================================================================
52 {
53  return 1;
54 }
55 
56 
57 //====================================================================
59 {
60  return 0;
61 }
62 
63 
64 //====================================================================
66 {
67 }
68 
69 
70 //====================================================================
71 void ThreadManager_OpenMP::barrier(int Nthread)
72 {
73 }
74 
75 
76 //====================================================================
78 {
80 }
81 
82 
83 //====================================================================
85  const int i_thread, const int Nthread)
86 {
87  reduce_sum_global(&a, 1, i_thread, Nthread);
88 }
89 
90 
91 //====================================================================
93  const int num,
94  const int i_thread, const int Nthread)
95 {
96  std::vector<dcomplex> sum(num);
97  Communicator::reduce_sum(num, &sum[0], a, 0);
98  for (int i = 0; i < num; i++) {
99  a[i] = sum[i];
100  }
101 }
102 
103 
104 //====================================================================
106  const int i_thread, const int Nthread)
107 {
108  reduce_sum_global(&a, 1, i_thread, Nthread);
109 }
110 
111 
112 //====================================================================
114  const int num,
115  const int i_thread, const int Nthread)
116 {
117  std::vector<double> sum(num);
118  Communicator::reduce_sum(num, &sum[0], a, 0);
119  for (int i = 0; i < num; i++) {
120  a[i] = sum[i];
121  }
122 }
123 
124 
125 //====================================================================
127  const int i_thread, const int Nthread)
128 {
129  reduce_sum_global(&a, 1, i_thread, Nthread);
130 }
131 
132 
133 //====================================================================
135  const int num,
136  const int i_thread, const int Nthread)
137 {
138  std::vector<float> sum(num);
139  Communicator::reduce_sum(num, &sum[0], a, 0);
140  for (int i = 0; i < num; i++) {
141  a[i] = sum[i];
142  }
143 }
144 
145 
146 //====================================================================
148  const std::string& class_name)
149 { // do nothing.
150 }
151 
152 
153 //====================================================================
154 //============================================================END=====
static int m_Nthread
number of threads.
BridgeIO vout
Definition: bridgeIO.cpp:503
static int get_num_threads()
returns available number of threads.
void general(const char *format,...)
Definition: bridgeIO.cpp:197
static std::vector< float > m_darray_reductionF
static Bridge::VerboseLevel Vlevel()
static int reduce_sum(int count, dcomplex *recv_buf, dcomplex *send_buf, int pattern=0)
make a global sum of an array of dcomplex over the communicator. pattern specifies the dimensions to ...
static void wait()
barrier among threads inside a node.
static int get_thread_id()
returns thread id.
static void init(int Nthread)
setup: called in main only once.
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.
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:235
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
static int sync()
synchronize within small world.
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.