QDP++
qdp_profile.h
Go to the documentation of this file.
1// -*- C++ -*-
2
8
9#ifndef QDP_PROFILE_INCLUDE
10#define QDP_PROFILE_INCLUDE
11
12namespace QDP {
13
14typedef unsigned long QDPTime_t;
15
17
21void initProfile(const std::string& file, const std::string& caller, int line);
22void closeProfile();
23void printProfile();
24int setProfileLevel(int n);
25int setProgramProfileLevel(int n);
26int getProfileLevel();
28void pushProfileInfo(int level, const std::string& file, const std::string& caller, int line);
29void popProfileInfo();
30
31
32//--------------------------------------------------------------------------------------
33// Selectively turn on profiling
34//--------------------------------------------------------------------------------------
35
36#if ! defined(QDP_USE_PROFILING)
37// No profiling
38#define QDP_PUSH_PROFILE(a)
39#define QDP_POP_PROFILE()
40
41#else // Profiling enabled
42
43#define QDP_PUSH_PROFILE(a) pushProfileInfo(a, __FILE__, __func__, __LINE__)
44#define QDP_POP_PROFILE() popProfileInfo()
45
46#include <PETE/ForEachInOrder.h>
47
48//-----------------------------------------------------------------------------
49// Support of printing
50//-----------------------------------------------------------------------------
51
52struct QDPProfile_t;
53void registerProfile(QDPProfile_t* qp);
54
55
57
60struct QDPProfile_t
61{
62 QDPTime_t time;
63 std::string expr;
64 int count;
65 QDPProfile_t* next;
66
67 void print();
68
69 void init();
70 QDPProfile_t() {init();}
71
73 template<class T, class C, class Op, class RHS, class C1>
74 QDPProfile_t(const QDPType<T,C>& dest, const Op& op, const QDPExpr<RHS,C1>& rhs)
75 {
76 init();
77
78 if (getProfileLevel() > 0)
79 {
80 ostringstream os;
81 printExprTree(os, dest, op, rhs);
82 expr = os.str();
83 registerProfile(this);
84 }
85 }
86
88 template<class T, class C, class Op, class OpOuter, class RHS, class C1>
89 QDPProfile_t(const QDPType<T,C>& dest, const Op& op, const OpOuter& opOuter, const QDPExpr<RHS,C1>& rhs)
90 {
91 init();
92
93 if (getProfileLevel() > 0)
94 {
95 typedef UnaryNode<OpOuter, typename CreateLeaf<QDPExpr<RHS,C1> >::Leaf_t> Tree_t;
96 typedef typename UnaryReturn<C1,OpOuter>::Type_t Container_t;
97
98 ostringstream os;
99 printExprTree(os, dest, op,
101 CreateLeaf<QDPExpr<RHS,C1> >::make(rhs))));
102 expr = os.str();
103 registerProfile(this);
104 }
105 }
106
108 template<class T, class C, class Op, class OpOuter, class T1, class C1>
109 QDPProfile_t(const QDPType<T,C>& dest, const Op& op, const OpOuter& opOuter, const QDPType<T1,C1>& rhs)
110 {
111 init();
112
113 if (getProfileLevel() > 0)
114 {
115 typedef UnaryNode<OpOuter, typename CreateLeaf<QDPType<T1,C1> >::Leaf_t> Tree_t;
116 typedef typename UnaryReturn<C1,OpOuter>::Type_t Container_t;
117
118 ostringstream os;
119 printExprTree(os, dest, op,
121 CreateLeaf<QDPType<T1,C1> >::make(rhs))));
122 expr = os.str();
123 registerProfile(this);
124 }
125 }
126};
127
128
129struct QDPProfileInfo_t
130{
131 int level;
132 std::string file;
133 std::string caller;
134 int line;
135
136 QDPProfileInfo_t() {line=level=0;}
137
138 QDPProfileInfo_t(const QDPProfileInfo_t& a) :
139 level(a.level), file(a.file), caller(a.caller), line(a.line) {}
140
141 QDPProfileInfo_t(int _level, const std::string& _file, const std::string& _caller, int _line) :
142 level(_level), file(_file), caller(_caller), line(_line) {}
143};
144
145
146struct QDPProfileHead_t
147{
148 QDPProfileInfo_t info;
149 QDPProfile_t* start;
150 QDPProfile_t* end;
151
152 QDPProfileHead_t() {start=0; end=0;}
153 QDPProfileHead_t(const QDPProfileInfo_t& a) : info(a), start(0), end(0) {}
154 QDPProfileHead_t(const QDPProfileHead_t& a) : info(a.info), start(a.start), end(a.end) {}
155};
156
157
158
160
164template<class T, class C, class Op, class RHS, class C1>
165//inline
166void printExprTree(ostream& os,
167 const QDPType<T,C>& dest, const Op& op, const QDPExpr<RHS,C1>& rhs)
168{
169 typedef EvalLeaf1 FTag_t;
170 typedef OpCombine CTag_t;
171 typedef NullCombine VTag_t;
172 typedef QDPExpr<RHS,C1> Expr;
173
174 typedef typename CreateLeaf<Expr>::Leaf_t Expr_t;
175 const Expr_t &e = CreateLeaf<Expr>::make(rhs);
176
177#if 0
178 // Compact version
179 typedef BinaryNode<Op, QDPType<T,C>, Expr_t> Assign_t;
180 typedef ForEachInOrder<Assign_t, PrintTag, PrintTag, NullTag> Print_t;
181 Assign_t t(op, dest, e);
182 Print_t::apply(t, PrintTag(os), PrintTag(os), NullTag());
183#else
184 // Makes assignment part special
185 typedef ForEachInOrder<RHS, PrintTag, PrintTag, NullTag> Print_t;
186 LeafFunctor<C,PrintTag>::apply(static_cast<const C&>(dest),PrintTag(os));
187 os << " ";
188 TagVisitor<Op,PrintTag>::visit(op, PrintTag(os));
189 os << " ";
190 Print_t::apply(e, PrintTag(os), PrintTag(os), NullTag());
191#endif
192
193 os << ";";
194}
195
196//
197// struct PrintTag
198//
199// Tag struct to carry an ostream ref through the parse tree.
200//
201
202struct PrintTag
203{
204 mutable ostream &os_m;
205 PrintTag(ostream &os) : os_m(os) {}
206};
207
208
209//
210// struct LeafFunctor<QDPType<T,C>, PrintTag>
211//
212// Specialication of TagFunctor class for applying the PrintTag tag to
213// a QDPType. The apply method simply prints the result to the
214// ostream carried by PrintTag.
215//
216
217template<class T, class C>
218struct LeafFunctor<QDPType<T,C>, PrintTag>
219{
220 typedef int Type_t;
221 static int apply(const QDPType<T,C> &s, const PrintTag &f)
222 {
223 return LeafFunctor<C,PrintTag>::apply(static_cast<const C&>(s),f);
224 }
225};
226
227//
228// struct LeafFunctor<T, PrintTag>
229//
230// Specialication of TagFunctor class for applying the PrintTag tag to
231// a "T". The apply method simply prints the result to the
232// ostream carried by PrintTag.
233//
234
235template<>
236struct LeafFunctor<float, PrintTag>
237{
238 typedef int Type_t;
239 static int apply(const float &s, const PrintTag &f)
240 {
241 f.os_m << "float";
242 return 0;
243 }
244};
245
246template<>
247struct LeafFunctor<double, PrintTag>
248{
249 typedef int Type_t;
250 static int apply(const double &s, const PrintTag &f)
251 {
252 f.os_m << "double";
253 return 0;
254 }
255};
256
257template<>
258struct LeafFunctor<int, PrintTag>
259{
260 typedef int Type_t;
261 static int apply(const int &s, const PrintTag &f)
262 {
263 f.os_m << "int";
264 return 0;
265 }
266};
267
268template<>
269struct LeafFunctor<char, PrintTag>
270{
271 typedef int Type_t;
272 static int apply(const char &s, const PrintTag &f)
273 {
274 f.os_m << "char";
275 return 0;
276 }
277};
278
279template<>
280struct LeafFunctor<bool, PrintTag>
281{
282 typedef int Type_t;
283 static int apply(const bool &s, const PrintTag &f)
284 {
285 f.os_m << "bool";
286 return 0;
287 }
288};
289
290template<class T>
291struct LeafFunctor<IScalar<T>, PrintTag>
292{
293 typedef int Type_t;
294 static int apply(const IScalar<T> &s, const PrintTag &f)
295 {
296 f.os_m << "IScal<";
297 LeafFunctor<T,PrintTag>::apply(s.elem(),f);
298 f.os_m << ">";
299 return 0;
300 }
301};
302
303template<class T, int N>
304struct LeafFunctor<ILattice<T,N>, PrintTag>
305{
306 typedef int Type_t;
307 static int apply(const ILattice<T,N> &s, const PrintTag &f)
308 {
309 f.os_m << "ILat<";
310 LeafFunctor<T,PrintTag>::apply(s.elem(0),f);
311 f.os_m << "," << N << ">";
312 return 0;
313 }
314};
315
316template<class T>
317struct LeafFunctor<RScalar<T>, PrintTag>
318{
319 typedef int Type_t;
320 static int apply(const RScalar<T> &s, const PrintTag &f)
321 {
322 f.os_m << "RScal<";
323 LeafFunctor<T,PrintTag>::apply(s.elem(),f);
324 f.os_m << ">";
325 return 0;
326 }
327};
328
329template<class T>
330struct LeafFunctor<RComplex<T>, PrintTag>
331{
332 typedef int Type_t;
333 static int apply(const RComplex<T> &s, const PrintTag &f)
334 {
335 f.os_m << "RCplx<";
336 LeafFunctor<T,PrintTag>::apply(s.real(),f);
337 f.os_m << ">";
338 return 0;
339 }
340};
341
342template<class T>
343struct LeafFunctor<PScalar<T>, PrintTag>
344{
345 typedef int Type_t;
346 static int apply(const PScalar<T> &s, const PrintTag &f)
347 {
348 f.os_m << "PScal<";
349 LeafFunctor<T,PrintTag>::apply(s.elem(),f);
350 f.os_m << ">";
351 return 0;
352 }
353};
354
355template<class T>
356struct LeafFunctor<PSeed<T>, PrintTag>
357{
358 typedef int Type_t;
359 static int apply(const PSeed<T> &s, const PrintTag &f)
360 {
361 f.os_m << "PSeed<";
362 LeafFunctor<T,PrintTag>::apply(s.elem(0),f);
363 f.os_m << ">";
364 return 0;
365 }
366};
367
368template <class T, int N>
369struct LeafFunctor<PColorMatrix<T,N>, PrintTag>
370{
371 typedef int Type_t;
372 static int apply(const PColorMatrix<T,N> &s, const PrintTag &f)
373 {
374 f.os_m << "CMat<";
375 LeafFunctor<T,PrintTag>::apply(s.elem(0,0),f);
376 f.os_m << "," << N << ">";
377 return 0;
378 }
379};
380
381template <class T, int N>
382struct LeafFunctor<PSpinMatrix<T,N>, PrintTag>
383{
384 typedef int Type_t;
385 static int apply(const PSpinMatrix<T,N> &s, const PrintTag &f)
386 {
387 f.os_m << "SMat<";
388 LeafFunctor<T,PrintTag>::apply(s.elem(0,0),f);
389 f.os_m << "," << N << ">";
390 return 0;
391 }
392};
393
394template <class T, int N>
395struct LeafFunctor<PColorVector<T,N>, PrintTag>
396{
397 typedef int Type_t;
398 static int apply(const PColorVector<T,N> &s, const PrintTag &f)
399 {
400 f.os_m << "ColorVec<";
401 LeafFunctor<T,PrintTag>::apply(s.elem(0),f);
402 f.os_m << "," << N << ">";
403 return 0;
404 }
405};
406
407template <class T, int N>
408struct LeafFunctor<PSpinVector<T,N>, PrintTag>
409{
410 typedef int Type_t;
411 static int apply(const PSpinVector<T,N> &s, const PrintTag &f)
412 {
413 f.os_m << "SpinVec<";
414 LeafFunctor<T,PrintTag>::apply(s.elem(0),f);
415 f.os_m << "," << N << ">";
416 return 0;
417 }
418};
419
420template <class T, int N, template<class,int> class C>
421struct LeafFunctor<PMatrix<T,N,C>, PrintTag>
422{
423 typedef int Type_t;
424 static int apply(const PMatrix<T,N,C> &s, const PrintTag &f)
425 {
426 return LeafFunctor<C<T,N>,PrintTag>::apply(static_cast<const C<T,N>&>(s),f);
427 }
428};
429
430template <class T, int N, template<class,int> class C>
431struct LeafFunctor<PVector<T,N,C>, PrintTag>
432{
433 typedef int Type_t;
434 static int apply(const PVector<T,N,C> &s, const PrintTag &f)
435 {
436 return LeafFunctor<C<T,N>,PrintTag>::apply(static_cast<const C<T,N>&>(s),f);
437 }
438};
439
440template<class T>
441struct LeafFunctor<OScalar<T>, PrintTag>
442{
443 typedef int Type_t;
444 static int apply(const OScalar<T> &s, const PrintTag &f)
445 {
446 f.os_m << "OScal<";
447 LeafFunctor<T,PrintTag>::apply(s.elem(),f);
448 f.os_m << ">";
449 return 0;
450 }
451};
452
453template<class T>
454struct LeafFunctor<OLattice<T>, PrintTag>
455{
456 typedef int Type_t;
457 static int apply(const OLattice<T> &s, const PrintTag &f)
458 {
459 f.os_m << "OLat<";
460 LeafFunctor<T,PrintTag>::apply(s.elem(0),f);
461 f.os_m << ">";
462 return 0;
463 }
464};
465
466template<int N>
467struct LeafFunctor<GammaType<N>, PrintTag>
468{
469 typedef int Type_t;
470 static int apply(const GammaType<N> &s, const PrintTag &f)
471 {
472 f.os_m << "GammaType";
473 return 0;
474 }
475};
476
477template<int N, int m>
478struct LeafFunctor<GammaConst<N,m>, PrintTag>
479{
480 typedef int Type_t;
481 static int apply(const GammaConst<N,m> &s, const PrintTag &f)
482 {
483 f.os_m << "GammaConst";
484 return 0;
485 }
486};
487
488
489
490
491//
492// struct ParenPrinter
493//
494// Utility class to provide start and finish functions that print the
495// open paren and closed paren for an expression as the ForEach moves
496// down and back up an edge of the parse-tree.
497//
498
499template<class Op>
500struct ParenPrinter
501{
502 static void start(Op,PrintTag p)
503 { p.os_m << "("; }
504
505 static void center(Op,PrintTag p)
506 { p.os_m << ","; }
507
508 static void finish(Op,PrintTag p)
509 { p.os_m << ")"; }
510};
511
512
513//
514// struct TagVisitor<Op, PrintTag>
515//
516// Specialication of TagVisitor class for applying the PrintTag
517// tag to Op nodes. The visit method simply prints a symbol
518// to the ostream carried by PrintTag.
519//
520// FnArcCos
521template <>
522struct TagVisitor<FnArcCos, PrintTag> : public ParenPrinter<FnArcCos>
523{
524 static void visit(FnArcCos op, PrintTag t)
525 { t.os_m << "acos"; }
526};
527
528// FnArcSin
529template <>
530struct TagVisitor<FnArcSin, PrintTag> : public ParenPrinter<FnArcSin>
531{
532 static void visit(FnArcSin op, PrintTag t)
533 { t.os_m << "asin"; }
534};
535
536// FnArcTan
537template <>
538struct TagVisitor<FnArcTan, PrintTag> : public ParenPrinter<FnArcTan>
539{
540 static void visit(FnArcTan op, PrintTag t)
541 { t.os_m << "atan"; }
542};
543
544// FnCeil
545template <>
546struct TagVisitor<FnCeil, PrintTag> : public ParenPrinter<FnCeil>
547{
548 static void visit(FnCeil op, PrintTag t)
549 { t.os_m << "ceil"; }
550};
551
552// FnCos
553template <>
554struct TagVisitor<FnCos, PrintTag> : public ParenPrinter<FnCos>
555{
556 static void visit(FnCos op, PrintTag t)
557 { t.os_m << "cos"; }
558};
559
560// FnHypCos
561template <>
562struct TagVisitor<FnHypCos, PrintTag> : public ParenPrinter<FnHypCos>
563{
564 static void visit(FnHypCos op, PrintTag t)
565 { t.os_m << "cosh"; }
566};
567
568// FnExp
569template <>
570struct TagVisitor<FnExp, PrintTag> : public ParenPrinter<FnExp>
571{
572 static void visit(FnExp op, PrintTag t)
573 { t.os_m << "exp"; }
574};
575
576// FnFabs
577template <>
578struct TagVisitor<FnFabs, PrintTag> : public ParenPrinter<FnFabs>
579{
580 static void visit(FnFabs op, PrintTag t)
581 { t.os_m << "fabs"; }
582};
583
584// FnFloor
585template <>
586struct TagVisitor<FnFloor, PrintTag> : public ParenPrinter<FnFloor>
587{
588 static void visit(FnFloor op, PrintTag t)
589 { t.os_m << "floor"; }
590};
591
592// FnLog
593template <>
594struct TagVisitor<FnLog, PrintTag> : public ParenPrinter<FnLog>
595{
596 static void visit(FnLog op, PrintTag t)
597 { t.os_m << "log"; }
598};
599
600// FnLog10
601template <>
602struct TagVisitor<FnLog10, PrintTag> : public ParenPrinter<FnLog10>
603{
604 static void visit(FnLog10 op, PrintTag t)
605 { t.os_m << "log10"; }
606};
607
608// FnSin
609template <>
610struct TagVisitor<FnSin, PrintTag> : public ParenPrinter<FnSin>
611{
612 static void visit(FnSin op, PrintTag t)
613 { t.os_m << "sin"; }
614};
615
616// FnHypSin
617template <>
618struct TagVisitor<FnHypSin, PrintTag> : public ParenPrinter<FnHypSin>
619{
620 static void visit(FnHypSin op, PrintTag t)
621 { t.os_m << "sinh"; }
622};
623
624// FnSqrt
625template <>
626struct TagVisitor<FnSqrt, PrintTag> : public ParenPrinter<FnSqrt>
627{
628 static void visit(FnSqrt op, PrintTag t)
629 { t.os_m << "sqrt"; }
630};
631
632// FnTan
633template <>
634struct TagVisitor<FnTan, PrintTag> : public ParenPrinter<FnTan>
635{
636 static void visit(FnTan op, PrintTag t)
637 { t.os_m << "tan"; }
638};
639
640// FnHypTan
641template <>
642struct TagVisitor<FnHypTan, PrintTag> : public ParenPrinter<FnHypTan>
643{
644 static void visit(FnHypTan op, PrintTag t)
645 { t.os_m << "tanh"; }
646};
647
648// OpUnaryMinus
649template <>
650struct TagVisitor<OpUnaryMinus, PrintTag> : public ParenPrinter<OpUnaryMinus>
651{
652 static void visit(OpUnaryMinus op, PrintTag t)
653 { t.os_m << "-"; }
654};
655
656// OpUnaryPlus
657template <>
658struct TagVisitor<OpUnaryPlus, PrintTag> : public ParenPrinter<OpUnaryPlus>
659{
660 static void visit(OpUnaryPlus op, PrintTag t)
661 { t.os_m << "+"; }
662};
663
664// OpBitwiseNot
665template <>
666struct TagVisitor<OpBitwiseNot, PrintTag> : public ParenPrinter<OpBitwiseNot>
667{
668 static void visit(OpBitwiseNot op, PrintTag t)
669 { t.os_m << "~"; }
670};
671
672// OpIdentity
673template <>
674struct TagVisitor<OpIdentity, PrintTag> : public ParenPrinter<OpIdentity>
675{
676 static void visit(OpIdentity op, PrintTag t)
677 { t.os_m << "PETE_identity"; }
678};
679
680// OpNot
681template <>
682struct TagVisitor<OpNot, PrintTag> : public ParenPrinter<OpNot>
683{
684 static void visit(OpNot op, PrintTag t)
685 { t.os_m << "!"; }
686};
687
688// OpAdd
689template <>
690struct TagVisitor<OpAdd, PrintTag> : public ParenPrinter<OpAdd>
691{
692 static void visit(OpAdd op, PrintTag t)
693 { t.os_m << "+"; }
694};
695
696// OpSubtract
697template <>
698struct TagVisitor<OpSubtract, PrintTag> : public ParenPrinter<OpSubtract>
699{
700 static void visit(OpSubtract op, PrintTag t)
701 { t.os_m << "-"; }
702};
703
704// OpMultiply
705template <>
706struct TagVisitor<OpMultiply, PrintTag> : public ParenPrinter<OpMultiply>
707{
708 static void visit(OpMultiply op, PrintTag t)
709 { t.os_m << "*"; }
710};
711
712// OpDivide
713template <>
714struct TagVisitor<OpDivide, PrintTag> : public ParenPrinter<OpDivide>
715{
716 static void visit(OpDivide op, PrintTag t)
717 { t.os_m << "/"; }
718};
719
720// OpMod
721template <>
722struct TagVisitor<OpMod, PrintTag> : public ParenPrinter<OpMod>
723{
724 static void visit(OpMod op, PrintTag t)
725 { t.os_m << "%"; }
726};
727
728// OpBitwiseAnd
729template <>
730struct TagVisitor<OpBitwiseAnd, PrintTag> : public ParenPrinter<OpBitwiseAnd>
731{
732 static void visit(OpBitwiseAnd op, PrintTag t)
733 { t.os_m << "&"; }
734};
735
736// OpBitwiseOr
737template <>
738struct TagVisitor<OpBitwiseOr, PrintTag> : public ParenPrinter<OpBitwiseOr>
739{
740 static void visit(OpBitwiseOr op, PrintTag t)
741 { t.os_m << "|"; }
742};
743
744// OpBitwiseXor
745template <>
746struct TagVisitor<OpBitwiseXor, PrintTag> : public ParenPrinter<OpBitwiseXor>
747{
748 static void visit(OpBitwiseXor op, PrintTag t)
749 { t.os_m << "^"; }
750};
751
752// FnLdexp
753template <>
754struct TagVisitor<FnLdexp, PrintTag> : public ParenPrinter<FnLdexp>
755{
756 static void visit(FnLdexp op, PrintTag t)
757 { t.os_m << "ldexp"; }
758};
759
760// FnPow
761template <>
762struct TagVisitor<FnPow, PrintTag> : public ParenPrinter<FnPow>
763{
764 static void visit(FnPow op, PrintTag t)
765 { t.os_m << "pow"; }
766};
767
768// FnFmod
769template <>
770struct TagVisitor<FnFmod, PrintTag> : public ParenPrinter<FnFmod>
771{
772 static void visit(FnFmod op, PrintTag t)
773 { t.os_m << "fmod"; }
774};
775
776// FnArcTan2
777template <>
778struct TagVisitor<FnArcTan2, PrintTag> : public ParenPrinter<FnArcTan2>
779{
780 static void visit(FnArcTan2 op, PrintTag t)
781 { t.os_m << "atan2"; }
782};
783
784// OpLT
785template <>
786struct TagVisitor<OpLT, PrintTag> : public ParenPrinter<OpLT>
787{
788 static void visit(OpLT op, PrintTag t)
789 { t.os_m << "<"; }
790};
791
792// OpLE
793template <>
794struct TagVisitor<OpLE, PrintTag> : public ParenPrinter<OpLE>
795{
796 static void visit(OpLE op, PrintTag t)
797 { t.os_m << "<="; }
798};
799
800// OpGT
801template <>
802struct TagVisitor<OpGT, PrintTag> : public ParenPrinter<OpGT>
803{
804 static void visit(OpGT op, PrintTag t)
805 { t.os_m << ">"; }
806};
807
808// OpGE
809template <>
810struct TagVisitor<OpGE, PrintTag> : public ParenPrinter<OpGE>
811{
812 static void visit(OpGE op, PrintTag t)
813 { t.os_m << ">="; }
814};
815
816// OpEQ
817template <>
818struct TagVisitor<OpEQ, PrintTag> : public ParenPrinter<OpEQ>
819{
820 static void visit(OpEQ op, PrintTag t)
821 { t.os_m << "=="; }
822};
823
824// OpNE
825template <>
826struct TagVisitor<OpNE, PrintTag> : public ParenPrinter<OpNE>
827{
828 static void visit(OpNE op, PrintTag t)
829 { t.os_m << "!="; }
830};
831
832// OpAnd
833template <>
834struct TagVisitor<OpAnd, PrintTag> : public ParenPrinter<OpAnd>
835{
836 static void visit(OpAnd op, PrintTag t)
837 { t.os_m << "&&"; }
838};
839
840// OpOr
841template <>
842struct TagVisitor<OpOr, PrintTag> : public ParenPrinter<OpOr>
843{
844 static void visit(OpOr op, PrintTag t)
845 { t.os_m << "||"; }
846};
847
848// OpLeftShift
849template <>
850struct TagVisitor<OpLeftShift, PrintTag> : public ParenPrinter<OpLeftShift>
851{
852 static void visit(OpLeftShift op, PrintTag t)
853 { t.os_m << "<<"; }
854};
855
856// OpRightShift
857template <>
858struct TagVisitor<OpRightShift, PrintTag> : public ParenPrinter<OpRightShift>
859{
860 static void visit(OpRightShift op, PrintTag t)
861 { t.os_m << ">>"; }
862};
863
864// OpAssign
865template <>
866struct TagVisitor<OpAssign, PrintTag> : public ParenPrinter<OpAssign>
867{
868 static void visit(OpAssign op, PrintTag t)
869 { t.os_m << "="; }
870};
871
872// OpAddAssign
873template <>
874struct TagVisitor<OpAddAssign, PrintTag> : public ParenPrinter<OpAddAssign>
875{
876 static void visit(OpAddAssign op, PrintTag t)
877 { t.os_m << "+="; }
878};
879
880// OpSubtractAssign
881template <>
882struct TagVisitor<OpSubtractAssign, PrintTag> : public ParenPrinter<OpSubtractAssign>
883{
884 static void visit(OpSubtractAssign op, PrintTag t)
885 { t.os_m << "-="; }
886};
887
888// OpMultiplyAssign
889template <>
890struct TagVisitor<OpMultiplyAssign, PrintTag> : public ParenPrinter<OpMultiplyAssign>
891{
892 static void visit(OpMultiplyAssign op, PrintTag t)
893 { t.os_m << "*="; }
894};
895
896// OpDivideAssign
897template <>
898struct TagVisitor<OpDivideAssign, PrintTag> : public ParenPrinter<OpDivideAssign>
899{
900 static void visit(OpDivideAssign op, PrintTag t)
901 { t.os_m << "/="; }
902};
903
904// OpModAssign
905template <>
906struct TagVisitor<OpModAssign, PrintTag> : public ParenPrinter<OpModAssign>
907{
908 static void visit(OpModAssign op, PrintTag t)
909 { t.os_m << "%="; }
910};
911
912// OpBitwiseOrAssign
913template <>
914struct TagVisitor<OpBitwiseOrAssign, PrintTag> : public ParenPrinter<OpBitwiseOrAssign>
915{
916 static void visit(OpBitwiseOrAssign op, PrintTag t)
917 { t.os_m << "|="; }
918};
919
920// OpBitwiseAndAssign
921template <>
922struct TagVisitor<OpBitwiseAndAssign, PrintTag> : public ParenPrinter<OpBitwiseAndAssign>
923{
924 static void visit(OpBitwiseAndAssign op, PrintTag t)
925 { t.os_m << "&="; }
926};
927
928// OpBitwiseXorAssign
929template <>
930struct TagVisitor<OpBitwiseXorAssign, PrintTag> : public ParenPrinter<OpBitwiseXorAssign>
931{
932 static void visit(OpBitwiseXorAssign op, PrintTag t)
933 { t.os_m << "^="; }
934};
935
936// OpLeftShiftAssign
937template <>
938struct TagVisitor<OpLeftShiftAssign, PrintTag> : public ParenPrinter<OpLeftShiftAssign>
939{
940 static void visit(OpLeftShiftAssign op, PrintTag t)
941 { t.os_m << "<<="; }
942};
943
944// OpRightShiftAssign
945template <>
946struct TagVisitor<OpRightShiftAssign, PrintTag> : public ParenPrinter<OpRightShiftAssign>
947{
948 static void visit(OpRightShiftAssign op, PrintTag t)
949 { t.os_m << ">>="; }
950};
951
952// FnWhere
953template <>
954struct TagVisitor<FnWhere, PrintTag> : public ParenPrinter<FnWhere>
955{
956 static void visit(FnWhere op, PrintTag t)
957 { t.os_m << "where"; }
958};
959
960// FnAdjoint
961template <>
962struct TagVisitor<FnAdjoint, PrintTag> : public ParenPrinter<FnAdjoint>
963{
964 static void visit(FnAdjoint op, PrintTag t)
965 { t.os_m << "adj"; }
966};
967
968// FnConjugate
969template <>
970struct TagVisitor<FnConjugate, PrintTag> : public ParenPrinter<FnConjugate>
971{
972 static void visit(FnConjugate op, PrintTag t)
973 { t.os_m << "conj"; }
974};
975
976// FnTranspose
977template <>
978struct TagVisitor<FnTranspose, PrintTag> : public ParenPrinter<FnTranspose>
979{
980 static void visit(FnTranspose op, PrintTag t)
981 { t.os_m << "transpose"; }
982};
983
984// FnTrace
985template <>
986struct TagVisitor<FnTrace, PrintTag> : public ParenPrinter<FnTrace>
987{
988 static void visit(FnTrace op, PrintTag t)
989 { t.os_m << "trace"; }
990};
991
992// FnRealTrace
993template <>
994struct TagVisitor<FnRealTrace, PrintTag> : public ParenPrinter<FnRealTrace>
995{
996 static void visit(FnRealTrace op, PrintTag t)
997 { t.os_m << "realTrace"; }
998};
999
1000// FnImagTrace
1001template <>
1002struct TagVisitor<FnImagTrace, PrintTag> : public ParenPrinter<FnImagTrace>
1003{
1004 static void visit(FnImagTrace op, PrintTag t)
1005 { t.os_m << "imagTrace"; }
1006};
1007
1008// FnTraceColor
1009template <>
1010struct TagVisitor<FnTraceColor, PrintTag> : public ParenPrinter<FnTraceColor>
1011{
1012 static void visit(FnTraceColor op, PrintTag t)
1013 { t.os_m << "traceColor"; }
1014};
1015
1016// FnTraceSpin
1017template <>
1018struct TagVisitor<FnTraceSpin, PrintTag> : public ParenPrinter<FnTraceSpin>
1019{
1020 static void visit(FnTraceSpin op, PrintTag t)
1021 { t.os_m << "traceSpin"; }
1022};
1023
1024// FnTransposeSpin
1025template <>
1026struct TagVisitor<FnTransposeSpin, PrintTag> : public ParenPrinter<FnTransposeSpin>
1027{
1028 static void visit(FnTransposeSpin op, PrintTag t)
1029 {
1030 t.os_m << "transposeSpin"; }
1031};
1032
1033// FnReal
1034template <>
1035struct TagVisitor<FnReal, PrintTag> : public ParenPrinter<FnReal>
1036{
1037 static void visit(FnReal op, PrintTag t)
1038 { t.os_m << "real"; }
1039};
1040
1041// FnImag
1042template <>
1043struct TagVisitor<FnImag, PrintTag> : public ParenPrinter<FnImag>
1044{
1045 static void visit(FnImag op, PrintTag t)
1046 { t.os_m << "imag"; }
1047};
1048
1049// FnLocalNorm2
1050template <>
1051struct TagVisitor<FnLocalNorm2, PrintTag> : public ParenPrinter<FnLocalNorm2>
1052{
1053 static void visit(FnLocalNorm2 op, PrintTag t)
1054 { t.os_m << "localNorm2"; }
1055};
1056
1057// FnTimesI
1058template <>
1059struct TagVisitor<FnTimesI, PrintTag> : public ParenPrinter<FnTimesI>
1060{
1061 static void visit(FnTimesI op, PrintTag t)
1062 { t.os_m << "timesI"; }
1063};
1064
1065// FnTimesMinusI
1066template <>
1067struct TagVisitor<FnTimesMinusI, PrintTag> : public ParenPrinter<FnTimesMinusI>
1068{
1069 static void visit(FnTimesMinusI op, PrintTag t)
1070 { t.os_m << "timesMinusI"; }
1071};
1072
1073// FnSeedToFloat
1074template <>
1075struct TagVisitor<FnSeedToFloat, PrintTag> : public ParenPrinter<FnSeedToFloat>
1076{
1077 static void visit(FnSeedToFloat op, PrintTag t)
1078 { t.os_m << "seedToFloat"; }
1079};
1080
1081// FnSpinProjectDir0Plus
1082template <>
1083struct TagVisitor<FnSpinProjectDir0Plus, PrintTag> : public ParenPrinter<FnSpinProjectDir0Plus>
1084{
1085 static void visit(FnSpinProjectDir0Plus op, PrintTag t)
1086 { t.os_m << "spinProjectDir0Plus"; }
1087};
1088
1089// FnSpinProjectDir1Plus
1090template <>
1091struct TagVisitor<FnSpinProjectDir1Plus, PrintTag> : public ParenPrinter<FnSpinProjectDir1Plus>
1092{
1093 static void visit(FnSpinProjectDir1Plus op, PrintTag t)
1094 { t.os_m << "spinProjectDir1Plus"; }
1095};
1096
1097// FnSpinProjectDir2Plus
1098template <>
1099struct TagVisitor<FnSpinProjectDir2Plus, PrintTag> : public ParenPrinter<FnSpinProjectDir2Plus>
1100{
1101 static void visit(FnSpinProjectDir2Plus op, PrintTag t)
1102 { t.os_m << "spinProjectDir2Plus"; }
1103};
1104
1105// FnSpinProjectDir3Plus
1106template <>
1107struct TagVisitor<FnSpinProjectDir3Plus, PrintTag> : public ParenPrinter<FnSpinProjectDir3Plus>
1108{
1109 static void visit(FnSpinProjectDir3Plus op, PrintTag t)
1110 { t.os_m << "spinProjectDir3Plus"; }
1111};
1112
1113// FnSpinProjectDir0Minus
1114template <>
1115struct TagVisitor<FnSpinProjectDir0Minus, PrintTag> : public ParenPrinter<FnSpinProjectDir0Minus>
1116{
1117 static void visit(FnSpinProjectDir0Minus op, PrintTag t)
1118 { t.os_m << "spinProjectDir0Minus"; }
1119};
1120
1121// FnSpinProjectDir1Minus
1122template <>
1123struct TagVisitor<FnSpinProjectDir1Minus, PrintTag> : public ParenPrinter<FnSpinProjectDir1Minus>
1124{
1125 static void visit(FnSpinProjectDir1Minus op, PrintTag t)
1126 { t.os_m << "spinProjectDir1Minus"; }
1127};
1128
1129// FnSpinProjectDir2Minus
1130template <>
1131struct TagVisitor<FnSpinProjectDir2Minus, PrintTag> : public ParenPrinter<FnSpinProjectDir2Minus>
1132{
1133 static void visit(FnSpinProjectDir2Minus op, PrintTag t)
1134 { t.os_m << "spinProjectDir2Minus"; }
1135};
1136
1137// FnSpinProjectDir3Minus
1138template <>
1139struct TagVisitor<FnSpinProjectDir3Minus, PrintTag> : public ParenPrinter<FnSpinProjectDir3Minus>
1140{
1141 static void visit(FnSpinProjectDir3Minus op, PrintTag t)
1142 { t.os_m << "spinProjectDir3Minus"; }
1143};
1144
1145// FnSpinReconstructDir0Plus
1146template <>
1147struct TagVisitor<FnSpinReconstructDir0Plus, PrintTag> : public ParenPrinter<FnSpinReconstructDir0Plus>
1148{
1149 static void visit(FnSpinReconstructDir0Plus op, PrintTag t)
1150 { t.os_m << "spinReconstructDir0Plus"; }
1151};
1152
1153// FnSpinReconstructDir1Plus
1154template <>
1155struct TagVisitor<FnSpinReconstructDir1Plus, PrintTag> : public ParenPrinter<FnSpinReconstructDir1Plus>
1156{
1157 static void visit(FnSpinReconstructDir1Plus op, PrintTag t)
1158 { t.os_m << "spinReconstructDir1Plus"; }
1159};
1160
1161// FnSpinReconstructDir2Plus
1162template <>
1163struct TagVisitor<FnSpinReconstructDir2Plus, PrintTag> : public ParenPrinter<FnSpinReconstructDir2Plus>
1164{
1165 static void visit(FnSpinReconstructDir2Plus op, PrintTag t)
1166 { t.os_m << "spinReconstructDir2Plus"; }
1167};
1168
1169// FnSpinReconstructDir3Plus
1170template <>
1171struct TagVisitor<FnSpinReconstructDir3Plus, PrintTag> : public ParenPrinter<FnSpinReconstructDir3Plus>
1172{
1173 static void visit(FnSpinReconstructDir3Plus op, PrintTag t)
1174 { t.os_m << "spinReconstructDir3Plus"; }
1175};
1176
1177// FnSpinReconstructDir0Minus
1178template <>
1179struct TagVisitor<FnSpinReconstructDir0Minus, PrintTag> : public ParenPrinter<FnSpinReconstructDir0Minus>
1180{
1181 static void visit(FnSpinReconstructDir0Minus op, PrintTag t)
1182 { t.os_m << "spinReconstructDir0Minus"; }
1183};
1184
1185// FnSpinReconstructDir1Minus
1186template <>
1187struct TagVisitor<FnSpinReconstructDir1Minus, PrintTag> : public ParenPrinter<FnSpinReconstructDir1Minus>
1188{
1189 static void visit(FnSpinReconstructDir1Minus op, PrintTag t)
1190 { t.os_m << "spinReconstructDir1Minus"; }
1191};
1192
1193// FnSpinReconstructDir2Minus
1194template <>
1195struct TagVisitor<FnSpinReconstructDir2Minus, PrintTag> : public ParenPrinter<FnSpinReconstructDir2Minus>
1196{
1197 static void visit(FnSpinReconstructDir2Minus op, PrintTag t)
1198 { t.os_m << "spinReconstructDir2Minus"; }
1199};
1200
1201// FnSpinReconstructDir3Minus
1202template <>
1203struct TagVisitor<FnSpinReconstructDir3Minus, PrintTag> : public ParenPrinter<FnSpinReconstructDir3Minus>
1204{
1205 static void visit(FnSpinReconstructDir3Minus op, PrintTag t)
1206 { t.os_m << "spinReconstructDir3Minus"; }
1207};
1208
1209// FnChiralProjectPlus
1210template <>
1211struct TagVisitor<FnChiralProjectPlus, PrintTag> : public ParenPrinter<FnChiralProjectPlus>
1212{
1213 static void visit(FnChiralProjectPlus op, PrintTag t)
1214 { t.os_m << "chiralProjectPlus"; }
1215};
1216
1217// FnChiralProjectMinus
1218template <>
1219struct TagVisitor<FnChiralProjectMinus, PrintTag> : public ParenPrinter<FnChiralProjectMinus>
1220{
1221 static void visit(FnChiralProjectMinus op, PrintTag t)
1222 { t.os_m << "chiralProjectMinus"; }
1223};
1224
1225// FnCmplx
1226template <>
1227struct TagVisitor<FnCmplx, PrintTag> : public ParenPrinter<FnCmplx>
1228{
1229 static void visit(FnCmplx op, PrintTag t)
1230 { t.os_m << "cmplx"; }
1231};
1232
1233// FnOuterProduct
1234template <>
1235struct TagVisitor<FnOuterProduct, PrintTag> : public ParenPrinter<FnOuterProduct>
1236{
1237 static void visit(FnOuterProduct op, PrintTag t)
1238 { t.os_m << "outerProduct"; }
1239};
1240
1241// FnLocalInnerProduct
1242template <>
1243struct TagVisitor<FnLocalInnerProduct, PrintTag> : public ParenPrinter<FnLocalInnerProduct>
1244{
1245 static void visit(FnLocalInnerProduct op, PrintTag t)
1246 { t.os_m << "localInnerProduct"; }
1247};
1248
1249// FnLocalInnerProductReal
1250template <>
1251struct TagVisitor<FnLocalInnerProductReal, PrintTag> : public ParenPrinter<FnLocalInnerProductReal>
1252{
1253 static void visit(FnLocalInnerProductReal op, PrintTag t)
1254 { t.os_m << "localInnerProductReal"; }
1255};
1256
1257// FnQuarkContract13
1258template <>
1259struct TagVisitor<FnQuarkContract13, PrintTag> : public ParenPrinter<FnQuarkContract13>
1260{
1261 static void visit(FnQuarkContract13 op, PrintTag t)
1262 { t.os_m << "quarkContract13"; }
1263};
1264
1265// FnQuarkContract14
1266template <>
1267struct TagVisitor<FnQuarkContract14, PrintTag> : public ParenPrinter<FnQuarkContract14>
1268{
1269 static void visit(FnQuarkContract14 op, PrintTag t)
1270 { t.os_m << "quarkContract14"; }
1271};
1272
1273// FnQuarkContract23
1274template <>
1275struct TagVisitor<FnQuarkContract23, PrintTag> : public ParenPrinter<FnQuarkContract23>
1276{
1277 static void visit(FnQuarkContract23 op, PrintTag t)
1278 { t.os_m << "quarkContract23"; }
1279};
1280
1281// FnQuarkContract24
1282template <>
1283struct TagVisitor<FnQuarkContract24, PrintTag> : public ParenPrinter<FnQuarkContract24>
1284{
1285 static void visit(FnQuarkContract24 op, PrintTag t)
1286 { t.os_m << "quarkContract24"; }
1287};
1288
1289// FnQuarkContract12
1290template <>
1291struct TagVisitor<FnQuarkContract12, PrintTag> : public ParenPrinter<FnQuarkContract12>
1292{
1293 static void visit(FnQuarkContract12 op, PrintTag t)
1294 { t.os_m << "quarkContract12"; }
1295};
1296
1297// FnQuarkContract34
1298template <>
1299struct TagVisitor<FnQuarkContract34, PrintTag> : public ParenPrinter<FnQuarkContract34>
1300{
1301 static void visit(FnQuarkContract34 op, PrintTag t)
1302 { t.os_m << "quarkContract34"; }
1303};
1304
1305// FnColorContract
1306template <>
1307struct TagVisitor<FnColorContract, PrintTag> : public ParenPrinter<FnColorContract>
1308{
1309 static void visit(FnColorContract op, PrintTag t)
1310 { t.os_m << "colorContract"; }
1311};
1312
1313
1314//-----------------------------------------------------------------------------
1315// Additional operator tags
1316//-----------------------------------------------------------------------------
1317
1318template <>
1319struct TagVisitor<FnSum, PrintTag> : public ParenPrinter<FnSum>
1320{
1321 static void visit(FnSum op, PrintTag t)
1322 { t.os_m << "sum"; }
1323};
1324
1325template <>
1326struct TagVisitor<FnNorm2, PrintTag> : public ParenPrinter<FnNorm2>
1327{
1328 static void visit(FnNorm2 op, PrintTag t)
1329 { t.os_m << "norm2"; }
1330};
1331
1332template <>
1333struct TagVisitor<OpGammaConstMultiply, PrintTag> : public ParenPrinter<OpGammaConstMultiply>
1334{
1335 static void visit(OpGammaConstMultiply op, PrintTag t)
1336 { t.os_m << "*"; }
1337};
1338
1339template <>
1340struct TagVisitor<OpMultiplyGammaConst, PrintTag> : public ParenPrinter<OpMultiplyGammaConst>
1341{
1342 static void visit(OpMultiplyGammaConst op, PrintTag t)
1343 { t.os_m << "*"; }
1344};
1345
1346template <>
1347struct TagVisitor<OpGammaTypeMultiply, PrintTag> : public ParenPrinter<OpGammaTypeMultiply>
1348{
1349 static void visit(OpGammaTypeMultiply op, PrintTag t)
1350 { t.os_m << "*"; }
1351};
1352
1353template <>
1354struct TagVisitor<OpMultiplyGammaType, PrintTag> : public ParenPrinter<OpMultiplyGammaType>
1355{
1356 static void visit(OpMultiplyGammaType op, PrintTag t)
1357 { t.os_m << "*"; }
1358};
1359
1360
1361//------------------------------------------------------------------------
1362// Special optimizations
1363//------------------------------------------------------------------------
1364
1365template <>
1366struct TagVisitor<OpAdjMultiply, PrintTag> : public ParenPrinter<OpAdjMultiply>
1367{
1368 static void visit(OpAdjMultiply op, PrintTag t)
1369 { t.os_m << "adjMultiply"; }
1370};
1371
1372template <>
1373struct TagVisitor<OpMultiplyAdj, PrintTag> : public ParenPrinter<OpMultiplyAdj>
1374{
1375 static void visit(OpMultiplyAdj op, PrintTag t)
1376 { t.os_m << "multiplyAdj"; }
1377};
1378
1379template <>
1380struct TagVisitor<OpAdjMultiplyAdj, PrintTag> : public ParenPrinter<OpAdjMultiplyAdj>
1381{
1382 static void visit(OpAdjMultiplyAdj op, PrintTag t)
1383 { t.os_m << "adjMultiplyAdj"; }
1384};
1385
1386template <>
1387struct TagVisitor<FnTraceMultiply, PrintTag> : public ParenPrinter<FnTraceMultiply>
1388{
1389 static void visit(FnTraceMultiply op, PrintTag t)
1390 { t.os_m << "traceMultiply"; }
1391};
1392
1393template <>
1394struct TagVisitor<FnTraceColorMultiply, PrintTag> : public ParenPrinter<FnTraceColorMultiply>
1395{
1396 static void visit(FnTraceColorMultiply op, PrintTag t)
1397 { t.os_m << "traceColorMultiply"; }
1398};
1399
1400template <>
1401struct TagVisitor<FnTraceSpinMultiply, PrintTag> : public ParenPrinter<FnTraceSpinMultiply>
1402{
1403 static void visit(FnTraceSpinMultiply op, PrintTag t)
1404 { t.os_m << "traceSpinMultiply"; }
1405};
1406
1407template <>
1408struct TagVisitor<FnTraceSpinQuarkContract13, PrintTag> : public ParenPrinter<FnTraceSpinQuarkContract13>
1409{
1410 static void visit(FnTraceSpinQuarkContract13 op, PrintTag t)
1411 { t.os_m << "traceSpinQuarkContract13"; }
1412};
1413
1414#endif // ! defined(QDP_USE_PROFILING)
1415
1416} // namespace QDP
1417
1418#endif // QDP_PROFILE_INCLUDE
Scalar inner lattice.
Definition qdp_inner.h:25
Outer grid Lattice type.
Definition qdp_outer.h:264
Outer grid Scalar class *‍/.
Definition qdp_outer.h:37
Primitive color Matrix class.
Primitive color Vector class.
Primitive Matrix class.
Primitive Scalar.
Primitive Seed class.
Primitive Spin Matrix class.
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
Reality complex.
Scalar reality (not complex).
Definition qdp_reality.h:28
OLattice< PScalar< PColorMatrix< RComplexFloat, 3 > > > C
void init()
Initializer for layout.
Yet another random number generator.
void printProfile()
int getProgramProfileLevel()
int getProfileLevel()
void popProfileInfo()
QDPTime_t getClockTime()
Get the wallclock time.
void closeProfile()
int setProfileLevel(int n)
void pushProfileInfo(int level, const std::string &file, const std::string &caller, int line)
int setProgramProfileLevel(int n)
void initProfile(const std::string &file, const std::string &caller, int line)
unsigned long QDPTime_t
Definition qdp_profile.h:14
static Expression_t make(const T &a)
Definition CreateLeaf.h:143
Scalar< T > Leaf_t
Definition qdp.h:97
static Leaf_t make(const T &a)
Definition qdp.h:100
static void visit(Op, VTag)