From 6d3343bd6a5c1866f1502caeada79605e77988ff Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Wed, 16 Oct 2024 14:27:21 +0000 Subject: [PATCH 1/4] Mods to allow copy in/out of full QDP-JIT spinors --- include/color_spinor_field_order.h | 8 ++++---- include/kernels/copy_color_spinor.cuh | 19 +++++++++++++++++-- lib/copy_color_spinor.cuh | 5 ----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/color_spinor_field_order.h b/include/color_spinor_field_order.h index 25f5234390..b4be52fd8a 100644 --- a/include/color_spinor_field_order.h +++ b/include/color_spinor_field_order.h @@ -1799,8 +1799,8 @@ namespace quda { for (int s = 0; s < Ns; s++) { for (int c = 0; c < Nc; c++) { - v[s * Nc + c] = complex(field[(((0 * Nc + c) * Ns + s) * 2 + (1 - parity)) * volumeCB + x], - field[(((1 * Nc + c) * Ns + s) * 2 + (1 - parity)) * volumeCB + x]); + v[s * Nc + c] = complex(field[(((0 * Nc + c) * Ns + s) * 2 + parity) * volumeCB + x], + field[(((1 * Nc + c) * Ns + s) * 2 + parity) * volumeCB + x]); } } } @@ -1809,8 +1809,8 @@ namespace quda { for (int s = 0; s < Ns; s++) { for (int c = 0; c < Nc; c++) { - field[(((0 * Nc + c) * Ns + s) * 2 + (1 - parity)) * volumeCB + x] = v[s * Nc + c].real(); - field[(((1 * Nc + c) * Ns + s) * 2 + (1 - parity)) * volumeCB + x] = v[s * Nc + c].imag(); + field[(((0 * Nc + c) * Ns + s) * 2 + parity) * volumeCB + x] = v[s * Nc + c].real(); + field[(((1 * Nc + c) * Ns + s) * 2 + parity) * volumeCB + x] = v[s * Nc + c].imag(); } } } diff --git a/include/kernels/copy_color_spinor.cuh b/include/kernels/copy_color_spinor.cuh index 39bc226f3f..b57533d54a 100644 --- a/include/kernels/copy_color_spinor.cuh +++ b/include/kernels/copy_color_spinor.cuh @@ -16,6 +16,21 @@ namespace quda using namespace colorspinor; + /** Helper function for parity computation */ + inline int computeParity(const ColorSpinorField &f) + { + + // Account for odd-even vs. even-odd site orders + int ret_val = f.SiteOrder() == QUDA_ODD_EVEN_SITE_ORDER ? 1 : 0; + + // Account for potential parity flip to access single parity subset QDP-JIT fields + if (f.FieldOrder() == QUDA_QDPJIT_FIELD_ORDER && f.SiteSubset() == QUDA_PARITY_SITE_SUBSET) { + ret_val = 1 - ret_val; + } + + return ret_val; + } + template class Basis_> struct CopyColorSpinorArg : kernel_param<> { @@ -32,8 +47,8 @@ namespace quda kernel_param(dim3(in.VolumeCB(), in.SiteSubset(), 1)), out(out, 1, Out_), in(in, 1, const_cast(In_)), - outParity(out.SiteOrder() == QUDA_ODD_EVEN_SITE_ORDER ? 1 : 0), - inParity(in.SiteOrder() == QUDA_ODD_EVEN_SITE_ORDER ? 1 : 0) + outParity(computeParity(out)), + inParity(computeParity(in)) { } }; diff --git a/lib/copy_color_spinor.cuh b/lib/copy_color_spinor.cuh index f9c40ba9fc..02e6357a35 100644 --- a/lib/copy_color_spinor.cuh +++ b/lib/copy_color_spinor.cuh @@ -181,11 +181,6 @@ namespace quda errorQuda("Copying to full fields with lexicographical ordering is not currently supported"); } - if (dst.SiteSubset() == QUDA_FULL_SITE_SUBSET - && (src.FieldOrder() == QUDA_QDPJIT_FIELD_ORDER || dst.FieldOrder() == QUDA_QDPJIT_FIELD_ORDER)) { - errorQuda("QDPJIT field ordering not supported for full site fields"); - } - genericCopyColorSpinor(param); } From 4474826975df49651b2098e180c91b3411c80246 Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Mon, 28 Oct 2024 16:15:15 +0000 Subject: [PATCH 2/4] QDPJIT parity only flopped on ODD parity --- include/kernels/copy_color_spinor.cuh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/kernels/copy_color_spinor.cuh b/include/kernels/copy_color_spinor.cuh index b57533d54a..5ed05c68ba 100644 --- a/include/kernels/copy_color_spinor.cuh +++ b/include/kernels/copy_color_spinor.cuh @@ -24,7 +24,9 @@ namespace quda int ret_val = f.SiteOrder() == QUDA_ODD_EVEN_SITE_ORDER ? 1 : 0; // Account for potential parity flip to access single parity subset QDP-JIT fields - if (f.FieldOrder() == QUDA_QDPJIT_FIELD_ORDER && f.SiteSubset() == QUDA_PARITY_SITE_SUBSET) { + // The Flip is only needed fir offsetting into Odd Parity Fields + if (f.FieldOrder() == QUDA_QDPJIT_FIELD_ORDER && f.SiteSubset() == QUDA_PARITY_SITE_SUBSET + && f.SuggestedParity() == QUDA_ODD_PARITY) { ret_val = 1 - ret_val; } From 25cfeeddf30be134d67e41fd2c87bd31dbbb9cfe Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Mon, 28 Oct 2024 16:49:24 +0000 Subject: [PATCH 3/4] Prettied doxygen for compute parity --- include/kernels/copy_color_spinor.cuh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/kernels/copy_color_spinor.cuh b/include/kernels/copy_color_spinor.cuh index 5ed05c68ba..3751a42411 100644 --- a/include/kernels/copy_color_spinor.cuh +++ b/include/kernels/copy_color_spinor.cuh @@ -16,7 +16,14 @@ namespace quda using namespace colorspinor; - /** Helper function for parity computation */ + /** + * @brief A helper function to figure out what parity to use for input and output. + * @details Pick parity from input field site order. Addditionally QDPJIT fields + * may need a relative parity flip compared to what is expected when dealing with + * only the odd parity since the pointer is always to the top of the full spinort. + * @param f[in] Reference to the field for parity computation + * @return the computed parity + */ inline int computeParity(const ColorSpinorField &f) { From 76947a339c158f017334f71ad9ae381e6b59aae1 Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Mon, 28 Oct 2024 17:37:49 +0000 Subject: [PATCH 4/4] Fixed another doxygen booboo --- include/kernels/copy_color_spinor.cuh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/kernels/copy_color_spinor.cuh b/include/kernels/copy_color_spinor.cuh index 3751a42411..505163cc93 100644 --- a/include/kernels/copy_color_spinor.cuh +++ b/include/kernels/copy_color_spinor.cuh @@ -21,7 +21,7 @@ namespace quda * @details Pick parity from input field site order. Addditionally QDPJIT fields * may need a relative parity flip compared to what is expected when dealing with * only the odd parity since the pointer is always to the top of the full spinort. - * @param f[in] Reference to the field for parity computation + * @param[in] f Reference to the field for parity computation * @return the computed parity */ inline int computeParity(const ColorSpinorField &f)