CHROMA
lwldslash_w_cppf.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Wilson Dslash linear operator
3  */
4 
5 #include "chromabase.h"
7 #include "cpp_dslash.h"
8 #include "cpp_dslash_qdp_packer.h"
9 
10 
11 using namespace CPlusPlusWilsonDslash;
12 
13 namespace Chroma
14 {
15 
16  //! Initialization routine
18  {
19  // Initialize using the total problem size -- this is a handle so will be destroyed/refcounted as needed.
20 
21  D = new Dslash<float>(Layout::lattSize().slice(),
22  Layout::QDPXX_getSiteCoords,
23  Layout::QDPXX_getLinearSiteIndex,
24  Layout::QDPXX_nodeNumber);
25  }
26 
27 
28  //! Empty constructor
29  CPPWilsonDslashF::CPPWilsonDslashF()
30 #ifndef CHROMA_STATIC_PACKED_GAUGE
31  : packed_gauge(nullptr)
32 #endif
33  {
34 
35  init();
36  }
37 
38  //! Full constructor
39  CPPWilsonDslashF::CPPWilsonDslashF(Handle< FermState<T,P,Q> > state)
40 #ifndef CHROMA_STATIC_PACKED_GAUGE
41  : packed_gauge(nullptr)
42 #endif
43  {
44 
45  init();
46  create(state);
47  }
48 
49  //! Full constructor with anisotropy
50  CPPWilsonDslashF::CPPWilsonDslashF(Handle< FermState<T,P,Q> > state,
51  const AnisoParam_t& aniso_)
52 #ifndef CHROMA_STATIC_PACKED_GAUGE
53  : packed_gauge(nullptr)
54 #endif
55  {
56 
57  init();
58  create(state, aniso_);
59  }
60 
61  //! Full constructor with general coefficients
62  CPPWilsonDslashF::CPPWilsonDslashF(Handle< FermState<T,P,Q> > state,
63  const multi1d<Real>& coeffs_)
64 #ifndef CHROMA_STATIC_PACKED_GAUGE
65  : packed_gauge(nullptr)
66 #endif
67  {
68 
69  init();
70  create(state, coeffs_);
71  }
72 
73  //! Creation routine
74  void CPPWilsonDslashF::create(Handle< FermState<T,P,Q> > state)
75  {
76  multi1d<Real> cf(Nd);
77  cf = 1.0;
78  create(state, cf);
79  }
80 
81  //! Creation routine with anisotropy
82  void CPPWilsonDslashF::create(Handle< FermState<T,P,Q> > state,
83  const AnisoParam_t& anisoParam)
84  {
85  START_CODE();
86 
87  create(state, makeFermCoeffs(anisoParam));
88 
89  END_CODE();
90  }
91 
92  //! Full constructor with general coefficients
93  void CPPWilsonDslashF::create(Handle< FermState<T,P,Q> > state,
94  const multi1d<Real>& coeffs_)
95  {
96  START_CODE();
97 
98  // Save a copy of the aniso params original fields and with aniso folded in
99  coeffs = coeffs_;
100 
101  // Save a copy of the fermbc
102  fbc = state->getFermBC();
103 
104  // Sanity check
105  if (fbc.operator->() == 0)
106  {
107  QDPIO::cerr << "CPPWilsonDslashF: error: fbc is null" << std::endl;
108  QDP_abort(1);
109  }
110 
111  // Fold in anisotropy
112  multi1d<LatticeColorMatrixF> u = state->getLinks();
113 
114  // Rescale the u fields by the anisotropy
115  for(int mu=0; mu < u.size(); ++mu)
116  {
117  u[mu] *= coeffs[mu];
118  }
119 
120  // Pack the gauge fields
121  //packed_gauge.resize( Nd * Layout::sitesOnNode() );
122  // Allocate as a pointer -- In the case of static allocation
123  // Always allocate if null. If the packed gauge is static, it will not be null after the first allocation.
124  if ( packed_gauge == nullptr ) {
125  packed_gauge = (PrimitiveSU3MatrixF *)QDP::Allocator::theQDPAllocator::Instance().allocate( Layout::sitesOnNode()*Nd*sizeof(PrimitiveSU3MatrixF),
127  if( packed_gauge == nullptr ) {
128  QDPIO::cout << "Failed to allocate packed gauge in CPP_Dslash " <<std::endl;
129  QDP_abort(1);
130  }
131  }
132 
133 #if 0
134  QDPIO::cout << "Done " << std::endl << std::flush;
135 
136  QDPIO::cout << "Calling pack_gauge_field..." << std::flush;
137 #endif
138 
139  qdp_pack_gauge(u, packed_gauge);
140 
141 #if 0
142  QDPIO::cout << "Done" << std::endl << std::flush;
143 #endif
144 
145  END_CODE();
146  }
147 
148 
149  CPPWilsonDslashF::~CPPWilsonDslashF()
150  {
151  START_CODE();
152 
153  // Handle will free the operator.
154 
155  // If we are not using static packed gauges, we need to free here
156  // otherwise we never free.
157 #ifndef CHROMA_STATIC_PACKED_GAUGE
158  QDP::Allocator::theQDPAllocator::Instance().free(packed_gauge);
159 #endif
160 
161  END_CODE();
162  }
163 
164  //! General Wilson-Dirac dslash
165  /*! \ingroup linop
166  * Wilson dslash
167  *
168  * Arguments:
169  *
170  * \param chi Result (Write)
171  * \param psi Pseudofermion field (Read)
172  * \param isign D'^dag or D' ( MINUS | PLUS ) resp. (Read)
173  * \param cb Checkerboard of OUTPUT std::vector (Read)
174  */
175  void
176  CPPWilsonDslashF::apply (T& chi, const T& psi,
177  enum PlusMinus isign, int cb) const
178  {
179  START_CODE();
180 
181  /* Pass the right parities.
182  *
183  * SZIN standard is that cb is cb of INPUT
184  * Chroma standard is that the cb is cb of OUTPUT
185  *
186  * Need to invert cb for SZIN style SSE call
187 
188  *
189  *
190  * Pass all the fermion and all the gauge pieces
191  *
192  * NOTE: this breaks usage from SZIN. However, Chroma and SSE dslash can handle
193  * odd subgrid lattice sizes, whereas SZIN cannot. Thus, I must pass all fermion
194  * cbs to support such flexibility.
195  *
196  */
197  int source_cb = 1 - cb;
198  int target_cb = cb;
199  int cbsites = QDP::Layout::sitesOnNode()/2;
200 
201  (*D)((float *)&(chi.elem(all.start()).elem(0).elem(0).real()),
202  (float *)&(psi.elem(all.start()).elem(0).elem(0).real()),
203  (float *)&(packed_gauge[0]),
204  isign,
205  source_cb);
206  // sse_su3dslash_wilson((SSEREAL *)&(packed_gauge[0]),
207  // (SSEREAL *)&(psi.elem(0).elem(0).elem(0).real()),
208  // (SSEREAL *)&(chi.elem(0).elem(0).elem(0).real()),
209  // (int)isign, source_cb);
210 
211 
212  getFermBC().modifyF(chi, QDP::rb[cb]);
213 
214  END_CODE();
215  }
216 
217 } // End Namespace Chroma
218 
Primary include file for CHROMA library code.
#define END_CODE()
Definition: chromabase.h:65
#define START_CODE()
Definition: chromabase.h:64
void create(Handle< FermState< T, P, Q > > state)
Creation routine.
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
int mu
Definition: cool.cc:24
Wilson Dslash linear operator.
Nd
Definition: meslate.cc:74
void init(MesonSpecData_t &data, XMLWriter &xml, const std::string &path, const std::string &id_tag, const Params &params)
Do some initialization.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
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
chi
Definition: pade_trln_w.cc:24
psi
Definition: pade_trln_w.cc:191
Parameters for anisotropy.
Definition: aniso_io.h:24