Bridge++  Ver. 2.0.2
threadManager.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::m_darray_reduction(0);
28 std::vector<float> ThreadManager::m_darray_reductionF(0);
29 
30 //====================================================================
31 void ThreadManager::init(int Nthread)
32 {
34 
35  m_Nthread = 1;
36 
37  vout.general(m_vl, "ThreadManager 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::barrier(int Nthread)
72 {
73 }
74 
75 
76 //====================================================================
78 {
80 }
81 
82 
83 //====================================================================
84 void ThreadManager::reduce_sum_global(dcomplex& a,
85  const int ith, const int nth)
86 {
87  reduce_sum_global(&a, 1, ith, nth);
88 }
89 
90 
91 //====================================================================
92 void ThreadManager::reduce_sum_global(dcomplex *a,
93  const int num,
94  const int ith, const int nth)
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 //====================================================================
105 void ThreadManager::reduce_sum_global(double& a,
106  const int ith, const int nth)
107 {
108  reduce_sum_global(&a, 1, ith, nth);
109 }
110 
111 
112 //====================================================================
113 void ThreadManager::reduce_sum_global(double *a,
114  const int num,
115  const int ith, const int nth)
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 ith, const int nth)
128 {
129  reduce_sum_global(&a, 1, ith, nth);
130 }
131 
132 
133 //====================================================================
135  const int num,
136  const int ith, const int nth)
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 //====================================================================
147 void ThreadManager::reduce_max_global(double *a, const int num,
148  const int ith, const int nth)
149 {
150  std::vector<double> vmax(num);
151  Communicator::reduce_max(num, &vmax[0], a, 0);
152  for (int i = 0; i < num; ++i) {
153  a[i] = vmax[i];
154  }
155 }
156 
157 
158 //====================================================================
159 void ThreadManager::reduce_max_global(double& a,
160  const int ith, const int nth)
161 {
162  reduce_max_global(&a, 1, ith, nth);
163 }
164 
165 
166 //====================================================================
167 void ThreadManager::assert_single_thread(const std::string& class_name)
168 {
169  // do nothing.
170 }
171 
172 
173 //============================================================END=====
Communicator::sync
static int sync()
synchronize within small world.
Definition: communicator.cpp:140
bridgeIO.h
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
Communicator::reduce_max
static int reduce_max(int count, double *recv_buf, double *send_buf, int pattern=0)
find a global maximum of an array of double over the communicator. pattern specifies the dimensions t...
Definition: communicator.cpp:290
ThreadManager::m_darray_reduction
static std::vector< double > m_darray_reduction
Definition: threadManager.h:49
ThreadManager::barrier
static void barrier(const int Nthread)
barrier among threads inside a node.
Definition: threadManager.cpp:269
Bridge::BridgeIO::paranoiac
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:238
Communicator::reduce_sum
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 ...
Definition: communicator.cpp:263
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.h
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
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
ThreadManager::finalize
static void finalize()
finalization.
Definition: threadManager.cpp:239
communicator.h
ThreadManager::get_thread_id
static int get_thread_id()
returns thread id.
Definition: threadManager.cpp:253
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Bridge::CRUCIAL
@ CRUCIAL
Definition: bridgeIO.h:44
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512