|
QUDA v0.3.2
A library for QCD on GPUs
|
00001 #include <dirac_quda.h> 00002 #include <dslash_quda.h> 00003 #include <blas_quda.h> 00004 #include <iostream> 00005 00006 Dirac::Dirac(const DiracParam ¶m) 00007 : gauge(*(param.gauge)), kappa(param.kappa), mass(param.mass), matpcType(param.matpcType), 00008 dagger(param.dagger), flops(0), tmp1(param.tmp1), tmp2(param.tmp2) { 00009 00010 } 00011 00012 Dirac::Dirac(const Dirac &dirac) 00013 : gauge(dirac.gauge), kappa(dirac.kappa), matpcType(dirac.matpcType), 00014 dagger(dirac.dagger), flops(0), tmp1(dirac.tmp1), tmp2(dirac.tmp2) { 00015 00016 } 00017 00018 Dirac::~Dirac() { 00019 00020 } 00021 00022 Dirac& Dirac::operator=(const Dirac &dirac) 00023 { 00024 if(&dirac != this) { 00025 gauge = dirac.gauge; 00026 kappa = dirac.kappa; 00027 matpcType = dirac.matpcType; 00028 dagger = dirac.dagger; 00029 flops = 0; 00030 tmp1 = dirac.tmp1; 00031 tmp2 = dirac.tmp2; 00032 } 00033 00034 return *this; 00035 } 00036 00037 bool Dirac::newTmp(cudaColorSpinorField **tmp, const cudaColorSpinorField &a) const { 00038 if (*tmp) return false; 00039 ColorSpinorParam param; 00040 param.create = QUDA_ZERO_FIELD_CREATE; // need to zero elements else padded region will be junk 00041 *tmp = new cudaColorSpinorField(a, param); 00042 return true; 00043 } 00044 00045 void Dirac::deleteTmp(cudaColorSpinorField **a, const bool &reset) const { 00046 if (reset) { 00047 delete *a; 00048 *a = NULL; 00049 } 00050 } 00051 00052 #define flip(x) (x) = ((x) == QUDA_DAG_YES ? QUDA_DAG_NO : QUDA_DAG_YES) 00053 00054 void Dirac::Mdag(cudaColorSpinorField &out, const cudaColorSpinorField &in) const 00055 { 00056 flip(dagger); 00057 M(out, in); 00058 flip(dagger); 00059 } 00060 00061 #undef flip 00062 00063 void Dirac::checkParitySpinor(const cudaColorSpinorField &out, const cudaColorSpinorField &in) const 00064 { 00065 if (in.GammaBasis() != QUDA_UKQCD_GAMMA_BASIS || 00066 out.GammaBasis() != QUDA_UKQCD_GAMMA_BASIS) { 00067 errorQuda("CUDA Dirac operator requires UKQCD basis, out = %d, in = %d", 00068 out.GammaBasis(), in.GammaBasis()); 00069 } 00070 00071 if (in.Precision() != out.Precision()) { 00072 errorQuda("Input precision %d and output spinor precision %d don't match in dslash_quda", 00073 in.Precision(), out.Precision()); 00074 } 00075 00076 if (in.Stride() != out.Stride()) { 00077 errorQuda("Input %d and output %d spinor strides don't match in dslash_quda", 00078 in.Stride(), out.Stride()); 00079 } 00080 00081 if (in.SiteSubset() != QUDA_PARITY_SITE_SUBSET || out.SiteSubset() != QUDA_PARITY_SITE_SUBSET) { 00082 errorQuda("ColorSpinorFields are not single parity: in = %d, out = %d", 00083 in.SiteSubset(), out.SiteSubset()); 00084 } 00085 00086 if (out.Ndim() != 5) { 00087 if ((out.Volume() != 2*gauge.volume && out.SiteSubset() == QUDA_FULL_SITE_SUBSET) || 00088 (out.Volume() != gauge.volume && out.SiteSubset() == QUDA_PARITY_SITE_SUBSET) ) { 00089 errorQuda("Spinor volume %d doesn't match gauge volume %d", out.Volume(), gauge.volume); 00090 } 00091 } else { 00092 // Domain wall fermions, compare 4d volumes not 5d 00093 if ((out.Volume()/out.X(4) != 2*gauge.volume && out.SiteSubset() == QUDA_FULL_SITE_SUBSET) || 00094 (out.Volume()/out.X(4) != gauge.volume && out.SiteSubset() == QUDA_PARITY_SITE_SUBSET) ) { 00095 errorQuda("Spinor volume %d doesn't match gauge volume %d", out.Volume(), gauge.volume); 00096 } 00097 } 00098 } 00099 00100 void Dirac::checkFullSpinor(const cudaColorSpinorField &out, const cudaColorSpinorField &in) const 00101 { 00102 if (in.SiteSubset() != QUDA_FULL_SITE_SUBSET || out.SiteSubset() != QUDA_FULL_SITE_SUBSET) { 00103 errorQuda("ColorSpinorFields are not full fields: in = %d, out = %d", 00104 in.SiteSubset(), out.SiteSubset()); 00105 } 00106 } 00107 00108 void Dirac::checkSpinorAlias(const cudaColorSpinorField &a, const cudaColorSpinorField &b) const { 00109 if (a.v == b.v) errorQuda("Aliasing pointers"); 00110 } 00111 00112 // Dirac operator factory 00113 Dirac* Dirac::create(const DiracParam ¶m) 00114 { 00115 if (param.type == QUDA_WILSON_DIRAC) { 00116 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracWilson operator\n"); 00117 return new DiracWilson(param); 00118 } else if (param.type == QUDA_WILSONPC_DIRAC) { 00119 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracWilsonPC operator\n"); 00120 return new DiracWilsonPC(param); 00121 } else if (param.type == QUDA_CLOVER_DIRAC) { 00122 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracClover operator\n"); 00123 return new DiracClover(param); 00124 } else if (param.type == QUDA_CLOVERPC_DIRAC) { 00125 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracCloverPC operator\n"); 00126 return new DiracCloverPC(param); 00127 } else if (param.type == QUDA_DOMAIN_WALL_DIRAC) { 00128 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracDomainWall operator\n"); 00129 return new DiracDomainWall(param); 00130 } else if (param.type == QUDA_DOMAIN_WALLPC_DIRAC) { 00131 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracDomainWallPC operator\n"); 00132 return new DiracDomainWallPC(param); 00133 } else if (param.type == QUDA_ASQTAD_DIRAC) { 00134 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracStaggered operator\n"); 00135 return new DiracStaggered(param); 00136 } else if (param.type == QUDA_ASQTADPC_DIRAC) { 00137 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracStaggeredPC operator\n"); 00138 return new DiracStaggeredPC(param); 00139 } else if (param.type == QUDA_TWISTED_MASS_DIRAC) { 00140 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracTwistedMass operator\n"); 00141 return new DiracTwistedMass(param); 00142 } else if (param.type == QUDA_TWISTED_MASSPC_DIRAC) { 00143 if (param.verbose >= QUDA_VERBOSE) printfQuda("Creating a DiracTwistedMassPC operator\n"); 00144 return new DiracTwistedMassPC(param); 00145 } else { 00146 return 0; 00147 } 00148 }
1.7.3