1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 01:35:36 +00:00

FFT improved and test_FFT passing under MPI 8 processes, 8^4 for LatticeComplexD and LatticeSpinMatrixD

This commit is contained in:
paboyle 2016-08-18 02:23:21 +01:00
parent 17097a93ec
commit e423a09974
3 changed files with 42 additions and 34 deletions

View File

@ -93,15 +93,12 @@ namespace Grid {
Lattice<sobj> plresult(&pencil_l); Lattice<sobj> plresult(&pencil_l);
{ {
assert(sizeof(typename sobj::scalar_type)==sizeof(ComplexD)); assert(sizeof(typename sobj::scalar_type)==sizeof(ComplexD));
assert(sizeof(fftw_complex)==sizeof(ComplexD)); assert(sizeof(fftw_complex)==sizeof(ComplexD));
assert(sizeof(fftw_complex)==sizeof(ComplexD)); assert(sizeof(fftw_complex)==sizeof(ComplexD));
int Ncomp = sizeof(sobj)/sizeof(fftw_complex); int Ncomp = sizeof(sobj)/sizeof(fftw_complex);
std::cout << "Ncomp = "<<Ncomp<<std::endl;
int rank = 1; /* not 2: we are computing 1d transforms */ int rank = 1; /* not 2: we are computing 1d transforms */
int n[] = {G}; /* 1d transforms of length G */ int n[] = {G}; /* 1d transforms of length G */
int howmany = Ncomp; int howmany = Ncomp;
@ -123,11 +120,9 @@ namespace Grid {
ostride, odist, ostride, odist,
sign,FFTW_ESTIMATE); sign,FFTW_ESTIMATE);
// Barrel shift and collect global pencil // Barrel shift and collect global pencil
for(int p=0;p<processors[dim];p++) { for(int p=0;p<processors[dim];p++) {
for(int idx=0;idx<sgrid->lSites();idx++) { for(int idx=0;idx<sgrid->lSites();idx++) {
std::vector<int> lcoor(Nd); std::vector<int> lcoor(Nd);
@ -145,8 +140,6 @@ namespace Grid {
ssource = Cshift(ssource,dim,L); ssource = Cshift(ssource,dim,L);
} }
std::cout << " pgsource pencil " << pgsource<<std::endl ;
// Loop over orthog coords // Loop over orthog coords
for(int idx=0;idx<sgrid->lSites();idx++) { for(int idx=0;idx<sgrid->lSites();idx++) {
@ -165,11 +158,6 @@ namespace Grid {
pokeLocalSite(s,plsource,pcoor); pokeLocalSite(s,plsource,pcoor);
} }
if ( idx==0) {
std::cout << " plsource pencil " << pgsource<<std::endl ;
}
// FFT the pencil // FFT the pencil
fftw_execute(p); fftw_execute(p);

View File

@ -36,7 +36,6 @@ template<class obj> inline auto func(const iScalar<obj> &z) -> iScalar<obj>\
{\ {\
iScalar<obj> ret;\ iScalar<obj> ret;\
ret._internal = func( (z._internal));\ ret._internal = func( (z._internal));\
std::cout << "Unary "<<#func<<" " << z._internal <<" -> "<< ret._internal <<" "<< typeid(obj).name() <<std::endl; \
return ret;\ return ret;\
}\ }\
template<class obj,int N> inline auto func(const iVector<obj,N> &z) -> iVector<obj,N>\ template<class obj,int N> inline auto func(const iVector<obj,N> &z) -> iVector<obj,N>\

View File

@ -39,6 +39,10 @@ int main (int argc, char ** argv)
std::vector<int> simd_layout( { vComplexD::Nsimd(),1,1,1}); std::vector<int> simd_layout( { vComplexD::Nsimd(),1,1,1});
std::vector<int> mpi_layout = GridDefaultMpi(); std::vector<int> mpi_layout = GridDefaultMpi();
int vol = 1;
for(int d=0;d<latt_size.size();d++){
vol = vol * latt_size[d];
}
GridCartesian Fine(latt_size,simd_layout,mpi_layout); GridCartesian Fine(latt_size,simd_layout,mpi_layout);
LatticeComplexD one(&Fine); LatticeComplexD one(&Fine);
@ -47,7 +51,10 @@ int main (int argc, char ** argv)
LatticeComplexD Ctilde(&Fine); LatticeComplexD Ctilde(&Fine);
LatticeComplexD coor(&Fine); LatticeComplexD coor(&Fine);
std::vector<RealD> p({1.0,2.0,3.0,2.0}); LatticeSpinMatrixD S(&Fine);
LatticeSpinMatrixD Stilde(&Fine);
std::vector<int> p({1,2,3,2});
one = ComplexD(1.0,0.0); one = ComplexD(1.0,0.0);
zz = ComplexD(0.0,0.0); zz = ComplexD(0.0,0.0);
@ -58,30 +65,44 @@ int main (int argc, char ** argv)
for(int mu=0;mu<4;mu++){ for(int mu=0;mu<4;mu++){
RealD TwoPiL = M_PI * 2.0/ latt_size[mu]; RealD TwoPiL = M_PI * 2.0/ latt_size[mu];
LatticeCoordinate(coor,mu); LatticeCoordinate(coor,mu);
C = C - TwoPiL * p[mu] * coor; C = C - (TwoPiL * p[mu]) * coor;
} }
std::cout << GridLogMessage<< " C " << C<<std::endl; C = exp(C*ci);
C = C*ci; S=zero;
std::cout << GridLogMessage<< " C " << C<<std::endl; S = S+C;
C = exp(C);
std::cout << GridLogMessage<< " C " << C<<std::endl;
FFT theFFT(&Fine); FFT theFFT(&Fine);
theFFT.FFT_dim(Ctilde,C,0,FFT::forward);
std::cout << GridLogMessage<< "FT[C] " << Ctilde<<std::endl;
C=Ctilde; theFFT.FFT_dim(Ctilde,C,0,FFT::forward); C=Ctilde;
theFFT.FFT_dim(Ctilde,C,1,FFT::forward); theFFT.FFT_dim(Ctilde,C,1,FFT::forward); C=Ctilde;
std::cout << GridLogMessage<< "FT[C] " << Ctilde<<std::endl; theFFT.FFT_dim(Ctilde,C,2,FFT::forward); C=Ctilde;
C=Ctilde;
theFFT.FFT_dim(Ctilde,C,2,FFT::forward);
std::cout << GridLogMessage<< "FT[C] " << Ctilde<<std::endl;
C=Ctilde;
theFFT.FFT_dim(Ctilde,C,3,FFT::forward); theFFT.FFT_dim(Ctilde,C,3,FFT::forward);
std::cout << GridLogMessage<< "FT[C] " << Ctilde<<std::endl;
// C=zero;
// Ctilde = where(abs(Ctilde)<1.0e-10,C,Ctilde);
TComplexD cVol;
cVol()()() = vol;
C=zero;
pokeSite(cVol,C,p);
C=C-Ctilde;
std::cout << "diff scalar "<<norm2(C) << std::endl;
theFFT.FFT_dim(Stilde,S,0,FFT::forward); S=Stilde;
theFFT.FFT_dim(Stilde,S,1,FFT::forward); S=Stilde;
theFFT.FFT_dim(Stilde,S,2,FFT::forward); S=Stilde;
theFFT.FFT_dim(Stilde,S,3,FFT::forward);
SpinMatrixD Sp;
Sp = zero; Sp = Sp+cVol;
S=zero;
pokeSite(Sp,S,p);
S= S-Stilde;
std::cout << "diff FT[SpinMat] "<<norm2(S) << std::endl;
Grid_finalize(); Grid_finalize();
} }