QUDA  v1.1.0
A library for QCD on GPUs
dslash_test_helpers.cpp
Go to the documentation of this file.
1 #include "dslash_test_helpers.h"
2 #include <quda.h>
3 #include <dirac_quda.h>
4 #include <dslash_quda.h>
5 #include <blas_quda.h>
6 #include <quda_internal.h>
7 
8 using namespace quda;
9 
10 // need a better solution here but as long as they gauge field live in interface probably ok
14 
16 {
18 
21  errorQuda("Gauge field not allocated");
22 
25 
26  ColorSpinorParam cpuParam(h_in, *inv_param, gauge.X(), true, inv_param->input_location);
28 
29  ColorSpinorParam cudaParam(cpuParam, *inv_param);
30  cudaColorSpinorField in(*in_h, cudaParam);
31 
33  double cpu = blas::norm2(*in_h);
34  double gpu = blas::norm2(in);
35  printfQuda("In CPU %e CUDA %e\n", cpu, gpu);
36  }
37 
38  cudaParam.create = QUDA_NULL_FIELD_CREATE;
39  cudaColorSpinorField out(in, cudaParam);
40 
42  if (parity == QUDA_EVEN_PARITY) {
44  } else {
46  }
47  blas::ax(gauge.Anisotropy(), in);
48  }
49  bool pc = true;
50 
51  DiracParam diracParam;
52  setDiracParam(diracParam, inv_param, pc);
53 
54  DiracDomainWall4DPC dirac(diracParam); // create the Dirac operator
55  printfQuda("kappa for QUDA input : %e\n", inv_param->kappa);
56  switch (test_type) {
57  case dslash_test_type::Dslash: dirac.Dslash4(out, in, parity); break;
58  case dslash_test_type::M5: dirac.Dslash5(out, in, parity); break;
59  case dslash_test_type::M5inv: dirac.Dslash5inv(out, in, parity, inv_param->kappa); break;
60  default: errorQuda("Unsupported dslash_test_type in dslashQuda_4dpc.");
61  }
62 
63  cpuParam.v = h_out;
65  ColorSpinorField *out_h = ColorSpinorField::Create(cpuParam);
66  *out_h = out;
67 
69  double cpu = blas::norm2(*out_h);
70  double gpu = blas::norm2(out);
71  printfQuda("Out CPU %e CUDA %e\n", cpu, gpu);
72  }
73 
74  delete out_h;
75  delete in_h;
76 
77  popVerbosity();
78 }
79 
81 {
83 
86  errorQuda("Gauge field not allocated");
87 
90 
91  ColorSpinorParam cpuParam(h_in, *inv_param, gauge.X(), true, inv_param->input_location);
93 
94  ColorSpinorParam cudaParam(cpuParam, *inv_param);
95  cudaColorSpinorField in(*in_h, cudaParam);
96 
98  double cpu = blas::norm2(*in_h);
99  double gpu = blas::norm2(in);
100  printfQuda("In CPU %e CUDA %e\n", cpu, gpu);
101  }
102 
103  cudaParam.create = QUDA_NULL_FIELD_CREATE;
104  cudaColorSpinorField out(in, cudaParam);
105 
107  if (parity == QUDA_EVEN_PARITY) {
109  } else {
111  }
112  blas::ax(gauge.Anisotropy(), in);
113  }
114  bool pc = true;
115 
116  DiracParam diracParam;
117  setDiracParam(diracParam, inv_param, pc);
118 
119  DiracMobiusPC dirac(diracParam); // create the Dirac operator
120  switch (test_type) {
121  case dslash_test_type::Dslash: dirac.Dslash4(out, in, parity); break;
122  case dslash_test_type::M5: dirac.Dslash5(out, in, parity); break;
123  case dslash_test_type::Dslash4pre: dirac.Dslash4pre(out, in, parity); break;
124  case dslash_test_type::M5inv: dirac.Dslash5inv(out, in, parity); break;
125  default: errorQuda("Unsupported dslash_test_type in dslashQuda_mdwf.");
126  }
127 
128  cpuParam.v = h_out;
129  cpuParam.location = inv_param->output_location;
130  ColorSpinorField *out_h = ColorSpinorField::Create(cpuParam);
131  *out_h = out;
132 
133  if (getVerbosity() >= QUDA_DEBUG_VERBOSE) {
134  double cpu = blas::norm2(*out_h);
135  double gpu = blas::norm2(out);
136  printfQuda("Out CPU %e CUDA %e\n", cpu, gpu);
137  }
138 
139  delete out_h;
140  delete in_h;
141 
142  popVerbosity();
143 }
144 
147 {
149  setKernelPackT(true);
150  } else {
151  errorQuda("This type of dslashQuda operator is defined for QUDA_MOBIUS_DWF_EOFA_DSLASH ONLY");
152  }
153 
154  if (gaugePrecise == nullptr) errorQuda("Gauge field not allocated");
155 
158 
159  bool precondition_output = test_type == dslash_test_type::Dslash ? false : true;
160 
161  ColorSpinorParam cpuParam(h_in, *inv_param, gaugePrecise->X(), precondition_output, inv_param->input_location);
162  ColorSpinorField *in_h = ColorSpinorField::Create(cpuParam);
163 
164  ColorSpinorParam cudaParam(cpuParam, *inv_param);
165  cudaColorSpinorField in(*in_h, cudaParam);
166 
167  if (getVerbosity() >= QUDA_DEBUG_VERBOSE) {
168  double cpu = blas::norm2(*in_h);
169  double gpu = blas::norm2(in);
170  printfQuda("In CPU: %16.12e CUDA: %16.12e\n", cpu, gpu);
171  }
172 
173  cudaParam.create = QUDA_NULL_FIELD_CREATE;
174  cudaColorSpinorField out(in, cudaParam);
175 
177  if (parity == QUDA_EVEN_PARITY) {
179  } else {
181  }
183  }
184  constexpr bool pc = true;
185 
186  DiracParam diracParam;
187  setDiracParam(diracParam, inv_param, pc);
188 
189  DiracMobiusEofaPC dirac(diracParam); // create the Dirac operator
190  switch (test_type) {
191  case dslash_test_type::MatPC: dirac.M(out, in); break;
192  case dslash_test_type::M5: dirac.m5_eofa(out, in); break;
193  case dslash_test_type::M5inv: dirac.m5inv_eofa(out, in); break;
194  default: errorQuda("test_type(=%d) NOT defined for M\"obius EOFA! :( \n", static_cast<int>(test_type));
195  }
196 }
static ColorSpinorField * Create(const ColorSpinorParam &param)
QudaFieldLocation location
virtual void Dslash4(ColorSpinorField &out, const ColorSpinorField &in, const QudaParity parity) const
Apply the local MdagM operator: equivalent to applying zero Dirichlet boundary condition to MdagM on ...
Definition: dirac_quda.h:243
virtual void M(ColorSpinorField &out, const ColorSpinorField &in) const
Apply M for the dirac op. E.g. the Schur Complement operator.
double Anisotropy() const
Definition: gauge_field.h:288
const int * X() const
int test_type
GaugeCovDev * dirac
Definition: covdev_test.cpp:42
QudaParity parity
Definition: covdev_test.cpp:40
QudaInvertParam inv_param
Definition: covdev_test.cpp:27
cudaGaugeField * gaugeFatPrecise
cudaGaugeField * gaugeLongPrecise
void dslashQuda_mdwf(void *h_out, void *h_in, QudaInvertParam *inv_param, QudaParity parity, dslash_test_type test_type)
void dslashQuda_mobius_eofa(void *h_out, void *h_in, QudaInvertParam *inv_param, QudaParity parity, dslash_test_type test_type)
void dslashQuda_4dpc(void *h_out, void *h_in, QudaInvertParam *inv_param, QudaParity parity, dslash_test_type test_type)
cudaGaugeField * gaugePrecise
dslash_test_type
@ QUDA_ASQTAD_DSLASH
Definition: enum_quda.h:98
@ QUDA_MOBIUS_DWF_EOFA_DSLASH
Definition: enum_quda.h:96
@ QUDA_DEBUG_VERBOSE
Definition: enum_quda.h:268
@ QUDA_EVEN_PARITY
Definition: enum_quda.h:284
@ QUDA_ODD_PARITY
Definition: enum_quda.h:284
@ QUDA_CPS_WILSON_DIRAC_ORDER
Definition: enum_quda.h:248
@ QUDA_NULL_FIELD_CREATE
Definition: enum_quda.h:360
enum QudaParity_s QudaParity
void ax(double a, ColorSpinorField &x)
double norm2(const ColorSpinorField &a)
void setKernelPackT(bool pack)
void setDiracParam(DiracParam &diracParam, QudaInvertParam *inv_param, bool pc)
Main header file for the QUDA library.
void printQudaInvertParam(QudaInvertParam *param)
Definition: check_params.h:342
QudaDslashType dslash_type
Definition: quda.h:106
QudaVerbosity verbosity
Definition: quda.h:271
QudaFieldLocation input_location
Definition: quda.h:103
QudaFieldLocation output_location
Definition: quda.h:104
QudaDiracFieldOrder dirac_order
Definition: quda.h:244
double kappa
Definition: quda.h:110
void pushVerbosity(QudaVerbosity verbosity)
Push a new verbosity onto the stack.
Definition: util_quda.cpp:83
#define printfQuda(...)
Definition: util_quda.h:114
void popVerbosity()
Pop the verbosity restoring the prior one on the stack.
Definition: util_quda.cpp:94
QudaVerbosity getVerbosity()
Definition: util_quda.cpp:21
#define errorQuda(...)
Definition: util_quda.h:120