4 template <
typename ReduceType,
typename Float,
int writeX,
int writeY,
int writeZ,
int writeW,
int writeV,
5 typename SpinorX,
typename SpinorY,
typename SpinorZ,
typename SpinorW,
typename SpinorV,
typename Reducer>
6 ReduceType
genericReduce(SpinorX &
X, SpinorY &Y, SpinorZ &
Z, SpinorW &W, SpinorV &
V, Reducer r)
13 for (
int x = 0; x < X.VolumeCB(); x++) {
15 for (
int s = 0;
s < X.Nspin();
s++) {
16 for (
int c = 0; c < X.Ncolor(); c++) {
17 complex<Float> X_ =
X(
parity, x,
s, c);
18 complex<Float> Y_ = Y(
parity, x,
s, c);
19 complex<Float> Z_ =
Z(
parity, x,
s, c);
20 complex<Float> W_ = W(
parity, x,
s, c);
21 complex<Float> V_ =
V(
parity, x,
s, c);
22 r(sum, X_, Y_, Z_, W_, V_);
24 if (writeY) Y(
parity, x,
s, c) = Y_;
26 if (writeW) W(
parity, x,
s, c) = W_;
37 template <
typename ReduceType,
typename Float,
typename zFloat,
int nSpin,
int nColor,
QudaFieldOrder order,
int writeX,
38 int writeY,
int writeZ,
int writeW,
int writeV,
typename R>
40 ColorSpinorField &x, ColorSpinorField &y, ColorSpinorField &z, ColorSpinorField &w, ColorSpinorField &v,
R r)
42 colorspinor::FieldOrderCB<Float, nSpin, nColor, 1, order>
X(x), Y(y), W(w),
V(v);
43 colorspinor::FieldOrderCB<zFloat, nSpin, nColor, 1, order>
Z(z);
44 return genericReduce<ReduceType, zFloat, writeX, writeY, writeZ, writeW, writeV>(
X, Y,
Z, W,
V, r);
47 template <
typename ReduceType,
typename Float,
typename zFloat,
int nSpin,
QudaFieldOrder order,
int writeX,
int writeY,
48 int writeZ,
int writeW,
int writeV,
typename R>
50 ColorSpinorField &x, ColorSpinorField &y, ColorSpinorField &z, ColorSpinorField &w, ColorSpinorField &v,
R r)
53 if (x.Ncolor() == 3) {
54 value = genericReduce<ReduceType, Float, zFloat, nSpin, 3, order, writeX, writeY, writeZ, writeW, writeV, R>(
56 }
else if (x.Ncolor() == 4) {
57 value = genericReduce<ReduceType, Float, zFloat, nSpin, 4, order, writeX, writeY, writeZ, writeW, writeV, R>(
59 }
else if (x.Ncolor() == 6) {
60 value = genericReduce<ReduceType, Float, zFloat, nSpin, 6, order, writeX, writeY, writeZ, writeW, writeV, R>(
62 }
else if (x.Ncolor() == 8) {
63 value = genericReduce<ReduceType, Float, zFloat, nSpin, 8, order, writeX, writeY, writeZ, writeW, writeV, R>(
65 }
else if (x.Ncolor() == 12) {
66 value = genericReduce<ReduceType, Float, zFloat, nSpin, 12, order, writeX, writeY, writeZ, writeW, writeV, R>(
68 }
else if (x.Ncolor() == 16) {
69 value = genericReduce<ReduceType, Float, zFloat, nSpin, 16, order, writeX, writeY, writeZ, writeW, writeV, R>(
71 }
else if (x.Ncolor() == 20) {
72 value = genericReduce<ReduceType, Float, zFloat, nSpin, 20, order, writeX, writeY, writeZ, writeW, writeV, R>(
74 }
else if (x.Ncolor() == 24) {
75 value = genericReduce<ReduceType, Float, zFloat, nSpin, 24, order, writeX, writeY, writeZ, writeW, writeV, R>(
77 }
else if (x.Ncolor() == 32) {
78 value = genericReduce<ReduceType, Float, zFloat, nSpin, 32, order, writeX, writeY, writeZ, writeW, writeV, R>(
80 }
else if (x.Ncolor() == 72) {
81 value = genericReduce<ReduceType, Float, zFloat, nSpin, 72, order, writeX, writeY, writeZ, writeW, writeV, R>(
83 }
else if (x.Ncolor() == 576) {
84 value = genericReduce<ReduceType, Float, zFloat, nSpin, 576, order, writeX, writeY, writeZ, writeW, writeV, R>(
88 errorQuda(
"nColor = %d not implemented", x.Ncolor());
93 template <
typename ReduceType,
typename Float,
typename zFloat,
QudaFieldOrder order,
int writeX,
int writeY,
94 int writeZ,
int writeW,
int writeV,
typename R>
96 ColorSpinorField &x, ColorSpinorField &y, ColorSpinorField &z, ColorSpinorField &w, ColorSpinorField &v,
R r)
100 if (x.Nspin() == 4) {
101 value = genericReduce<ReduceType, Float, zFloat, 4, order, writeX, writeY, writeZ, writeW, writeV, R>(
103 }
else if (x.Nspin() == 2) {
104 value = genericReduce<ReduceType, Float, zFloat, 2, order, writeX, writeY, writeZ, writeW, writeV, R>(
106 #ifdef GPU_STAGGERED_DIRAC 107 }
else if (x.Nspin() == 1) {
108 value = genericReduce<ReduceType, Float, zFloat, 1, order, writeX, writeY, writeZ, writeW, writeV, R>(
112 errorQuda(
"nSpin = %d not implemented", x.Nspin());
117 template <
typename doubleN,
typename ReduceType,
typename Float,
typename zFloat,
int writeX,
int writeY,
int writeZ,
118 int writeW,
int writeV,
typename R>
120 ColorSpinorField &x, ColorSpinorField &y, ColorSpinorField &z, ColorSpinorField &w, ColorSpinorField &v,
R r)
126 writeV,
R>(x, y, z, w, v, r);
128 warningQuda(
"CPU reductions not implemented for %d field order", x.FieldOrder());
static void sum(Float *dst, Float *a, Float *b, int cnt)
enum QudaFieldOrder_s QudaFieldOrder
void zero(ColorSpinorField &a)
ReduceType genericReduce(SpinorX &X, SpinorY &Y, SpinorZ &Z, SpinorW &W, SpinorV &V, Reducer r)