Bridge++  Ver. 2.0.2
afopr_Clover_coarse.h
Go to the documentation of this file.
1 
10 #ifndef QXS_AFOPR_CLOVER_COARSE_INCLUDED
11 #define QXS_AFOPR_CLOVER_COARSE_INCLUDED
12 
13 #include <cstdio>
14 #include <cstdlib>
15 
16 #include <string>
17 using std::string;
18 
19 #include <vector>
20 using std::vector;
21 
22 #include "lib/Fopr/afopr.h"
23 
25 #include "lib/IO/bridgeIO.h"
26 using Bridge::vout;
27 
30 
31 #include "lib/Tools/timer.h"
32 
36 
37 class Field;
38 
39 template<typename AFIELD>
40 class AFopr_Clover_coarse : public AFopr<AFIELD>
41 {
42  public:
43  typedef typename AFIELD::real_t real_t;
44  typedef typename AFIELD::complex_t complex_t;
45  static const std::string class_name;
46 
47  protected:
48  int m_Nx, m_Ny, m_Nz, m_Nt, m_Nst;
50 
52  int m_ncol;
53  int m_Nc, m_Nc2;
54  int m_Nvc, m_Ndf;
55 
56  size_t m_coarse_lvol;
57 
61 
62  std::string m_repr;
63 
65 
67 
68  std::string m_mode;
69 
71 
73 
74  int do_comm[4]; // switchs of communication (4=Ndim): (0: n, 1: y).
75  int do_comm_any; // switchs of communication (if any): (0: n, 1: y).
76 
77  std::vector<int> m_bdsize;
78  using allocator_t = typename AFIELD::template aligned_allocator<char>;
80  std::vector<Channel> chsend_up, chrecv_up, chsend_dn, chrecv_dn;
82 
83  std::vector<complex_t> tmp_buffer1;
84  std::vector<complex_t> tmp_buffer2;
85  std::vector<complex_t> tmp_buffer3;
86  std::vector<real_t *> work_shifted;
87 
88  public:
91  {
92  init();
93  set_parameters(params);
94  }
95 
97  {
98  init();
99  }
100 
103 
105  void set_parameters(const Parameters& params);
106 
108  void set_parameters(const int num_testvectors,
109  const std::vector<int>& coarse_lattice);
110 
112  void set_config(Field *u);
113 
115  bool needs_convert() { return true; }
116 
118  void convert(AFIELD& v, const Field& w);
119 
121  void reverse(Field& v, const AFIELD& w);
122 
124  // inline Field* get_conf(void){return &m_U.ptr();};
125 
127  // void set_mode(std::string mode){ m_mode = mode; }
128  void set_mode(std::string mode);
129 
131  std::string get_mode() const;
132 
133  void mult(AFIELD&, const AFIELD&);
134  void mult_dag(AFIELD&, const AFIELD&);
135  void mult_gm5(AFIELD&, const AFIELD&);
136 
137  void mult_csw(AFIELD&, const AFIELD&);
138 
139  void mult_up(int mu, AFIELD&, const AFIELD&);
140  void mult_dn(int mu, AFIELD&, const AFIELD&);
141 
142  void generate_coarse_op(AFopr_dd<AFIELD> *fine_afopr, const std::vector<AFIELD>& testvec);
143 
144 
146  int field_nin() { return 2 * m_Nc; }
147 
149  int field_nvol() { return m_Nst; }
150 
152  int field_nex() { return 1; }
153 
155  double flop_count() { return flop_count(m_mode); }
156 
158  double flop_count(const std::string mode);
159 
160  // for debug
161  void dump();
162 
163  private:
165  void init();
166 
168  void tidyup();
169 
171  void setup_channels();
172 
174  void set_boundary();
175 
177  void set_csw();
178 
180  void mult_csw(real_t *, real_t *);
181 
182  void DdagD(AFIELD&, const AFIELD&);
183  void Ddag(AFIELD&, const AFIELD&);
184  void H(AFIELD&, const AFIELD&);
185  void D(AFIELD&, const AFIELD&);
186 
187  void mult_gm4(AFIELD&, const AFIELD&);
188 
190  void mult_D(AFIELD&, const AFIELD&);
191 
193  //void mult_D_qws(AFIELD&, const AFIELD&);
194 
196  void mult_D_alt(AFIELD&, const AFIELD&);
197  void mult_D_alt_keep(AFIELD&, const AFIELD&);
198  void mult_D_alt_keep2(AFIELD&, const AFIELD&);
199 
200  void mult_xp(real_t *, real_t *);
201  void mult_xm(real_t *, real_t *);
202  void mult_yp(real_t *, real_t *);
203  void mult_ym(real_t *, real_t *);
204  void mult_zp(real_t *, real_t *);
205  void mult_zm(real_t *, real_t *);
206  void mult_tp(real_t *, real_t *);
207  void mult_tm(real_t *, real_t *);
208 
209  void mult_xp1(real_t *, real_t *);
210  void mult_xm1(real_t *, real_t *);
211  void mult_yp1(real_t *, real_t *);
212  void mult_ym1(real_t *, real_t *);
213  void mult_zp1(real_t *, real_t *);
214  void mult_zm1(real_t *, real_t *);
215  void mult_tp1(real_t *, real_t *);
216  void mult_tm1(real_t *, real_t *);
217 
218  void mult_xpb2(real_t *, real_t *);
219  void mult_xmb2(real_t *, real_t *);
220  void mult_ypb2(real_t *, real_t *);
221  void mult_ymb2(real_t *, real_t *);
222  void mult_zpb2(real_t *, real_t *);
223  void mult_zmb2(real_t *, real_t *);
224  void mult_tpb2(real_t *, real_t *);
225  void mult_tmb2(real_t *, real_t *);
226 
227  void mult_gm5(real_t *, real_t *);
228 
229  void clear(real_t *);
230 
231  void aypx(complex_t, real_t *, real_t *);
232  void gm5_aypx(complex_t, real_t *, real_t *);
233 
234  void set_list();
235 
236  std::vector<std::vector<int> > m_list_boundary;
237  unique_ptr<Timer> timer_pack;
238  unique_ptr<Timer> timer_bulk;
239  unique_ptr<Timer> timer_boundary;
240  unique_ptr<Timer> timer_comm;
241  unique_ptr<Timer> timer_comm_recv_wait;
242  unique_ptr<Timer> timer_comm_send_wait;
243  unique_ptr<Timer> timer_comm_send_start;
244  unique_ptr<Timer> timer_comm_recv_start;
245  unique_ptr<Timer> timer_comm_test_all;
246  unique_ptr<Timer> timer_mult;
247  unique_ptr<Timer> timer_clear;
248 
249 #ifdef USE_FACTORY
250  private:
251  static AFopr<AFIELD> *create_object_with_params(const Parameters& params)
252  { return new AFopr_Clover_coarse(params); }
253 
254  public:
255  static bool register_factory()
256  {
257  bool init1 = AFopr<AFIELD>::Factory_params::Register("Clover_coarse",
258  create_object_with_params);
259  return init1;
260  }
261 #endif
262 };
263 
264 #endif // AFOPR_CLOVER_INCLUDED
AFopr_Clover_coarse::chset_recv
ChannelSet chset_recv
Definition: afopr_Clover_coarse.h:81
AFopr_Clover_coarse::mult_dag
void mult_dag(AFIELD &, const AFIELD &)
hermitian conjugate of mult.
Definition: afopr_Clover_coarse-tmpl.h:1433
AFopr_Clover_coarse::do_comm_any
int do_comm_any
Definition: afopr_Clover_coarse.h:75
AFopr_Clover_coarse::mult_gm4
void mult_gm4(AFIELD &, const AFIELD &)
AFopr_Clover_coarse::mult_tm1
void mult_tm1(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:2300
bridgeIO.h
AFopr_Clover_coarse::m_Nst
int m_Nst
Definition: afopr_Clover_coarse.h:48
AFopr_Clover_coarse::m_Nt
int m_Nt
Definition: afopr_Clover_coarse.h:48
AFopr_Clover_coarse::m_repr
std::string m_repr
gamma matrix representation
Definition: afopr_Clover_coarse.h:62
afield.h
AFopr_Clover_coarse::do_comm
int do_comm[4]
Definition: afopr_Clover_coarse.h:74
AFopr_Clover_coarse::mult_yp
void mult_yp(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:1882
AFopr_Clover_coarse::timer_comm_send_start
unique_ptr< Timer > timer_comm_send_start
Definition: afopr_Clover_coarse.h:243
AFopr
Definition: afopr.h:48
AFopr_Clover_coarse::m_T
AFIELD m_T
clover term
Definition: afopr_Clover_coarse.h:72
AFopr_Clover_coarse::m_bdsize
std::vector< int > m_bdsize
Definition: afopr_Clover_coarse.h:77
AFopr_Clover_coarse::mult_D
void mult_D(AFIELD &, const AFIELD &)
standard D mult.
Definition: afopr_Clover_coarse-tmpl.h:1554
AFopr_Clover_coarse::get_mode
std::string get_mode() const
returns mult mode.
Definition: afopr_Clover_coarse-tmpl.h:1406
AFopr_Clover_coarse::timer_pack
unique_ptr< Timer > timer_pack
Definition: afopr_Clover_coarse.h:237
AFopr_Clover_coarse::~AFopr_Clover_coarse
~AFopr_Clover_coarse()
destructor.
Definition: afopr_Clover_coarse.h:102
AFopr_Clover_coarse::dump
void dump()
AFopr_Clover_coarse::m_Nx
int m_Nx
Definition: afopr_Clover_coarse.h:48
AFopr_Clover_coarse::Ddag
void Ddag(AFIELD &, const AFIELD &)
Definition: afopr_Clover_coarse-tmpl.h:1473
communicator_impl.h
AFopr_Clover_coarse::generate_coarse_op
void generate_coarse_op(AFopr_dd< AFIELD > *fine_afopr, const std::vector< AFIELD > &testvec)
Definition: afopr_Clover_coarse-tmpl.h:1172
Parameters
Class for parameters.
Definition: parameters.h:46
AFopr_Clover_coarse::timer_comm_test_all
unique_ptr< Timer > timer_comm_test_all
Definition: afopr_Clover_coarse.h:245
AFopr_Clover_coarse::real_t
AFIELD::real_t real_t
Definition: afopr_Clover_coarse.h:43
AFopr_Clover_coarse::convert
void convert(AFIELD &v, const Field &w)
convert of spinor field.
Definition: afopr_Clover_coarse-tmpl.h:1331
AFopr_Clover_coarse::mult_D_alt
void mult_D_alt(AFIELD &, const AFIELD &)
D mult using QWS library.
Definition: afopr_Clover_coarse-tmpl.h:1663
AFopr_Clover_coarse::mult_xm1
void mult_xm1(real_t *, real_t *)
AFopr_Clover_coarse::timer_clear
unique_ptr< Timer > timer_clear
Definition: afopr_Clover_coarse.h:247
AFopr_Clover_coarse::timer_comm_recv_start
unique_ptr< Timer > timer_comm_recv_start
Definition: afopr_Clover_coarse.h:244
AFopr_Clover_coarse::mult_ym
void mult_ym(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:1971
AFopr_Clover_coarse::set_mode
void set_mode(std::string mode)
returns the pointer to gauge configuration.
Definition: afopr_Clover_coarse-tmpl.h:1393
AFopr_Clover_coarse::mult_tp
void mult_tp(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:2221
AFopr_Clover_coarse::m_Nvc
int m_Nvc
Definition: afopr_Clover_coarse.h:54
AFopr_Clover_coarse::init
void init()
initial setup.
Definition: afopr_Clover_coarse-tmpl.h:846
AFopr_Clover_coarse::m_v1
AFIELD m_v1
Definition: afopr_Clover_coarse.h:60
ChannelSet
ChannelSet class for a collection of channels.
Definition: channel.h:148
AFopr_Clover_coarse::timer_boundary
unique_ptr< Timer > timer_boundary
Definition: afopr_Clover_coarse.h:239
AFopr_Clover_coarse::tmp_buffer2
std::vector< complex_t > tmp_buffer2
Definition: afopr_Clover_coarse.h:84
AFopr_Clover_coarse::D
void D(AFIELD &, const AFIELD &)
Definition: afopr_Clover_coarse-tmpl.h:1452
AFopr_Clover_coarse::mult_zm1
void mult_zm1(real_t *, real_t *)
AFopr_Clover_coarse::m_Nxv
int m_Nxv
Definition: afopr_Clover_coarse.h:49
AFopr_Clover_coarse::m_Nc2
int m_Nc2
Definition: afopr_Clover_coarse.h:53
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
AFopr_Clover_coarse::m_Ndf
int m_Ndf
caution! not color, but just inner dof.
Definition: afopr_Clover_coarse.h:54
AFopr_Clover_coarse::mult_zmb2
void mult_zmb2(real_t *, real_t *)
AFopr_Clover_coarse::work_shifted
std::vector< real_t * > work_shifted
Definition: afopr_Clover_coarse.h:86
AFopr_Clover_coarse::m_coarse_lvol
size_t m_coarse_lvol
Definition: afopr_Clover_coarse.h:56
AFopr_Clover_coarse::gm5_aypx
void gm5_aypx(complex_t, real_t *, real_t *)
AFopr_dd
Base class of fermion operator family.
Definition: afopr_dd.h:24
AFopr_Clover_coarse::mult_tmb2
void mult_tmb2(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:2327
AFopr_Clover_coarse::workvec3
AFIELD workvec3
Definition: afopr_Clover_coarse.h:66
AFopr_Clover_coarse::mult_ypb2
void mult_ypb2(real_t *, real_t *)
AFopr_Clover_coarse::mult_tpb2
void mult_tpb2(real_t *, real_t *)
AFopr_Clover_coarse::mult_D_alt_keep2
void mult_D_alt_keep2(AFIELD &, const AFIELD &)
AFopr_Clover_coarse::mult_zpb2
void mult_zpb2(real_t *, real_t *)
AFopr_Clover_coarse::flop_count
double flop_count()
returns floating operation counts.
Definition: afopr_Clover_coarse.h:155
Field::real_t
double real_t
Definition: field.h:51
AFopr_Clover_coarse::m_num_testvectors
int m_num_testvectors
Definition: afopr_Clover_coarse.h:51
AFopr_Clover_coarse::DdagD
void DdagD(AFIELD &, const AFIELD &)
Definition: afopr_Clover_coarse-tmpl.h:1462
AFopr_Clover_coarse::m_Nyv
int m_Nyv
Definition: afopr_Clover_coarse.h:49
AFopr_Clover_coarse::mult_up
void mult_up(int mu, AFIELD &, const AFIELD &)
upward nearest neighbor hopping term.
Definition: afopr_Clover_coarse-tmpl.h:1347
AFopr_Clover_coarse::set_list
void set_list()
Definition: afopr_Clover_coarse-tmpl.h:1063
AFopr_Clover_coarse::mult_xp
void mult_xp(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:1720
AFopr_Clover_coarse::mult_xm
void mult_xm(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:1800
AFopr_Clover_coarse::set_parameters
void set_parameters(const Parameters &params)
setting parameters by a Parameter object.
Definition: afopr_Clover_coarse-tmpl.h:958
AFopr_Clover_coarse::chrecv_dn
std::vector< Channel > chrecv_dn
Definition: afopr_Clover_coarse.h:80
aindex_lex.h
AFopr_Clover_coarse::m_list_boundary
std::vector< std::vector< int > > m_list_boundary
Definition: afopr_Clover_coarse.h:236
AFopr_Clover_coarse::tmp_buffer3
std::vector< complex_t > tmp_buffer3
Definition: afopr_Clover_coarse.h:85
timer.h
AFopr_Clover_coarse::m_mode
std::string m_mode
mult mode
Definition: afopr_Clover_coarse.h:68
AFopr_Clover_coarse::AFopr_Clover_coarse
AFopr_Clover_coarse(const Parameters &params)
constructor.
Definition: afopr_Clover_coarse.h:90
afopr_Clover_dd.h
AFopr_Clover_coarse::chsend_dn
std::vector< Channel > chsend_dn
Definition: afopr_Clover_coarse.h:80
AFopr_Clover_coarse::mult_xp1
void mult_xp1(real_t *, real_t *)
AFopr_Clover_coarse
Definition: afopr_Clover_coarse.h:40
AFopr_Clover_coarse::mult
void mult(AFIELD &, const AFIELD &)
multiplies fermion operator to a given field.
Definition: afopr_Clover_coarse-tmpl.h:1414
AFopr_Clover_coarse::timer_comm
unique_ptr< Timer > timer_comm
Definition: afopr_Clover_coarse.h:240
AFopr_Clover_coarse::mult_zp
void mult_zp(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:2059
AFopr_Clover_coarse::tmp_buffer1
std::vector< complex_t > tmp_buffer1
Definition: afopr_Clover_coarse.h:83
AFopr_Clover_coarse::AFopr_Clover_coarse
AFopr_Clover_coarse()
Definition: afopr_Clover_coarse.h:96
AFopr_Clover_coarse::mult_gm5
void mult_gm5(AFIELD &, const AFIELD &)
multiplies gamma_5 matrix.
Definition: afopr_Clover_coarse-tmpl.h:1483
AFopr_Clover_coarse::mult_D_alt_keep
void mult_D_alt_keep(AFIELD &, const AFIELD &)
AFopr_Clover_coarse::mult_csw
void mult_csw(AFIELD &, const AFIELD &)
Definition: afopr_Clover_coarse-tmpl.h:1498
AFopr_Clover_coarse::m_Ny
int m_Ny
Definition: afopr_Clover_coarse.h:48
AFopr_Clover_coarse::class_name
static const std::string class_name
Definition: afopr_Clover_coarse.h:45
AFopr_Clover_coarse::chrecv_up
std::vector< Channel > chrecv_up
Definition: afopr_Clover_coarse.h:80
AFopr_Clover_coarse::timer_bulk
unique_ptr< Timer > timer_bulk
Definition: afopr_Clover_coarse.h:238
AFopr_Clover_coarse::reverse
void reverse(Field &v, const AFIELD &w)
reverse of spinor field.
Definition: afopr_Clover_coarse-tmpl.h:1339
AFopr_Clover_coarse::chset_send
ChannelSet chset_send
Definition: afopr_Clover_coarse.h:81
AFopr_Clover_coarse::mult_zm
void mult_zm(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:2140
AFopr_Clover_coarse::tidyup
void tidyup()
final tidy-up.
Definition: afopr_Clover_coarse-tmpl.h:930
AFopr_Clover_coarse::field_nvol
int field_nvol()
returns local volume size parameter.
Definition: afopr_Clover_coarse.h:149
AFopr_Clover_coarse::m_Nz
int m_Nz
Definition: afopr_Clover_coarse.h:48
AFopr_Clover_coarse::m_Nstv
int m_Nstv
Definition: afopr_Clover_coarse.h:49
AFopr_Clover_coarse::timer_comm_send_wait
unique_ptr< Timer > timer_comm_send_wait
Definition: afopr_Clover_coarse.h:242
AFopr_Clover_coarse::aypx
void aypx(complex_t, real_t *, real_t *)
AFopr_Clover_coarse::mult_ym1
void mult_ym1(real_t *, real_t *)
AFopr_Clover_coarse::mult_tm
void mult_tm(real_t *, real_t *)
Definition: afopr_Clover_coarse-tmpl.h:2357
AFopr_Clover_coarse::m_ncol
int m_ncol
Definition: afopr_Clover_coarse.h:52
AFopr_Clover_coarse::m_Clov
AFIELD m_Clov
Definition: afopr_Clover_coarse.h:59
AFopr_Clover_coarse::timer_mult
unique_ptr< Timer > timer_mult
Definition: afopr_Clover_coarse.h:246
AFopr_Clover_coarse::clear
void clear(real_t *)
Definition: afopr_Clover_coarse-tmpl.h:1702
AFopr_Clover_coarse::timer_comm_recv_wait
unique_ptr< Timer > timer_comm_recv_wait
Definition: afopr_Clover_coarse.h:241
AFopr_Clover_coarse::m_vl
Bridge::VerboseLevel m_vl
verbose level
Definition: afopr_Clover_coarse.h:64
AFopr_Clover_coarse::m_v2
AFIELD m_v2
Definition: afopr_Clover_coarse.h:70
complex_t
ComplexTraits< double >::complex_t complex_t
Definition: afopr_Clover_coarse_double.cpp:23
AFopr_Clover_coarse::H
void H(AFIELD &, const AFIELD &)
Definition: afopr_Clover_coarse-tmpl.h:1693
AFopr_Clover_coarse::set_csw
void set_csw()
set_csw now assumes Dirac repr.
commonParameters.h
AFopr_Clover_coarse::mult_tp1
void mult_tp1(real_t *, real_t *)
AFopr_Clover_coarse::needs_convert
bool needs_convert()
QXS version requires convert of spinor field.
Definition: afopr_Clover_coarse.h:115
AFopr_Clover_coarse::mult_dn
void mult_dn(int mu, AFIELD &, const AFIELD &)
downward nearest neighbor hopping term.
Definition: afopr_Clover_coarse-tmpl.h:1370
AFopr_Clover_coarse::m_U
AFIELD m_U
Definition: afopr_Clover_coarse.h:58
AFopr_Clover_coarse::mult_xpb2
void mult_xpb2(real_t *, real_t *)
AFopr_Clover_coarse::chsend_up
std::vector< Channel > chsend_up
Definition: afopr_Clover_coarse.h:80
Field
Container of Field-type object.
Definition: field.h:46
AFopr_Clover_coarse::mult_yp1
void mult_yp1(real_t *, real_t *)
afopr.h
communicator.h
AFopr_Clover_coarse::allocator_t
typename AFIELD::template aligned_allocator< char > allocator_t
Definition: afopr_Clover_coarse.h:78
AFopr_Clover_coarse::setup_channels
void setup_channels()
setup channels for communication.
Definition: afopr_Clover_coarse-tmpl.h:894
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
AFopr_Clover_coarse::m_Nc
int m_Nc
Definition: afopr_Clover_coarse.h:53
AFopr_Clover_coarse::mult_zp1
void mult_zp1(real_t *, real_t *)
AFopr_Clover_coarse::field_nex
int field_nex()
returns external size parameter.
Definition: afopr_Clover_coarse.h:152
AFopr_Clover_coarse::workvec1
AFIELD workvec1
Definition: afopr_Clover_coarse.h:66
AFopr_Clover_coarse::workvec2
AFIELD workvec2
Definition: afopr_Clover_coarse.h:66
AFopr_Clover_coarse::field_nin
int field_nin()
returns inner size parameter.
Definition: afopr_Clover_coarse.h:146
AFopr_Clover_coarse::complex_t
AFIELD::complex_t complex_t
Definition: afopr_Clover_coarse.h:44
Channel_impl
Definition: channel.h:86
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
AFopr_Clover_coarse::set_config
void set_config(Field *u)
setting gauge configuration.
Definition: afopr_Clover_coarse-tmpl.h:1322
AFopr_Clover_coarse::mult_xmb2
void mult_xmb2(real_t *, real_t *)
AFopr_Clover_coarse::mult_ymb2
void mult_ymb2(real_t *, real_t *)
AFopr_Clover_coarse::set_boundary
void set_boundary()
inpose the boundary condition to link variable.