From ac530636cabdb18ac9360fb6677c277bf6333305 Mon Sep 17 00:00:00 2001 From: fionnoh Date: Thu, 27 Jun 2019 13:44:47 +0800 Subject: [PATCH 1/8] A2Aloop bugfix --- Hadrons/Modules/MContraction/A2ALoop.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hadrons/Modules/MContraction/A2ALoop.hpp b/Hadrons/Modules/MContraction/A2ALoop.hpp index 2ef99354..7e7ffac0 100644 --- a/Hadrons/Modules/MContraction/A2ALoop.hpp +++ b/Hadrons/Modules/MContraction/A2ALoop.hpp @@ -112,7 +112,7 @@ void TA2ALoop::execute(void) loop = zero; for (unsigned int i = 0; i < left.size(); ++i) { - loop += outerProduct(adj(left[i]), right[i]); + loop += outerProduct(left[i], right[i]); } } From 421a0a8a36015e72da769a7fa4ee647afa4ee326 Mon Sep 17 00:00:00 2001 From: fionnoh Date: Thu, 27 Jun 2019 13:45:20 +0800 Subject: [PATCH 2/8] Changes to A2Autils, A2AMatirx and DiskVector code that is needed for Hadrons 4 quark contraction module --- Grid/qcd/utils/A2Autils.h | 118 +++++++++++++++---- Hadrons/A2AMatrix.hpp | 81 ++++++++----- Hadrons/DiskVector.hpp | 233 +++++++++++++++++++++++--------------- 3 files changed, 290 insertions(+), 142 deletions(-) diff --git a/Grid/qcd/utils/A2Autils.h b/Grid/qcd/utils/A2Autils.h index 97188ffe..966d84f7 100644 --- a/Grid/qcd/utils/A2Autils.h +++ b/Grid/qcd/utils/A2Autils.h @@ -68,8 +68,17 @@ public: const std::vector &emB1, int orthogdim, double *t_kernel = nullptr, double *t_gsum = nullptr); - static void ContractWWVV(std::vector &WWVV, - const Eigen::Tensor &WW_sd, + template + typename std::enable_if, TensorType>::value, void>::type + static ContractWWVV(std::vector &WWVV, + const TensorType &WW_sd, + const FermionField *vs, + const FermionField *vd); + + template + typename std::enable_if, TensorType>::value, void>::type + static ContractWWVV(std::vector &WWVV, + const TensorType &WW_sd, const FermionField *vs, const FermionField *vd); @@ -99,6 +108,11 @@ public: const FermionField *vd, int orthogdim); #endif +private: + inline static void OuterProductWWVV(std::vector &WWVV, + const vobj &lhs, + const vobj &rhs, + const int Ns, const int ss, const int t); }; template @@ -961,12 +975,15 @@ void A2Autils::AslashField(TensorType &mat, // Take WW_sd v^dag_d (x) v_s // -template -void A2Autils::ContractWWVV(std::vector &WWVV, - const Eigen::Tensor &WW_sd, +template +template +typename std::enable_if, TensorType>::value, void>::type +A2Autils::ContractWWVV(std::vector &WWVV, + const TensorType &WW_sd, const FermionField *vs, const FermionField *vd) { + std::cout << "Start contraction" << std::endl; GridBase *grid = vs[0]._grid; int nd = grid->_ndimension; @@ -989,33 +1006,90 @@ void A2Autils::ContractWWVV(std::vector &WWVV, vobj tmp2 = zero; vobj tmp3 = zero; - for(int d=d_o;d +template +typename std::enable_if, TensorType>::value, void>::type +A2Autils::ContractWWVV(std::vector &WWVV, + const TensorType &WW_sd, + const FermionField *vs, + const FermionField *vd) +{ + GridBase *grid = vs[0]._grid; + + int nd = grid->_ndimension; + int Nsimd = grid->Nsimd(); + int N_t = WW_sd.dimensions()[0]; + int N_s = WW_sd.dimensions()[1]; + int N_d = WW_sd.dimensions()[2]; + + int d_unroll = 32;// Empirical optimisation + + Eigen::Matrix buf; + + for(int t=0;t::saveBlock(const A2AMatrixSet &m, template template