Bridge++  Ver. 2.0.2
aprecond_Mixedprec-tmpl.h
Go to the documentation of this file.
1 
9 #include <cassert>
10 
12 
13 
14 template<typename AFIELD, typename AFIELD2>
16  = "APrecond_Mixedprec";
17 //====================================================================
18 template<typename AFIELD, typename AFIELD2>
20 {
22 
23  int nin = m_solver->get_fopr()->field_nin();
24  int nvol = m_solver->get_fopr()->field_nvol();
25  int nex = m_solver->get_fopr()->field_nex();
26 
27  m_v2.reset(nin, nvol, nex);
28  m_w2.reset(nin, nvol, nex);
29 
30  int Nvol = CommonParameters::Nvol();
31  if (nvol == Nvol) {
32  m_field_type = LEXICAL;
33  } else if (nvol == Nvol / 2) {
34  m_field_type = EVEN_ODD;
35  } else {
36  vout.crucial("%s: unsupported field_type.\n", class_name.c_str());
37  exit(EXIT_FAILURE);
38  }
39 
40  m_accum_flop = 0.0;
41 }
42 
43 
44 //====================================================================
45 template<typename AFIELD, typename AFIELD2>
47 {
48  // ThreadManager::assert_single_thread(class_name);
49  // delete m_solver;
50 }
51 
52 
53 //====================================================================
54 template<typename AFIELD, typename AFIELD2>
56  const AFIELD& w)
57 {
58  int nin = v.nin();
59  int nvol = v.nvol();
60  int nex = v.nex();
61  assert(w.check_size(nin, nvol, nex));
62  assert(m_v2.check_size(nin, nvol, nex));
63  assert(m_w2.check_size(nin, nvol, nex));
64 
65  int nconv = -1;
66  real_t2 diff;
67 
68 #pragma omp barrier
69 
70  if (m_field_type == LEXICAL) {
73  convert(index_f, m_w2, index_d, w);
74  } else if (m_field_type == EVEN_ODD) {
77  convert_h(index_f, m_w2, index_d, w);
78  } else {
79  vout.crucial("%s: unsupported field_type.\n", class_name.c_str());
80  exit(EXIT_FAILURE);
81  }
82 
83 #pragma omp barrier
84 
85  m_solver->solve(m_v2, m_w2, nconv, diff);
86 #pragma omp barrier
87 
88 #pragma omp master
89  {
90  m_accum_flop += m_solver->flop_count();
91  }
92 
93  vout.detailed("%s: nconv = %d diff = %e\n",
94  class_name.c_str(), nconv, diff);
95 
96  if (m_field_type == LEXICAL) {
99  convert(index_d, v, index_f, m_v2);
100  } else if (m_field_type == EVEN_ODD) {
103  convert_h(index_d, v, index_f, m_v2);
104  }
105 
106 #pragma omp barrier
107 }
108 
109 
110 //====================================================================
111 template<typename AFIELD, typename AFIELD2>
113 {
114 #pragma omp master
115  {
116  m_accum_flop = 0.0;
117  }
118 }
119 
120 
121 //====================================================================
122 template<typename AFIELD, typename AFIELD2>
124 {
125  return m_accum_flop;
126 }
127 
128 
129 //============================================================END=====
AIndex_lex
Definition: aindex_lex_base.h:17
convert
void convert(INDEX &index, AFIELD &v, const Field &w)
Definition: afield-inc.h:129
Bridge::BridgeIO::detailed
void detailed(const char *format,...)
Definition: bridgeIO.cpp:219
Field::nex
int nex() const
Definition: field.h:128
Field::check_size
bool check_size(const int nin, const int nvol, const int nex) const
checking size parameters. [23 May 2016 H.Matsufuru]
Definition: field.h:135
APrecond_Mixedprec::tidyup
void tidyup()
Definition: aprecond_Mixedprec-tmpl.h:46
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
APrecond_Mixedprec::reset_flop_count
void reset_flop_count()
Definition: aprecond_Mixedprec-tmpl.h:112
Field::nin
int nin() const
Definition: field.h:126
APrecond_Mixedprec::real_t2
AFIELD2::real_t real_t2
Definition: aprecond_Mixedprec.h:32
aprecond_Mixedprec.h
Field::nvol
int nvol() const
Definition: field.h:127
APrecond_Mixedprec::flop_count
double flop_count()
Definition: aprecond_Mixedprec-tmpl.h:123
APrecond_Mixedprec
Definition: aprecond_Mixedprec.h:28
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field
Container of Field-type object.
Definition: field.h:46
convert_h
void convert_h(INDEX2 &index2, FIELD2 &v2, const INDEX1 &index1, const FIELD1 &v1)
Definition: afield-inc.h:307
ThreadManager::assert_single_thread
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Definition: threadManager.cpp:372
APrecond_Mixedprec::init
void init()
Definition: aprecond_Mixedprec-tmpl.h:19
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
AIndex_eo
Definition: aindex_eo_base.h:17
APrecond_Mixedprec::mult
void mult(AFIELD &, const AFIELD &)
Definition: aprecond_Mixedprec-tmpl.h:55