QDP++
qdp_scalarsite_generic_cblas.h
Go to the documentation of this file.
1#ifndef QDP_SCALARSITE_GENERIC_CBLAS
2#define QDP_SCALARSITE_GENERIC_CBLAS
4// Complex BLAS routines
5
11
12namespace QDP {
13
18// Threading evaluates
19//
20// by Xu Guo, EPCC, 26 August, 2008
21
22
23// the wrappers for the functions to be threaded
25
26// vector z *= complex a
27template<>
28inline
30 const OpMultiplyAssign &op,
31 const QDPExpr<
34 OScalar< CScal > > &rhs,
35 const Subset& s)
36{
37 const OScalar< CScal >& a = static_cast< const OScalar<CScal >&>(rhs.expression().child());
39#ifdef DEBUG_CBLAS
40 QDPIO::cout << "BJ: Complex v *= a " << a << endl;
41#endif
42
43 REAL *a_start = (REAL *) &(a.elem().elem().elem().real());
44
45 if( s.hasOrderedRep() ) {
46 REAL *d_start = &(d.elem(s.start()).elem(0).elem(0).real());
48 int total_n_3vec = (s.end()-s.start()+1);
49
50 ordered_vcscal_user_arg a = {d_start, a_start, d_start};
51
55 // Original code
57 //int n_3vec =( s.end() - s.start() + 1 )*Ns;
58 //vcscal(d_start, a_start, d_start, n_3vec);
59 }
60 else {
61 const int* tab = s.siteTable().slice();
62
63 int totalSize = s.numSiteTable();
64
65
66
67 unordered_vcscal_user_arg arg(d, d, a_start, tab);
68
70
72 // Original code
74 /*for(int j=0; j < s.numSiteTable(); j++) {
75 int i = tab[j];
76 REAL *d_start = &(d.elem(i).elem(0).elem(0).real());
78 vcscal(d_start, a_start, d_start, 4);
79 }*/
80 }
81
82}
83
84
85// vector z = complex a * vector x
86template<>
87inline
89 const OpAssign &op,
90 const QDPExpr<
94 OLattice< CTVec > > &rhs,
95 const Subset& s)
96{
97 const OScalar< CScal >& a = static_cast< const OScalar<CScal >&>(rhs.expression().left());
98
99 const OLattice< CTVec > &x = static_cast<const OLattice< CTVec >&>(rhs.expression().right());
100
101#ifdef DEBUG_CBLAS
102 QDPIO::cout << "BJ: Complex v = a*x " << a << endl;
103#endif
104
105 REAL *a_start = (REAL *) &(a.elem().elem().elem().real());
106
107 if( s.hasOrderedRep() ) {
109 REAL *d_start = &(d.elem(s.start()).elem(0).elem(0).real());
110 REAL *x_start = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
112 int total_n_3vec = (s.end()-s.start()+1);
113
114 ordered_vcscal_user_arg a = {d_start, a_start, x_start};
115
117
119 // Original code
121 //int n_3vec =( s.end() - s.start() + 1 )*Ns;
122
123 //vcscal(d_start, a_start, x_start, n_3vec);
124 }
125 else {
126 const int* tab = s.siteTable().slice();
127
128 int totalSize = s.numSiteTable();
129
130
131 unordered_vcscal_user_arg arg(x, d, a_start, tab);
132
134
135 ////////////////
136 // Original code
138 /*
139 for(int j=0; j < s.numSiteTable(); j++) {
140 int i = tab[j];
141
142 REAL *d_start = &(d.elem(i).elem(0).elem(0).real());
143 REAL *x_start = (REAL *) &(x.elem(i).elem(0).elem(0).real());
146 vcscal(d_start, a_start, x_start, 4);
148 */
149 }
150}
151
152// vector z = vector x * complex a
153template<>
154inline
156 const OpAssign &op,
157 const QDPExpr<
161 OLattice< CTVec > > &rhs,
162 const Subset& s)
163{
164 const OScalar< CScal >& a = static_cast< const OScalar<CScal >&>(rhs.expression().right());
165
166 const OLattice< CTVec > &x = static_cast<const OLattice< CTVec >&>(rhs.expression().left());
167
168#ifdef DEBUG_CBLAS
169 QDPIO::cout << "BJ: Complex v = x*a " << a << endl;
170#endif
171
172
173 REAL *a_start = (REAL *) &(a.elem().elem().elem().real());
174
175 if( s.hasOrderedRep() ) {
176 REAL *d_start = &(d.elem(s.start()).elem(0).elem(0).real());
177 REAL *x_start = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
178
179 int total_n_3vec = (s.end()-s.start()+1);
180
181 ordered_vcscal_user_arg a = {d_start, a_start, x_start};
186 // Original code
187
188 //int n_3vec =( s.end() - s.start() + 1 )*Ns;
189
190 //vcscal(d_start, a_start, x_start, n_3vec);
191 }
192 else {
193 const int* tab = s.siteTable().slice();
194
195 int totalSize = s.numSiteTable();
196
197 unordered_vcscal_user_arg arg(x, d, a_start, tab);
198
200
202 // Original code
204 /*
205 for(int j=0; j < s.numSiteTable(); j++) {
206 int i = tab[j];
207 REAL *d_start = &(d.elem(i).elem(0).elem(0).real());
208 REAL *x_start = (REAL *) &(x.elem(i).elem(0).elem(0).real());
209
210 vcscal(d_start, a_start, x_start, 4);
211 }*/
212 }
213}
216// AXPYs.
218// y += a*x
219template<>
220inline
222 const OpAddAssign& op,
224 Reference< QDPType< CScal, OScalar < CScal > > >,
226 OLattice< CTVec > > &rhs,
227 const Subset& s)
228{
229
230#ifdef DEBUG_CBLAS
231 QDPIO::cout << "y += a*x" << endl;
232#endif
233
234 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec > &>(rhs.expression().right());
235 const OScalar< CScal >& a = static_cast<const OScalar< CScal > &> (rhs.expression().left());
236
237 REAL* ar = (REAL *)&(a.elem().elem().elem().real());
238 if( s.hasOrderedRep() ) {
239
240 REAL* xptr = (REAL *)&(x.elem(s.start()).elem(0).elem(0).real());
241 REAL* yptr = &(d.elem(s.start()).elem(0).elem(0).real());
242
243 int total_n_3vec = (s.end()-s.start()+1);
244
245 ordered_vcaxpy3_user_arg a = {yptr, ar, xptr, yptr};
246
248
250 // Original code
253 //int n_3vec = (s.end()-s.start()+1)*Ns;
254 //vcaxpy3(yptr, ar, xptr, yptr, n_3vec);
256 else {
257 const int* tab = s.siteTable().slice();
258
259 int totalSize = s.numSiteTable();
261
262
263 unordered_vcaxpy3_y_user_arg arg(x, d, ar, tab);
264
266
268 // Original code
270 /*for(int j=0; j < s.numSiteTable(); j++) {
271 int i = tab[j];
272
273 REAL* xptr = (REAL *)&(x.elem(i).elem(0).elem(0).real());
274 REAL* yptr = &(d.elem(i).elem(0).elem(0).real());
275
276 vcaxpy3(yptr, ar, xptr, yptr, 4);
278 }*/
279 }
280}
281
282// y += x*a
283template<>
284inline
286 const OpAddAssign& op,
289 Reference< QDPType< CScal, OScalar < CScal > > > >,
291 const Subset& s)
292{
293
294#ifdef DEBUG_CBLAS
295 QDPIO::cout << "y += x*a" << endl;
296#endif
297
298 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec > &>(rhs.expression().left());
299 const OScalar< CScal >& a = static_cast<const OScalar< CScal > &> (rhs.expression().right());
300
301 REAL* ar = (REAL *)&(a.elem().elem().elem().real());
302
303 if( s.hasOrderedRep()) {
304 REAL* xptr = (REAL *)&(x.elem(s.start()).elem(0).elem(0).real());
305 REAL* yptr = &(d.elem(s.start()).elem(0).elem(0).real());
306
307 int total_n_3vec = (s.end()-s.start()+1);
308
309 ordered_vcaxpy3_user_arg a = {yptr, ar, xptr, yptr};
310
312
314 // Original code
316 //int n_3vec = (s.end()-s.start()+1)*Ns;
317 //vcaxpy3(yptr, ar, xptr, yptr, n_3vec);
318 }
319 else {
320 const int* tab = s.siteTable().slice();
321
322 int totalSize = s.numSiteTable();
323
331
332 /*for(int j=0; j < s.numSiteTable(); j++) {
333 int i = tab[j];
335 REAL* xptr = (REAL *)&(x.elem(i).elem(0).elem(0).real());
336 REAL* yptr = &(d.elem(i).elem(0).elem(0).real());
337
338 vcaxpy3(yptr, ar, xptr, yptr, 4);
339
340 }*/
341 }
342}
343
344// y -= a*x
345template<>
346inline
348 const OpSubtractAssign& op,
350 Reference< QDPType< CScal, OScalar < CScal > > >,
353 const Subset& s)
354{
355
356#ifdef DEBUG_CBLAS
357 QDPIO::cout << "y -= a*x" << endl;
358#endif
359
360 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec > &>(rhs.expression().right());
361 const OScalar< CScal >& a = static_cast<const OScalar< CScal > &> (rhs.expression().left());
363 // Get minus a
366 REAL* ar = (REAL *)&(m_a.elem().elem().elem().real());
367 if( s.hasOrderedRep() ) {
368 REAL* xptr = (REAL *)&(x.elem(s.start()).elem(0).elem(0).real());
369 REAL* yptr = &(d.elem(s.start()).elem(0).elem(0).real());
370 // cout << "Specialised axpy a ="<< ar << endl;
371
372 int total_n_3vec = (s.end()-s.start()+1);
373
374 ordered_vcaxpy3_user_arg a = {yptr, ar, xptr, yptr};
375
377
379 // Original code
381 //int n_3vec = (s.end()-s.start()+1)*Ns;
382 //vcaxpy3(yptr, ar, xptr, yptr, n_3vec);
383 }
384 else {
385 const int* tab = s.siteTable().slice();
386
387 int totalSize = s.numSiteTable();
388
389
390 unordered_vcaxpy3_y_user_arg arg(x, d, ar, tab);
391
393
395 // Original code
397 /*
398 for(int j=0; j < s.numSiteTable(); j++) {
399 int i = tab[j];
400
401 REAL* xptr = (REAL *)&(x.elem(i).elem(0).elem(0).real());
402 REAL* yptr = &(d.elem(i).elem(0).elem(0).real());
403
404 vcaxpy3(yptr, ar, xptr, yptr, 4);
405
406 }*/
407 }
408}
409
410// y -= x*a
411template<>
412inline
414 const OpSubtractAssign& op,
417 Reference< QDPType< CScal, OScalar < CScal > > > >,
418 OLattice< CTVec > > &rhs,
419 const Subset& s)
420{
421#ifdef DEBUG_CBLAS
422 QDPIO::cout << "y -= x*a" << endl;
423#endif
424
425 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec > &>(rhs.expression().left());
426 const OScalar< CScal >& a = static_cast<const OScalar< CScal > &> (rhs.expression().right());
427
428 // Get minus a
429 OScalar<CScal> m_a = -a;
430
431 REAL* ar = (REAL *)&(m_a.elem().elem().elem().real());
432
433 if( s.hasOrderedRep() ) {
434 REAL* xptr = (REAL *)&(x.elem(s.start()).elem(0).elem(0).real());
435 REAL* yptr = &(d.elem(s.start()).elem(0).elem(0).real());
436 // cout << "Specialised axpy a ="<< ar << endl;
437
438 int total_n_3vec = (s.end()-s.start()+1);
439
440 ordered_vcaxpy3_user_arg a = {yptr, ar, xptr, yptr};
441
443
445 // Original code
447 //int n_3vec = (s.end()-s.start()+1)*Ns;
448 //vcaxpy3(yptr, ar, xptr, yptr, n_3vec);
449 }
450 else {
451 const int* tab = s.siteTable().slice();
452
453 int totalSize = s.numSiteTable();
454
455 unordered_vcaxpy3_y_user_arg arg(x, d, ar, tab);
456
458
460 // Original code
462 /*for(int j=0; j < s.numSiteTable(); j++) {
463 int i = tab[j];
464
465 REAL* xptr = (REAL *)&(x.elem(i).elem(0).elem(0).real());
466 REAL* yptr = &(d.elem(i).elem(0).elem(0).real());
467
468 vcaxpy3(yptr, ar, xptr, yptr, 4);
469
470 }*/
471 }
472}
473
474// z = a*x + y
475template<>
476inline
478 const OpAssign &op,
479 const QDPExpr<
485 OLattice< CTVec > > &rhs,
486 const Subset& s)
487{
488
489#ifdef DEBUG_CBLAS
490 QDPIO::cout << "z = a*x + y" << endl;
491#endif
492
493 // Peel the stuff out of the expression
494 // y is the right side of rhs
495 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&> (rhs.expression().right());
496
497 // ax is the left side of rhs and is in a binary node
498 typedef BinaryNode<OpMultiply,
501
502 // get the binary node
503 const BN &mulNode = static_cast<const BN&> (rhs.expression().left());
504
505 // get a and x out of the bynary node
506 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode.left());
507 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode.right());
508 // Set pointers
509 REAL *ar = (REAL *) &(a.elem().elem().elem().real());
510
511 if( s.hasOrderedRep() ) {
512
513 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
514 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
515 REAL *zptr = &(d.elem(s.start()).elem(0).elem(0).real());
516
517 int total_n_3vec = (s.end()-s.start()+1);
518
519 ordered_vcaxpy3_user_arg a = {zptr, ar, xptr, yptr};
520
522
524 // Original code
526 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
527 //int n_3vec = (s.end()-s.start()+1)*Ns;
528 //vcaxpy3(zptr, ar, xptr, yptr, n_3vec);
529 }
530 else {
531 const int* tab = s.siteTable().slice();
532
533 int totalSize = s.numSiteTable();
534
535 unordered_vcaxpy3_z_user_arg arg(x, y, d, ar, tab);
536
538
540 // Original code
542 /*for(int j=0; j < s.numSiteTable(); j++) {
543 int i = tab[j];
544
545 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
546 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
547 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
548
549
550 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
551 vcaxpy3(zptr, ar, xptr, yptr, 4);
552
553 }*/
554 }
555}
556
557// z = x*a + y
558template<>
559inline
561 const OpAssign &op,
562 const QDPExpr<
568 OLattice< CTVec > > &rhs,
569 const Subset& s)
570{
571
572#ifdef DEBUG_CBLAS
573 QDPIO::cout << "z = x*a + y" << endl;
574#endif
575
576 // Peel the stuff out of the expression
577 // y is the right side of rhs
578 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&> (rhs.expression().right());
579
580 // ax is the left side of rhs and is in a binary node
581 typedef BinaryNode<OpMultiply,
584
585
586 // get the binary node
587 const BN &mulNode = static_cast<const BN&> (rhs.expression().left());
588
589 // get a and x out of the bynary node
590 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode.right());
591 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode.left());
592 // Set pointers
593 REAL *ar = (REAL *) &(a.elem().elem().elem().real());
594
595 if( s.hasOrderedRep() ) {
596 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
597 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
598 REAL *zptr = &(d.elem(s.start()).elem(0).elem(0).real());
599
600 int total_n_3vec = (s.end()-s.start()+1);
601
602 ordered_vcaxpy3_user_arg a = {zptr, ar, xptr, yptr};
603
605
607 // Original code
609 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
610 //int n_3vec = (s.end()-s.start()+1)*Ns;
611 //vcaxpy3(zptr, ar, xptr, yptr, n_3vec);
612 }
613 else {
614 const int* tab = s.siteTable().slice();
615
616 int totalSize = s.numSiteTable();
617
618 unordered_vcaxpy3_z_user_arg arg(x, y, d, ar, tab);
619
621
623 // Original code
625 /*for(int j=0; j < s.numSiteTable(); j++) {
626 int i = tab[j];
627
628 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
629 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
630 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
631
632
633 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
634 vcaxpy3(zptr, ar, xptr, yptr, 4);
635
636 }*/
637 }
638}
639
640// z = a*x - y
641template<>
642inline
644 const OpAssign &op,
645 const QDPExpr<
651 OLattice< CTVec > > &rhs,
652 const Subset& s)
653{
654
655#ifdef DEBUG_CBLAS
656 QDPIO::cout << "z = a*x - y" << endl;
657#endif
658
659 // Peel the stuff out of the expression
660 // y is the right side of rhs
661 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&> (rhs.expression().right());
662
663 // ax is the left side of rhs and is in a binary node
664 typedef BinaryNode<OpMultiply,
667
668 // get the binary node
669 const BN &mulNode = static_cast<const BN&> (rhs.expression().left());
670
671 // get a and x out of the bynary node
672 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode.left());
673 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode.right());
674 // Set pointers
675 REAL *ar = (REAL *) &(a.elem().elem().elem().real());
676
677 if( s.hasOrderedRep() ) {
678 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
679 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
680 REAL *zptr = &(d.elem(s.start()).elem(0).elem(0).real());
681
682 int total_n_3vec = (s.end()-s.start()+1);
683
684 ordered_vcaxmy3_user_arg a = {zptr, ar, xptr, yptr};
685
687
689 // Original code
691 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
692 //int n_3vec = (s.end()-s.start()+1)*Ns;
693 //vcaxmy3(zptr, ar, xptr, yptr, n_3vec);
694 }
695 else {
696 const int* tab = s.siteTable().slice();
697
698 int totalSize = s.numSiteTable();
699
700 unordered_vcaxmy3_user_arg arg(x, y, d, ar, tab);
701
703
705 // Original code
707 /*for(int j=0; j < s.numSiteTable(); j++) {
708 int i = tab[j];
709
710 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
711 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
712 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
713
714
715 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
716 vcaxmy3(zptr, ar, xptr, yptr, 4);
717
718 }*/
719 }
720}
721
722// z = x*a - y
723template<>
724inline
726 const OpAssign &op,
727 const QDPExpr<
733 OLattice< CTVec > > &rhs,
734 const Subset& s)
735{
736
737#ifdef DEBUG_CBLAS
738 QDPIO::cout << "z = x*a - y" << endl;
739#endif
740
741 // Peel the stuff out of the expression
742 // y is the right side of rhs
743 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&> (rhs.expression().right());
744
745 // ax is the left side of rhs and is in a binary node
746 typedef BinaryNode<OpMultiply,
749
750
751 // get the binary node
752 const BN &mulNode = static_cast<const BN&> (rhs.expression().left());
753
754 // get a and x out of the bynary node
755 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode.right());
756 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode.left());
757 // Set pointers
758 REAL *ar = (REAL *) &(a.elem().elem().elem().real());
759
760 if( s.hasOrderedRep() ) {
761 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
762 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
763 REAL *zptr = &(d.elem(s.start()).elem(0).elem(0).real());
764
765 int total_n_3vec = (s.end()-s.start()+1);
766
767 ordered_vcaxmy3_user_arg a = {zptr, ar, xptr, yptr};
768
770
772 // Original code
774 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
775 //int n_3vec = (s.end()-s.start()+1)*Ns;
776 //vcaxmy3(zptr, ar, xptr, yptr, n_3vec);
777 }
778 else {
779 const int* tab = s.siteTable().slice();
780
781 int totalSize = s.numSiteTable();
782
783 unordered_vcaxmy3_user_arg arg(x, y, d, ar, tab);
784
786
788 // Original code
790 /*
791 for(int j=0; j < s.numSiteTable(); j++) {
792 int i = tab[j];
793
794 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
795 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
796 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
797
798
799 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
800 vcaxmy3(zptr, ar, xptr, yptr, 4);
801
802 }*/
803 }
804}
805
806
807// z = y + a*x
808template<>
809inline
811 const OpAssign &op,
812 const QDPExpr<
818 OLattice< CTVec > > &rhs,
819 const Subset& s)
820{
821
822#ifdef DEBUG_CBLAS
823 QDPIO::cout << "z = y + a*x" << endl;
824#endif
825
826 // Peel the stuff out of the expression
827
828 // y is the left side of rhs
829 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&> (rhs.expression().left());
830
831 // ax is the right side of rhs and is in a binary node
832 typedef BinaryNode<OpMultiply,
835
836 // get the binary node
837 const BN &mulNode = static_cast<const BN&> (rhs.expression().right());
838
839 // get a and x out of the bynary node
840 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode.left());
841 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode.right());
842 // Set pointers
843 REAL *ar = (REAL *) &(a.elem().elem().elem().real());
844 if( s.hasOrderedRep()) {
845 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
846 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
847 REAL *zptr = &(d.elem(s.start()).elem(0).elem(0).real());
848
849 int total_n_3vec = (s.end()-s.start()+1);
850
851 ordered_vcaxpy3_user_arg a = {zptr, ar, xptr, yptr};
852
854
856 // Original code
858 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
859 //int n_3vec = (s.end()-s.start()+1)*Ns;
860 //vcaxpy3(zptr, ar, xptr, yptr, n_3vec);
861 }
862 else {
863 const int* tab = s.siteTable().slice();
864
865 int totalSize = s.numSiteTable();
866
867 unordered_vcaxpy3_z_user_arg arg(x, y, d, ar, tab);
868
870
872 // Original code
874 /*
875 for(int j=0; j < s.numSiteTable(); j++) {
876 int i = tab[j];
877
878 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
879 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
880 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
881
882
883 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
884 vcaxpy3(zptr, ar, xptr, yptr, 4);
885
886 }*/
887 }
888}
889
890
891// z = y + x*a
892template<>
893inline
895 const OpAssign &op,
896 const QDPExpr<
902 OLattice< CTVec > > &rhs,
903 const Subset& s)
904{
905
906#ifdef DEBUG_CBLAS
907 QDPIO::cout << "z = y + x*a" << endl;
908#endif
909
910 // Peel the stuff out of the expression
911
912 // y is the left side of rhs
913 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&> (rhs.expression().left());
914
915 // ax is the right side of rhs and is in a binary node
916 typedef BinaryNode<OpMultiply,
919
920
921 // get the binary node
922 const BN &mulNode = static_cast<const BN&> (rhs.expression().right());
923
924 // get a and x out of the bynary node
925 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode.right());
926 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode.left());
927 // Set pointers
928 REAL *ar = (REAL *) &(a.elem().elem().elem().real());
929
930 if( s.hasOrderedRep() ) {
931 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
932 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
933 REAL *zptr = &(d.elem(s.start()).elem(0).elem(0).real());
934
935 int total_n_3vec = (s.end()-s.start()+1);
936
937 ordered_vcaxpy3_user_arg a = {zptr, ar, xptr, yptr};
938
940
942 // Original code
944 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
945 //int n_3vec = (s.end()-s.start()+1)*Ns;
946 //vcaxpy3(zptr, ar, xptr, yptr, n_3vec);
947 }
948 else {
949 const int* tab = s.siteTable().slice();
950
951 int totalSize = s.numSiteTable();
952
953 unordered_vcaxpy3_z_user_arg arg(x, y, d, ar, tab);
954
956
958 // Original code
960 /*
961 for(int j=0; j < s.numSiteTable(); j++) {
962 int i = tab[j];
963
964 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
965 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
966 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
967
968
969 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
970 vcaxpy3(zptr, ar, xptr, yptr, 4);
971
972 }
973 */
974 }
975}
976
977// z = y - a*x
978template<>
979inline
981 const OpAssign &op,
982 const QDPExpr<
988 OLattice< CTVec > > &rhs,
989 const Subset& s)
990{
991
992#ifdef DEBUG_CBLAS
993 QDPIO::cout << "z = y - a*x" << endl;
994#endif
995
996 // Peel the stuff out of the expression
997
998 // y is the left side of rhs
999 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&> (rhs.expression().left());
1000
1001 // ax is the right side of rhs and is in a binary node
1002 typedef BinaryNode<OpMultiply,
1005
1006 // get the binary node
1007 const BN &mulNode = static_cast<const BN&> (rhs.expression().right());
1008
1009 // get a and x out of the bynary node
1010 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode.left());
1011 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode.right());
1012
1013 OScalar<CScal> m_a = -a;
1014
1015 // Set pointers
1016 REAL *ar = (REAL *) &(m_a.elem().elem().elem().real());
1017
1018 if( s.hasOrderedRep() ) {
1019 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1020 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1021 REAL *zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1022
1023 int total_n_3vec = (s.end()-s.start()+1);
1024
1025 ordered_vcaxpy3_user_arg a = {zptr, ar, xptr, yptr};
1026
1028
1030 // Original code
1032 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1033 //int n_3vec = (s.end()-s.start()+1)*Ns;
1034 //vcaxpy3(zptr, ar, xptr, yptr, n_3vec);
1035 }
1036 else {
1037 const int* tab = s.siteTable().slice();
1038
1039 int totalSize = s.numSiteTable();
1040
1041 unordered_vcaxpy3_z_user_arg arg(x, y, d, ar, tab);
1042
1044
1046 // Original code
1048 /*for(int j=0; j < s.numSiteTable(); j++) {
1049 int i = tab[j];
1050
1051 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1052 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1053 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1054
1055
1056 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1057 vcaxpy3(zptr, ar, xptr, yptr, 4);
1058
1059 }*/
1060 }
1061}
1062
1063
1064// z = y - x*a
1065template<>
1066inline
1068 const OpAssign &op,
1069 const QDPExpr<
1075 OLattice< CTVec > > &rhs,
1076 const Subset& s)
1077{
1078
1079#ifdef DEBUG_CBLAS
1080 QDPIO::cout << "z = y - x*a" << endl;
1081#endif
1082
1083 // Peel the stuff out of the expression
1084
1085 // y is the left side of rhs
1086 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&> (rhs.expression().left());
1087
1088 // ax is the right side of rhs and is in a binary node
1089 typedef BinaryNode<OpMultiply,
1092
1093
1094 // get the binary node
1095 const BN &mulNode = static_cast<const BN&> (rhs.expression().right());
1096
1097 // get a and x out of the bynary node
1098 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode.right());
1099 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode.left());
1100
1101 OScalar<CScal> m_a = -a;
1102
1103 // Set pointers
1104 REAL *ar = (REAL *) &(m_a.elem().elem().elem().real());
1105
1106 if( s.hasOrderedRep() ) {
1107 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1108 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1109 REAL *zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1110
1111 int total_n_3vec = (s.end()-s.start()+1);
1112
1113 ordered_vcaxpy3_user_arg a = {zptr, ar, xptr, yptr};
1114
1116
1118 // Original code
1120 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1121 //int n_3vec = (s.end()-s.start()+1)*Ns;
1122 //vcaxpy3(zptr, ar, xptr, yptr, n_3vec);
1123 }
1124 else {
1125 const int* tab = s.siteTable().slice();
1126
1127 int totalSize = s.numSiteTable();
1128
1129 unordered_vcaxpy3_z_user_arg arg(x, y, d, ar, tab);
1130
1132
1134 // Original code
1136 /*for(int j=0; j < s.numSiteTable(); j++) {
1137 int i = tab[j];
1138
1139 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1140 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1141 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1142
1143
1144 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1145 vcaxpy3(zptr, ar, xptr, yptr, 4);
1146
1147 }*/
1148 }
1149}
1150
1151
1152// z = ax + by
1153template<>
1154inline
1156 const OpAssign &op,
1157 const QDPExpr<
1165 OLattice< CTVec > > &rhs,
1166 const Subset& s)
1167{
1168
1169#ifdef DEBUG_CBLAS
1170 QDPIO::cout << "z = a*x + b*y" << endl;
1171#endif
1172
1173 // Peel the stuff out of the expression
1174 // y is the right side of rhs
1175
1176 // ax is the left side of rhs and is in a binary node
1177 typedef BinaryNode<OpMultiply,
1180
1181 // get the binary node
1182 const BN &mulNode1 = static_cast<const BN&> (rhs.expression().left());
1183 const BN &mulNode2 = static_cast<const BN&> (rhs.expression().right());
1184
1185 // get a and x out of the binary node
1186 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode1.left());
1187 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode1.right());
1188
1189 // get b and y out of the binary node
1190 const OScalar< CScal >& b = static_cast<const OScalar< CScal >&>(mulNode2.left());
1191 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&>(mulNode2.right());
1192
1193
1194 // Set pointers
1195 REAL *aptr = (REAL *)&(a.elem().elem().elem().real());
1196 REAL *bptr = (REAL *)&(b.elem().elem().elem().real());
1197
1198 if( s.hasOrderedRep() ) {
1199
1200 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1201 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1202 REAL* zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1203
1204 int total_n_3vec = (s.end()-s.start()+1);
1205
1206 ordered_vcaxpby3_user_arg a = {zptr, aptr, xptr, bptr, yptr};
1207
1209
1211 // Original code
1213 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1214 //int n_3vec = (s.end()-s.start() + 1)*Ns;
1215 //vcaxpby3(zptr, aptr, xptr, bptr, yptr, n_3vec);
1216 }
1217 else {
1218 const int* tab = s.siteTable().slice();
1219
1220 int totalSize = s.numSiteTable();
1221
1222 unordered_vcaxpby3_user_arg arg(x, y, d, aptr, bptr, tab);
1223
1225
1227 // Original code
1229 /*for(int j=0; j < s.numSiteTable(); j++) {
1230 int i = tab[j];
1231
1232 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1233 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1234 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1235
1236
1237 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1238 vcaxpby3(zptr, aptr, xptr, bptr, yptr, 4);
1239
1240 }*/
1241 }
1242}
1243
1244
1245// z = xa + by
1246template<>
1247inline
1249 const OpAssign &op,
1250 const QDPExpr<
1258 OLattice< CTVec > > &rhs,
1259 const Subset& s)
1260{
1261
1262#ifdef DEBUG_CBLAS
1263 QDPIO::cout << "z = x*a + b*y" << endl;
1264#endif
1265
1266 // Peel the stuff out of the expression
1267 // y is the right side of rhs
1268
1269 // ax is the left side of rhs and is in a binary node
1270 typedef BinaryNode<OpMultiply,
1273
1274 typedef BinaryNode<OpMultiply,
1277
1278
1279
1280 // get the binary node
1281 const BN1 &mulNode1 = static_cast<const BN1&> (rhs.expression().left());
1282 const BN2 &mulNode2 = static_cast<const BN2&> (rhs.expression().right());
1283
1284 // get a and x out of the binary node
1285 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode1.left());
1286
1287 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode1.right());
1288
1289 // get b and y out of the binary node
1290 const OScalar< CScal >& b = static_cast<const OScalar< CScal >&>(mulNode2.left());
1291 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&>(mulNode2.right());
1292
1293
1294 // Set pointers
1295 REAL *aptr = (REAL *)&(a.elem().elem().elem().real());
1296 REAL *bptr = (REAL *)&(b.elem().elem().elem().real());
1297 if( s.hasOrderedRep() ) {
1298
1299 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1300 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1301 REAL* zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1302
1303 int total_n_3vec = (s.end()-s.start()+1);
1304
1305 ordered_vcaxpby3_user_arg a = {zptr, aptr, xptr, bptr, yptr};
1306
1308
1310 // Original code
1312 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1313 //int n_3vec = (s.end()-s.start()+1)*Ns;
1314 //vcaxpby3(zptr, aptr, xptr, bptr, yptr, n_3vec);
1315 }
1316 else {
1317 const int* tab = s.siteTable().slice();
1318
1319 int totalSize = s.numSiteTable();
1320
1321 unordered_vcaxpby3_user_arg arg(x, y, d, aptr, bptr, tab);
1322
1324
1326 // Original code
1328 /*for(int j=0; j < s.numSiteTable(); j++) {
1329 int i = tab[j];
1330
1331 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1332 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1333 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1334
1335
1336 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1337 vcaxpby3(zptr, aptr, xptr, bptr, yptr, 4);
1338
1339 }*/
1340 }
1341}
1342
1343// z = ax + yb
1344template<>
1345inline
1347 const OpAssign &op,
1348 const QDPExpr<
1356 OLattice< CTVec > > &rhs,
1357 const Subset& s)
1358{
1359
1360#ifdef DEBUG_CBLAS
1361 QDPIO::cout << "z = a*x + y*b" << endl;
1362#endif
1363
1364 // Peel the stuff out of the expression
1365 // y is the right side of rhs
1366
1367 // type of a*x
1368 typedef BinaryNode<OpMultiply,
1371
1372 // type of y*b
1373 typedef BinaryNode<OpMultiply,
1376
1377
1378
1379 // get the binary nodes
1380 // a*x node
1381 const BN1 &mulNode1 = static_cast<const BN1&> (rhs.expression().left());
1382
1383 // y*b node
1384 const BN2 &mulNode2 = static_cast<const BN2&> (rhs.expression().right());
1385
1386 // get a and x out of the binary node
1387 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode1.left());
1388
1389 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode1.right());
1390
1391
1392 // get b and y out of the binary node
1393 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&>(mulNode2.left());
1394
1395 const OScalar< CScal >& b = static_cast<const OScalar< CScal >&>(mulNode2.right());
1396
1397
1398 // Set pointers
1399 REAL *aptr = (REAL *)&(a.elem().elem().elem().real());
1400 REAL *bptr = (REAL *)&(b.elem().elem().elem().real());
1401
1402 if( s.hasOrderedRep() ) {
1403 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1404 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1405 REAL* zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1406
1407 int total_n_3vec = (s.end()-s.start()+1);
1408
1409 ordered_vcaxpby3_user_arg a = {zptr, aptr, xptr, bptr, yptr};
1410
1412
1414 // Original code
1416 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1417 //int n_3vec = (s.end()-s.start()+1)*Ns;
1418 //vcaxpby3(zptr, aptr, xptr, bptr, yptr, n_3vec);
1419 }
1420 else {
1421 const int* tab = s.siteTable().slice();
1422
1423 int totalSize = s.numSiteTable();
1424
1425 unordered_vcaxpby3_user_arg arg(x, y, d, aptr, bptr, tab);
1426
1428
1430 // Original code
1432 /*for(int j=0; j < s.numSiteTable(); j++) {
1433 int i = tab[j];
1434
1435 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1436 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1437 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1438
1439
1440 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1441 vcaxpby3(zptr, aptr, xptr, bptr, yptr, 4);
1442
1443 }*/
1444 }
1445}
1446
1447// z = xa + yb
1448template<>
1449inline
1451 const OpAssign &op,
1452 const QDPExpr<
1460 OLattice< CTVec > > &rhs,
1461 const Subset& s)
1462{
1463
1464#ifdef DEBUG_CBLAS
1465 QDPIO::cout << "z = x*a + y*b" << endl;
1466#endif
1467
1468 // Peel the stuff out of the expression
1469 // y is the right side of rhs
1470
1471 // ax is the left side of rhs and is in a binary node
1472 typedef BinaryNode<OpMultiply,
1475
1476 // get the binary node
1477 const BN &mulNode1 = static_cast<const BN&> (rhs.expression().left());
1478 const BN &mulNode2 = static_cast<const BN&> (rhs.expression().right());
1479
1480 // get a and x out of the binary node
1481 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode1.left());
1482 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode1.right());
1483
1484 // get b and y out of the binary node
1485 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&>(mulNode2.left());
1486
1487 const OScalar< CScal >& b = static_cast<const OScalar< CScal >&>(mulNode2.right());
1488
1489 // Set pointers
1490 REAL *aptr = (REAL *)&(a.elem().elem().elem().real());
1491 REAL *bptr = (REAL *)&(b.elem().elem().elem().real());
1492
1493 if( s.hasOrderedRep() ) {
1494 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1495 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1496 REAL* zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1497
1498 int total_n_3vec = (s.end()-s.start()+1);
1499
1500 ordered_vcaxpby3_user_arg a = {zptr, aptr, xptr, bptr, yptr};
1501
1503
1505 // Original code
1507 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1508 //int n_3vec = (s.end()-s.start()+1)*Ns;
1509 //vcaxpby3(zptr, aptr, xptr, bptr, yptr, n_3vec);
1510 }
1511 else {
1512 const int* tab = s.siteTable().slice();
1513
1514 int totalSize = s.numSiteTable();
1515
1516 unordered_vcaxpby3_user_arg arg(x, y, d, aptr, bptr, tab);
1517
1519
1521 // Original code
1523 /*for(int j=0; j < s.numSiteTable(); j++) {
1524 int i = tab[j];
1525
1526 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1527 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1528 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1529
1530
1531 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1532 vcaxpby3(zptr, aptr, xptr, bptr, yptr, 4);
1533
1534 }*/
1535 }
1536}
1537
1538// z = ax - by
1539template<>
1540inline
1542 const OpAssign &op,
1543 const QDPExpr<
1551 OLattice< CTVec > > &rhs,
1552 const Subset& s)
1553{
1554
1555#ifdef DEBUG_CBLAS
1556 QDPIO::cout << "z = a*x - b*y" << endl;
1557#endif
1558
1559 // Peel the stuff out of the expression
1560 // y is the right side of rhs
1561
1562 // ax is the left side of rhs and is in a binary node
1563 typedef BinaryNode<OpMultiply,
1566
1567 // get the binary node
1568 const BN &mulNode1 = static_cast<const BN&> (rhs.expression().left());
1569 const BN &mulNode2 = static_cast<const BN&> (rhs.expression().right());
1570
1571 // get a and x out of the binary node
1572 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode1.left());
1573 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode1.right());
1574
1575 // get b and y out of the binary node
1576 const OScalar< CScal >& b = static_cast<const OScalar< CScal >&>(mulNode2.left());
1577 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&>(mulNode2.right());
1578
1579
1580 // Set pointers
1581 REAL *aptr = (REAL *)&(a.elem().elem().elem().real());
1582 REAL *bptr = (REAL *)&(b.elem().elem().elem().real());
1583
1584 if( s.hasOrderedRep() ) {
1585 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1586 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1587 REAL* zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1588
1589 int total_n_3vec = (s.end()-s.start()+1);
1590
1591 ordered_vcaxmby3_user_arg a = {zptr, aptr, xptr, bptr, yptr};
1592
1594
1596 // Original code
1598 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1599 //int n_3vec = (s.end()-s.start()+1)*Ns;
1600 //vcaxmby3(zptr, aptr, xptr, bptr, yptr, n_3vec);
1601 }
1602 else {
1603 const int* tab = s.siteTable().slice();
1604
1605 int totalSize = s.numSiteTable();
1606
1607 unordered_vcaxmby3_user_arg arg(x, y, d, aptr, bptr, tab);
1608
1610
1612 // Original code
1614 /*
1615 for(int j=0; j < s.numSiteTable(); j++) {
1616 int i = tab[j];
1617
1618 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1619 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1620 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1621
1622
1623 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1624 vcaxmby3(zptr, aptr, xptr, bptr, yptr, 4);
1625
1626 }*/
1627 }
1628}
1629
1630
1631// z = xa - by
1632template<>
1633inline
1635 const OpAssign &op,
1636 const QDPExpr<
1644 OLattice< CTVec > > &rhs,
1645 const Subset& s)
1646{
1647
1648#ifdef DEBUG_CBLAS
1649 QDPIO::cout << "z = x*a - b*y" << endl;
1650#endif
1651
1652 // Peel the stuff out of the expression
1653 // y is the right side of rhs
1654
1655 // ax is the left side of rhs and is in a binary node
1656 typedef BinaryNode<OpMultiply,
1659
1660 typedef BinaryNode<OpMultiply,
1663
1664
1665
1666 // get the binary node
1667 const BN1 &mulNode1 = static_cast<const BN1&> (rhs.expression().left());
1668 const BN2 &mulNode2 = static_cast<const BN2&> (rhs.expression().right());
1669
1670 // get a and x out of the binary node
1671 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode1.left());
1672
1673 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode1.right());
1674
1675 // get b and y out of the binary node
1676 const OScalar< CScal >& b = static_cast<const OScalar< CScal >&>(mulNode2.left());
1677 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&>(mulNode2.right());
1678
1679
1680 // Set pointers
1681 REAL *aptr = (REAL *)&(a.elem().elem().elem().real());
1682 REAL *bptr = (REAL *)&(b.elem().elem().elem().real());
1683
1684 if( s.hasOrderedRep() ) {
1685 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1686 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1687 REAL* zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1688
1689 int total_n_3vec = (s.end()-s.start()+1);
1690
1691 ordered_vcaxmby3_user_arg a = {zptr, aptr, xptr, bptr, yptr};
1692
1694
1696 // Original code
1698 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1699 //int n_3vec = (s.end()-s.start()+1)*Ns;
1700 //vcaxmby3(zptr, aptr, xptr, bptr, yptr, n_3vec);
1701 }
1702 else {
1703 const int* tab = s.siteTable().slice();
1704
1705 int totalSize = s.numSiteTable();
1706
1707 unordered_vcaxmby3_user_arg arg(x, y, d, aptr, bptr, tab);
1708
1710
1712 // Original code
1714 /*for(int j=0; j < s.numSiteTable(); j++) {
1715 int i = tab[j];
1716
1717 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1718 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1719 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1720
1721
1722 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1723 vcaxmby3(zptr, aptr, xptr, bptr, yptr, 4);
1724
1725 }*/
1726 }
1727}
1728
1729// z = ax - yb
1730template<>
1731inline
1733 const OpAssign &op,
1734 const QDPExpr<
1742 OLattice< CTVec > > &rhs,
1743 const Subset& s)
1744{
1745
1746#ifdef DEBUG_CBLAS
1747 QDPIO::cout << "z = a*x - y*b" << endl;
1748#endif
1749
1750 // Peel the stuff out of the expression
1751 // y is the right side of rhs
1752
1753 // type of a*x
1754 typedef BinaryNode<OpMultiply,
1757
1758 // type of y*b
1759 typedef BinaryNode<OpMultiply,
1762
1763
1764
1765 // get the binary nodes
1766 // a*x node
1767 const BN1 &mulNode1 = static_cast<const BN1&> (rhs.expression().left());
1768
1769 // y*b node
1770 const BN2 &mulNode2 = static_cast<const BN2&> (rhs.expression().right());
1771
1772 // get a and x out of the binary node
1773 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode1.left());
1774
1775 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode1.right());
1776
1777
1778 // get b and y out of the binary node
1779 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&>(mulNode2.left());
1780
1781 const OScalar< CScal >& b = static_cast<const OScalar< CScal >&>(mulNode2.right());
1782
1783
1784 // Set pointers
1785 REAL *aptr = (REAL *)&(a.elem().elem().elem().real());
1786 REAL *bptr = (REAL *)&(b.elem().elem().elem().real());
1787
1788 if( s.hasOrderedRep() ) {
1789 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1790 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1791 REAL* zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1792
1793 int total_n_3vec = (s.end()-s.start()+1);
1794
1795 ordered_vcaxmby3_user_arg a = {zptr, aptr, xptr, bptr, yptr};
1796
1798
1800 // Original code
1802 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1803 //int n_3vec = (s.end()-s.start()+1)*Ns;
1804 //vcaxmby3(zptr, aptr, xptr, bptr, yptr, n_3vec);
1805 }
1806 else {
1807 const int* tab = s.siteTable().slice();
1808
1809 int totalSize = s.numSiteTable();
1810
1811 unordered_vcaxmby3_user_arg arg(x, y, d, aptr, bptr, tab);
1812
1814
1816 // Original code
1818 /*for(int j=0; j < s.numSiteTable(); j++) {
1819 int i = tab[j];
1820
1821 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1822 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1823 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1824
1825
1826 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1827 vcaxmby3(zptr, aptr, xptr, bptr, yptr, 4);
1828
1829 }*/
1830 }
1831}
1832
1833// z = xa - yb
1834template<>
1835inline
1837 const OpAssign &op,
1838 const QDPExpr<
1846 OLattice< CTVec > > &rhs,
1847 const Subset& s)
1848{
1849
1850#ifdef DEBUG_CBLAS
1851 QDPIO::cout << "z = x*a - y*b" << endl;
1852#endif
1853
1854 // Peel the stuff out of the expression
1855 // y is the right side of rhs
1856
1857 // ax is the left side of rhs and is in a binary node
1858 typedef BinaryNode<OpMultiply,
1861
1862 // get the binary node
1863 const BN &mulNode1 = static_cast<const BN&> (rhs.expression().left());
1864 const BN &mulNode2 = static_cast<const BN&> (rhs.expression().right());
1865
1866 // get a and x out of the binary node
1867 const OLattice< CTVec >& x = static_cast<const OLattice< CTVec >&>(mulNode1.left());
1868 const OScalar< CScal >& a = static_cast<const OScalar< CScal >&>(mulNode1.right());
1869
1870 // get b and y out of the binary node
1871 const OLattice< CTVec >& y = static_cast<const OLattice< CTVec >&>(mulNode2.left());
1872
1873 const OScalar< CScal >& b = static_cast<const OScalar< CScal >&>(mulNode2.right());
1874
1875 // Set pointers
1876 REAL *aptr = (REAL *)&(a.elem().elem().elem().real());
1877 REAL *bptr = (REAL *)&(b.elem().elem().elem().real());
1878
1879 if( s.hasOrderedRep() ) {
1880 REAL *xptr = (REAL *) &(x.elem(s.start()).elem(0).elem(0).real());
1881 REAL *yptr = (REAL *) &(y.elem(s.start()).elem(0).elem(0).real());
1882 REAL* zptr = &(d.elem(s.start()).elem(0).elem(0).real());
1883
1884 int total_n_3vec = (s.end()-s.start()+1);
1885
1886 ordered_vcaxmby3_user_arg a = {zptr, aptr, xptr, bptr, yptr};
1887
1889
1891 // Original code
1893 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1894 //int n_3vec = (s.end()-s.start()+1)*Ns;
1895 //vcaxmby3(zptr, aptr, xptr, bptr, yptr, n_3vec);
1896 }
1897 else {
1898 const int* tab = s.siteTable().slice();
1899
1900 int totalSize = s.numSiteTable();
1901
1902 unordered_vcaxmby3_user_arg arg(x, y, d, aptr, bptr, tab);
1903
1905
1907 // Original code
1909 /*for(int j=0; j < s.numSiteTable(); j++) {
1910 int i = tab[j];
1911
1912 REAL *xptr = (REAL *) &(x.elem(i).elem(0).elem(0).real());
1913 REAL *yptr = (REAL *) &(y.elem(i).elem(0).elem(0).real());
1914 REAL *zptr = &(d.elem(i).elem(0).elem(0).real());
1915
1916
1917 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
1918 vcaxmby3(zptr, aptr, xptr, bptr, yptr, 4);
1919
1920 }*/
1921 }
1922}
1923
1924
1925} // namespace QDP;
1926#endif
Outer grid Lattice type.
Definition qdp_outer.h:264
T & elem(int i)
Definition qdp_outer.h:400
Outer grid Scalar class *‍/.
Definition qdp_outer.h:37
Primitive Scalar.
Primitive spin 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
int end() const
Definition qdp_subset.h:81
const multi1d< int > & siteTable() const
Definition qdp_subset.h:83
int numSiteTable() const
Definition qdp_subset.h:84
bool hasOrderedRep() const
Definition qdp_subset.h:79
int start() const
Definition qdp_subset.h:80
const T * slice() const
Return ref to a column slice.
Definition qdp_multi.h:225
Generic Scalar VAXPY routine.
Generic Scalar VAXPY routine.
Generic Scalar VAXPY routine.
Generic Scalar VSCAL routine.
REAL32 REAL
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)
StandardOutputStream cout
Definition qdp_stdio.cc:21
Yet another random number generator.
void unordered_vcaxpby3_evaluate_function(int lo, int hi, int myId, unordered_vcaxpby3_user_arg *a)
PScalar< PScalar< RComplex< REAL > > > CScal
void dispatch_to_threads(int numSiteTable, Arg a, void(*func)(int, int, int, Arg *))
PSpinVector< PColorVector< RComplex< REAL >, 3 >, 4 > CTVec
void ordered_vcaxpy3_evaluate_function(int lo, int hi, int myId, ordered_vcaxpy3_user_arg *a)
void ordered_vcscal_evaluate_function(int lo, int hi, int myId, ordered_vcscal_user_arg *a)
void unordered_vcaxmy3_evaluate_function(int lo, int hi, int myId, unordered_vcaxmy3_user_arg *a)
void ordered_vcaxpby3_evaluate_function(int lo, int hi, int myId, ordered_vcaxpby3_user_arg *a)
void unordered_vcaxpy3_y_evaluate_function(int lo, int hi, int myId, unordered_vcaxpy3_y_user_arg *a)
void ordered_vcaxmy3_evaluate_function(int lo, int hi, int myId, ordered_vcaxmy3_user_arg *a)
void ordered_vcaxmby3_evaluate_function(int lo, int hi, int myId, ordered_vcaxmby3_user_arg *a)
void unordered_vcaxpy3_z_evaluate_function(int lo, int hi, int myId, unordered_vcaxpy3_z_user_arg *a)
void unordered_vcaxmby3_evaluate_function(int lo, int hi, int myId, unordered_vcaxmby3_user_arg *a)
void ordered_vcaxpy3_evaluate_function(int lo, int hi, int myId, ordered_vcaxpy3_user_arg *a)
void unordered_vcscal_evaluate_function(int lo, int hi, int myId, unordered_vcscal_user_arg *a)