1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +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,23 +93,20 @@ namespace Grid {
Lattice<sobj> plresult(&pencil_l);
{
assert(sizeof(typename sobj::scalar_type)==sizeof(ComplexD));
assert(sizeof(fftw_complex)==sizeof(ComplexD));
assert(sizeof(fftw_complex)==sizeof(ComplexD));
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 howmany = Ncomp;
int odist,idist,istride,ostride;
idist = odist = 1;
istride = ostride = Ncomp; /* distance between two elements in the same column */
int *inembed = n, *onembed = n;
fftw_complex *in = (fftw_complex *)&plsource._odata[0];
fftw_complex *out= (fftw_complex *)&plresult._odata[0];
@ -123,11 +120,9 @@ namespace Grid {
ostride, odist,
sign,FFTW_ESTIMATE);
// Barrel shift and collect global pencil
for(int p=0;p<processors[dim];p++) {
for(int idx=0;idx<sgrid->lSites();idx++) {
std::vector<int> lcoor(Nd);
@ -144,8 +139,6 @@ namespace Grid {
ssource = Cshift(ssource,dim,L);
}
std::cout << " pgsource pencil " << pgsource<<std::endl ;
// Loop over orthog coords
for(int idx=0;idx<sgrid->lSites();idx++) {
@ -165,11 +158,6 @@ namespace Grid {
pokeLocalSite(s,plsource,pcoor);
}
if ( idx==0) {
std::cout << " plsource pencil " << pgsource<<std::endl ;
}
// FFT the pencil
fftw_execute(p);

View File

@ -36,7 +36,6 @@ template<class obj> inline auto func(const iScalar<obj> &z) -> iScalar<obj>\
{\
iScalar<obj> ret;\
ret._internal = func( (z._internal));\
std::cout << "Unary "<<#func<<" " << z._internal <<" -> "<< ret._internal <<" "<< typeid(obj).name() <<std::endl; \
return ret;\
}\
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> 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);
LatticeComplexD one(&Fine);
@ -46,8 +50,11 @@ int main (int argc, char ** argv)
LatticeComplexD C(&Fine);
LatticeComplexD Ctilde(&Fine);
LatticeComplexD coor(&Fine);
LatticeSpinMatrixD S(&Fine);
LatticeSpinMatrixD Stilde(&Fine);
std::vector<RealD> p({1.0,2.0,3.0,2.0});
std::vector<int> p({1,2,3,2});
one = ComplexD(1.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++){
RealD TwoPiL = M_PI * 2.0/ latt_size[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;
std::cout << GridLogMessage<< " C " << C<<std::endl;
C = exp(C);
std::cout << GridLogMessage<< " C " << C<<std::endl;
S=zero;
S = S+C;
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,1,FFT::forward);
std::cout << GridLogMessage<< "FT[C] " << Ctilde<<std::endl;
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,0,FFT::forward); C=Ctilde;
theFFT.FFT_dim(Ctilde,C,1,FFT::forward); C=Ctilde;
theFFT.FFT_dim(Ctilde,C,2,FFT::forward); C=Ctilde;
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();
}