mirror of
https://github.com/paboyle/Grid.git
synced 2026-09-05 17:29:36 +01:00
Grids in FermionOperator
This commit is contained in:
@@ -66,8 +66,7 @@ public:
|
|||||||
FermionField in_k(in.Grid());
|
FermionField in_k(in.Grid());
|
||||||
FermionField prop_k(in.Grid());
|
FermionField prop_k(in.Grid());
|
||||||
|
|
||||||
GRID_ASSERT(in.Grid() == this->FermionGrid());
|
PlannedFFT<typename FermionField::vector_object> &theFFT = this->ThePlannedFFT(in.Grid());
|
||||||
PlannedFFT<typename FermionField::vector_object> &theFFT = this->FermionGridFFT();
|
|
||||||
|
|
||||||
//phase for boundary condition
|
//phase for boundary condition
|
||||||
ComplexField coor(in.Grid());
|
ComplexField coor(in.Grid());
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ public:
|
|||||||
FermionField in_k(in.Grid());
|
FermionField in_k(in.Grid());
|
||||||
FermionField prop_k(in.Grid());
|
FermionField prop_k(in.Grid());
|
||||||
|
|
||||||
GRID_ASSERT(in.Grid() == this->FermionGrid());
|
PlannedFFT<typename FermionField::vector_object> &theFFT = this->ThePlannedFFT(in.Grid());
|
||||||
PlannedFFT<typename FermionField::vector_object> &theFFT = this->FermionGridFFT();
|
|
||||||
|
|
||||||
//phase for boundary condition
|
//phase for boundary condition
|
||||||
ComplexField coor(in.Grid());
|
ComplexField coor(in.Grid());
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
INHERIT_IMPL_TYPES(Impl);
|
INHERIT_IMPL_TYPES(Impl);
|
||||||
|
|
||||||
FermionOperator(const ImplParams &p= ImplParams()) : Impl(p) {};
|
FermionOperator(const ImplParams &p= ImplParams()) : Impl(p) {};
|
||||||
virtual ~FermionOperator(void) { if ( _fermionGridFFT ) delete _fermionGridFFT; }
|
virtual ~FermionOperator(void) { if ( _thePlannedFFT ) delete _thePlannedFFT; }
|
||||||
|
|
||||||
virtual FermionField &tmp(void) = 0;
|
virtual FermionField &tmp(void) = 0;
|
||||||
|
|
||||||
@@ -96,22 +96,27 @@ public:
|
|||||||
virtual void MomentumSpacePropagator(FermionField &out,const FermionField &in,RealD _m,std::vector<double> twist) { GRID_ASSERT(0);};
|
virtual void MomentumSpacePropagator(FermionField &out,const FermionField &in,RealD _m,std::vector<double> twist) { GRID_ASSERT(0);};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Cached planned FFT on the fermion grid -- a general utility (FreePropagator
|
// Cached planned FFT for the ACTIVE field grid -- a general utility (FreePropagator
|
||||||
// today; smoother, smearings and other users anticipated). Frontier FFTW plan
|
// today; smoother, smearings and other users anticipated). Frontier FFTW plan
|
||||||
// create+destroy is ~22 ms/call (measured, Test_fft_prop PLANCOST) -- ~4x the
|
// create+destroy is ~22 ms/call (measured, Test_fft_prop PLANCOST) -- ~4x the
|
||||||
// transform itself and ~80% of an unplanned call -- so a per-call `FFT theFFT(grid)`
|
// transform itself and ~80% of an unplanned call -- so a per-call `FFT theFFT(grid)`
|
||||||
// dominates. Lazily built once on FermionGrid() and reused; owned, deleted in the dtor.
|
// dominates. We cache BOTH the FFT and the grid it was built on; when called with a
|
||||||
PlannedFFT<typename FermionField::vector_object> *_fermionGridFFT{nullptr};
|
// different grid (e.g. the 5D propagator vs the 4D physical propagator) we rebuild.
|
||||||
PlannedFFT<typename FermionField::vector_object> & FermionGridFFT(void) {
|
// Lazily built, owned, deleted in the dtor. Raw pointer, no smart pointers.
|
||||||
if ( _fermionGridFFT == nullptr )
|
PlannedFFT<typename FermionField::vector_object> *_thePlannedFFT{nullptr};
|
||||||
_fermionGridFFT = new PlannedFFT<typename FermionField::vector_object>((GridCartesian *)this->FermionGrid());
|
GridBase *_thePlannedFFTGrid{nullptr};
|
||||||
return *_fermionGridFFT;
|
PlannedFFT<typename FermionField::vector_object> & ThePlannedFFT(GridBase *grid) {
|
||||||
|
if ( _thePlannedFFT == nullptr || _thePlannedFFTGrid != grid ) {
|
||||||
|
if ( _thePlannedFFT != nullptr ) delete _thePlannedFFT; // active grid changed: rebuild
|
||||||
|
_thePlannedFFT = new PlannedFFT<typename FermionField::vector_object>((GridCartesian *)grid);
|
||||||
|
_thePlannedFFTGrid = grid;
|
||||||
|
}
|
||||||
|
return *_thePlannedFFT;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
virtual void FreePropagator(const FermionField &in,FermionField &out,RealD mass,std::vector<Complex> boundary,std::vector<double> twist)
|
virtual void FreePropagator(const FermionField &in,FermionField &out,RealD mass,std::vector<Complex> boundary,std::vector<double> twist)
|
||||||
{
|
{
|
||||||
GRID_ASSERT(in.Grid() == this->FermionGrid());
|
PlannedFFT<typename FermionField::vector_object> &theFFT = this->ThePlannedFFT(in.Grid());
|
||||||
PlannedFFT<typename FermionField::vector_object> &theFFT = this->FermionGridFFT();
|
|
||||||
|
|
||||||
typedef typename Simd::scalar_type Scalar;
|
typedef typename Simd::scalar_type Scalar;
|
||||||
|
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ public:
|
|||||||
FermionField in_k(in.Grid());
|
FermionField in_k(in.Grid());
|
||||||
FermionField prop_k(in.Grid());
|
FermionField prop_k(in.Grid());
|
||||||
|
|
||||||
GRID_ASSERT(in.Grid() == this->FermionGrid());
|
PlannedFFT<typename FermionField::vector_object> &theFFT = this->ThePlannedFFT(in.Grid());
|
||||||
PlannedFFT<typename FermionField::vector_object> &theFFT = this->FermionGridFFT();
|
|
||||||
|
|
||||||
//phase for boundary condition
|
//phase for boundary condition
|
||||||
ComplexField coor(in.Grid());
|
ComplexField coor(in.Grid());
|
||||||
|
|||||||
Reference in New Issue
Block a user