CHROMA
lwldslash_w_sse.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Wilson Dslash linear operator
3  */
4 
5 #include "chromabase.h"
7 #include <sse_config.h>
8 #include "sse_dslash.h"
9 #include "sse_dslash_qdp_packer.h"
10 
11 namespace Chroma
12 {
13  namespace SSERefCount {
14  static bool initedP = false;
15  }
16  //! Initialization routine
18  {
19  // Initialize internal structures for DSLASH
20 #if 0
21  QDPIO::cout << "Calling init_sse_su3dslash()... " << std::endl;
22 #endif
23 
24  if( SSERefCount::initedP == false ) {
25  // Initialize using the total problem size
26  init_sse_su3dslash(Layout::lattSize().slice(),
27  Layout::QDPXX_getSiteCoords,
28  Layout::QDPXX_getLinearSiteIndex,
29  Layout::QDPXX_nodeNumber);
30  SSERefCount::initedP = true;
31  }
32  }
33 
34 
35  //! Empty constructor
37  {
38  init();
39  }
40 
41  //! Full constructor
43  {
44  init();
45  create(state);
46  }
47 
48  //! Full constructor with anisotropy
50  const AnisoParam_t& aniso_)
51  {
52  init();
53  create(state, aniso_);
54  }
55 
56  //! Full constructor with general coefficients
58  const multi1d<Real>& coeffs_)
59  {
60  init();
61  create(state, coeffs_);
62  }
63 
64  //! Creation routine
66  {
67  multi1d<Real> cf(Nd);
68  cf = 1.0;
69  create(state, cf);
70  }
71 
72  //! Creation routine with anisotropy
74  const AnisoParam_t& anisoParam)
75  {
76  START_CODE();
77 
78  create(state, makeFermCoeffs(anisoParam));
79 
80  END_CODE();
81  }
82 
83  //! Full constructor with general coefficients
85  const multi1d<Real>& coeffs_)
86  {
87  START_CODE();
88 
89  // Save a copy of the aniso params original fields and with aniso folded in
90  coeffs = coeffs_;
91 
92  // Save a copy of the fermbc
93  fbc = state->getFermBC();
94 
95  // Sanity check
96  if (fbc.operator->() == 0)
97  {
98  QDPIO::cerr << "SSEWilsonDslash: error: fbc is null" << std::endl;
99  QDP_abort(1);
100  }
101 
102  // Fold in anisotropy
103  multi1d<LatticeColorMatrix> u = state->getLinks();
104 
105  // Rescale the u fields by the anisotropy
106  for(int mu=0; mu < u.size(); ++mu)
107  {
108  u[mu] *= coeffs[mu];
109  }
110 
111  // Pack the gauge fields
112  packed_gauge.resize( Nd * Layout::sitesOnNode() );
113 
114 #if 0
115  QDPIO::cout << "Done " << std::endl << std::flush;
116 
117  QDPIO::cout << "Calling pack_gauge_field..." << std::flush;
118 #endif
119 
120  SSEDslash::qdp_pack_gauge(u, packed_gauge);
121 
122 #if 0
123  QDPIO::cout << "Done" << std::endl << std::flush;
124 #endif
125 
126  END_CODE();
127  }
128 
129 
131  {
132  START_CODE();
133 
134 #if 0
135  QDPIO::cout << "Calling free_sse_su3dslash()... " << std::endl;
136 #endif
137 
138  // Never free
139  // free_sse_su3dslash();
140 
141  END_CODE();
142  }
143 
144  //! General Wilson-Dirac dslash
145  /*! \ingroup linop
146  * Wilson dslash
147  *
148  * Arguments:
149  *
150  * \param chi Result (Write)
151  * \param psi Pseudofermion field (Read)
152  * \param isign D'^dag or D' ( MINUS | PLUS ) resp. (Read)
153  * \param cb Checkerboard of OUTPUT std::vector (Read)
154  */
155  void
156  SSEWilsonDslash::apply (LatticeFermion& chi, const LatticeFermion& psi,
157  enum PlusMinus isign, int cb) const
158  {
159  START_CODE();
160 
161  /* Pass the right parities.
162  *
163  * SZIN standard is that cb is cb of INPUT
164  * Chroma standard is that the cb is cb of OUTPUT
165  *
166  * Need to invert cb for SZIN style SSE call
167 
168  *
169  *
170  * Pass all the fermion and all the gauge pieces
171  *
172  * NOTE: this breaks usage from SZIN. However, Chroma and SSE dslash can handle
173  * odd subgrid lattice sizes, whereas SZIN cannot. Thus, I must pass all fermion
174  * cbs to support such flexibility.
175  *
176  */
177  int source_cb = 1 - cb;
178  int target_cb = cb;
179  int cbsites = QDP::Layout::sitesOnNode()/2;
180 
181  sse_su3dslash_wilson((SSEREAL *)&(packed_gauge[0]),
182  (SSEREAL *)&(psi.elem(0).elem(0).elem(0).real()),
183  (SSEREAL *)&(chi.elem(0).elem(0).elem(0).real()),
184  (int)isign, source_cb);
185 
186 
187  getFermBC().modifyF(chi, QDP::rb[cb]);
188 
189  END_CODE();
190  }
191 
192 } // End Namespace Chroma
193 
Primary include file for CHROMA library code.
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
void init()
Init internals.
Handle< FermBC< T, P, Q > > fbc
SSEWilsonDslash()
Empty constructor. Must use create later.
~SSEWilsonDslash()
No real need for cleanup here.
void create(Handle< FermState< T, P, Q > > state)
Creation routine.
const FermBC< T, P, Q > & getFermBC() const
Return the fermion BC object for this linear operator.
multi1d< PrimitiveSU3Matrix > packed_gauge
int mu
Definition: cool.cc:24
void apply(LatticeFermion &chi, const LatticeFermion &psi, enum PlusMinus isign, int cb) const
General Wilson-Dirac dslash.
Wilson Dslash linear operator.
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
int cb
Definition: invbicg.cc:120
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
multi1d< Real > makeFermCoeffs(const AnisoParam_t &aniso)
Make fermion coefficients.
Definition: aniso_io.cc:63
Parameters for anisotropy.
Definition: aniso_io.h:24