QDP++
qdp_scalarsite_pabasm.h
Go to the documentation of this file.
1// -*- C++ -*-
8
9#ifndef QDP_SCALARSITE_GENERIC_H
10#define QDP_SCALARSITE_GENERIC_H
11
12
13#include "qdp_diagnostics.h"
14
15QDPXX_MESSAGE("Using PABASM Scalarsite")
16
17namespace QDP {
18
25
26// Use this def just to safe some typing later on in the file
27#define RComplexFloat RComplex<float>
28
29
37
38
39// #define QDP_SCALARSITE_DEBUG
40
41// Optimized version of
42// PColorMatrix<RComplexFloat,3> <- PColorMatrix<RComplexFloat,3> * PColorMatrix<RComplexFloat,3>
43template<>
45 PMatrix<RComplexFloat,3,PColorMatrix>, OpMultiply>::Type_t
48{
51
52#if defined(QDP_SCALARSITE_DEBUG)
53 cout << "M*M" << endl;
54#endif
55
57
58 return d;
59}
60
61
62// Optimized version of
63// PScalar<PColorMatrix<RComplexFloat,3>> <- PScalar<PColorMatrix<RComplexFloat,3>> *
64// PScalar<PColorMatrix<RComplexFloat,3>>
65template<>
67 PScalar<PColorMatrix<RComplexFloat,3> >, OpMultiply>::Type_t
70{
73
74#if defined(QDP_SCALARSITE_DEBUG)
75 cout << "PSc<M>*PSc<M>" << endl;
76#endif
77
78 _inline_generic_mult_su3_nn(l.elem(),r.elem(),d.elem());
79
80 return d;
81}
83
84// Optimized version of
85// PColorMatrix<RComplexFloat,3> <- adj(PColorMatrix<RComplexFloat,3>) * PColorMatrix<RComplexFloat,3>
86template<>
88 PMatrix<RComplexFloat,3,PColorMatrix>, OpAdjMultiply>::Type_t
91{
94
95#if defined(QDP_SCALARSITE_DEBUG)
96 cout << "adj(M)*M" << endl;
97#endif
98
100
101 return d;
102}
103
104
105// Optimized version of
106// PScalar<PColorMatrix<RComplexFloat,3>> <- adj(PScalar<PColorMatrix<RComplexFloat,3>>) * PScalar<PColorMatrix<RComplexFloat,3>>
107template<>
109 PScalar<PColorMatrix<RComplexFloat,3> >, OpAdjMultiply>::Type_t
112{
115
116#if defined(QDP_SCALARSITE_DEBUG)
117 cout << "adj(PSc<M>)*PSc<M>" << endl;
118#endif
119
120 _inline_generic_mult_su3_an(l.elem(),r.elem(),d.elem());
121
122 return d;
123}
124
125
126// Optimized version of
127// PColorMatrix<RComplexFloat,3> <- PColorMatrix<RComplexFloat,3> * adj(PColorMatrix<RComplexFloat,3>)
128template<>
130 PMatrix<RComplexFloat,3,PColorMatrix>, OpMultiplyAdj>::Type_t
133{
136
137#if defined(QDP_SCALARSITE_DEBUG)
138 cout << "M*adj(M)" << endl;
139#endif
140
142
143 return d;
144}
145
146
147// Optimized version of
148// PScalar<PColorMatrix<RComplexFloat,3>> <- PScalar<PColorMatrix<RComplexFloat,3>> * adj(PScalar<PColorMatrix<RComplexFloat,3>>)
149template<>
151 PScalar<PColorMatrix<RComplexFloat,3> >, OpMultiplyAdj>::Type_t
154{
157
158#if defined(QDP_SCALARSITE_DEBUG)
159 cout << "PSc<M>*adj(PSc<M>)" << endl;
160#endif
161
162 _inline_generic_mult_su3_na(l.elem(),r.elem(),d.elem());
163
164 return d;
165}
166
167
168#if 0
169// Do not use this routine - for some unknown reason on P4 it is slower than
170// the default code!!
171
172// Optimized version of
173// PColorMatrix<RComplexFloat,3> <- adj(PColorMatrix<RComplexFloat,3>) * adj(PColorMatrix<RComplexFloat,3>)
174template<>
176 PMatrix<RComplexFloat,3,PColorMatrix>, OpAdjMultiplyAdj>::Type_t
177adjMultiplyAdj(const PMatrix<RComplexFloat,3,PColorMatrix>& l,
178 const PMatrix<RComplexFloat,3,PColorMatrix>& r)
179{
181 PMatrix<RComplexFloat,3,PColorMatrix>, OpAdjMultiplyAdj>::Type_t d;
182
183#if defined(QDP_SCALARSITE_DEBUG)
184 cout << "adj(PSc<M>)*adj(PSc<M>)" << endl;
185#endif
186
188
189 return d;
190}
191#endif
192
193
194// Optimized version of
195// PColorVector<RComplexFloat,3> <- PColorMatrix<RComplexFloat,3> * PColorVector<RComplexFloat,3>
196template<>
198 PVector<RComplexFloat,3,PColorVector>, OpMultiply>::Type_t
201{
204
205#if defined(QDP_SCALARSITE_DEBUG)
206 cout << "M*V" << endl;
207#endif
208
210
211 return d;
212}
213
214
215// Optimized version of
216// PScalar<PColorVector<RComplexFloat,3>> <- PScalar<PColorMatrix<RComplexFloat,3>> * PScalar<PColorVector<RComplexFloat,3>>
217template<>
219 PScalar<PColorVector<RComplexFloat,3> >, OpMultiply>::Type_t
222{
225
226#if defined(QDP_SCALARSITE_DEBUG)
227 cout << "PSc<M>*PSc<V>" << endl;
228#endif
229
230 _inline_generic_mult_su3_mat_vec(l.elem(),r.elem(),d.elem());
231
232 return d;
233}
234
235
236// Optimized version of
237// PColorVector<RComplexFloat,3> <- adj(PColorMatrix<RComplexFloat,3>) * PColorVector<RComplexFloat,3>
238template<>
240 PVector<RComplexFloat,3,PColorVector>, OpAdjMultiply>::Type_t
243{
246
247#if defined(QDP_SCALARSITE_DEBUG)
248 cout << "adj(M)*V" << endl;
249#endif
250
252
253 return d;
254}
255
256
257// Optimized version of StaggeredFermion <- ColorMatrix*StaggeredFermion
258// PSpinVector<PColorVector<RComplexFloat,3>,1> <- PScalar<PColorMatrix<RComplexFloat,3>> * PSpinVector<PColorVector<RComplexFloat,3>,1>
259template<>
261 PVector<PColorVector<RComplexFloat,3>,1,PSpinVector>, OpMultiply>::Type_t
264{
267
268#if defined(QDP_SCALARSITE_DEBUG)
269 cout << "PSc<M>*S" << endl;
270#endif
271
272 _inline_generic_mult_su3_mat_vec(l.elem(),r.elem(0),d.elem(0));
273
274 return d;
275}
276
277
278// Optimized version of
279// PScalar<PColorVector<RComplexFloat,3>> <- adj(PScalar<PColorMatrix<RComplexFloat,3>>) * PScalar<PColorVector<RComplexFloat,3>>
280template<>
282 PScalar<PColorVector<RComplexFloat,3> >, OpAdjMultiply>::Type_t
285{
288
289#if defined(QDP_SCALARSITE_DEBUG)
290 cout << "adj(PSc<M>)*PSc<V>" << endl;
291#endif
292
293 _inline_generic_mult_adj_su3_mat_vec(l.elem(),r.elem(),d.elem());
294
295 return d;
296}
297
298
299// Optimized version of StaggeredFermion <- adj(ColorMatrix)*StaggeredFermion
300// PSpinVector<PColorVector<RComplexFloat,3>,1> <- adj(PScalar<PColorMatrix<RComplexFloat,3>>) * PSpinVector<PColorVector<RComplexFloat,3>,1>
301template<>
303 PVector<PColorVector<RComplexFloat,3>,1,PSpinVector>, OpAdjMultiply>::Type_t
306{
309
310#if defined(QDP_SCALARSITE_DEBUG)
311 cout << "adj(PSc<M>)*S" << endl;
312#endif
313
314 _inline_generic_mult_adj_su3_mat_vec(l.elem(),r.elem(0),d.elem(0));
315
316 return d;
317}
318
319
320// Optimized version of HalfFermion <- ColorMatrix*HalfFermion
321// PSpinVector<PColorVector<RComplexFloat,3>,2> <- PScalar<PColorMatrix<RComplexFloat,3>> *
322// PSpinVector<ColorVector<RComplexFloat,3>,2>
323template<>
325 PVector<PColorVector<RComplexFloat,3>,2,PSpinVector>, OpMultiply>::Type_t
328{
331
332#if defined(QDP_SCALARSITE_DEBUG)
333 cout << "PSc<M>*H" << endl;
334#endif
335
336 _inline_generic_mult_su3_mat_vec(l.elem(),r.elem(0),d.elem(0));
337 _inline_generic_mult_su3_mat_vec(l.elem(),r.elem(1),d.elem(1));
338
339 return d;
340}
341
342
343// Optimized version of HalfFermion <- ColorMatrix*HalfFermion
344// PSpinVector<PColorVector<RComplexFloat,3>,2> <- adj(PScalar<PColorMatrix<RComplexFloat,3>>) *
345// PSpinVector<ColorVector<RComplexFloat,3>,2>
346template<>
348 PVector<PColorVector<RComplexFloat,3>,2,PSpinVector>, OpAdjMultiply>::Type_t
351{
354
355#if defined(QDP_SCALARSITE_DEBUG)
356 cout << "adj(PSc<M>)*H" << endl;
357#endif
358
359 _inline_generic_mult_adj_su3_mat_vec(l.elem(),r.elem(0),d.elem(0));
360 _inline_generic_mult_adj_su3_mat_vec(l.elem(),r.elem(1),d.elem(1));
361
362 return d;
363}
364
365
366// Optimized version of
367// PColorVector<RComplexFloat,3> <- PColorVector<RComplexFloat,3> + PColorVector<RComplexFloat,3>
368template<>
370 PVector<RComplexFloat,3,PColorVector>, OpAdd>::Type_t
373{
376
377#if defined(QDP_SCALARSITE_DEBUG)
378 cout << "V+V" << endl;
379#endif
380
382
383 return d;
384}
385
386
387// Optimized version of DiracFermion <- ColorMatrix*DiracFermion
388// PSpinVector<PColorVector<RComplexFloat,3>,4> <- PScalar<PColorMatrix<RComplexFloat,3>>
389// * PSpinVector<PColorVector<RComplexFloat,3>,4>
390template<>
392 PVector<PColorVector<RComplexFloat,3>,4,PSpinVector>, OpMultiply>::Type_t
395{
398
399#if defined(QDP_SCALARSITE_DEBUG)
400 cout << "PSc<M>*D" << endl;
401#endif
402
403 _inline_generic_mult_su3_mat_vec(l.elem(),r.elem(0),d.elem(0));
404 _inline_generic_mult_su3_mat_vec(l.elem(),r.elem(1),d.elem(1));
405 _inline_generic_mult_su3_mat_vec(l.elem(),r.elem(2),d.elem(2));
406 _inline_generic_mult_su3_mat_vec(l.elem(),r.elem(3),d.elem(3));
407
408 return d;
409}
410
411
412// Optimized version of DiracFermion <- adj(ColorMatrix)*DiracFermion
413// PSpinVector<PColorVector<RComplexFloat,3>,4> <- adj(PScalar<PColorMatrix<RComplexFloat,3>>)
414// * PSpinVector<PColorVector<RComplexFloat,3>,4>
415template<>
417 PVector<PColorVector<RComplexFloat,3>,4,PSpinVector>, OpAdjMultiply>::Type_t
420{
423
424#if defined(QDP_SCALARSITE_DEBUG)
425 cout << "adj(PSc<M>)*D" << endl;
426#endif
427
428 _inline_generic_mult_adj_su3_mat_vec(l.elem(),r.elem(0),d.elem(0));
429 _inline_generic_mult_adj_su3_mat_vec(l.elem(),r.elem(1),d.elem(1));
430 _inline_generic_mult_adj_su3_mat_vec(l.elem(),r.elem(2),d.elem(2));
431 _inline_generic_mult_adj_su3_mat_vec(l.elem(),r.elem(3),d.elem(3));
432
433 return d;
434}
435
436
437
438// Optimized version of
439// PScalar<PColorVector<RComplexFloat,3>> <- PScalar<PColorVector<RComplexFloat,3>>
440// + PScalar<PColorVector<RComplexFloat,3>>
441template<>
443 PScalar<PColorVector<RComplexFloat,3> >, OpAdd>::Type_t
446{
449
450#if defined(QDP_SCALARSITE_DEBUG)
451 cout << "PSc<V>+PSc<V>" << endl;
452#endif
453
454 _inline_generic_add_su3_vector(l.elem(),r.elem(),d.elem());
455
456 return d;
457}
458
459
460#if 1
461// Specialization to optimize the case
462// LatticeHalfFermion = LatticeColorMatrix * LatticeHalfFermion
463// NOTE: let this be a subroutine to save space
464template<>
465inline
467 const OpAssign& op,
474 const Subset& s)
475{
476#if defined(QDP_SCALARSITE_DEBUG)
477 cout << "specialized QDP_H_M_times_H" << endl;
478#endif
479
482
483 const C& l = static_cast<const C&>(rhs.expression().left());
484 const H& r = static_cast<const H&>(rhs.expression().right());
485
486 const int *tab = s.siteTable().slice();
487
488 for(int j=0; j <= s.numSiteTable(); ++j)
489 {
490 int i = tab[j];
491
493 r.elem(i).elem(0),
494 d.elem(i).elem(0));
496 r.elem(i).elem(1),
497 d.elem(i).elem(1));
498 }
499}
500
501#endif
502 // end of group optimizations
504
505#if defined(QDP_SCALARSITE_DEBUG)
506#undef QDP_SCALARSITE_DEBUG
507#endif
508
509} // namespace QDP
510
511#endif
MakeReturn< BinaryNode< OpMultiply, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpMultiply >::Type_t >::Expression_t operator*(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< BinaryNode< OpAdd, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpAdd >::Type_t >::Expression_t operator+(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
Outer grid Lattice type.
Definition qdp_outer.h:264
T & elem(int i)
Definition qdp_outer.h:400
Primitive color Matrix class.
Primitive color Vector class.
Primitive Matrix class.
Primitive Scalar.
Primitive spin Vector class.
Primitive Vector class.
Expression class for QDP.
Definition qdp_qdpexpr.h:16
QDPType - major type class/container for all QDP objects.
Definition qdp_qdptype.h:29
Subsets - controls how lattices are looped.
Definition qdp_subset.h:39
const multi1d< int > & siteTable() const
Definition qdp_subset.h:83
int numSiteTable() const
Definition qdp_subset.h:84
const T * slice() const
Return ref to a column slice.
Definition qdp_multi.h:225
BinaryReturn< IScalar< T1 >, IScalar< T2 >, OpMultiplyAdj >::Type_t multiplyAdj(const IScalar< T1 > &l, const IScalar< T2 > &r)
Definition qdp_inner.h:1189
BinaryReturn< IScalar< T1 >, IScalar< T2 >, OpAdjMultiply >::Type_t adjMultiply(const IScalar< T1 > &l, const IScalar< T2 > &r)
Definition qdp_inner.h:1180
OLattice< PSpinVector< PColorVector< RComplexFloat, 3 >, 2 > > H
void evaluate(OLattice< DCol > &d, const OpAssign &op, const QDPExpr< BinaryNode< OpMultiply, Reference< QDPType< DCol, OLattice< DCol > > >, Reference< QDPType< DCol, OLattice< DCol > > > >, OLattice< DCol > > &rhs, const Subset &s)
OLattice< PScalar< PColorMatrix< RComplexFloat, 3 > > > C
Yet another random number generator.
#define QDPXX_MESSAGE(s)
#define _inline_generic_mult_adj_su3_mat_vec(aa, bb, cc)
#define _inline_generic_mult_su3_an(aa, bb, cc)
#define _inline_generic_mult_su3_aa(aa, bb, cc)
#define _inline_generic_mult_su3_na(aa, bb, cc)
#define _inline_generic_add_su3_vector(aa, bb, cc)
#define _inline_generic_mult_su3_nn(aa, bb, cc)
#define _inline_generic_mult_su3_mat_vec(aa, bb, cc)