mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	Adding tests for WilsonFlow classes
This commit is contained in:
		
							
								
								
									
										65
									
								
								lib/Init.cc
									
									
									
									
									
								
							
							
						
						
									
										65
									
								
								lib/Init.cc
									
									
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
    /*************************************************************************************
 | 
			
		||||
 | 
			
		||||
    Grid physics library, www.github.com/paboyle/Grid 
 | 
			
		||||
    Grid physics library, www.github.com/paboyle/Grid
 | 
			
		||||
 | 
			
		||||
    Source file: ./lib/Init.cc
 | 
			
		||||
 | 
			
		||||
@@ -36,7 +36,7 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <sys/mman.h>
 | 
			
		||||
#include <sys/stat.h> 
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <sys/time.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
@@ -92,14 +92,14 @@ const std::vector<int> GridDefaultSimd(int dims,int nsimd)
 | 
			
		||||
      if ( nn>=2) {
 | 
			
		||||
	layout[d]=2;
 | 
			
		||||
	nn/=2;
 | 
			
		||||
      } else { 
 | 
			
		||||
      } else {
 | 
			
		||||
	layout[d]=1;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    assert(nn==1);
 | 
			
		||||
    return layout;
 | 
			
		||||
}
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////
 | 
			
		||||
// Command line parsing assist for stock controls
 | 
			
		||||
////////////////////////////////////////////////////////////
 | 
			
		||||
@@ -143,7 +143,7 @@ void GridCmdOptionIntVector(std::string &str,std::vector<int> & vec)
 | 
			
		||||
    vec.push_back(i);
 | 
			
		||||
    if(std::ispunct(ss.peek()))
 | 
			
		||||
      ss.ignore();
 | 
			
		||||
  }    
 | 
			
		||||
  }
 | 
			
		||||
  return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -248,24 +248,24 @@ void Grid_init(int *argc,char ***argv)
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --help : this message"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"Geometry:"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --mpi n.n.n.n   : default MPI decomposition"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --mpi n.n.n.n   : default MPI decomposition"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --threads n     : default number of OMP threads"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --grid n.n.n.n  : default Grid size"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --shm  M        : allocate M megabytes of shared memory for comms"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --grid n.n.n.n  : default Grid size"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --shm  M        : allocate M megabytes of shared memory for comms"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"Verbose and debug:"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --log list      : comma separted list of streams from Error,Warning,Message,Performance,Iterative,Integrator,Debug,Colours"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --decomposition : report on default omp,mpi and simd decomposition"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --decomposition : report on default omp,mpi and simd decomposition"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --debug-signals : catch sigsegv and print a blame report"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --debug-stdout  : print stdout from EVERY node"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --notimestamp   : suppress millisecond resolution stamps"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --debug-stdout  : print stdout from EVERY node"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --notimestamp   : suppress millisecond resolution stamps"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"Performance:"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --dslash-generic: Wilson kernel for generic Nc"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --dslash-unroll : Wilson kernel for Nc=3"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --dslash-asm    : Wilson kernel for AVX512"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --lebesgue      : Cache oblivious Lebesgue curve/Morton order/Z-graph stencil looping"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --cacheblocking n.m.o.p : Hypercuboidal cache blocking"<<std::endl;    
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --dslash-generic: Wilson kernel for generic Nc"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --dslash-unroll : Wilson kernel for Nc=3"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --dslash-asm    : Wilson kernel for AVX512"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --lebesgue      : Cache oblivious Lebesgue curve/Morton order/Z-graph stencil looping"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<"  --cacheblocking n.m.o.p : Hypercuboidal cache blocking"<<std::endl;
 | 
			
		||||
    std::cout<<GridLogMessage<<std::endl;
 | 
			
		||||
    exit(EXIT_SUCCESS);
 | 
			
		||||
  }
 | 
			
		||||
@@ -281,22 +281,22 @@ void Grid_init(int *argc,char ***argv)
 | 
			
		||||
  std::string COL_BLUE   = GridLogColours.colour["BLUE"];
 | 
			
		||||
  std::string COL_YELLOW = GridLogColours.colour["YELLOW"];
 | 
			
		||||
  std::string COL_BACKGROUND = GridLogColours.colour["NORMAL"];
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  std::cout <<std::endl;
 | 
			
		||||
  std::cout <<COL_RED  << "__|__|__|__|__"<<             "|__|__|_"<<COL_PURPLE<<"_|__|__|"<<                "__|__|__|__|__"<<std::endl; 
 | 
			
		||||
  std::cout <<COL_RED  << "__|__|__|__|__"<<             "|__|__|_"<<COL_PURPLE<<"_|__|__|"<<                "__|__|__|__|__"<<std::endl; 
 | 
			
		||||
  std::cout <<COL_RED  << "__|_ |  |  |  "<<             "|  |  | "<<COL_PURPLE<<" |  |  |"<<                "  |  |  | _|__"<<std::endl; 
 | 
			
		||||
  std::cout <<COL_RED  << "__|_          "<<             "        "<<COL_PURPLE<<"        "<<                "          _|__"<<std::endl; 
 | 
			
		||||
  std::cout <<COL_RED  << "__|__|__|__|__"<<             "|__|__|_"<<COL_PURPLE<<"_|__|__|"<<                "__|__|__|__|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_RED  << "__|__|__|__|__"<<             "|__|__|_"<<COL_PURPLE<<"_|__|__|"<<                "__|__|__|__|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_RED  << "__|_ |  |  |  "<<             "|  |  | "<<COL_PURPLE<<" |  |  |"<<                "  |  |  | _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_RED  << "__|_          "<<             "        "<<COL_PURPLE<<"        "<<                "          _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_RED  << "__|_  "<<COL_GREEN<<" GGGG   "<<COL_RED<<" RRRR   "<<COL_BLUE  <<" III    "<<COL_PURPLE<<"DDDD  "<<COL_PURPLE<<"    _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_RED  << "__|_  "<<COL_GREEN<<"G       "<<COL_RED<<" R   R  "<<COL_BLUE  <<"  I     "<<COL_PURPLE<<"D   D "<<COL_PURPLE<<"    _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_RED  << "__|_  "<<COL_GREEN<<"G       "<<COL_RED<<" R   R  "<<COL_BLUE  <<"  I     "<<COL_PURPLE<<"D    D"<<COL_PURPLE<<"    _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_BLUE << "__|_  "<<COL_GREEN<<"G  GG   "<<COL_RED<<" RRRR   "<<COL_BLUE  <<"  I     "<<COL_PURPLE<<"D    D"<<COL_GREEN <<"    _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_BLUE << "__|_  "<<COL_GREEN<<"G   G   "<<COL_RED<<" R  R   "<<COL_BLUE  <<"  I     "<<COL_PURPLE<<"D   D "<<COL_GREEN <<"    _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_BLUE << "__|_  "<<COL_GREEN<<" GGGG   "<<COL_RED<<" R   R  "<<COL_BLUE  <<" III    "<<COL_PURPLE<<"DDDD  "<<COL_GREEN <<"    _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_BLUE << "__|_          "<<             "        "<<COL_GREEN <<"        "<<                "          _|__"<<std::endl; 
 | 
			
		||||
  std::cout <<COL_BLUE << "__|__|__|__|__"<<             "|__|__|_"<<COL_GREEN <<"_|__|__|"<<                "__|__|__|__|__"<<std::endl; 
 | 
			
		||||
  std::cout <<COL_BLUE << "__|__|__|__|__"<<             "|__|__|_"<<COL_GREEN <<"_|__|__|"<<                "__|__|__|__|__"<<std::endl; 
 | 
			
		||||
  std::cout <<COL_BLUE << "  |  |  |  |  "<<             "|  |  | "<<COL_GREEN <<" |  |  |"<<                "  |  |  |  |  "<<std::endl; 
 | 
			
		||||
  std::cout <<COL_BLUE << "__|_          "<<             "        "<<COL_GREEN <<"        "<<                "          _|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_BLUE << "__|__|__|__|__"<<             "|__|__|_"<<COL_GREEN <<"_|__|__|"<<                "__|__|__|__|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_BLUE << "__|__|__|__|__"<<             "|__|__|_"<<COL_GREEN <<"_|__|__|"<<                "__|__|__|__|__"<<std::endl;
 | 
			
		||||
  std::cout <<COL_BLUE << "  |  |  |  |  "<<             "|  |  | "<<COL_GREEN <<" |  |  |"<<                "  |  |  |  |  "<<std::endl;
 | 
			
		||||
  std::cout << std::endl;
 | 
			
		||||
  std::cout << std::endl;
 | 
			
		||||
  std::cout <<COL_YELLOW<< std::endl;
 | 
			
		||||
@@ -342,7 +342,7 @@ void Grid_init(int *argc,char ***argv)
 | 
			
		||||
  }
 | 
			
		||||
  if( GridCmdOptionExists(*argv,*argv+*argc,"--notimestamp") ){
 | 
			
		||||
    GridLogTimestamp(0);
 | 
			
		||||
  } else { 
 | 
			
		||||
  } else {
 | 
			
		||||
    GridLogTimestamp(1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -350,7 +350,7 @@ void Grid_init(int *argc,char ***argv)
 | 
			
		||||
		  Grid_default_latt,
 | 
			
		||||
		  Grid_default_mpi);
 | 
			
		||||
 | 
			
		||||
  std::cout << GridLogMessage << "Requesting "<< CartesianCommunicator::MAX_MPI_SHM_BYTES <<" byte stencil comms buffers "<<std::endl;
 | 
			
		||||
  std::cout << GridLogDebug << "Requesting "<< CartesianCommunicator::MAX_MPI_SHM_BYTES <<" byte stencil comms buffers "<<std::endl;
 | 
			
		||||
 | 
			
		||||
  if( GridCmdOptionExists(*argv,*argv+*argc,"--decomposition") ){
 | 
			
		||||
    std::cout<<GridLogMessage<<"Grid Decomposition\n";
 | 
			
		||||
@@ -366,15 +366,22 @@ void Grid_init(int *argc,char ***argv)
 | 
			
		||||
  Grid_is_initialised = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
void Grid_finalize(void)
 | 
			
		||||
{
 | 
			
		||||
#if defined (GRID_COMMS_MPI) || defined (GRID_COMMS_MPI3) 
 | 
			
		||||
#if defined (GRID_COMMS_MPI) || defined (GRID_COMMS_MPI3)
 | 
			
		||||
  MPI_Finalize();
 | 
			
		||||
  Grid_unquiesce_nodes();
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GridLogLayout() {
 | 
			
		||||
    std::cout << GridLogMessage << "Grid Layout\n";
 | 
			
		||||
    std::cout << GridLogMessage << "\tGlobal lattice size  : "<< GridCmdVectorIntToString(GridDefaultLatt()) << std::endl;
 | 
			
		||||
    std::cout << GridLogMessage << "\tOpenMP threads       : "<< GridThread::GetThreads() <<std::endl;
 | 
			
		||||
    std::cout << GridLogMessage << "\tMPI tasks            : "<< GridCmdVectorIntToString(GridDefaultMpi()) << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void * Grid_backtrace_buffer[_NBACKTRACE];
 | 
			
		||||
 | 
			
		||||
void Grid_sa_signal_handler(int sig,siginfo_t *si,void * ptr)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
    /*************************************************************************************
 | 
			
		||||
 | 
			
		||||
    Grid physics library, www.github.com/paboyle/Grid 
 | 
			
		||||
    Grid physics library, www.github.com/paboyle/Grid
 | 
			
		||||
 | 
			
		||||
    Source file: ./lib/Init.h
 | 
			
		||||
 | 
			
		||||
@@ -46,6 +46,7 @@ namespace Grid {
 | 
			
		||||
  const int              &GridThreads(void)  ;
 | 
			
		||||
  void                    GridSetThreads(int t) ;
 | 
			
		||||
  void GridLogTimestamp(int);
 | 
			
		||||
  void GridLogLayout();
 | 
			
		||||
 | 
			
		||||
  // Common parsing chores
 | 
			
		||||
  std::string GridCmdOptionPayload(char ** begin, char ** end, const std::string & option);
 | 
			
		||||
 
 | 
			
		||||
@@ -38,9 +38,9 @@ class WilsonFlow: public Smear<Gimpl>{
 | 
			
		||||
    unsigned int Nstep;
 | 
			
		||||
    RealD epsilon;
 | 
			
		||||
 | 
			
		||||
    WilsonGaugeAction<Gimpl> &SG;
 | 
			
		||||
    mutable WilsonGaugeAction<Gimpl> SG;
 | 
			
		||||
 | 
			
		||||
    void evolve_step(typename Gimpl::GaugeField&);
 | 
			
		||||
    void evolve_step(typename Gimpl::GaugeField&) const;
 | 
			
		||||
    RealD tau(unsigned int t)const {return epsilon*(t+1.0); }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -50,7 +50,7 @@ class WilsonFlow: public Smear<Gimpl>{
 | 
			
		||||
    explicit WilsonFlow(unsigned int Nstep, RealD epsilon):
 | 
			
		||||
        Nstep(Nstep),
 | 
			
		||||
        epsilon(epsilon),
 | 
			
		||||
        SG(3.0) {
 | 
			
		||||
        SG(WilsonGaugeAction<Gimpl>(3.0)) {
 | 
			
		||||
            // WilsonGaugeAction with beta 3.0
 | 
			
		||||
            assert(epsilon > 0.0);
 | 
			
		||||
            LogMessage();
 | 
			
		||||
@@ -58,24 +58,29 @@ class WilsonFlow: public Smear<Gimpl>{
 | 
			
		||||
 | 
			
		||||
    void LogMessage() {
 | 
			
		||||
        std::cout << GridLogMessage
 | 
			
		||||
            << "[WilsonFlow] Nstep   : " << Nstep
 | 
			
		||||
            << "[WilsonFlow] epsilon : " << epsilon
 | 
			
		||||
            << "[WilsonFlow] full trajectory : " << Nstep * epsilon
 | 
			
		||||
            << std::endl;
 | 
			
		||||
            << "[WilsonFlow] Nstep   : " << Nstep << std::endl;
 | 
			
		||||
        std::cout << GridLogMessage
 | 
			
		||||
            << "[WilsonFlow] epsilon : " << epsilon << std::endl;
 | 
			
		||||
        std::cout << GridLogMessage
 | 
			
		||||
            << "[WilsonFlow] full trajectory : " << Nstep * epsilon << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void smear(GaugeField&, const GaugeField&) const;
 | 
			
		||||
 | 
			
		||||
    virtual void derivative(GaugeField&, const GaugeField&, const GaugeField&) const {
 | 
			
		||||
                  assert(0);
 | 
			
		||||
                  // undefined for WilsonFlow
 | 
			
		||||
        assert(0);
 | 
			
		||||
        // undefined for WilsonFlow
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    RealD energyDensityPlaquette(unsigned int step, const GaugeField& U) const;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// Implementations
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
template <class Gimpl>
 | 
			
		||||
void WilsonFlow<Gimpl>::evolve_step(typename Gimpl::GaugeField &U) {
 | 
			
		||||
void WilsonFlow<Gimpl>::evolve_step(typename Gimpl::GaugeField &U) const{
 | 
			
		||||
    GaugeField Z(U._grid);
 | 
			
		||||
    GaugeField tmp(U._grid);
 | 
			
		||||
    SG.deriv(U, Z);
 | 
			
		||||
@@ -104,13 +109,11 @@ void WilsonFlow<Gimpl>::smear(GaugeField& out, const GaugeField& in) const {
 | 
			
		||||
    out = in;
 | 
			
		||||
    for (unsigned int step = 0; step < Nstep; step++) {
 | 
			
		||||
        evolve_step(out);
 | 
			
		||||
        // Energy density, plaquette
 | 
			
		||||
        std::cout << GridLogMessage
 | 
			
		||||
            << "[WilsonFlow] Energy Density (step) : "
 | 
			
		||||
            << step
 | 
			
		||||
            << " " << energyDensityPlaquette(step, out)
 | 
			
		||||
            << std::endl;
 | 
			
		||||
}
 | 
			
		||||
        std::cout << "[WilsonFlow] Energy density (plaq) : "
 | 
			
		||||
            << step << " "
 | 
			
		||||
            << energyDensityPlaquette(step,out) << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace QCD
 | 
			
		||||
 
 | 
			
		||||
@@ -99,6 +99,7 @@ public:
 | 
			
		||||
  //////////////////////////////////////////////////
 | 
			
		||||
  static RealD sumPlaquette(const GaugeLorentz &Umu) {
 | 
			
		||||
    std::vector<GaugeMat> U(Nd, Umu._grid);
 | 
			
		||||
    // inefficient here
 | 
			
		||||
    for (int mu = 0; mu < Nd; mu++) {
 | 
			
		||||
      U[mu] = PeekIndex<LorentzIndex>(Umu, mu);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user