mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-13 01:05:36 +00:00
working 7-link; Grid_log; generalShift
This commit is contained in:
parent
b9c70d156b
commit
36600899e2
@ -191,6 +191,27 @@ extern Colours GridLogColours;
|
|||||||
|
|
||||||
std::string demangle(const char* name) ;
|
std::string demangle(const char* name) ;
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
inline std::string sjoin(Args&&... args) noexcept {
|
||||||
|
std::ostringstream msg;
|
||||||
|
(msg << ... << args);
|
||||||
|
return msg.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! @brief make log messages work like python print */
|
||||||
|
template <typename... Args>
|
||||||
|
inline void Grid_log(Args&&... args) {
|
||||||
|
std::string msg = sjoin(std::forward<Args>(args)...);
|
||||||
|
std::cout << GridLogMessage << msg << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! @brief make warning messages work like python print */
|
||||||
|
template <typename... Args>
|
||||||
|
inline void Grid_warn(Args&&... args) {
|
||||||
|
std::string msg = sjoin(std::forward<Args>(args)...);
|
||||||
|
std::cout << GridLogWarning << msg << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
#define _NBACKTRACE (256)
|
#define _NBACKTRACE (256)
|
||||||
extern void * Grid_backtrace_buffer[_NBACKTRACE];
|
extern void * Grid_backtrace_buffer[_NBACKTRACE];
|
||||||
|
|
||||||
|
@ -32,17 +32,25 @@ directory
|
|||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Grid/Grid.h>
|
#include <Grid/Grid.h>
|
||||||
#include <Grid/lattice/PaddedCell.h>
|
#include <Grid/lattice/PaddedCell.h>
|
||||||
#include <Grid/stencil/GeneralLocalStencil.h>
|
#include <Grid/stencil/GeneralLocalStencil.h>
|
||||||
|
|
||||||
#define BACKWARD_CONST 16
|
|
||||||
#define NO_SHIFT -1
|
|
||||||
|
|
||||||
NAMESPACE_BEGIN(Grid);
|
NAMESPACE_BEGIN(Grid);
|
||||||
|
|
||||||
|
|
||||||
|
/*! @brief append arbitrary shift path to shifts */
|
||||||
|
template<typename... Args>
|
||||||
|
void appendShift(std::vector<Coordinate>& 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)
|
// This is to optimize the SIMD (will also need to be in the class, at least for now)
|
||||||
template<class vobj> void gpermute(vobj & inout,int perm) {
|
template<class vobj> void gpermute(vobj & inout,int perm) {
|
||||||
vobj tmp=inout;
|
vobj tmp=inout;
|
||||||
@ -53,14 +61,6 @@ template<class vobj> 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 */
|
/*! @brief figure out the stencil index from mu and nu */
|
||||||
inline int stencilIndex(int mu, int nu) {
|
inline int stencilIndex(int mu, int nu) {
|
||||||
// Nshifts depends on how you built the stencil
|
// 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<typename... Args>
|
|
||||||
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<typename... Args>
|
|
||||||
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<typename... Args>
|
|
||||||
void appendShift(std::vector<Coordinate>& 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 */
|
/*! @brief structure holding the link treatment */
|
||||||
struct SmearingParameters{
|
struct SmearingParameters{
|
||||||
SmearingParameters(){}
|
SmearingParameters(){}
|
||||||
@ -189,17 +149,16 @@ public:
|
|||||||
// This is where contributions from the smearing get added together
|
// This is where contributions from the smearing get added together
|
||||||
Ughost_fat=Zero();
|
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;mu++) {
|
for(int mu=0;mu<Nd;mu++) {
|
||||||
|
|
||||||
// TODO: This approach is slightly memory inefficient. It uses 25% more memory than
|
// Create the accessors
|
||||||
// needs to be used.
|
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);
|
||||||
|
|
||||||
|
// TODO: This approach is slightly memory inefficient. It uses 25% extra memory
|
||||||
Ughost_3link =Zero();
|
Ughost_3link =Zero();
|
||||||
Ughost_5linkA=Zero();
|
Ughost_5linkA=Zero();
|
||||||
Ughost_5linkB=Zero();
|
Ughost_5linkB=Zero();
|
||||||
@ -321,7 +280,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // end mu loop
|
||||||
|
|
||||||
u_smr = Ghost.Extract(Ughost_fat) + lt.c_1*u_thin;
|
u_smr = Ghost.Extract(Ughost_fat) + lt.c_1*u_thin;
|
||||||
};
|
};
|
||||||
|
@ -137,5 +137,49 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////
|
||||||
|
// Some machinery to streamline making a stencil
|
||||||
|
////////////////////////////////////////////////
|
||||||
|
#define BACKWARD_CONST 16
|
||||||
|
#define NO_SHIFT -1
|
||||||
|
|
||||||
|
// TODO: put a check somewhere that BACKWARD_CONST > 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<typename... Args>
|
||||||
|
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<typename... Args>
|
||||||
|
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);
|
NAMESPACE_END(Grid);
|
||||||
|
|
||||||
|
@ -38,20 +38,6 @@ directory
|
|||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
|
|
||||||
|
|
||||||
/*! @brief make the logger work like python print */
|
|
||||||
template<typename... Args>
|
|
||||||
inline std::string sjoin(Args&&... args) noexcept {
|
|
||||||
std::ostringstream msg;
|
|
||||||
(msg << ... << args);
|
|
||||||
return msg.str();
|
|
||||||
}
|
|
||||||
template <typename... Args>
|
|
||||||
inline void Grid_log(Args&&... args) {
|
|
||||||
std::string msg = sjoin(std::forward<Args>(args)...);
|
|
||||||
std::cout << GridLogMessage << msg << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! @brief parameter file to easily adjust Nloop */
|
/*! @brief parameter file to easily adjust Nloop */
|
||||||
struct ConfParameters: Serializable {
|
struct ConfParameters: Serializable {
|
||||||
GRID_SERIALIZABLE_CLASS_MEMBERS(
|
GRID_SERIALIZABLE_CLASS_MEMBERS(
|
||||||
|
Loading…
Reference in New Issue
Block a user