From 36600899e21094e130ec21b7aad74deab6550a62 Mon Sep 17 00:00:00 2001 From: david clarke Date: Thu, 12 Oct 2023 11:11:39 -0600 Subject: [PATCH] working 7-link; Grid_log; generalShift --- Grid/log/Log.h | 21 ++++++++ Grid/qcd/smearing/HISQSmearing.h | 81 ++++++++---------------------- Grid/stencil/GeneralLocalStencil.h | 44 ++++++++++++++++ tests/smearing/Test_fatLinks.cc | 14 ------ 4 files changed, 85 insertions(+), 75 deletions(-) diff --git a/Grid/log/Log.h b/Grid/log/Log.h index 2d663a3c..b88bf61f 100644 --- a/Grid/log/Log.h +++ b/Grid/log/Log.h @@ -191,6 +191,27 @@ extern Colours GridLogColours; std::string demangle(const char* name) ; +template +inline std::string sjoin(Args&&... args) noexcept { + std::ostringstream msg; + (msg << ... << args); + return msg.str(); +} + +/*! @brief make log messages work like python print */ +template +inline void Grid_log(Args&&... args) { + std::string msg = sjoin(std::forward(args)...); + std::cout << GridLogMessage << msg << std::endl; +} + +/*! @brief make warning messages work like python print */ +template +inline void Grid_warn(Args&&... args) { + std::string msg = sjoin(std::forward(args)...); + std::cout << GridLogWarning << msg << std::endl; +} + #define _NBACKTRACE (256) extern void * Grid_backtrace_buffer[_NBACKTRACE]; diff --git a/Grid/qcd/smearing/HISQSmearing.h b/Grid/qcd/smearing/HISQSmearing.h index 8c60d874..1ea1b7b9 100644 --- a/Grid/qcd/smearing/HISQSmearing.h +++ b/Grid/qcd/smearing/HISQSmearing.h @@ -32,17 +32,25 @@ directory #pragma once - #include #include #include -#define BACKWARD_CONST 16 -#define NO_SHIFT -1 NAMESPACE_BEGIN(Grid); +/*! @brief append arbitrary shift path to shifts */ +template +void appendShift(std::vector& shifts, int dir, Args... args) { + Coordinate shift(Nd,0); + generalShift(shift, dir, args...); + // push_back creates an element at the end of shifts and + // assigns the data in the argument to it. + shifts.push_back(shift); +} + + // This is to optimize the SIMD (will also need to be in the class, at least for now) template void gpermute(vobj & inout,int perm) { vobj tmp=inout; @@ -53,14 +61,6 @@ template void gpermute(vobj & inout,int perm) { } -/*! @brief signals that you want to go backwards in direction dir */ -inline int Back(const int dir) { - // generalShift will use BACKWARD_CONST to determine whether we step forward or - // backward. Should work as long as BACKWARD_CONST > Nd. Trick inspired by SIMULATeQCD. - return dir + BACKWARD_CONST; -} - - /*! @brief figure out the stencil index from mu and nu */ inline int stencilIndex(int mu, int nu) { // Nshifts depends on how you built the stencil @@ -69,46 +69,6 @@ inline int stencilIndex(int mu, int nu) { } -/*! @brief shift one unit in direction dir */ -template -void generalShift(Coordinate& shift, int dir) { - if (dir >= BACKWARD_CONST) { - dir -= BACKWARD_CONST; - shift[dir]+=-1; - } else if (dir == NO_SHIFT) { - ; // do nothing - } else { - shift[dir]+=1; - } -} - -// Move into general stencil header, beneath definition of general stencil -/*! @brief follow a path of directions, shifting one unit in each direction */ -template -void generalShift(Coordinate& shift, int dir, Args... args) { - if (dir >= BACKWARD_CONST) { - dir -= BACKWARD_CONST; - shift[dir]+=-1; - } else if (dir == NO_SHIFT) { - ; // do nothing - } else { - shift[dir]+=1; - } - generalShift(shift, args...); -} - - -/*! @brief append arbitrary shift path to shifts */ -template -void appendShift(std::vector& shifts, int dir, Args... args) { - Coordinate shift(Nd,0); - generalShift(shift, dir, args...); - // push_back creates an element at the end of shifts and - // assigns the data in the argument to it. - shifts.push_back(shift); -} - - /*! @brief structure holding the link treatment */ struct SmearingParameters{ SmearingParameters(){} @@ -189,17 +149,16 @@ public: // This is where contributions from the smearing get added together Ughost_fat=Zero(); - // Create the accessors - autoView(U_v , Ughost , CpuRead); - autoView(U_fat_v , Ughost_fat , CpuWrite); - autoView(U_3link_v , Ughost_3link , CpuWrite); - autoView(U_5linkA_v, Ughost_5linkA, CpuWrite); - autoView(U_5linkB_v, Ughost_5linkB, CpuWrite); - for(int mu=0;mu Nd! + +/*! @brief signals that you want to go backwards in direction dir */ +inline int Back(const int dir) { + // generalShift will use BACKWARD_CONST to determine whether we step forward or + // backward. Trick inspired by SIMULATeQCD. + return dir + BACKWARD_CONST; +} + +/*! @brief shift one unit in direction dir */ +template +void generalShift(Coordinate& shift, int dir) { + if (dir >= BACKWARD_CONST) { + dir -= BACKWARD_CONST; + shift[dir]+=-1; + } else if (dir == NO_SHIFT) { + ; // do nothing + } else { + shift[dir]+=1; + } +} + +/*! @brief follow a path of directions, shifting one unit in each direction */ +template +void generalShift(Coordinate& shift, int dir, Args... args) { + if (dir >= BACKWARD_CONST) { + dir -= BACKWARD_CONST; + shift[dir]+=-1; + } else if (dir == NO_SHIFT) { + ; // do nothing + } else { + shift[dir]+=1; + } + generalShift(shift, args...); +} + + NAMESPACE_END(Grid); diff --git a/tests/smearing/Test_fatLinks.cc b/tests/smearing/Test_fatLinks.cc index 200e2af6..f5c7b5ca 100644 --- a/tests/smearing/Test_fatLinks.cc +++ b/tests/smearing/Test_fatLinks.cc @@ -38,20 +38,6 @@ directory using namespace Grid; -/*! @brief make the logger work like python print */ -template -inline std::string sjoin(Args&&... args) noexcept { - std::ostringstream msg; - (msg << ... << args); - return msg.str(); -} -template -inline void Grid_log(Args&&... args) { - std::string msg = sjoin(std::forward(args)...); - std::cout << GridLogMessage << msg << std::endl; -} - - /*! @brief parameter file to easily adjust Nloop */ struct ConfParameters: Serializable { GRID_SERIALIZABLE_CLASS_MEMBERS(