// creates a copy of src, any differences defined in param cudaColorSpinorField::cudaColorSpinorField(const ColorSpinorField &src, const ColorSpinorParam ¶m) : ColorSpinorField(src), v(0), norm(0), alloc(false), init(true) { // can only overide if we are not using a reference or parity special case if (param.create != QUDA_REFERENCE_FIELD_CREATE || (param.create == QUDA_REFERENCE_FIELD_CREATE && src.SiteSubset() == QUDA_FULL_SITE_SUBSET && param.siteSubset == QUDA_PARITY_SITE_SUBSET && src.FieldLocation() == QUDA_CUDA_FIELD_LOCATION) ) { reset(param); } else { errorQuda("Undefined behaviour"); // else silent bug possible? } fieldLocation = QUDA_CUDA_FIELD_LOCATION; create(param.create); if (param.create == QUDA_NULL_FIELD_CREATE) { // do nothing } else if (param.create == QUDA_ZERO_FIELD_CREATE) { zero(); } else if (param.create == QUDA_COPY_FIELD_CREATE) { if (src.FieldLocation() == QUDA_CUDA_FIELD_LOCATION) { copy(dynamic_cast<const cudaColorSpinorField&>(src)); } else if (src.FieldLocation() == QUDA_CPU_FIELD_LOCATION) { loadCPUSpinorField(dynamic_cast<const cpuColorSpinorField&>(src)); } else { errorQuda("FieldLocation %d not supported", src.FieldLocation()); } } else if (param.create == QUDA_REFERENCE_FIELD_CREATE) { if (src.FieldLocation() == QUDA_CUDA_FIELD_LOCATION) { v = (dynamic_cast<const cudaColorSpinorField&>(src)).v; norm = (dynamic_cast<const cudaColorSpinorField&>(src)).norm; } else { errorQuda("Cannot reference a non cuda field"); } } else { errorQuda("CreateType %d not implemented", param.create); } }
/* This is special case constructor used to create parity subset references with in a full field */ cpuColorSpinorField::cpuColorSpinorField(const ColorSpinorField &src, const ColorSpinorParam ¶m) : ColorSpinorField(src), init(false), reference(false) { // can only overide if we parity subset reference special case if ( param.create == QUDA_REFERENCE_FIELD_CREATE && src.SiteSubset() == QUDA_FULL_SITE_SUBSET && param.siteSubset == QUDA_PARITY_SITE_SUBSET && typeid(src) == typeid(cpuColorSpinorField) ) { reset(param); } else { errorQuda("Undefined behaviour"); // else silent bug possible? } // need to set this before create if (param.create == QUDA_REFERENCE_FIELD_CREATE) { v = (void*)src.V(); norm = (void*)src.Norm(); } create(param.create); }
void DiracStaggered::checkParitySpinor(const ColorSpinorField &in, const ColorSpinorField &out) const { if (in.Ndim() != 5 || out.Ndim() != 5) { errorQuda("Staggered dslash requires 5-d fermion fields"); } if (in.Precision() != out.Precision()) { errorQuda("Input and output spinor precisions don't match in dslash_quda"); } if (in.Stride() != out.Stride()) { errorQuda("Input %d and output %d spinor strides don't match in dslash_quda", in.Stride(), out.Stride()); } if (in.SiteSubset() != QUDA_PARITY_SITE_SUBSET || out.SiteSubset() != QUDA_PARITY_SITE_SUBSET) { errorQuda("ColorSpinorFields are not single parity, in = %d, out = %d", in.SiteSubset(), out.SiteSubset()); } if ((out.Volume()/out.X(4) != 2*gauge->VolumeCB() && out.SiteSubset() == QUDA_FULL_SITE_SUBSET) || (out.Volume()/out.X(4) != gauge->VolumeCB() && out.SiteSubset() == QUDA_PARITY_SITE_SUBSET) ) { errorQuda("Spinor volume %d doesn't match gauge volume %d", out.Volume(), gauge->VolumeCB()); } }