QUDA  v1.1.0
A library for QCD on GPUs
instantiate_dslash.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <typeinfo>
4 
5 #include <color_spinor_field.h>
6 #include <gauge_field.h>
7 #include <instantiate.h>
8 
9 namespace quda
10 {
11 
19  template <template <typename, int, QudaReconstructType> class Apply, typename Recon, typename Float, int nColor,
20  typename... Args>
21  inline void instantiate(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, Args &&... args)
22  {
23  if (U.Reconstruct() == Recon::recon[0]) {
24 #if QUDA_RECONSTRUCT & 4
25  Apply<Float, nColor, Recon::recon[0]>(out, in, U, args...);
26 #else
27  errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-18", QUDA_RECONSTRUCT);
28 #endif
29  } else if (U.Reconstruct() == Recon::recon[1]) {
30 #if QUDA_RECONSTRUCT & 2
31  Apply<Float, nColor, Recon::recon[1]>(out, in, U, args...);
32 #else
33  errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-12/13", QUDA_RECONSTRUCT);
34 #endif
35  } else if (U.Reconstruct() == Recon::recon[2]) {
36 #if QUDA_RECONSTRUCT & 1
37  Apply<Float, nColor, Recon::recon[2]>(out, in, U, args...);
38 #else
39  errorQuda("QUDA_RECONSTRUCT=%d does not enable reconstruct-8/9", QUDA_RECONSTRUCT);
40 #endif
41  } else {
42  errorQuda("Unsupported reconstruct type %d\n", U.Reconstruct());
43  }
44  }
45 
53  template <template <typename, int, QudaReconstructType> class Apply, typename Recon, typename Float, typename... Args>
54  inline void instantiate(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, Args &&... args)
55  {
56  if (in.Ncolor() == 3) {
57  instantiate<Apply, Recon, Float, 3>(out, in, U, args...);
58  } else {
59  errorQuda("Unsupported number of colors %d\n", U.Ncolor());
60  }
61  }
62 
70  template <template <typename, int, QudaReconstructType> class Apply, typename Recon = WilsonReconstruct, typename... Args>
71  inline void instantiate(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, Args &&... args)
72  {
73  if (U.Precision() == QUDA_DOUBLE_PRECISION) {
74 #if QUDA_PRECISION & 8
75  instantiate<Apply, Recon, double>(out, in, U, args...);
76 #else
77  errorQuda("QUDA_PRECISION=%d does not enable double precision", QUDA_PRECISION);
78 #endif
79  } else if (U.Precision() == QUDA_SINGLE_PRECISION) {
80 #if QUDA_PRECISION & 4
81  instantiate<Apply, Recon, float>(out, in, U, args...);
82 #else
83  errorQuda("QUDA_PRECISION=%d does not enable single precision", QUDA_PRECISION);
84 #endif
85  } else if (U.Precision() == QUDA_HALF_PRECISION) {
86 #if QUDA_PRECISION & 2
87  instantiate<Apply, Recon, short>(out, in, U, args...);
88 #else
89  errorQuda("QUDA_PRECISION=%d does not enable half precision", QUDA_PRECISION);
90 #endif
91  } else if (U.Precision() == QUDA_QUARTER_PRECISION) {
92 #if QUDA_PRECISION & 1
93  instantiate<Apply, Recon, int8_t>(out, in, U, args...);
94 #else
95  errorQuda("QUDA_PRECISION=%d does not enable quarter precision", QUDA_PRECISION);
96 #endif
97  } else {
98  errorQuda("Unsupported precision %d\n", U.Precision());
99  }
100  }
101 
112  template <template <typename, int, QudaReconstructType> class Apply, typename Recon = WilsonReconstruct, typename... Args>
114  Args &&... args)
115  {
116  if (U.Precision() == QUDA_HALF_PRECISION) {
117 #if QUDA_PRECISION & 2
118  instantiate<Apply, Recon, short>(out, in, U, args...);
119 #else
120  errorQuda("QUDA_PRECISION=%d does not enable half precision", QUDA_PRECISION);
121 #endif
122  } else if (U.Precision() == QUDA_QUARTER_PRECISION) {
123 #if QUDA_PRECISION & 1
124  instantiate<Apply, Recon, int8_t>(out, in, U, args...);
125 #else
126  errorQuda("QUDA_PRECISION=%d does not enable quarter precision", QUDA_PRECISION);
127 #endif
128  } else {
129  errorQuda("Unsupported precision %d\n", U.Precision());
130  }
131  }
132 
133 } // namespace quda
int Ncolor() const
Definition: gauge_field.h:285
QudaReconstructType Reconstruct() const
Definition: gauge_field.h:286
QudaPrecision Precision() const
const int nColor
Definition: covdev_test.cpp:44
@ QUDA_DOUBLE_PRECISION
Definition: enum_quda.h:65
@ QUDA_SINGLE_PRECISION
Definition: enum_quda.h:64
@ QUDA_QUARTER_PRECISION
Definition: enum_quda.h:62
@ QUDA_HALF_PRECISION
Definition: enum_quda.h:63
constexpr void instantiate(G &U, Args &&... args)
This instantiate function is used to instantiate the colors.
Definition: instantiate.h:117
void instantiatePreconditioner(ColorSpinorField &out, const ColorSpinorField &in, const GaugeField &U, Args &&... args)
This instantiatePrecondtiioner function is used to instantiate the precisions for a preconditioner....
FloatingPoint< float > Float
#define errorQuda(...)
Definition: util_quda.h:120