Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
threadManager_OpenMP.cpp
Go to the documentation of this file.
1 
15 
16 
18 #include "IO/bridgeIO.h"
19 using Bridge::vout;
20 
21 // These are stub routine when OpenMP is not used.
22 // [11 Mar 2014 H.Matsufuru]
23 //====================================================================
24 // initialization of static member variables.
25 
28 std::vector<double> ThreadManager_OpenMP::m_darray_reduction(0);
29 std::vector<float> ThreadManager_OpenMP::m_darray_reductionF(0);
30 
31 //====================================================================
32 void ThreadManager_OpenMP::init(int Nthread)
33 {
35 
36  m_Nthread = 1;
37 
38  vout.general(m_vl, "ThreadManager_OpenMP being setup.\n");
39  vout.general(m_vl, " Number of thread = %d\n", m_Nthread);
40  vout.general(m_vl, " OpenMP is not used: stub implementation.\n");
41 }
42 
43 
44 //====================================================================
46 {
47  vout.paranoiac(m_vl, "Thread manager says good-bye.\n");
48 }
49 
50 
51 //====================================================================
53 {
54  return 1;
55 }
56 
57 
58 //====================================================================
60 {
61  return 0;
62 }
63 
64 
65 //====================================================================
67 {
68 }
69 
70 
71 //====================================================================
72 void ThreadManager_OpenMP::barrier(int Nthread)
73 {
74 }
75 
76 
77 //====================================================================
79 {
81 }
82 
83 //====================================================================
85  const int num,
86  const int i_thread, const int Nthread)
87 {
88  std::vector<double> sum(num);
89  Communicator::reduce_sum(num, &sum[0], a, 0);
90  for(int i=0; i<num; i++){
91  a[i] = sum[i];
92  }
93 }
94 
95 //====================================================================
97  const int num,
98  const int i_thread, const int Nthread)
99 {
100  std::vector<float> sum(num);
101  Communicator::reduce_sum(num, &sum[0], a, 0);
102  for(int i=0; i<num; i++){
103  a[i] = sum[i];
104  }
105 }
106 
107 
108 //====================================================================
110  const int i_thread, const int Nthread)
111 {
112  reduce_sum_global(&a, 1, i_thread, Nthread);
113 }
114 
115 
116 //====================================================================
118  const int i_thread, const int Nthread)
119 {
120  reduce_sum_global(&a, 1, i_thread, Nthread);
121 }
122 
123 
124 //====================================================================
126  const std::string& class_name)
127 { // do nothing.
128 }
129 
130 
131 //====================================================================
132 //============================================================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 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 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.
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:235
static Bridge::VerboseLevel m_vl
verbose level.
static std::vector< double > m_darray_reduction
VerboseLevel
Definition: bridgeIO.h:42
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
static int sync()
synchronize within small world.
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.