mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 12:47:05 +01:00
Merge branch 'master' of https://github.com/paboyle/Grid into scidac1_2
Conflicts: lib/qcd/action/fermion/WilsonKernels.h tests/Make.inc
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
|
||||
HFILES=./algorithms/approx/bigfloat.h ./algorithms/approx/bigfloat_double.h ./algorithms/approx/Chebyshev.h ./algorithms/approx/MultiShiftFunction.h ./algorithms/approx/Remez.h ./algorithms/approx/Zolotarev.h ./algorithms/CoarsenedMatrix.h ./algorithms/iterative/AdefGeneric.h ./algorithms/iterative/ConjugateGradient.h ./algorithms/iterative/ConjugateGradientMultiShift.h ./algorithms/iterative/ConjugateResidual.h ./algorithms/iterative/ImplicitlyRestartedLanczos.h ./algorithms/iterative/MatrixUtils.h ./algorithms/iterative/NormalEquations.h ./algorithms/iterative/PrecConjugateResidual.h ./algorithms/iterative/PrecGeneralisedConjugateResidual.h ./algorithms/iterative/SchurRedBlack.h ./algorithms/LinearOperator.h ./algorithms/Preconditioner.h ./algorithms/SparseMatrix.h ./Algorithms.h ./AlignedAllocator.h ./cartesian/Cartesian_base.h ./cartesian/Cartesian_full.h ./cartesian/Cartesian_red_black.h ./Cartesian.h ./communicator/Communicator_base.h ./Communicator.h ./Config.h ./cshift/Cshift_common.h ./cshift/Cshift_mpi.h ./cshift/Cshift_none.h ./Cshift.h ./Grid.h ./Init.h ./lattice/Lattice_arith.h ./lattice/Lattice_base.h ./lattice/Lattice_comparison.h ./lattice/Lattice_comparison_utils.h ./lattice/Lattice_conformable.h ./lattice/Lattice_coordinate.h ./lattice/Lattice_ET.h ./lattice/Lattice_local.h ./lattice/Lattice_overload.h ./lattice/Lattice_peekpoke.h ./lattice/Lattice_reality.h ./lattice/Lattice_reduction.h ./lattice/Lattice_rng.h ./lattice/Lattice_trace.h ./lattice/Lattice_transfer.h ./lattice/Lattice_transpose.h ./lattice/Lattice_unary.h ./lattice/Lattice_where.h ./Lattice.h ./Log.h ./Old/Tensor_peek.h ./Old/Tensor_poke.h ./parallelIO/BinaryIO.h ./parallelIO/NerscIO.h ./pugixml/pugixml.h ./qcd/action/ActionBase.h ./qcd/action/ActionParams.h ./qcd/action/Actions.h ./qcd/action/fermion/CayleyFermion5D.h ./qcd/action/fermion/ContinuedFractionFermion5D.h ./qcd/action/fermion/DomainWallFermion.h ./qcd/action/fermion/FermionOperator.h ./qcd/action/fermion/FermionOperatorImpl.h ./qcd/action/fermion/g5HermitianLinop.h ./qcd/action/fermion/MobiusFermion.h ./qcd/action/fermion/MobiusZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonCayleyTanhFermion.h ./qcd/action/fermion/OverlapWilsonCayleyZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonContfracTanhFermion.h ./qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h ./qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h ./qcd/action/fermion/PartialFractionFermion5D.h ./qcd/action/fermion/ScaledShamirFermion.h ./qcd/action/fermion/ShamirZolotarevFermion.h ./qcd/action/fermion/WilsonCompressor.h ./qcd/action/fermion/WilsonFermion.h ./qcd/action/fermion/WilsonFermion5D.h ./qcd/action/fermion/WilsonKernels.h ./qcd/action/gauge/WilsonGaugeAction.h ./qcd/action/pseudofermion/EvenOddSchurDifferentiable.h ./qcd/action/pseudofermion/OneFlavourEvenOddRational.h ./qcd/action/pseudofermion/OneFlavourEvenOddRationalRatio.h ./qcd/action/pseudofermion/OneFlavourRational.h ./qcd/action/pseudofermion/OneFlavourRationalRatio.h ./qcd/action/pseudofermion/TwoFlavour.h ./qcd/action/pseudofermion/TwoFlavourEvenOdd.h ./qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h ./qcd/action/pseudofermion/TwoFlavourRatio.h ./qcd/hmc/HMC.h ./qcd/hmc/integrators/Integrator.h ./qcd/hmc/integrators/Integrator_algorithm.h ./qcd/QCD.h ./qcd/spin/Dirac.h ./qcd/spin/TwoSpinor.h ./qcd/utils/CovariantCshift.h ./qcd/utils/LinalgUtils.h ./qcd/utils/SpaceTimeGrid.h ./qcd/utils/SUn.h ./qcd/utils/WilsonLoops.h ./serialisation/BaseIO.h ./serialisation/BinaryIO.h ./serialisation/MacroMagic.h ./serialisation/Serialisation.h ./serialisation/TextIO.h ./serialisation/XmlIO.h ./simd/Grid_avx.h ./simd/Grid_avx512.h ./simd/Grid_empty.h ./simd/Grid_imci.h ./simd/Grid_neon.h ./simd/Grid_qpx.h ./simd/Grid_sse4.h ./simd/Grid_vector_types.h ./simd/Grid_vector_unops.h ./Simd.h ./stencil/Lebesgue.h ./Stencil.h ./tensors/Tensor_arith.h ./tensors/Tensor_arith_add.h ./tensors/Tensor_arith_mac.h ./tensors/Tensor_arith_mul.h ./tensors/Tensor_arith_scalar.h ./tensors/Tensor_arith_sub.h ./tensors/Tensor_class.h ./tensors/Tensor_determinant.h ./tensors/Tensor_exp.h ./tensors/Tensor_extract_merge.h ./tensors/Tensor_index.h ./tensors/Tensor_inner.h ./tensors/Tensor_logical.h ./tensors/Tensor_outer.h ./tensors/Tensor_reality.h ./tensors/Tensor_Ta.h ./tensors/Tensor_trace.h ./tensors/Tensor_traits.h ./tensors/Tensor_transpose.h ./tensors/Tensor_unary.h ./Tensors.h ./Threads.h ./Timer.h
|
||||
HFILES=./algorithms/approx/bigfloat.h ./algorithms/approx/bigfloat_double.h ./algorithms/approx/Chebyshev.h ./algorithms/approx/MultiShiftFunction.h ./algorithms/approx/Remez.h ./algorithms/approx/Zolotarev.h ./algorithms/CoarsenedMatrix.h ./algorithms/iterative/AdefGeneric.h ./algorithms/iterative/ConjugateGradient.h ./algorithms/iterative/ConjugateGradientMultiShift.h ./algorithms/iterative/ConjugateResidual.h ./algorithms/iterative/DenseMatrix.h ./algorithms/iterative/EigenSort.h ./algorithms/iterative/Francis.h ./algorithms/iterative/Householder.h ./algorithms/iterative/ImplicitlyRestartedLanczos.h ./algorithms/iterative/Matrix.h ./algorithms/iterative/MatrixUtils.h ./algorithms/iterative/NormalEquations.h ./algorithms/iterative/PrecConjugateResidual.h ./algorithms/iterative/PrecGeneralisedConjugateResidual.h ./algorithms/iterative/SchurRedBlack.h ./algorithms/LinearOperator.h ./algorithms/Preconditioner.h ./algorithms/SparseMatrix.h ./Algorithms.h ./AlignedAllocator.h ./cartesian/Cartesian_base.h ./cartesian/Cartesian_full.h ./cartesian/Cartesian_red_black.h ./Cartesian.h ./communicator/Communicator_base.h ./Communicator.h ./cshift/Cshift_common.h ./cshift/Cshift_mpi.h ./cshift/Cshift_none.h ./Cshift.h ./Grid.h ./Init.h ./lattice/Lattice_arith.h ./lattice/Lattice_base.h ./lattice/Lattice_comparison.h ./lattice/Lattice_comparison_utils.h ./lattice/Lattice_conformable.h ./lattice/Lattice_coordinate.h ./lattice/Lattice_ET.h ./lattice/Lattice_local.h ./lattice/Lattice_overload.h ./lattice/Lattice_peekpoke.h ./lattice/Lattice_reality.h ./lattice/Lattice_reduction.h ./lattice/Lattice_rng.h ./lattice/Lattice_trace.h ./lattice/Lattice_transfer.h ./lattice/Lattice_transpose.h ./lattice/Lattice_unary.h ./lattice/Lattice_where.h ./Lattice.h ./Log.h ./Old/Tensor_peek.h ./Old/Tensor_poke.h ./parallelIO/BinaryIO.h ./parallelIO/NerscIO.h ./PerfCount.h ./pugixml/pugixml.h ./qcd/action/ActionBase.h ./qcd/action/ActionParams.h ./qcd/action/Actions.h ./qcd/action/fermion/CayleyFermion5D.h ./qcd/action/fermion/ContinuedFractionFermion5D.h ./qcd/action/fermion/DomainWallFermion.h ./qcd/action/fermion/FermionOperator.h ./qcd/action/fermion/FermionOperatorImpl.h ./qcd/action/fermion/g5HermitianLinop.h ./qcd/action/fermion/MobiusFermion.h ./qcd/action/fermion/MobiusZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonCayleyTanhFermion.h ./qcd/action/fermion/OverlapWilsonCayleyZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonContfracTanhFermion.h ./qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h ./qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h ./qcd/action/fermion/PartialFractionFermion5D.h ./qcd/action/fermion/ScaledShamirFermion.h ./qcd/action/fermion/ShamirZolotarevFermion.h ./qcd/action/fermion/WilsonCompressor.h ./qcd/action/fermion/WilsonFermion.h ./qcd/action/fermion/WilsonFermion5D.h ./qcd/action/fermion/WilsonKernels.h ./qcd/action/gauge/WilsonGaugeAction.h ./qcd/action/pseudofermion/EvenOddSchurDifferentiable.h ./qcd/action/pseudofermion/OneFlavourEvenOddRational.h ./qcd/action/pseudofermion/OneFlavourEvenOddRationalRatio.h ./qcd/action/pseudofermion/OneFlavourRational.h ./qcd/action/pseudofermion/OneFlavourRationalRatio.h ./qcd/action/pseudofermion/TwoFlavour.h ./qcd/action/pseudofermion/TwoFlavourEvenOdd.h ./qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h ./qcd/action/pseudofermion/TwoFlavourRatio.h ./qcd/hmc/HMC.h ./qcd/hmc/integrators/Integrator.h ./qcd/hmc/integrators/Integrator_algorithm.h ./qcd/QCD.h ./qcd/spin/Dirac.h ./qcd/spin/TwoSpinor.h ./qcd/utils/CovariantCshift.h ./qcd/utils/LinalgUtils.h ./qcd/utils/SpaceTimeGrid.h ./qcd/utils/SUn.h ./qcd/utils/WilsonLoops.h ./serialisation/BaseIO.h ./serialisation/BinaryIO.h ./serialisation/MacroMagic.h ./serialisation/Serialisation.h ./serialisation/TextIO.h ./serialisation/XmlIO.h ./simd/Avx512Asm.h ./simd/Grid_avx.h ./simd/Grid_avx512.h ./simd/Grid_empty.h ./simd/Grid_imci.h ./simd/Grid_neon.h ./simd/Grid_qpx.h ./simd/Grid_sse4.h ./simd/Grid_vector_types.h ./simd/Grid_vector_unops.h ./Simd.h ./stencil/Lebesgue.h ./Stencil.h ./tensors/Tensor_arith.h ./tensors/Tensor_arith_add.h ./tensors/Tensor_arith_mac.h ./tensors/Tensor_arith_mul.h ./tensors/Tensor_arith_scalar.h ./tensors/Tensor_arith_sub.h ./tensors/Tensor_class.h ./tensors/Tensor_determinant.h ./tensors/Tensor_exp.h ./tensors/Tensor_extract_merge.h ./tensors/Tensor_index.h ./tensors/Tensor_inner.h ./tensors/Tensor_logical.h ./tensors/Tensor_outer.h ./tensors/Tensor_reality.h ./tensors/Tensor_Ta.h ./tensors/Tensor_trace.h ./tensors/Tensor_traits.h ./tensors/Tensor_transpose.h ./tensors/Tensor_unary.h ./Tensors.h ./Threads.h ./Timer.h
|
||||
|
||||
CCFILES=./algorithms/approx/MultiShiftFunction.cc ./algorithms/approx/Remez.cc ./algorithms/approx/Zolotarev.cc ./Init.cc ./Log.cc ./pugixml/pugixml.cc ./qcd/action/fermion/CayleyFermion5D.cc ./qcd/action/fermion/ContinuedFractionFermion5D.cc ./qcd/action/fermion/PartialFractionFermion5D.cc ./qcd/action/fermion/WilsonFermion.cc ./qcd/action/fermion/WilsonFermion5D.cc ./qcd/action/fermion/WilsonKernels.cc ./qcd/action/fermion/WilsonKernelsHand.cc ./qcd/hmc/HMC.cc ./qcd/spin/Dirac.cc ./qcd/utils/SpaceTimeGrid.cc ./serialisation/BinaryIO.cc ./serialisation/TextIO.cc ./serialisation/XmlIO.cc ./stencil/Lebesgue.cc ./stencil/Stencil_common.cc
|
||||
CCFILES=./algorithms/approx/MultiShiftFunction.cc ./algorithms/approx/Remez.cc ./algorithms/approx/Zolotarev.cc ./Init.cc ./Log.cc ./PerfCount.cc ./pugixml/pugixml.cc ./qcd/action/fermion/CayleyFermion5D.cc ./qcd/action/fermion/ContinuedFractionFermion5D.cc ./qcd/action/fermion/PartialFractionFermion5D.cc ./qcd/action/fermion/WilsonFermion.cc ./qcd/action/fermion/WilsonFermion5D.cc ./qcd/action/fermion/WilsonKernels.cc ./qcd/action/fermion/WilsonKernelsAsm.cc ./qcd/action/fermion/WilsonKernelsHand.cc ./qcd/hmc/HMC.cc ./qcd/spin/Dirac.cc ./qcd/utils/SpaceTimeGrid.cc ./serialisation/BinaryIO.cc ./serialisation/TextIO.cc ./serialisation/XmlIO.cc ./stencil/Lebesgue.cc ./stencil/Stencil_common.cc
|
||||
|
@ -3,8 +3,11 @@
|
||||
#include <PerfCount.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
#define CacheControl(L,O,R) ((PERF_COUNT_HW_CACHE_##L)|(PERF_COUNT_HW_CACHE_OP_##O<<8)| (PERF_COUNT_HW_CACHE_RESULT_##R<<16))
|
||||
|
||||
const PerformanceCounter::PerformanceCounterConfig PerformanceCounter::PerformanceCounterConfigs [] = {
|
||||
#ifdef __linux__
|
||||
{ PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES , "CPUCYCLES.........." },
|
||||
{ PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS , "INSTRUCTIONS......." },
|
||||
{ PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES , "CACHE_REFERENCES..." },
|
||||
@ -23,6 +26,7 @@ const PerformanceCounter::PerformanceCounterConfig PerformanceCounter::Performan
|
||||
{ PERF_TYPE_HW_CACHE, CacheControl(LL,PREFETCH,ACCESS) , "LL_PREFETCH_ACCESS."},
|
||||
{ PERF_TYPE_HW_CACHE, CacheControl(L1I,READ,MISS) , "L1I_READ_MISS......"},
|
||||
{ PERF_TYPE_HW_CACHE, CacheControl(L1I,READ,ACCESS) , "L1I_READ_ACCESS...."}
|
||||
#endif
|
||||
// { PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, "STALL_CYCLES" },
|
||||
};
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
#ifdef __linux__
|
||||
#include <syscall.h>
|
||||
#include <linux/perf_event.h>
|
||||
#else
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
namespace Grid {
|
||||
|
||||
@ -30,6 +32,7 @@ static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||
|
||||
class PerformanceCounter {
|
||||
private:
|
||||
|
||||
typedef struct {
|
||||
public:
|
||||
uint32_t type;
|
||||
|
@ -11,7 +11,6 @@
|
||||
// Vector types are arch dependent
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint32_t Integer;
|
||||
|
||||
#define _MM_SELECT_FOUR_FOUR(A,B,C,D) ((A<<6)|(B<<4)|(C<<2)|(D))
|
||||
#define _MM_SELECT_EIGHT_TWO(A,B,C,D,E,F,G,H) ((A<<7)|(B<<6)|(C<<5)|(D<<4)|(E<<3)|(F<<2)|(G<<4)|(H))
|
||||
@ -20,6 +19,8 @@ typedef uint32_t Integer;
|
||||
|
||||
namespace Grid {
|
||||
|
||||
typedef uint32_t Integer;
|
||||
|
||||
typedef float RealF;
|
||||
typedef double RealD;
|
||||
#ifdef GRID_DEFAULT_PRECISION_DOUBLE
|
||||
|
@ -166,8 +166,9 @@ public:
|
||||
pcoor.resize(_ndimension);
|
||||
lcoor.resize(_ndimension);
|
||||
for(int mu=0;mu<_ndimension;mu++){
|
||||
pcoor[mu] = gcoor[mu]/_ldimensions[mu];
|
||||
lcoor[mu] = gcoor[mu]%_ldimensions[mu];
|
||||
int _fld = _fdimensions[mu]/_processors[mu];
|
||||
pcoor[mu] = gcoor[mu]/_fld;
|
||||
lcoor[mu] = gcoor[mu]%_fld;
|
||||
}
|
||||
}
|
||||
void GlobalCoorToRankIndex(int &rank, int &o_idx, int &i_idx ,const std::vector<int> &gcoor)
|
||||
@ -176,8 +177,16 @@ public:
|
||||
std::vector<int> lcoor;
|
||||
GlobalCoorToProcessorCoorLocalCoor(pcoor,lcoor,gcoor);
|
||||
rank = RankFromProcessorCoor(pcoor);
|
||||
i_idx= iIndex(lcoor);
|
||||
o_idx= oIndex(lcoor);
|
||||
|
||||
std::vector<int> cblcoor(lcoor);
|
||||
for(int d=0;d<cblcoor.size();d++){
|
||||
if( this->CheckerBoarded(d) ) {
|
||||
cblcoor[d] = lcoor[d]/2;
|
||||
}
|
||||
}
|
||||
|
||||
i_idx= iIndex(cblcoor);// this does not imply divide by 2 on checker dim
|
||||
o_idx= oIndex(lcoor);// this implies divide by 2 on checkerdim
|
||||
}
|
||||
|
||||
void RankIndexToGlobalCoor(int rank, int o_idx, int i_idx , std::vector<int> &gcoor)
|
||||
|
@ -114,7 +114,7 @@ namespace QCD {
|
||||
// Apply Dw
|
||||
this->DW(psi,Din,DaggerYes);
|
||||
|
||||
Meooe5D(Din,chi);
|
||||
MeooeDag5D(Din,chi);
|
||||
|
||||
int Ls=this->Ls;
|
||||
for(int s=0;s<Ls;s++){
|
||||
@ -163,7 +163,6 @@ namespace QCD {
|
||||
FermionField tmp(psi._grid);
|
||||
// Assemble the 5d matrix
|
||||
Meooe5D(psi,tmp);
|
||||
|
||||
#if 0
|
||||
std::cout << "Meooe Test replacement norm2 tmp = " <<norm2(tmp)<<std::endl;
|
||||
for(int s=0;s<Ls;s++){
|
||||
@ -202,7 +201,7 @@ namespace QCD {
|
||||
this->DhopOE(psi,tmp,DaggerYes);
|
||||
}
|
||||
|
||||
Meooe5D(tmp,chi);
|
||||
MeooeDag5D(tmp,chi);
|
||||
#if 0
|
||||
std::cout << "Meooe Test replacement norm2 chi new = " <<norm2(chi)<<std::endl;
|
||||
// Assemble the 5d matrix
|
||||
|
@ -3,9 +3,12 @@ namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
template<class Impl>
|
||||
void WilsonKernels<Impl>::DiracOptDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out)
|
||||
WilsonKernels<Impl>::WilsonKernels(const ImplParams &p): Base(p) {};
|
||||
|
||||
template<class Impl>
|
||||
void WilsonKernels<Impl>::DiracOptDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out)
|
||||
{
|
||||
SiteHalfSpinor tmp;
|
||||
SiteHalfSpinor chi;
|
||||
@ -122,7 +125,7 @@ void WilsonKernels<Impl>::DiracOptDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
void WilsonKernels<Impl>::DiracOptDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
void WilsonKernels<Impl>::DiracOptDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out)
|
||||
{
|
||||
@ -369,6 +372,16 @@ void WilsonKernels<Impl>::DiracOptDhopDir(StencilImpl &st,DoubledGaugeField &U,
|
||||
vstream(out._odata[sF],result*(-0.5));
|
||||
}
|
||||
|
||||
#if ( ! defined(AVX512) ) && ( ! defined(IMCI) )
|
||||
template<class Impl>
|
||||
void WilsonKernels<Impl>::DiracOptAsmDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out,uint64_t *p)
|
||||
{
|
||||
DiracOptDhopSite(st,U,buf,sF,sU,in,out); // will template override for Wilson Nc=3
|
||||
}
|
||||
#endif
|
||||
|
||||
FermOpTemplateInstantiate(WilsonKernels);
|
||||
GparityFermOpTemplateInstantiate(WilsonKernels);
|
||||
|
||||
|
@ -28,11 +28,11 @@ namespace Grid {
|
||||
void DiracOptDhopDir(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out,int dirdisp,int gamma);
|
||||
#if defined(AVX512) || defined(IMCI)
|
||||
|
||||
void DiracOptAsmDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out,uint64_t *);
|
||||
#else
|
||||
#if 0
|
||||
void DiracOptAsmDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out,uint64_t *p){
|
||||
@ -41,7 +41,7 @@ namespace Grid {
|
||||
#endif
|
||||
// doesn't seem to work with Gparity at the moment
|
||||
#undef HANDOPT
|
||||
#ifdef HANDOPT
|
||||
//#define HANDOPT
|
||||
void DiracOptHandDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out);
|
||||
@ -49,25 +49,9 @@ namespace Grid {
|
||||
void DiracOptHandDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out);
|
||||
#else
|
||||
|
||||
void DiracOptHandDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out)
|
||||
{
|
||||
DiracOptDhopSite(st,U,buf,sF,sU,in,out); // will template override for Wilson Nc=3
|
||||
}
|
||||
|
||||
void DiracOptHandDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int sF,int sU,const FermionField &in, FermionField &out)
|
||||
{
|
||||
DiracOptDhopSiteDag(st,U,buf,sF,sU,in,out); // will template override for Wilson Nc=3
|
||||
}
|
||||
#endif
|
||||
|
||||
WilsonKernels(const ImplParams &p= ImplParams()) : Base(p) {};
|
||||
|
||||
WilsonKernels(const ImplParams &p= ImplParams());
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ namespace QCD {
|
||||
|
||||
#ifdef HANDOPT
|
||||
template<class Impl>
|
||||
void WilsonKernels<Impl >::DiracOptHandDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
void WilsonKernels<Impl >::DiracOptHandDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int ss,int sU,const FermionField &in, FermionField &out)
|
||||
{
|
||||
@ -526,7 +526,7 @@ void WilsonKernels<Impl >::DiracOptHandDhopSite(StencilImpl &st,DoubledGaugeFiel
|
||||
}
|
||||
|
||||
template<class Impl>
|
||||
void WilsonKernels<Impl >::DiracOptHandDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
void WilsonKernels<Impl >::DiracOptHandDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int ss,int sU,const FermionField &in, FermionField &out)
|
||||
{
|
||||
@ -767,6 +767,36 @@ void WilsonKernels<Impl >::DiracOptHandDhopSiteDag(StencilImpl &st,DoubledGaugeF
|
||||
vstream(ref()(3)(2),result_32*(-0.5));
|
||||
}
|
||||
}
|
||||
FermOpTemplateInstantiate(WilsonKernels);
|
||||
#else
|
||||
template<class Impl>
|
||||
void WilsonKernels<Impl >::DiracOptHandDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int ss,int sU,const FermionField &in, FermionField &out)
|
||||
{
|
||||
DiracOptDhopSite(st,U,buf,sF,sU,in,out); // will template override for Wilson Nc=3
|
||||
}
|
||||
|
||||
template<class Impl>
|
||||
void WilsonKernels<Impl >::DiracOptHandDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int ss,int sU,const FermionField &in, FermionField &out)
|
||||
{
|
||||
DiracOptDhopSiteDag(st,U,buf,sF,sU,in,out); // will template override for Wilson Nc=3
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template void WilsonKernels<WilsonImplF>::DiracOptHandDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int ss,int sU,const FermionField &in, FermionField &out);
|
||||
template void WilsonKernels<WilsonImplD>::DiracOptHandDhopSite(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int ss,int sU,const FermionField &in, FermionField &out);
|
||||
template void WilsonKernels<WilsonImplF>::DiracOptHandDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int ss,int sU,const FermionField &in, FermionField &out);
|
||||
template void WilsonKernels<WilsonImplD>::DiracOptHandDhopSiteDag(StencilImpl &st,DoubledGaugeField &U,
|
||||
std::vector<SiteHalfSpinor,alignedAllocator<SiteHalfSpinor> > &buf,
|
||||
int ss,int sU,const FermionField &in, FermionField &out);
|
||||
|
||||
}}
|
||||
|
@ -45,13 +45,13 @@ namespace QCD {
|
||||
// To fail is not to err (Cryptic clue: suggest to Google SFINAE ;) )
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spProjXp (iVector<vtype,Nhs> &hspin,const iVector<vtype,Ns> &fspin)
|
||||
{
|
||||
hspin(0)=fspin(0)-timesI(fspin(3));
|
||||
hspin(1)=fspin(1)-timesI(fspin(2));
|
||||
hspin(0)=fspin(0)+timesI(fspin(3));
|
||||
hspin(1)=fspin(1)+timesI(fspin(2));
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spProjXm (iVector<vtype,Nhs> &hspin,const iVector<vtype,Ns> &fspin)
|
||||
{
|
||||
hspin(0)=fspin(0)+timesI(fspin(3));
|
||||
hspin(1)=fspin(1)+timesI(fspin(2));
|
||||
hspin(0)=fspin(0)-timesI(fspin(3));
|
||||
hspin(1)=fspin(1)-timesI(fspin(2));
|
||||
}
|
||||
|
||||
// 0 0 0 -1 [0] -+ [3]
|
||||
@ -60,13 +60,13 @@ namespace QCD {
|
||||
// -1 0 0 0
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spProjYp (iVector<vtype,Nhs> &hspin,const iVector<vtype,Ns> &fspin)
|
||||
{
|
||||
hspin(0)=fspin(0)+fspin(3);
|
||||
hspin(1)=fspin(1)-fspin(2);
|
||||
hspin(0)=fspin(0)-fspin(3);
|
||||
hspin(1)=fspin(1)+fspin(2);
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spProjYm (iVector<vtype,Nhs> &hspin,const iVector<vtype,Ns> &fspin)
|
||||
{
|
||||
hspin(0)=fspin(0)-fspin(3);
|
||||
hspin(1)=fspin(1)+fspin(2);
|
||||
hspin(0)=fspin(0)+fspin(3);
|
||||
hspin(1)=fspin(1)-fspin(2);
|
||||
}
|
||||
/*Gz
|
||||
* 0 0 i 0 [0]+-i[2]
|
||||
@ -76,14 +76,14 @@ namespace QCD {
|
||||
*/
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spProjZp (iVector<vtype,Nhs> &hspin,const iVector<vtype,Ns> &fspin)
|
||||
{
|
||||
hspin(0)=fspin(0)-timesI(fspin(2));
|
||||
hspin(1)=fspin(1)+timesI(fspin(3));
|
||||
hspin(0)=fspin(0)+timesI(fspin(2));
|
||||
hspin(1)=fspin(1)-timesI(fspin(3));
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spProjZm (iVector<vtype,Nhs> &hspin,const iVector<vtype,Ns> &fspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
hspin(0)=fspin(0)+timesI(fspin(2));
|
||||
hspin(1)=fspin(1)-timesI(fspin(3));
|
||||
hspin(0)=fspin(0)-timesI(fspin(2));
|
||||
hspin(1)=fspin(1)+timesI(fspin(3));
|
||||
}
|
||||
/*Gt
|
||||
* 0 0 1 0 [0]+-[2]
|
||||
@ -94,14 +94,14 @@ namespace QCD {
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spProjTp (iVector<vtype,Nhs> &hspin,const iVector<vtype,Ns> &fspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
hspin(0)=fspin(0)-fspin(2);
|
||||
hspin(1)=fspin(1)-fspin(3);
|
||||
hspin(0)=fspin(0)+fspin(2);
|
||||
hspin(1)=fspin(1)+fspin(3);
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spProjTm (iVector<vtype,Nhs> &hspin,const iVector<vtype,Ns> &fspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
hspin(0)=fspin(0)+fspin(2);
|
||||
hspin(1)=fspin(1)+fspin(3);
|
||||
hspin(0)=fspin(0)-fspin(2);
|
||||
hspin(1)=fspin(1)-fspin(3);
|
||||
}
|
||||
/*G5
|
||||
* 1 0 0 0
|
||||
@ -157,32 +157,32 @@ namespace QCD {
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)=hspin(0);
|
||||
fspin(1)=hspin(1);
|
||||
fspin(2)=timesI(hspin(1));
|
||||
fspin(3)=timesI(hspin(0));
|
||||
fspin(2)=timesMinusI(hspin(1));
|
||||
fspin(3)=timesMinusI(hspin(0));
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spReconXm (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)=hspin(0);
|
||||
fspin(1)=hspin(1);
|
||||
fspin(2)=timesMinusI(hspin(1));
|
||||
fspin(3)=timesMinusI(hspin(0));
|
||||
fspin(2)=timesI(hspin(1));
|
||||
fspin(3)=timesI(hspin(0));
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void accumReconXp (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)+=hspin(0);
|
||||
fspin(1)+=hspin(1);
|
||||
fspin(2)+=timesI(hspin(1));
|
||||
fspin(3)+=timesI(hspin(0));
|
||||
fspin(2)-=timesI(hspin(1));
|
||||
fspin(3)-=timesI(hspin(0));
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void accumReconXm (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)+=hspin(0);
|
||||
fspin(1)+=hspin(1);
|
||||
fspin(2)-=timesI(hspin(1));
|
||||
fspin(3)-=timesI(hspin(0));
|
||||
fspin(2)+=timesI(hspin(1));
|
||||
fspin(3)+=timesI(hspin(0));
|
||||
}
|
||||
|
||||
// 0 0 0 -1 [0] -+ [3]
|
||||
@ -195,32 +195,32 @@ namespace QCD {
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)=hspin(0);
|
||||
fspin(1)=hspin(1);
|
||||
fspin(2)=-hspin(1);
|
||||
fspin(3)= hspin(0);
|
||||
fspin(2)= hspin(1);
|
||||
fspin(3)=-hspin(0);//Unary minus?
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spReconYm (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)=hspin(0);
|
||||
fspin(1)=hspin(1);
|
||||
fspin(2)= hspin(1);
|
||||
fspin(3)=-hspin(0);//Unary minus?
|
||||
fspin(2)=-hspin(1);
|
||||
fspin(3)= hspin(0);
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void accumReconYp (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)+=hspin(0);
|
||||
fspin(1)+=hspin(1);
|
||||
fspin(2)-=hspin(1);
|
||||
fspin(3)+=hspin(0);
|
||||
fspin(2)+=hspin(1);
|
||||
fspin(3)-=hspin(0);
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void accumReconYm (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)+=hspin(0);
|
||||
fspin(1)+=hspin(1);
|
||||
fspin(2)+=hspin(1);
|
||||
fspin(3)-=hspin(0);
|
||||
fspin(2)-=hspin(1);
|
||||
fspin(3)+=hspin(0);
|
||||
}
|
||||
|
||||
/*Gz
|
||||
@ -234,32 +234,32 @@ namespace QCD {
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)=hspin(0);
|
||||
fspin(1)=hspin(1);
|
||||
fspin(2)= timesI(hspin(0));
|
||||
fspin(3)=timesMinusI(hspin(1));
|
||||
fspin(2)=timesMinusI(hspin(0));
|
||||
fspin(3)=timesI(hspin(1));
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spReconZm (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)=hspin(0);
|
||||
fspin(1)=hspin(1);
|
||||
fspin(2)=timesMinusI(hspin(0));
|
||||
fspin(3)=timesI(hspin(1));
|
||||
fspin(2)= timesI(hspin(0));
|
||||
fspin(3)=timesMinusI(hspin(1));
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void accumReconZp (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)+=hspin(0);
|
||||
fspin(1)+=hspin(1);
|
||||
fspin(2)+=timesI(hspin(0));
|
||||
fspin(3)-=timesI(hspin(1));
|
||||
fspin(2)-=timesI(hspin(0));
|
||||
fspin(3)+=timesI(hspin(1));
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void accumReconZm (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)+=hspin(0);
|
||||
fspin(1)+=hspin(1);
|
||||
fspin(2)-=timesI(hspin(0));
|
||||
fspin(3)+=timesI(hspin(1));
|
||||
fspin(2)+=timesI(hspin(0));
|
||||
fspin(3)-=timesI(hspin(1));
|
||||
}
|
||||
/*Gt
|
||||
* 0 0 1 0 [0]+-[2]
|
||||
@ -272,32 +272,32 @@ namespace QCD {
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)=hspin(0);
|
||||
fspin(1)=hspin(1);
|
||||
fspin(2)=-hspin(0);
|
||||
fspin(3)=-hspin(1);
|
||||
fspin(2)=hspin(0);
|
||||
fspin(3)=hspin(1);
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void spReconTm (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)=hspin(0);
|
||||
fspin(1)=hspin(1);
|
||||
fspin(2)=hspin(0);
|
||||
fspin(3)=hspin(1);
|
||||
fspin(2)=-hspin(0);
|
||||
fspin(3)=-hspin(1);
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void accumReconTp (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)+=hspin(0);
|
||||
fspin(1)+=hspin(1);
|
||||
fspin(2)-=hspin(0);
|
||||
fspin(3)-=hspin(1);
|
||||
fspin(2)+=hspin(0);
|
||||
fspin(3)+=hspin(1);
|
||||
}
|
||||
template<class vtype,IfSpinor<iVector<vtype,Ns> > = 0> strong_inline void accumReconTm (iVector<vtype,Ns> &fspin,const iVector<vtype,Nhs> &hspin)
|
||||
{
|
||||
//typename std::enable_if<matchGridTensorIndex<iVector<vtype,Ns>,SpinorIndex>::value,iVector<vtype,Ns> >::type *SFINAE;
|
||||
fspin(0)+=hspin(0);
|
||||
fspin(1)+=hspin(1);
|
||||
fspin(2)+=hspin(0);
|
||||
fspin(3)+=hspin(1);
|
||||
fspin(2)-=hspin(0);
|
||||
fspin(3)-=hspin(1);
|
||||
}
|
||||
/*G5
|
||||
* 1 0 0 0
|
||||
|
@ -22,7 +22,12 @@ namespace Grid {
|
||||
typename std::enable_if<std::is_base_of<Serializable, U>::value, void>::type
|
||||
write(const std::string& s, const U &output);
|
||||
template <typename U>
|
||||
typename std::enable_if<!std::is_base_of<Serializable, U>::value, void>::type
|
||||
typename std::enable_if<std::is_enum<U>::value, void>::type
|
||||
write(const std::string& s, const U &output);
|
||||
template <typename U>
|
||||
typename std::enable_if<
|
||||
!(std::is_base_of<Serializable, U>::value or std::is_enum<U>::value),
|
||||
void>::type
|
||||
write(const std::string& s, const U &output);
|
||||
private:
|
||||
T *upcast;
|
||||
@ -41,7 +46,12 @@ namespace Grid {
|
||||
typename std::enable_if<std::is_base_of<Serializable, U>::value, void>::type
|
||||
read(const std::string& s, U &output);
|
||||
template <typename U>
|
||||
typename std::enable_if<!std::is_base_of<Serializable, U>::value, void>::type
|
||||
typename std::enable_if<std::is_enum<U>::value, void>::type
|
||||
read(const std::string& s, U &output);
|
||||
template <typename U>
|
||||
typename std::enable_if<
|
||||
!(std::is_base_of<Serializable, U>::value or std::is_enum<U>::value),
|
||||
void>::type
|
||||
read(const std::string& s, U &output);
|
||||
protected:
|
||||
template <typename U>
|
||||
@ -146,7 +156,17 @@ namespace Grid {
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
typename std::enable_if<!std::is_base_of<Serializable, U>::value, void>::type
|
||||
typename std::enable_if<std::is_enum<U>::value, void>::type
|
||||
Writer<T>::write(const std::string &s, const U &output)
|
||||
{
|
||||
EnumIO<U>::write(*this, s, output);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
typename std::enable_if<
|
||||
!(std::is_base_of<Serializable, U>::value or std::is_enum<U>::value),
|
||||
void>::type
|
||||
Writer<T>::write(const std::string &s, const U &output)
|
||||
{
|
||||
upcast->writeDefault(s, output);
|
||||
@ -181,7 +201,17 @@ namespace Grid {
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
typename std::enable_if<!std::is_base_of<Serializable, U>::value, void>::type
|
||||
typename std::enable_if<std::is_enum<U>::value, void>::type
|
||||
Reader<T>::read(const std::string &s, U &output)
|
||||
{
|
||||
EnumIO<U>::read(*this, s, output);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
typename std::enable_if<
|
||||
!(std::is_base_of<Serializable, U>::value or std::is_enum<U>::value),
|
||||
void>::type
|
||||
Reader<T>::read(const std::string &s, U &output)
|
||||
{
|
||||
upcast->readDefault(s, output);
|
||||
@ -205,7 +235,7 @@ namespace Grid {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,36 +1,43 @@
|
||||
#include <Grid.h>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace std;
|
||||
|
||||
namespace Grid {
|
||||
// Writer implementation ///////////////////////////////////////////////////////
|
||||
BinaryWriter::BinaryWriter(const std::string &fileName)
|
||||
: file_(fileName, std::ios::binary|std::ios::out)
|
||||
BinaryWriter::BinaryWriter(const string &fileName)
|
||||
: file_(fileName, ios::binary|ios::out)
|
||||
{}
|
||||
|
||||
template <>
|
||||
void BinaryWriter::writeDefault(const std::string &s, const std::string &output)
|
||||
void BinaryWriter::writeDefault(const string &s, const string &x)
|
||||
{
|
||||
uint64_t sz = output.size();
|
||||
uint64_t sz = x.size();
|
||||
|
||||
write("", sz);
|
||||
for (uint64_t i = 0; i < sz; ++i)
|
||||
{
|
||||
write("", x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void BinaryWriter::writeDefault(const string &s, const char *x)
|
||||
{
|
||||
string sx(x);
|
||||
|
||||
write("", sz);
|
||||
for (uint64_t i = 0; i < sz; ++i)
|
||||
{
|
||||
write("", output[i]);
|
||||
}
|
||||
writeDefault(s, sx);
|
||||
}
|
||||
|
||||
// Reader implementation ///////////////////////////////////////////////////////
|
||||
BinaryReader::BinaryReader(const std::string &fileName)
|
||||
: file_(fileName, std::ios::binary|std::ios::in)
|
||||
BinaryReader::BinaryReader(const string &fileName)
|
||||
: file_(fileName, ios::binary|ios::in)
|
||||
{}
|
||||
|
||||
template <>
|
||||
void BinaryReader::readDefault(const std::string &s, std::string &output)
|
||||
void BinaryReader::readDefault(const string &s, string &output)
|
||||
{
|
||||
uint64_t sz;
|
||||
uint64_t sz;
|
||||
|
||||
read("", sz);
|
||||
output.reserve(sz);
|
||||
file_.read((char *)output.data(), sz);
|
||||
}
|
||||
read("", sz);
|
||||
output.resize(sz);
|
||||
file_.read((char *)output.data(), sz);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace Grid {
|
||||
void writeDefault(const std::string &s, const U &x);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const std::vector<U> &x);
|
||||
void writeDefault(const std::string &s, const char *x);
|
||||
private:
|
||||
std::ofstream file_;
|
||||
};
|
||||
@ -48,6 +49,9 @@ namespace Grid {
|
||||
file_.write((char *)&x, sizeof(U));
|
||||
}
|
||||
|
||||
template <>
|
||||
void BinaryWriter::writeDefault(const std::string &s, const std::string &x);
|
||||
|
||||
template <typename U>
|
||||
void BinaryWriter::writeDefault(const std::string &s, const std::vector<U> &x)
|
||||
{
|
||||
@ -67,6 +71,9 @@ namespace Grid {
|
||||
file_.read((char *)&output, sizeof(U));
|
||||
}
|
||||
|
||||
template <>
|
||||
void BinaryReader::readDefault(const std::string &s, std::string &output);
|
||||
|
||||
template <typename U>
|
||||
void BinaryReader::readDefault(const std::string &s, std::vector<U> &output)
|
||||
{
|
||||
|
@ -109,12 +109,11 @@ THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GRID_MACRO_MEMBER(A,B) A B;
|
||||
|
||||
#define GRID_MACRO_OS_WRITE_MEMBER(A,B) os<< #A <<" "#B <<" = "<< obj. B <<" ; " <<std::endl;
|
||||
#define GRID_MACRO_READ_MEMBER(A,B) Grid::read(RD,#B,obj. B);
|
||||
#define GRID_MACRO_WRITE_MEMBER(A,B) Grid::write(WR,#B,obj. B);
|
||||
|
||||
#define GRID_DECL_CLASS_MEMBERS(cname,...) \
|
||||
#define GRID_SERIALIZABLE_CLASS_MEMBERS(cname,...) \
|
||||
\
|
||||
\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_MEMBER,__VA_ARGS__)) \
|
||||
@ -144,4 +143,51 @@ THE SOFTWARE.
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define GRID_ENUM_TYPE(obj) std::remove_reference<decltype(obj)>::type
|
||||
#define GRID_MACRO_ENUMVAL(A,B) A = B,
|
||||
#define GRID_MACRO_ENUMCASE(A,B) case GRID_ENUM_TYPE(obj)::A: Grid::write(WR,s,#A); break;
|
||||
#define GRID_MACRO_ENUMTEST(A,B) else if (buf == #A) {obj = GRID_ENUM_TYPE(obj)::A;}
|
||||
#define GRID_MACRO_ENUMCASEIO(A,B) case GRID_ENUM_TYPE(obj)::A: os << #A; break;
|
||||
|
||||
namespace Grid {
|
||||
template <typename U>
|
||||
class EnumIO {};
|
||||
}
|
||||
|
||||
#define GRID_SERIALIZABLE_ENUM(name,undefname,...)\
|
||||
enum class name {\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMVAL,__VA_ARGS__))\
|
||||
undefname = -1\
|
||||
};\
|
||||
\
|
||||
template<>\
|
||||
class EnumIO<name> {\
|
||||
public:\
|
||||
template <typename T>\
|
||||
static void write(Writer<T> &WR,const std::string &s, const name &obj){ \
|
||||
switch (obj) {\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\
|
||||
default: Grid::write(WR,s,#undefname); break;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
template <typename T>\
|
||||
static void read(Reader<T> &RD,const std::string &s, name &obj){ \
|
||||
std::string buf;\
|
||||
Grid::read(RD, s, buf);\
|
||||
if (buf == #undefname) {obj = name::undefname;}\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMTEST,__VA_ARGS__))\
|
||||
else {obj = name::undefname;}\
|
||||
}\
|
||||
};\
|
||||
\
|
||||
std::ostream & operator << (std::ostream &os, const name &obj ) { \
|
||||
switch (obj) {\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\
|
||||
default: os << #undefname; break;\
|
||||
}\
|
||||
return os;\
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,12 +1,14 @@
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
using namespace Grid;
|
||||
using namespace std;
|
||||
|
||||
// Writer implementation ///////////////////////////////////////////////////////
|
||||
TextWriter::TextWriter(const std::string &fileName)
|
||||
: file_(fileName, std::ios::out)
|
||||
TextWriter::TextWriter(const string &fileName)
|
||||
: file_(fileName, ios::out)
|
||||
{}
|
||||
|
||||
void TextWriter::push(const std::string &s)
|
||||
void TextWriter::push(const string &s)
|
||||
{
|
||||
level_++;
|
||||
};
|
||||
@ -25,11 +27,11 @@ void TextWriter::indent(void)
|
||||
};
|
||||
|
||||
// Reader implementation ///////////////////////////////////////////////////////
|
||||
TextReader::TextReader(const std::string &fileName)
|
||||
: file_(fileName, std::ios::in)
|
||||
TextReader::TextReader(const string &fileName)
|
||||
: file_(fileName, ios::in)
|
||||
{}
|
||||
|
||||
void TextReader::push(const std::string &s)
|
||||
void TextReader::push(const string &s)
|
||||
{
|
||||
level_++;
|
||||
};
|
||||
@ -48,9 +50,9 @@ void TextReader::checkIndent(void)
|
||||
file_.get(c);
|
||||
if (c != '\t')
|
||||
{
|
||||
std::cerr << "mismatch on tab " << c << " level " << level_;
|
||||
std::cerr << " i "<< i <<std::endl;
|
||||
std::abort();
|
||||
cerr << "mismatch on tab " << c << " level " << level_;
|
||||
cerr << " i "<< i << endl;
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,8 +60,7 @@ void TextReader::checkIndent(void)
|
||||
template <>
|
||||
void TextReader::readDefault(const std::string &s, std::string &output)
|
||||
{
|
||||
checkIndent();
|
||||
output.clear();
|
||||
getline(file_, output);
|
||||
}
|
||||
checkIndent();
|
||||
output.clear();
|
||||
getline(file_, output);
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ namespace Grid
|
||||
void push(const std::string &s);
|
||||
void pop(void);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const U &output);
|
||||
void writeDefault(const std::string &s, const U &x);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const std::vector<U> &output);
|
||||
void writeDefault(const std::string &s, const std::vector<U> &x);
|
||||
private:
|
||||
void indent(void);
|
||||
private:
|
||||
@ -50,21 +50,21 @@ namespace Grid
|
||||
|
||||
// Writer template implementation ////////////////////////////////////////////
|
||||
template <typename U>
|
||||
void TextWriter::writeDefault(const std::string &s, const U &output)
|
||||
void TextWriter::writeDefault(const std::string &s, const U &x)
|
||||
{
|
||||
indent();
|
||||
file_ << std::boolalpha << output << std::endl;
|
||||
file_ << std::boolalpha << x << std::endl;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
void TextWriter::writeDefault(const std::string &s, const std::vector<U> &output)
|
||||
void TextWriter::writeDefault(const std::string &s, const std::vector<U> &x)
|
||||
{
|
||||
uint64_t sz = output.size();
|
||||
uint64_t sz = x.size();
|
||||
|
||||
write(s, sz);
|
||||
for (uint64_t i = 0; i < sz; ++i)
|
||||
{
|
||||
write(s, output[i]);
|
||||
write(s, x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +78,9 @@ namespace Grid
|
||||
fromString(output, buf);
|
||||
}
|
||||
|
||||
template <>
|
||||
void TextReader::readDefault(const std::string &s, std::string &output);
|
||||
|
||||
template <typename U>
|
||||
void TextReader::readDefault(const std::string &s, std::vector<U> &output)
|
||||
{
|
||||
|
@ -1,8 +1,10 @@
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
using namespace Grid;
|
||||
using namespace std;
|
||||
|
||||
// Writer implementation ///////////////////////////////////////////////////////
|
||||
XmlWriter::XmlWriter(const std::string &fileName)
|
||||
XmlWriter::XmlWriter(const string &fileName)
|
||||
: fileName_(fileName)
|
||||
{
|
||||
node_ = doc_.append_child();
|
||||
@ -14,7 +16,7 @@ XmlWriter::~XmlWriter(void)
|
||||
doc_.save_file(fileName_.c_str(), " ");
|
||||
}
|
||||
|
||||
void XmlWriter::push(const std::string &s)
|
||||
void XmlWriter::push(const string &s)
|
||||
{
|
||||
node_ = node_.append_child(s.c_str());
|
||||
}
|
||||
@ -25,22 +27,22 @@ void XmlWriter::pop(void)
|
||||
}
|
||||
|
||||
// Reader implementation ///////////////////////////////////////////////////////
|
||||
XmlReader::XmlReader(const std::string &fileName)
|
||||
XmlReader::XmlReader(const string &fileName)
|
||||
: fileName_(fileName)
|
||||
{
|
||||
pugi::xml_parse_result result = doc_.load_file(fileName_.c_str());
|
||||
|
||||
if ( !result )
|
||||
{
|
||||
std::cerr << "XML error description: " << result.description() << "\n";
|
||||
std::cerr << "XML error offset : " << result.offset << "\n";
|
||||
std::abort();
|
||||
cerr << "XML error description: " << result.description() << "\n";
|
||||
cerr << "XML error offset : " << result.offset << "\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
node_ = doc_.child("grid");
|
||||
}
|
||||
|
||||
void XmlReader::push(const std::string &s)
|
||||
void XmlReader::push(const string &s)
|
||||
{
|
||||
node_ = node_.child(s.c_str());
|
||||
}
|
||||
@ -51,8 +53,7 @@ void XmlReader::pop(void)
|
||||
}
|
||||
|
||||
template <>
|
||||
void XmlReader::readDefault(const std::string &s, std::string &output)
|
||||
void XmlReader::readDefault(const string &s, string &output)
|
||||
{
|
||||
output = node_.child(s.c_str()).first_child().value();
|
||||
}
|
||||
}
|
||||
|
@ -81,10 +81,12 @@ namespace Grid
|
||||
fromString(output, buf);
|
||||
}
|
||||
|
||||
template <>
|
||||
void XmlReader::readDefault(const std::string &s, std::string &output);
|
||||
|
||||
template <typename U>
|
||||
void XmlReader::readDefault(const std::string &s, std::vector<U> &output)
|
||||
{
|
||||
pugi::xml_node nodeCpy;
|
||||
std::string buf;
|
||||
unsigned int i = 0;
|
||||
|
||||
@ -96,7 +98,6 @@ namespace Grid
|
||||
node_.child("elem").set_name("elem-done");
|
||||
i++;
|
||||
}
|
||||
// assert( is.tellg()==-1);
|
||||
pop();
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#define _mm256_set_m128i(hi,lo) _mm256_insertf128_si256(_mm256_castsi128_si256(lo),(hi),1)
|
||||
#endif
|
||||
|
||||
namespace Grid {
|
||||
namespace Optimization {
|
||||
|
||||
template<class vtype>
|
||||
@ -467,7 +468,7 @@ namespace Optimization {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// Here assign types
|
||||
namespace Grid {
|
||||
|
||||
typedef __m256 SIMD_Ftype; // Single precision type
|
||||
typedef __m256d SIMD_Dtype; // Double precision type
|
||||
typedef __m256i SIMD_Itype; // Integer type
|
||||
@ -488,8 +489,8 @@ namespace Grid {
|
||||
typedef Optimization::Vstore VstoreSIMD;
|
||||
typedef Optimization::Vset VsetSIMD;
|
||||
typedef Optimization::Vstream VstreamSIMD;
|
||||
template <typename S, typename T> using ReduceSIMD = Optimization::Reduce<S,T>;
|
||||
|
||||
template <typename S, typename T> using ReduceSIMD = Optimization::Reduce<S,T>;
|
||||
|
||||
// Arithmetic operations
|
||||
typedef Optimization::Sum SumSIMD;
|
||||
|
Reference in New Issue
Block a user