1 #include <color_spinor_field.h>
2 #include <color_spinor_field_order.h>
4 #include <kernels/copy_field_offset.cuh>
6 #include <instantiate.h>
11 template <class Field, class Element, class F>
12 void copy_color_spinor_offset(Field &out, const Field &in, CommKey offset, QudaPCType pc_type)
16 if (pc_type == QUDA_4D_PC) {
17 CopyFieldOffsetArg<Field, Element, F, QUDA_4D_PC> arg(out_accessor, out, in_accessor, in, offset);
18 CopyFieldOffset<decltype(arg)> copier(arg, in);
19 } else if (pc_type == QUDA_5D_PC) {
20 CopyFieldOffsetArg<Field, Element, F, QUDA_5D_PC> arg(out_accessor, out, in_accessor, in, offset);
21 CopyFieldOffset<decltype(arg)> copier(arg, in);
23 errorQuda("pc_type should either be QUDA_4D_PC or QUDA_5D_PC.\n");
27 template <class Float, int nColor, int nSpin>
28 void copy_color_spinor_offset(ColorSpinorField &out, const ColorSpinorField &in, CommKey offset, QudaPCType pc_type)
30 using Field = ColorSpinorField;
31 using real = typename mapper<Float>::type;
32 using Element = ColorSpinor<real, nColor, nSpin>;
34 if (in.Location() == QUDA_CPU_FIELD_LOCATION) {
35 if (in.FieldOrder() == QUDA_SPACE_COLOR_SPIN_FIELD_ORDER) {
36 using F = typename colorspinor_order_mapper<Float, QUDA_SPACE_COLOR_SPIN_FIELD_ORDER, nSpin, nColor>::type;
37 copy_color_spinor_offset<Field, Element, F>(out, in, offset, pc_type);
38 } else if (in.FieldOrder() == QUDA_SPACE_SPIN_COLOR_FIELD_ORDER) {
39 using F = typename colorspinor_order_mapper<Float, QUDA_SPACE_SPIN_COLOR_FIELD_ORDER, nSpin, nColor>::type;
40 copy_color_spinor_offset<Field, Element, F>(out, in, offset, pc_type);
42 errorQuda("Unsupported field order = %d.", in.FieldOrder());
45 if (!in.isNative() || !out.isNative()) { errorQuda("CUDA field has be in native order."); }
47 using F = typename colorspinor_mapper<Float, nSpin, nColor>::type;
48 copy_color_spinor_offset<Field, Element, F>(out, in, offset, pc_type);
52 template <class Float, int nColor> struct CopyColorSpinorOffset {
53 CopyColorSpinorOffset(ColorSpinorField &out, const ColorSpinorField &in, CommKey offset, QudaPCType pc_type)
55 if (in.Nspin() == 4) {
56 copy_color_spinor_offset<Float, nColor, 4>(out, in, offset, pc_type);
57 } else if (in.Nspin() == 1) {
58 copy_color_spinor_offset<Float, nColor, 1>(out, in, offset, pc_type);
60 errorQuda("Unsupported spin = %d.\n", in.Nspin());
65 void copyFieldOffset(ColorSpinorField &out, const ColorSpinorField &in, CommKey offset, QudaPCType pc_type)
67 checkPrecision(out, in);
68 checkLocation(out, in); // check all locations match
69 instantiate<CopyColorSpinorOffset>(out, in, offset, pc_type);