mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-03 21:44:33 +00:00 
			
		
		
		
	Compare commits
	
		
			9 Commits
		
	
	
		
			249c7aee39
			...
			feature/ft
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					09146cfc43 | ||
| 
						 | 
					a450e96827 | ||
| 
						 | 
					0f3678b9be | ||
| 
						 | 
					8dd8338e14 | ||
| 
						 | 
					11e0dc9851 | ||
| 
						 | 
					f4ef6dae43 | ||
| 
						 | 
					b6e147372b | ||
| 
						 | 
					3a4a662dc6 | ||
| 
						 | 
					8d06bda6fb | 
@@ -66,10 +66,6 @@ if BUILD_FERMION_REPS
 | 
				
			|||||||
  extra_sources+=$(ADJ_FERMION_FILES)
 | 
					  extra_sources+=$(ADJ_FERMION_FILES)
 | 
				
			||||||
  extra_sources+=$(TWOIND_FERMION_FILES)
 | 
					  extra_sources+=$(TWOIND_FERMION_FILES)
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
if BUILD_SP
 | 
					 | 
				
			||||||
    extra_sources+=$(SP_FERMION_FILES)
 | 
					 | 
				
			||||||
    extra_sources+=$(SP_TWOIND_FERMION_FILES)
 | 
					 | 
				
			||||||
endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
lib_LIBRARIES = libGrid.a
 | 
					lib_LIBRARIES = libGrid.a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -419,15 +419,14 @@ until convergence
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if ( Nconv < Nstop ) {
 | 
					      if ( Nconv < Nstop )
 | 
				
			||||||
	std::cout << GridLogIRL << "Nconv ("<<Nconv<<") < Nstop ("<<Nstop<<")"<<std::endl;
 | 
						std::cout << GridLogIRL << "Nconv ("<<Nconv<<") < Nstop ("<<Nstop<<")"<<std::endl;
 | 
				
			||||||
	std::cout << GridLogIRL << "returning Nstop vectors, the last "<< Nstop-Nconv << "of which might meet convergence criterion only approximately" <<std::endl;
 | 
					
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      eval=eval2;
 | 
					      eval=eval2;
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      //Keep only converged
 | 
					      //Keep only converged
 | 
				
			||||||
      eval.resize(Nstop);// was Nconv
 | 
					      eval.resize(Nconv);// Nstop?
 | 
				
			||||||
      evec.resize(Nstop,grid);// was Nconv
 | 
					      evec.resize(Nconv,grid);// Nstop?
 | 
				
			||||||
      basisSortInPlace(evec,eval,reverse);
 | 
					      basisSortInPlace(evec,eval,reverse);
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -222,9 +222,6 @@ void MemoryManager::InitMessage(void) {
 | 
				
			|||||||
#ifdef GRID_SYCL
 | 
					#ifdef GRID_SYCL
 | 
				
			||||||
  std::cout << GridLogMessage<< "MemoryManager::Init() Using SYCL malloc_shared"<<std::endl;
 | 
					  std::cout << GridLogMessage<< "MemoryManager::Init() Using SYCL malloc_shared"<<std::endl;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef GRID_OMPTARGET
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage<< "MemoryManager::Init() Using OMPTARGET managed memory"<<std::endl;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
  std::cout << GridLogMessage<< "MemoryManager::Init() Non unified: Caching accelerator data in dedicated memory"<<std::endl;
 | 
					  std::cout << GridLogMessage<< "MemoryManager::Init() Non unified: Caching accelerator data in dedicated memory"<<std::endl;
 | 
				
			||||||
#ifdef GRID_CUDA
 | 
					#ifdef GRID_CUDA
 | 
				
			||||||
@@ -236,9 +233,6 @@ void MemoryManager::InitMessage(void) {
 | 
				
			|||||||
#ifdef GRID_SYCL
 | 
					#ifdef GRID_SYCL
 | 
				
			||||||
  std::cout << GridLogMessage<< "MemoryManager::Init() Using SYCL malloc_device"<<std::endl;
 | 
					  std::cout << GridLogMessage<< "MemoryManager::Init() Using SYCL malloc_device"<<std::endl;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef GRID_OMPTARGET
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage<< "MemoryManager::Init() Using OMPTARGET omp_alloc_device"<<std::endl;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -604,8 +604,8 @@ void GlobalSharedMemory::SharedMemoryAllocate(uint64_t bytes, int flags)
 | 
				
			|||||||
#ifdef GRID_SYCL_LEVEL_ZERO_IPC
 | 
					#ifdef GRID_SYCL_LEVEL_ZERO_IPC
 | 
				
			||||||
    typedef struct { int fd; pid_t pid ; ze_ipc_mem_handle_t ze; } clone_mem_t;
 | 
					    typedef struct { int fd; pid_t pid ; ze_ipc_mem_handle_t ze; } clone_mem_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    auto zeDevice    = cl::sycl::get_native<cl::sycl::backend::ext_oneapi_level_zero>(theGridAccelerator->get_device());
 | 
					    auto zeDevice    = cl::sycl::get_native<cl::sycl::backend::level_zero>(theGridAccelerator->get_device());
 | 
				
			||||||
    auto zeContext   = cl::sycl::get_native<cl::sycl::backend::ext_oneapi_level_zero>(theGridAccelerator->get_context());
 | 
					    auto zeContext   = cl::sycl::get_native<cl::sycl::backend::level_zero>(theGridAccelerator->get_context());
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
    ze_ipc_mem_handle_t ihandle;
 | 
					    ze_ipc_mem_handle_t ihandle;
 | 
				
			||||||
    clone_mem_t handle;
 | 
					    clone_mem_t handle;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,8 +68,7 @@ void GlobalSharedMemory::SharedMemoryAllocate(uint64_t bytes, int flags)
 | 
				
			|||||||
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
					  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
  // Each MPI rank should allocate our own buffer
 | 
					  // Each MPI rank should allocate our own buffer
 | 
				
			||||||
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
					  ///////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
  ShmCommBuf = acceleratorAllocShared(bytes);
 | 
					  ShmCommBuf = acceleratorAllocDevice(bytes);
 | 
				
			||||||
  //ShmCommBuf = acceleratorAllocDevice(bytes);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (ShmCommBuf == (void *)NULL ) {
 | 
					  if (ShmCommBuf == (void *)NULL ) {
 | 
				
			||||||
    std::cerr << " SharedMemoryNone.cc acceleratorAllocDevice failed NULL pointer for " << bytes<<" bytes " << std::endl;
 | 
					    std::cerr << " SharedMemoryNone.cc acceleratorAllocDevice failed NULL pointer for " << bytes<<" bytes " << std::endl;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,27 +29,8 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
NAMESPACE_BEGIN(Grid);
 | 
					NAMESPACE_BEGIN(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern std::vector<std::pair<int,int> > Cshift_table; 
 | 
					extern Vector<std::pair<int,int> > Cshift_table; 
 | 
				
			||||||
extern commVector<std::pair<int,int> > Cshift_table_device; 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline std::pair<int,int> *MapCshiftTable(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  // GPU version
 | 
					 | 
				
			||||||
#ifdef ACCELERATOR_CSHIFT    
 | 
					 | 
				
			||||||
  uint64_t sz=Cshift_table.size();
 | 
					 | 
				
			||||||
  if (Cshift_table_device.size()!=sz )    {
 | 
					 | 
				
			||||||
    Cshift_table_device.resize(sz);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  acceleratorCopyToDevice((void *)&Cshift_table[0],
 | 
					 | 
				
			||||||
			  (void *)&Cshift_table_device[0],
 | 
					 | 
				
			||||||
			  sizeof(Cshift_table[0])*sz);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return &Cshift_table_device[0];
 | 
					 | 
				
			||||||
#else 
 | 
					 | 
				
			||||||
  return &Cshift_table[0];
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
  // CPU version use identify map
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Gather for when there is no need to SIMD split 
 | 
					// Gather for when there is no need to SIMD split 
 | 
				
			||||||
///////////////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////////////
 | 
				
			||||||
@@ -93,7 +74,7 @@ Gather_plane_simple (const Lattice<vobj> &rhs,cshiftVector<vobj> &buffer,int dim
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    auto buffer_p = & buffer[0];
 | 
					    auto buffer_p = & buffer[0];
 | 
				
			||||||
    auto table = MapCshiftTable();
 | 
					    auto table = &Cshift_table[0];
 | 
				
			||||||
#ifdef ACCELERATOR_CSHIFT    
 | 
					#ifdef ACCELERATOR_CSHIFT    
 | 
				
			||||||
    autoView(rhs_v , rhs, AcceleratorRead);
 | 
					    autoView(rhs_v , rhs, AcceleratorRead);
 | 
				
			||||||
    accelerator_for(i,ent,vobj::Nsimd(),{
 | 
					    accelerator_for(i,ent,vobj::Nsimd(),{
 | 
				
			||||||
@@ -244,7 +225,7 @@ template<class vobj> void Scatter_plane_simple (Lattice<vobj> &rhs,cshiftVector<
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    auto buffer_p = & buffer[0];
 | 
					    auto buffer_p = & buffer[0];
 | 
				
			||||||
    auto table = MapCshiftTable();
 | 
					    auto table = &Cshift_table[0];
 | 
				
			||||||
#ifdef ACCELERATOR_CSHIFT    
 | 
					#ifdef ACCELERATOR_CSHIFT    
 | 
				
			||||||
    autoView( rhs_v, rhs, AcceleratorWrite);
 | 
					    autoView( rhs_v, rhs, AcceleratorWrite);
 | 
				
			||||||
    accelerator_for(i,ent,vobj::Nsimd(),{
 | 
					    accelerator_for(i,ent,vobj::Nsimd(),{
 | 
				
			||||||
@@ -316,6 +297,30 @@ template<class vobj> void Scatter_plane_merge(Lattice<vobj> &rhs,ExtractPointerA
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if (defined(GRID_CUDA) || defined(GRID_HIP)) && defined(ACCELERATOR_CSHIFT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					T iDivUp(T a, T b) // Round a / b to nearest higher integer value
 | 
				
			||||||
 | 
					{ return (a % b != 0) ? (a / b + 1) : (a / b); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					__global__ void populate_Cshift_table(T* vector, T lo, T ro, T e1, T e2, T stride)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int idx = blockIdx.x*blockDim.x + threadIdx.x;
 | 
				
			||||||
 | 
					    if (idx >= e1*e2) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int n, b, o;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    n = idx / e2;
 | 
				
			||||||
 | 
					    b = idx % e2;
 | 
				
			||||||
 | 
					    o = n*stride + b;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    vector[2*idx + 0] = lo + o;
 | 
				
			||||||
 | 
					    vector[2*idx + 1] = ro + o;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//////////////////////////////////////////////////////
 | 
					//////////////////////////////////////////////////////
 | 
				
			||||||
// local to node block strided copies
 | 
					// local to node block strided copies
 | 
				
			||||||
//////////////////////////////////////////////////////
 | 
					//////////////////////////////////////////////////////
 | 
				
			||||||
@@ -340,12 +345,20 @@ template<class vobj> void Copy_plane(Lattice<vobj>& lhs,const Lattice<vobj> &rhs
 | 
				
			|||||||
  int ent=0;
 | 
					  int ent=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if(cbmask == 0x3 ){
 | 
					  if(cbmask == 0x3 ){
 | 
				
			||||||
 | 
					#if (defined(GRID_CUDA) || defined(GRID_HIP)) && defined(ACCELERATOR_CSHIFT)
 | 
				
			||||||
 | 
					    ent = e1*e2;
 | 
				
			||||||
 | 
					    dim3 blockSize(acceleratorThreads());
 | 
				
			||||||
 | 
					    dim3 gridSize(iDivUp((unsigned int)ent, blockSize.x));
 | 
				
			||||||
 | 
					    populate_Cshift_table<<<gridSize, blockSize>>>(&Cshift_table[0].first, lo, ro, e1, e2, stride);
 | 
				
			||||||
 | 
					    accelerator_barrier();
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
    for(int n=0;n<e1;n++){
 | 
					    for(int n=0;n<e1;n++){
 | 
				
			||||||
      for(int b=0;b<e2;b++){
 | 
					      for(int b=0;b<e2;b++){
 | 
				
			||||||
        int o =n*stride+b;
 | 
					        int o =n*stride+b;
 | 
				
			||||||
	Cshift_table[ent++] = std::pair<int,int>(lo+o,ro+o);
 | 
						Cshift_table[ent++] = std::pair<int,int>(lo+o,ro+o);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  } else { 
 | 
					  } else { 
 | 
				
			||||||
    for(int n=0;n<e1;n++){
 | 
					    for(int n=0;n<e1;n++){
 | 
				
			||||||
      for(int b=0;b<e2;b++){
 | 
					      for(int b=0;b<e2;b++){
 | 
				
			||||||
@@ -359,7 +372,7 @@ template<class vobj> void Copy_plane(Lattice<vobj>& lhs,const Lattice<vobj> &rhs
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    auto table = MapCshiftTable();
 | 
					    auto table = &Cshift_table[0];
 | 
				
			||||||
#ifdef ACCELERATOR_CSHIFT    
 | 
					#ifdef ACCELERATOR_CSHIFT    
 | 
				
			||||||
    autoView(rhs_v , rhs, AcceleratorRead);
 | 
					    autoView(rhs_v , rhs, AcceleratorRead);
 | 
				
			||||||
    autoView(lhs_v , lhs, AcceleratorWrite);
 | 
					    autoView(lhs_v , lhs, AcceleratorWrite);
 | 
				
			||||||
@@ -396,11 +409,19 @@ template<class vobj> void Copy_plane_permute(Lattice<vobj>& lhs,const Lattice<vo
 | 
				
			|||||||
  int ent=0;
 | 
					  int ent=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ( cbmask == 0x3 ) {
 | 
					  if ( cbmask == 0x3 ) {
 | 
				
			||||||
 | 
					#if (defined(GRID_CUDA) || defined(GRID_HIP)) && defined(ACCELERATOR_CSHIFT)
 | 
				
			||||||
 | 
					    ent = e1*e2;
 | 
				
			||||||
 | 
					    dim3 blockSize(acceleratorThreads());
 | 
				
			||||||
 | 
					    dim3 gridSize(iDivUp((unsigned int)ent, blockSize.x));
 | 
				
			||||||
 | 
					    populate_Cshift_table<<<gridSize, blockSize>>>(&Cshift_table[0].first, lo, ro, e1, e2, stride);
 | 
				
			||||||
 | 
					    accelerator_barrier();
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
    for(int n=0;n<e1;n++){
 | 
					    for(int n=0;n<e1;n++){
 | 
				
			||||||
    for(int b=0;b<e2;b++){
 | 
					    for(int b=0;b<e2;b++){
 | 
				
			||||||
      int o  =n*stride;
 | 
					      int o  =n*stride;
 | 
				
			||||||
      Cshift_table[ent++] = std::pair<int,int>(lo+o+b,ro+o+b);
 | 
					      Cshift_table[ent++] = std::pair<int,int>(lo+o+b,ro+o+b);
 | 
				
			||||||
    }}
 | 
					    }}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    for(int n=0;n<e1;n++){
 | 
					    for(int n=0;n<e1;n++){
 | 
				
			||||||
    for(int b=0;b<e2;b++){
 | 
					    for(int b=0;b<e2;b++){
 | 
				
			||||||
@@ -411,7 +432,7 @@ template<class vobj> void Copy_plane_permute(Lattice<vobj>& lhs,const Lattice<vo
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    auto table = MapCshiftTable();
 | 
					    auto table = &Cshift_table[0];
 | 
				
			||||||
#ifdef ACCELERATOR_CSHIFT    
 | 
					#ifdef ACCELERATOR_CSHIFT    
 | 
				
			||||||
    autoView( rhs_v, rhs, AcceleratorRead);
 | 
					    autoView( rhs_v, rhs, AcceleratorRead);
 | 
				
			||||||
    autoView( lhs_v, lhs, AcceleratorWrite);
 | 
					    autoView( lhs_v, lhs, AcceleratorWrite);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,8 +52,7 @@ template<class vobj> Lattice<vobj> Cshift(const Lattice<vobj> &rhs,int dimension
 | 
				
			|||||||
  int comm_dim        = rhs.Grid()->_processors[dimension] >1 ;
 | 
					  int comm_dim        = rhs.Grid()->_processors[dimension] >1 ;
 | 
				
			||||||
  int splice_dim      = rhs.Grid()->_simd_layout[dimension]>1 && (comm_dim);
 | 
					  int splice_dim      = rhs.Grid()->_simd_layout[dimension]>1 && (comm_dim);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  RealD t1,t0;
 | 
					
 | 
				
			||||||
  t0=usecond();
 | 
					 | 
				
			||||||
  if ( !comm_dim ) {
 | 
					  if ( !comm_dim ) {
 | 
				
			||||||
    //std::cout << "CSHIFT: Cshift_local" <<std::endl;
 | 
					    //std::cout << "CSHIFT: Cshift_local" <<std::endl;
 | 
				
			||||||
    Cshift_local(ret,rhs,dimension,shift); // Handles checkerboarding
 | 
					    Cshift_local(ret,rhs,dimension,shift); // Handles checkerboarding
 | 
				
			||||||
@@ -64,8 +63,6 @@ template<class vobj> Lattice<vobj> Cshift(const Lattice<vobj> &rhs,int dimension
 | 
				
			|||||||
    //std::cout << "CSHIFT: Cshift_comms" <<std::endl;
 | 
					    //std::cout << "CSHIFT: Cshift_comms" <<std::endl;
 | 
				
			||||||
    Cshift_comms(ret,rhs,dimension,shift);
 | 
					    Cshift_comms(ret,rhs,dimension,shift);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  t1=usecond();
 | 
					 | 
				
			||||||
  //  std::cout << GridLogPerformance << "Cshift took "<< (t1-t0)/1e3 << " ms"<<std::endl;
 | 
					 | 
				
			||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -130,20 +127,16 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
  int cb= (cbmask==0x2)? Odd : Even;
 | 
					  int cb= (cbmask==0x2)? Odd : Even;
 | 
				
			||||||
  int sshift= rhs.Grid()->CheckerBoardShiftForCB(rhs.Checkerboard(),dimension,shift,cb);
 | 
					  int sshift= rhs.Grid()->CheckerBoardShiftForCB(rhs.Checkerboard(),dimension,shift,cb);
 | 
				
			||||||
  RealD tcopy=0.0;
 | 
					
 | 
				
			||||||
  RealD tgather=0.0;
 | 
					 | 
				
			||||||
  RealD tscatter=0.0;
 | 
					 | 
				
			||||||
  RealD tcomms=0.0;
 | 
					 | 
				
			||||||
  uint64_t xbytes=0;
 | 
					 | 
				
			||||||
  for(int x=0;x<rd;x++){       
 | 
					  for(int x=0;x<rd;x++){       
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int sx        =  (x+sshift)%rd;
 | 
					    int sx        =  (x+sshift)%rd;
 | 
				
			||||||
    int comm_proc = ((x+sshift)/rd)%pd;
 | 
					    int comm_proc = ((x+sshift)/rd)%pd;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (comm_proc==0) {
 | 
					    if (comm_proc==0) {
 | 
				
			||||||
      tcopy-=usecond();
 | 
					
 | 
				
			||||||
      Copy_plane(ret,rhs,dimension,x,sx,cbmask); 
 | 
					      Copy_plane(ret,rhs,dimension,x,sx,cbmask); 
 | 
				
			||||||
      tcopy+=usecond();
 | 
					
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      int words = buffer_size;
 | 
					      int words = buffer_size;
 | 
				
			||||||
@@ -151,39 +144,26 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      int bytes = words * sizeof(vobj);
 | 
					      int bytes = words * sizeof(vobj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      tgather-=usecond();
 | 
					 | 
				
			||||||
      Gather_plane_simple (rhs,send_buf,dimension,sx,cbmask);
 | 
					      Gather_plane_simple (rhs,send_buf,dimension,sx,cbmask);
 | 
				
			||||||
      tgather+=usecond();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //      int rank           = grid->_processor;
 | 
					      //      int rank           = grid->_processor;
 | 
				
			||||||
      int recv_from_rank;
 | 
					      int recv_from_rank;
 | 
				
			||||||
      int xmit_to_rank;
 | 
					      int xmit_to_rank;
 | 
				
			||||||
      grid->ShiftedRanks(dimension,comm_proc,xmit_to_rank,recv_from_rank);
 | 
					      grid->ShiftedRanks(dimension,comm_proc,xmit_to_rank,recv_from_rank);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      tcomms-=usecond();
 | 
					      grid->Barrier();
 | 
				
			||||||
      //      grid->Barrier();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      grid->SendToRecvFrom((void *)&send_buf[0],
 | 
					      grid->SendToRecvFrom((void *)&send_buf[0],
 | 
				
			||||||
			   xmit_to_rank,
 | 
								   xmit_to_rank,
 | 
				
			||||||
			   (void *)&recv_buf[0],
 | 
								   (void *)&recv_buf[0],
 | 
				
			||||||
			   recv_from_rank,
 | 
								   recv_from_rank,
 | 
				
			||||||
			   bytes);
 | 
								   bytes);
 | 
				
			||||||
      xbytes+=bytes;
 | 
					 | 
				
			||||||
      //      grid->Barrier();
 | 
					 | 
				
			||||||
      tcomms+=usecond();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      tscatter-=usecond();
 | 
					      grid->Barrier();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      Scatter_plane_simple (ret,recv_buf,dimension,x,cbmask);
 | 
					      Scatter_plane_simple (ret,recv_buf,dimension,x,cbmask);
 | 
				
			||||||
      tscatter+=usecond();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  /*
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift copy    "<<tcopy/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift gather  "<<tgather/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift scatter "<<tscatter/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift comm    "<<tcomms/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift BW      "<<(2.0*xbytes)/tcomms<<" MB/s "<<2*xbytes<< " Bytes "<<std::endl;
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vobj> &rhs,int dimension,int shift,int cbmask)
 | 
					template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vobj> &rhs,int dimension,int shift,int cbmask)
 | 
				
			||||||
@@ -210,12 +190,6 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
  assert(shift>=0);
 | 
					  assert(shift>=0);
 | 
				
			||||||
  assert(shift<fd);
 | 
					  assert(shift<fd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  RealD tcopy=0.0;
 | 
					 | 
				
			||||||
  RealD tgather=0.0;
 | 
					 | 
				
			||||||
  RealD tscatter=0.0;
 | 
					 | 
				
			||||||
  RealD tcomms=0.0;
 | 
					 | 
				
			||||||
  uint64_t xbytes=0;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  int permute_type=grid->PermuteType(dimension);
 | 
					  int permute_type=grid->PermuteType(dimension);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ///////////////////////////////////////////////
 | 
					  ///////////////////////////////////////////////
 | 
				
			||||||
@@ -253,9 +227,7 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
      pointers[i] = &send_buf_extract[i][0];
 | 
					      pointers[i] = &send_buf_extract[i][0];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    int sx   = (x+sshift)%rd;
 | 
					    int sx   = (x+sshift)%rd;
 | 
				
			||||||
    tgather-=usecond();
 | 
					 | 
				
			||||||
    Gather_plane_extract(rhs,pointers,dimension,sx,cbmask);
 | 
					    Gather_plane_extract(rhs,pointers,dimension,sx,cbmask);
 | 
				
			||||||
    tgather+=usecond();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for(int i=0;i<Nsimd;i++){
 | 
					    for(int i=0;i<Nsimd;i++){
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
@@ -280,8 +252,7 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
      if(nbr_proc){
 | 
					      if(nbr_proc){
 | 
				
			||||||
	grid->ShiftedRanks(dimension,nbr_proc,xmit_to_rank,recv_from_rank); 
 | 
						grid->ShiftedRanks(dimension,nbr_proc,xmit_to_rank,recv_from_rank); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tcomms-=usecond();
 | 
						grid->Barrier();
 | 
				
			||||||
	//	grid->Barrier();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	send_buf_extract_mpi = &send_buf_extract[nbr_lane][0];
 | 
						send_buf_extract_mpi = &send_buf_extract[nbr_lane][0];
 | 
				
			||||||
	recv_buf_extract_mpi = &recv_buf_extract[i][0];
 | 
						recv_buf_extract_mpi = &recv_buf_extract[i][0];
 | 
				
			||||||
@@ -291,9 +262,7 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
			     recv_from_rank,
 | 
								     recv_from_rank,
 | 
				
			||||||
			     bytes);
 | 
								     bytes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xbytes+=bytes;
 | 
						grid->Barrier();
 | 
				
			||||||
	//	grid->Barrier();
 | 
					 | 
				
			||||||
	tcomms+=usecond();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rpointers[i] = &recv_buf_extract[i][0];
 | 
						rpointers[i] = &recv_buf_extract[i][0];
 | 
				
			||||||
      } else { 
 | 
					      } else { 
 | 
				
			||||||
@@ -301,17 +270,9 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    tscatter-=usecond();
 | 
					 | 
				
			||||||
    Scatter_plane_merge(ret,rpointers,dimension,x,cbmask);
 | 
					    Scatter_plane_merge(ret,rpointers,dimension,x,cbmask);
 | 
				
			||||||
    tscatter+=usecond();
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  /*
 | 
					
 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift (s) copy    "<<tcopy/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift (s) gather  "<<tgather/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift (s) scatter "<<tscatter/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift (s) comm    "<<tcomms/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift BW      "<<(2.0*xbytes)/tcomms<<" MB/s "<<2*xbytes<< " Bytes "<<std::endl;
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#else 
 | 
					#else 
 | 
				
			||||||
template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &rhs,int dimension,int shift,int cbmask)
 | 
					template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &rhs,int dimension,int shift,int cbmask)
 | 
				
			||||||
@@ -331,11 +292,6 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
 | 
				
			|||||||
  assert(comm_dim==1);
 | 
					  assert(comm_dim==1);
 | 
				
			||||||
  assert(shift>=0);
 | 
					  assert(shift>=0);
 | 
				
			||||||
  assert(shift<fd);
 | 
					  assert(shift<fd);
 | 
				
			||||||
  RealD tcopy=0.0;
 | 
					 | 
				
			||||||
  RealD tgather=0.0;
 | 
					 | 
				
			||||||
  RealD tscatter=0.0;
 | 
					 | 
				
			||||||
  RealD tcomms=0.0;
 | 
					 | 
				
			||||||
  uint64_t xbytes=0;
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  int buffer_size = rhs.Grid()->_slice_nblock[dimension]*rhs.Grid()->_slice_block[dimension];
 | 
					  int buffer_size = rhs.Grid()->_slice_nblock[dimension]*rhs.Grid()->_slice_block[dimension];
 | 
				
			||||||
  static cshiftVector<vobj> send_buf_v; send_buf_v.resize(buffer_size);
 | 
					  static cshiftVector<vobj> send_buf_v; send_buf_v.resize(buffer_size);
 | 
				
			||||||
@@ -359,9 +315,7 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    if (comm_proc==0) {
 | 
					    if (comm_proc==0) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      tcopy-=usecond();
 | 
					 | 
				
			||||||
      Copy_plane(ret,rhs,dimension,x,sx,cbmask); 
 | 
					      Copy_plane(ret,rhs,dimension,x,sx,cbmask); 
 | 
				
			||||||
      tcopy+=usecond();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -370,9 +324,7 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      int bytes = words * sizeof(vobj);
 | 
					      int bytes = words * sizeof(vobj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      tgather-=usecond();
 | 
					 | 
				
			||||||
      Gather_plane_simple (rhs,send_buf_v,dimension,sx,cbmask);
 | 
					      Gather_plane_simple (rhs,send_buf_v,dimension,sx,cbmask);
 | 
				
			||||||
      tgather+=usecond();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //      int rank           = grid->_processor;
 | 
					      //      int rank           = grid->_processor;
 | 
				
			||||||
      int recv_from_rank;
 | 
					      int recv_from_rank;
 | 
				
			||||||
@@ -380,8 +332,7 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
 | 
				
			|||||||
      grid->ShiftedRanks(dimension,comm_proc,xmit_to_rank,recv_from_rank);
 | 
					      grid->ShiftedRanks(dimension,comm_proc,xmit_to_rank,recv_from_rank);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      tcomms-=usecond();
 | 
					      grid->Barrier();
 | 
				
			||||||
      //      grid->Barrier();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      acceleratorCopyDeviceToDevice((void *)&send_buf_v[0],(void *)&send_buf[0],bytes);
 | 
					      acceleratorCopyDeviceToDevice((void *)&send_buf_v[0],(void *)&send_buf[0],bytes);
 | 
				
			||||||
      grid->SendToRecvFrom((void *)&send_buf[0],
 | 
					      grid->SendToRecvFrom((void *)&send_buf[0],
 | 
				
			||||||
@@ -389,24 +340,13 @@ template<class vobj> void Cshift_comms(Lattice<vobj> &ret,const Lattice<vobj> &r
 | 
				
			|||||||
			   (void *)&recv_buf[0],
 | 
								   (void *)&recv_buf[0],
 | 
				
			||||||
			   recv_from_rank,
 | 
								   recv_from_rank,
 | 
				
			||||||
			   bytes);
 | 
								   bytes);
 | 
				
			||||||
      xbytes+=bytes;
 | 
					 | 
				
			||||||
      acceleratorCopyDeviceToDevice((void *)&recv_buf[0],(void *)&recv_buf_v[0],bytes);
 | 
					      acceleratorCopyDeviceToDevice((void *)&recv_buf[0],(void *)&recv_buf_v[0],bytes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //      grid->Barrier();
 | 
					      grid->Barrier();
 | 
				
			||||||
      tcomms+=usecond();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      tscatter-=usecond();
 | 
					 | 
				
			||||||
      Scatter_plane_simple (ret,recv_buf_v,dimension,x,cbmask);
 | 
					      Scatter_plane_simple (ret,recv_buf_v,dimension,x,cbmask);
 | 
				
			||||||
      tscatter+=usecond();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  /*
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift copy    "<<tcopy/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift gather  "<<tgather/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift scatter "<<tscatter/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift comm    "<<tcomms/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift BW      "<<(2.0*xbytes)/tcomms<<" MB/s "<<2*xbytes<< " Bytes "<<std::endl;
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vobj> &rhs,int dimension,int shift,int cbmask)
 | 
					template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vobj> &rhs,int dimension,int shift,int cbmask)
 | 
				
			||||||
@@ -432,11 +372,6 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
  assert(simd_layout==2);
 | 
					  assert(simd_layout==2);
 | 
				
			||||||
  assert(shift>=0);
 | 
					  assert(shift>=0);
 | 
				
			||||||
  assert(shift<fd);
 | 
					  assert(shift<fd);
 | 
				
			||||||
  RealD tcopy=0.0;
 | 
					 | 
				
			||||||
  RealD tgather=0.0;
 | 
					 | 
				
			||||||
  RealD tscatter=0.0;
 | 
					 | 
				
			||||||
  RealD tcomms=0.0;
 | 
					 | 
				
			||||||
  uint64_t xbytes=0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int permute_type=grid->PermuteType(dimension);
 | 
					  int permute_type=grid->PermuteType(dimension);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -479,10 +414,8 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
    for(int i=0;i<Nsimd;i++){       
 | 
					    for(int i=0;i<Nsimd;i++){       
 | 
				
			||||||
      pointers[i] = &send_buf_extract[i][0];
 | 
					      pointers[i] = &send_buf_extract[i][0];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    tgather-=usecond();
 | 
					 | 
				
			||||||
    int sx   = (x+sshift)%rd;
 | 
					    int sx   = (x+sshift)%rd;
 | 
				
			||||||
    Gather_plane_extract(rhs,pointers,dimension,sx,cbmask);
 | 
					    Gather_plane_extract(rhs,pointers,dimension,sx,cbmask);
 | 
				
			||||||
    tgather+=usecond();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for(int i=0;i<Nsimd;i++){
 | 
					    for(int i=0;i<Nsimd;i++){
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
@@ -507,8 +440,7 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
      if(nbr_proc){
 | 
					      if(nbr_proc){
 | 
				
			||||||
	grid->ShiftedRanks(dimension,nbr_proc,xmit_to_rank,recv_from_rank); 
 | 
						grid->ShiftedRanks(dimension,nbr_proc,xmit_to_rank,recv_from_rank); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tcomms-=usecond();
 | 
						grid->Barrier();
 | 
				
			||||||
	//	grid->Barrier();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	acceleratorCopyDeviceToDevice((void *)&send_buf_extract[nbr_lane][0],(void *)send_buf_extract_mpi,bytes);
 | 
						acceleratorCopyDeviceToDevice((void *)&send_buf_extract[nbr_lane][0],(void *)send_buf_extract_mpi,bytes);
 | 
				
			||||||
	grid->SendToRecvFrom((void *)send_buf_extract_mpi,
 | 
						grid->SendToRecvFrom((void *)send_buf_extract_mpi,
 | 
				
			||||||
@@ -517,28 +449,17 @@ template<class vobj> void  Cshift_comms_simd(Lattice<vobj> &ret,const Lattice<vo
 | 
				
			|||||||
			     recv_from_rank,
 | 
								     recv_from_rank,
 | 
				
			||||||
			     bytes);
 | 
								     bytes);
 | 
				
			||||||
	acceleratorCopyDeviceToDevice((void *)recv_buf_extract_mpi,(void *)&recv_buf_extract[i][0],bytes);
 | 
						acceleratorCopyDeviceToDevice((void *)recv_buf_extract_mpi,(void *)&recv_buf_extract[i][0],bytes);
 | 
				
			||||||
	xbytes+=bytes;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//	grid->Barrier();
 | 
						grid->Barrier();
 | 
				
			||||||
	tcomms+=usecond();
 | 
					 | 
				
			||||||
	rpointers[i] = &recv_buf_extract[i][0];
 | 
						rpointers[i] = &recv_buf_extract[i][0];
 | 
				
			||||||
      } else { 
 | 
					      } else { 
 | 
				
			||||||
	rpointers[i] = &send_buf_extract[nbr_lane][0];
 | 
						rpointers[i] = &send_buf_extract[nbr_lane][0];
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    tscatter-=usecond();
 | 
					 | 
				
			||||||
    Scatter_plane_merge(ret,rpointers,dimension,x,cbmask);
 | 
					    Scatter_plane_merge(ret,rpointers,dimension,x,cbmask);
 | 
				
			||||||
    tscatter+=usecond();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  /*
 | 
					
 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift (s) copy    "<<tcopy/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift (s) gather  "<<tgather/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift (s) scatter "<<tscatter/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift (s) comm    "<<tcomms/1e3<<" ms"<<std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogPerformance << " Cshift BW      "<<(2.0*xbytes)/tcomms<<" MB/s"<<std::endl;
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
NAMESPACE_END(Grid); 
 | 
					NAMESPACE_END(Grid); 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
#include <Grid/GridCore.h>       
 | 
					#include <Grid/GridCore.h>       
 | 
				
			||||||
NAMESPACE_BEGIN(Grid);
 | 
					NAMESPACE_BEGIN(Grid);
 | 
				
			||||||
std::vector<std::pair<int,int> > Cshift_table; 
 | 
					Vector<std::pair<int,int> > Cshift_table; 
 | 
				
			||||||
commVector<std::pair<int,int> > Cshift_table_device; 
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,4 +47,3 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
 | 
				
			|||||||
#include <Grid/lattice/Lattice_transfer.h>
 | 
					#include <Grid/lattice/Lattice_transfer.h>
 | 
				
			||||||
#include <Grid/lattice/Lattice_basis.h>
 | 
					#include <Grid/lattice/Lattice_basis.h>
 | 
				
			||||||
#include <Grid/lattice/Lattice_crc.h>
 | 
					#include <Grid/lattice/Lattice_crc.h>
 | 
				
			||||||
#include <Grid/lattice/PaddedCell.h>
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -345,9 +345,7 @@ GridUnopClass(UnaryNot, Not(a));
 | 
				
			|||||||
GridUnopClass(UnaryTrace, trace(a));
 | 
					GridUnopClass(UnaryTrace, trace(a));
 | 
				
			||||||
GridUnopClass(UnaryTranspose, transpose(a));
 | 
					GridUnopClass(UnaryTranspose, transpose(a));
 | 
				
			||||||
GridUnopClass(UnaryTa, Ta(a));
 | 
					GridUnopClass(UnaryTa, Ta(a));
 | 
				
			||||||
GridUnopClass(UnarySpTa, SpTa(a));
 | 
					 | 
				
			||||||
GridUnopClass(UnaryProjectOnGroup, ProjectOnGroup(a));
 | 
					GridUnopClass(UnaryProjectOnGroup, ProjectOnGroup(a));
 | 
				
			||||||
GridUnopClass(UnaryProjectOnSpGroup, ProjectOnSpGroup(a));
 | 
					 | 
				
			||||||
GridUnopClass(UnaryTimesI, timesI(a));
 | 
					GridUnopClass(UnaryTimesI, timesI(a));
 | 
				
			||||||
GridUnopClass(UnaryTimesMinusI, timesMinusI(a));
 | 
					GridUnopClass(UnaryTimesMinusI, timesMinusI(a));
 | 
				
			||||||
GridUnopClass(UnaryAbs, abs(a));
 | 
					GridUnopClass(UnaryAbs, abs(a));
 | 
				
			||||||
@@ -458,9 +456,7 @@ GRID_DEF_UNOP(operator!, UnaryNot);
 | 
				
			|||||||
GRID_DEF_UNOP(trace, UnaryTrace);
 | 
					GRID_DEF_UNOP(trace, UnaryTrace);
 | 
				
			||||||
GRID_DEF_UNOP(transpose, UnaryTranspose);
 | 
					GRID_DEF_UNOP(transpose, UnaryTranspose);
 | 
				
			||||||
GRID_DEF_UNOP(Ta, UnaryTa);
 | 
					GRID_DEF_UNOP(Ta, UnaryTa);
 | 
				
			||||||
GRID_DEF_UNOP(SpTa, UnarySpTa);
 | 
					 | 
				
			||||||
GRID_DEF_UNOP(ProjectOnGroup, UnaryProjectOnGroup);
 | 
					GRID_DEF_UNOP(ProjectOnGroup, UnaryProjectOnGroup);
 | 
				
			||||||
GRID_DEF_UNOP(ProjectOnSpGroup, UnaryProjectOnSpGroup);
 | 
					 | 
				
			||||||
GRID_DEF_UNOP(timesI, UnaryTimesI);
 | 
					GRID_DEF_UNOP(timesI, UnaryTimesI);
 | 
				
			||||||
GRID_DEF_UNOP(timesMinusI, UnaryTimesMinusI);
 | 
					GRID_DEF_UNOP(timesMinusI, UnaryTimesMinusI);
 | 
				
			||||||
GRID_DEF_UNOP(abs, UnaryAbs);  // abs overloaded in cmath C++98; DON'T do the
 | 
					GRID_DEF_UNOP(abs, UnaryAbs);  // abs overloaded in cmath C++98; DON'T do the
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -270,42 +270,5 @@ RealD axpby_norm(Lattice<vobj> &ret,sobj a,sobj b,const Lattice<vobj> &x,const L
 | 
				
			|||||||
    return axpby_norm_fast(ret,a,b,x,y);
 | 
					    return axpby_norm_fast(ret,a,b,x,y);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Trace product
 | 
					 | 
				
			||||||
template<class obj> auto traceProduct(const Lattice<obj> &rhs_1,const Lattice<obj> &rhs_2)
 | 
					 | 
				
			||||||
  -> Lattice<decltype(trace(obj()))>
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  typedef decltype(trace(obj())) robj;
 | 
					 | 
				
			||||||
  Lattice<robj> ret_i(rhs_1.Grid());
 | 
					 | 
				
			||||||
  autoView( rhs1 , rhs_1, AcceleratorRead);
 | 
					 | 
				
			||||||
  autoView( rhs2 , rhs_2, AcceleratorRead);
 | 
					 | 
				
			||||||
  autoView( ret , ret_i, AcceleratorWrite);
 | 
					 | 
				
			||||||
  ret.Checkerboard() = rhs_1.Checkerboard();
 | 
					 | 
				
			||||||
  accelerator_for(ss,rhs1.size(),obj::Nsimd(),{
 | 
					 | 
				
			||||||
      coalescedWrite(ret[ss],traceProduct(rhs1(ss),rhs2(ss)));
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
  return ret_i;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template<class obj1,class obj2> auto traceProduct(const Lattice<obj1> &rhs_1,const obj2 &rhs2)
 | 
					 | 
				
			||||||
  -> Lattice<decltype(trace(obj1()))>
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  typedef decltype(trace(obj1())) robj;
 | 
					 | 
				
			||||||
  Lattice<robj> ret_i(rhs_1.Grid());
 | 
					 | 
				
			||||||
  autoView( rhs1 , rhs_1, AcceleratorRead);
 | 
					 | 
				
			||||||
  autoView( ret , ret_i, AcceleratorWrite);
 | 
					 | 
				
			||||||
  ret.Checkerboard() = rhs_1.Checkerboard();
 | 
					 | 
				
			||||||
  accelerator_for(ss,rhs1.size(),obj1::Nsimd(),{
 | 
					 | 
				
			||||||
      coalescedWrite(ret[ss],traceProduct(rhs1(ss),rhs2));
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
  return ret_i;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
template<class obj1,class obj2> auto traceProduct(const obj2 &rhs_2,const Lattice<obj1> &rhs_1)
 | 
					 | 
				
			||||||
  -> Lattice<decltype(trace(obj1()))>
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  return traceProduct(rhs_1,rhs_2);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,7 +62,7 @@ void basisRotate(VField &basis,Matrix& Qt,int j0, int j1, int k0,int k1,int Nm)
 | 
				
			|||||||
    basis_v.push_back(basis[k].View(AcceleratorWrite));
 | 
					    basis_v.push_back(basis[k].View(AcceleratorWrite));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if ( !(defined(GRID_CUDA) || defined(GRID_HIP) || defined(GRID_SYCL)) )
 | 
					#if ( (!defined(GRID_CUDA)) )
 | 
				
			||||||
  int max_threads = thread_max();
 | 
					  int max_threads = thread_max();
 | 
				
			||||||
  Vector < vobj > Bt(Nm * max_threads);
 | 
					  Vector < vobj > Bt(Nm * max_threads);
 | 
				
			||||||
  thread_region
 | 
					  thread_region
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -251,10 +251,10 @@ inline ComplexD rankInnerProduct(const Lattice<vobj> &left,const Lattice<vobj> &
 | 
				
			|||||||
    autoView( right_v,right, AcceleratorRead);
 | 
					    autoView( right_v,right, AcceleratorRead);
 | 
				
			||||||
    // This code could read coalesce
 | 
					    // This code could read coalesce
 | 
				
			||||||
    // GPU - SIMT lane compliance...
 | 
					    // GPU - SIMT lane compliance...
 | 
				
			||||||
    accelerator_for( ss, sites, 1,{
 | 
					    accelerator_for( ss, sites, nsimd,{
 | 
				
			||||||
        auto x_l = left_v[ss];
 | 
						auto x_l = left_v(ss);
 | 
				
			||||||
        auto y_l = right_v[ss];
 | 
						auto y_l = right_v(ss);
 | 
				
			||||||
        inner_tmp_v[ss]=innerProductD(x_l,y_l);
 | 
						coalescedWrite(inner_tmp_v[ss],innerProductD(x_l,y_l));
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
@@ -267,18 +267,11 @@ inline ComplexD rankInnerProduct(const Lattice<vobj> &left,const Lattice<vobj> &
 | 
				
			|||||||
    autoView( right_v,right, AcceleratorRead);
 | 
					    autoView( right_v,right, AcceleratorRead);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // GPU - SIMT lane compliance...
 | 
					    // GPU - SIMT lane compliance...
 | 
				
			||||||
    //accelerator_for( ss, sites, nsimd,{
 | 
					    accelerator_for( ss, sites, nsimd,{
 | 
				
			||||||
    //    auto x_l = left_v(ss);
 | 
						auto x_l = left_v(ss);
 | 
				
			||||||
    //    auto y_l = right_v(ss);
 | 
						auto y_l = right_v(ss);
 | 
				
			||||||
    //    coalescedWrite(inner_tmp_v[ss],innerProduct(x_l,y_l));
 | 
					 | 
				
			||||||
    //});
 | 
					 | 
				
			||||||
    #pragma omp target map ( to:left_v, right_v ) map ( tofrom:inner_tmp_v )
 | 
					 | 
				
			||||||
    #pragma omp teams distribute parallel for thread_limit(THREAD_LIMIT) //nowait
 | 
					 | 
				
			||||||
    for ( uint64_t ss=0;ss<sites;ss++) { 
 | 
					 | 
				
			||||||
        auto x_l = left_v[ss];
 | 
					 | 
				
			||||||
        auto y_l = right_v[ss];
 | 
					 | 
				
			||||||
	coalescedWrite(inner_tmp_v[ss],innerProduct(x_l,y_l));
 | 
						coalescedWrite(inner_tmp_v[ss],innerProduct(x_l,y_l));
 | 
				
			||||||
    }
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  // This is in single precision and fails some tests
 | 
					  // This is in single precision and fails some tests
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,10 +30,7 @@ int getNumBlocksAndThreads(const Iterator n, const size_t sizeofsobj, Iterator &
 | 
				
			|||||||
  cudaGetDevice(&device);
 | 
					  cudaGetDevice(&device);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef GRID_HIP
 | 
					#ifdef GRID_HIP
 | 
				
			||||||
  auto r=hipGetDevice(&device);
 | 
					  hipGetDevice(&device);
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef GRID_OMPTARGET
 | 
					 | 
				
			||||||
  device = omp_get_device_num();  
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  Iterator warpSize            = gpu_props[device].warpSize;
 | 
					  Iterator warpSize            = gpu_props[device].warpSize;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -152,7 +152,6 @@ public:
 | 
				
			|||||||
#ifdef RNG_FAST_DISCARD
 | 
					#ifdef RNG_FAST_DISCARD
 | 
				
			||||||
  static void Skip(RngEngine &eng,uint64_t site)
 | 
					  static void Skip(RngEngine &eng,uint64_t site)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
    /////////////////////////////////////////////////////////////////////////////////////
 | 
					    /////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
    // Skip by 2^40 elements between successive lattice sites
 | 
					    // Skip by 2^40 elements between successive lattice sites
 | 
				
			||||||
    // This goes by 10^12.
 | 
					    // This goes by 10^12.
 | 
				
			||||||
@@ -180,9 +179,6 @@ public:
 | 
				
			|||||||
    assert((skip >> shift)==site); // check for overflow
 | 
					    assert((skip >> shift)==site); // check for overflow
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    eng.discard(skip);
 | 
					    eng.discard(skip);
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    eng.discardhi(site);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    //      std::cout << " Engine  " <<site << " state " <<eng<<std::endl;
 | 
					    //      std::cout << " Engine  " <<site << " state " <<eng<<std::endl;
 | 
				
			||||||
  } 
 | 
					  } 
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,65 +66,6 @@ inline auto TraceIndex(const Lattice<vobj> &lhs) -> Lattice<decltype(traceIndex<
 | 
				
			|||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<int N, class Vec>
 | 
					 | 
				
			||||||
Lattice<iScalar<iScalar<iScalar<Vec> > > > Determinant(const Lattice<iScalar<iScalar<iMatrix<Vec, N> > > > &Umu)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  GridBase *grid=Umu.Grid();
 | 
					 | 
				
			||||||
  auto lvol = grid->lSites();
 | 
					 | 
				
			||||||
  Lattice<iScalar<iScalar<iScalar<Vec> > > > ret(grid);
 | 
					 | 
				
			||||||
  typedef typename Vec::scalar_type scalar;
 | 
					 | 
				
			||||||
  autoView(Umu_v,Umu,CpuRead);
 | 
					 | 
				
			||||||
  autoView(ret_v,ret,CpuWrite);
 | 
					 | 
				
			||||||
  thread_for(site,lvol,{
 | 
					 | 
				
			||||||
    Eigen::MatrixXcd EigenU = Eigen::MatrixXcd::Zero(N,N);
 | 
					 | 
				
			||||||
    Coordinate lcoor;
 | 
					 | 
				
			||||||
    grid->LocalIndexToLocalCoor(site, lcoor);
 | 
					 | 
				
			||||||
    iScalar<iScalar<iMatrix<scalar, N> > > Us;
 | 
					 | 
				
			||||||
    peekLocalSite(Us, Umu_v, lcoor);
 | 
					 | 
				
			||||||
    for(int i=0;i<N;i++){
 | 
					 | 
				
			||||||
      for(int j=0;j<N;j++){
 | 
					 | 
				
			||||||
	scalar tmp= Us()()(i,j);
 | 
					 | 
				
			||||||
	ComplexD ztmp(real(tmp),imag(tmp));
 | 
					 | 
				
			||||||
	EigenU(i,j)=ztmp;
 | 
					 | 
				
			||||||
      }}
 | 
					 | 
				
			||||||
    ComplexD detD  = EigenU.determinant();
 | 
					 | 
				
			||||||
    typename Vec::scalar_type det(detD.real(),detD.imag());
 | 
					 | 
				
			||||||
    pokeLocalSite(det,ret_v,lcoor);
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template<int N>
 | 
					 | 
				
			||||||
Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > Inverse(const Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  GridBase *grid=Umu.Grid();
 | 
					 | 
				
			||||||
  auto lvol = grid->lSites();
 | 
					 | 
				
			||||||
  Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > ret(grid);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  autoView(Umu_v,Umu,CpuRead);
 | 
					 | 
				
			||||||
  autoView(ret_v,ret,CpuWrite);
 | 
					 | 
				
			||||||
  thread_for(site,lvol,{
 | 
					 | 
				
			||||||
    Eigen::MatrixXcd EigenU = Eigen::MatrixXcd::Zero(N,N);
 | 
					 | 
				
			||||||
    Coordinate lcoor;
 | 
					 | 
				
			||||||
    grid->LocalIndexToLocalCoor(site, lcoor);
 | 
					 | 
				
			||||||
    iScalar<iScalar<iMatrix<ComplexD, N> > > Us;
 | 
					 | 
				
			||||||
    iScalar<iScalar<iMatrix<ComplexD, N> > > Ui;
 | 
					 | 
				
			||||||
    peekLocalSite(Us, Umu_v, lcoor);
 | 
					 | 
				
			||||||
    for(int i=0;i<N;i++){
 | 
					 | 
				
			||||||
      for(int j=0;j<N;j++){
 | 
					 | 
				
			||||||
	EigenU(i,j) = Us()()(i,j);
 | 
					 | 
				
			||||||
      }}
 | 
					 | 
				
			||||||
    Eigen::MatrixXcd EigenUinv = EigenU.inverse();
 | 
					 | 
				
			||||||
    for(int i=0;i<N;i++){
 | 
					 | 
				
			||||||
      for(int j=0;j<N;j++){
 | 
					 | 
				
			||||||
	Ui()()(i,j) = EigenUinv(i,j);
 | 
					 | 
				
			||||||
      }}
 | 
					 | 
				
			||||||
    pokeLocalSite(Ui,ret_v,lcoor);
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -469,13 +469,15 @@ inline void blockSum(Lattice<vobj> &coarseData,const Lattice<vobj> &fineData)
 | 
				
			|||||||
  Coordinate fine_rdimensions = fine->_rdimensions;
 | 
					  Coordinate fine_rdimensions = fine->_rdimensions;
 | 
				
			||||||
  Coordinate coarse_rdimensions = coarse->_rdimensions;
 | 
					  Coordinate coarse_rdimensions = coarse->_rdimensions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  vobj zz = Zero();
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  accelerator_for(sc,coarse->oSites(),1,{
 | 
					  accelerator_for(sc,coarse->oSites(),1,{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // One thread per sub block
 | 
					      // One thread per sub block
 | 
				
			||||||
      Coordinate coor_c(_ndimension);
 | 
					      Coordinate coor_c(_ndimension);
 | 
				
			||||||
      Lexicographic::CoorFromIndex(coor_c,sc,coarse_rdimensions);  // Block coordinate
 | 
					      Lexicographic::CoorFromIndex(coor_c,sc,coarse_rdimensions);  // Block coordinate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      vobj cd = Zero();
 | 
					      vobj cd = zz;
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      for(int sb=0;sb<blockVol;sb++){
 | 
					      for(int sb=0;sb<blockVol;sb++){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -695,68 +697,8 @@ void localCopyRegion(const Lattice<vobj> &From,Lattice<vobj> & To,Coordinate Fro
 | 
				
			|||||||
  for(int d=0;d<nd;d++){
 | 
					  for(int d=0;d<nd;d++){
 | 
				
			||||||
    assert(Fg->_processors[d]  == Tg->_processors[d]);
 | 
					    assert(Fg->_processors[d]  == Tg->_processors[d]);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // the above should guarantee that the operations are local
 | 
					  // the above should guarantee that the operations are local
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
#if 1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  size_t nsite = 1;
 | 
					 | 
				
			||||||
  for(int i=0;i<nd;i++) nsite *= RegionSize[i];
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  size_t tbytes = 4*nsite*sizeof(int);
 | 
					 | 
				
			||||||
  int *table = (int*)malloc(tbytes);
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
  thread_for(idx, nsite, {
 | 
					 | 
				
			||||||
      Coordinate from_coor, to_coor;
 | 
					 | 
				
			||||||
      size_t rem = idx;
 | 
					 | 
				
			||||||
      for(int i=0;i<nd;i++){
 | 
					 | 
				
			||||||
	size_t base_i  = rem % RegionSize[i]; rem /= RegionSize[i];
 | 
					 | 
				
			||||||
	from_coor[i] = base_i + FromLowerLeft[i];
 | 
					 | 
				
			||||||
	to_coor[i] = base_i + ToLowerLeft[i];
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      int foidx = Fg->oIndex(from_coor);
 | 
					 | 
				
			||||||
      int fiidx = Fg->iIndex(from_coor);
 | 
					 | 
				
			||||||
      int toidx = Tg->oIndex(to_coor);
 | 
					 | 
				
			||||||
      int tiidx = Tg->iIndex(to_coor);
 | 
					 | 
				
			||||||
      int* tt = table + 4*idx;
 | 
					 | 
				
			||||||
      tt[0] = foidx;
 | 
					 | 
				
			||||||
      tt[1] = fiidx;
 | 
					 | 
				
			||||||
      tt[2] = toidx;
 | 
					 | 
				
			||||||
      tt[3] = tiidx;
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  int* table_d = (int*)acceleratorAllocDevice(tbytes);
 | 
					 | 
				
			||||||
  acceleratorCopyToDevice(table,table_d,tbytes);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef typename vobj::vector_type vector_type;
 | 
					 | 
				
			||||||
  typedef typename vobj::scalar_type scalar_type;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  autoView(from_v,From,AcceleratorRead);
 | 
					 | 
				
			||||||
  autoView(to_v,To,AcceleratorWrite);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  accelerator_for(idx,nsite,1,{
 | 
					 | 
				
			||||||
      static const int words=sizeof(vobj)/sizeof(vector_type);
 | 
					 | 
				
			||||||
      int* tt = table_d + 4*idx;
 | 
					 | 
				
			||||||
      int from_oidx = *tt++;
 | 
					 | 
				
			||||||
      int from_lane = *tt++;
 | 
					 | 
				
			||||||
      int to_oidx = *tt++;
 | 
					 | 
				
			||||||
      int to_lane = *tt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      const vector_type* from = (const vector_type *)&from_v[from_oidx];
 | 
					 | 
				
			||||||
      vector_type* to = (vector_type *)&to_v[to_oidx];
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      scalar_type stmp;
 | 
					 | 
				
			||||||
      for(int w=0;w<words;w++){
 | 
					 | 
				
			||||||
	stmp = getlane(from[w], from_lane);
 | 
					 | 
				
			||||||
	putlane(to[w], stmp, to_lane);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  acceleratorFreeDevice(table_d);    
 | 
					 | 
				
			||||||
  free(table);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#else  
 | 
					 | 
				
			||||||
  Coordinate ldf = Fg->_ldimensions;
 | 
					  Coordinate ldf = Fg->_ldimensions;
 | 
				
			||||||
  Coordinate rdf = Fg->_rdimensions;
 | 
					  Coordinate rdf = Fg->_rdimensions;
 | 
				
			||||||
  Coordinate isf = Fg->_istride;
 | 
					  Coordinate isf = Fg->_istride;
 | 
				
			||||||
@@ -796,8 +738,6 @@ void localCopyRegion(const Lattice<vobj> &From,Lattice<vobj> & To,Coordinate Fro
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -890,8 +830,6 @@ void ExtractSlice(Lattice<vobj> &lowDim,const Lattice<vobj> & higherDim,int slic
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//Insert subvolume orthogonal to direction 'orthog' with slice index 'slice_lo' from 'lowDim' onto slice index 'slice_hi' of higherDim
 | 
					 | 
				
			||||||
//The local dimensions of both 'lowDim' and 'higherDim' orthogonal to 'orthog' should be the same
 | 
					 | 
				
			||||||
template<class vobj>
 | 
					template<class vobj>
 | 
				
			||||||
void InsertSliceLocal(const Lattice<vobj> &lowDim, Lattice<vobj> & higherDim,int slice_lo,int slice_hi, int orthog)
 | 
					void InsertSliceLocal(const Lattice<vobj> &lowDim, Lattice<vobj> & higherDim,int slice_lo,int slice_hi, int orthog)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -913,65 +851,6 @@ void InsertSliceLocal(const Lattice<vobj> &lowDim, Lattice<vobj> & higherDim,int
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 1
 | 
					 | 
				
			||||||
  size_t nsite = lg->lSites()/lg->LocalDimensions()[orthog];
 | 
					 | 
				
			||||||
  size_t tbytes = 4*nsite*sizeof(int);
 | 
					 | 
				
			||||||
  int *table = (int*)malloc(tbytes);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  thread_for(idx,nsite,{
 | 
					 | 
				
			||||||
    Coordinate lcoor(nl);
 | 
					 | 
				
			||||||
    Coordinate hcoor(nh);
 | 
					 | 
				
			||||||
    lcoor[orthog] = slice_lo;
 | 
					 | 
				
			||||||
    hcoor[orthog] = slice_hi;
 | 
					 | 
				
			||||||
    size_t rem = idx;
 | 
					 | 
				
			||||||
    for(int mu=0;mu<nl;mu++){
 | 
					 | 
				
			||||||
      if(mu != orthog){
 | 
					 | 
				
			||||||
	int xmu = rem % lg->LocalDimensions()[mu];  rem /= lg->LocalDimensions()[mu];
 | 
					 | 
				
			||||||
	lcoor[mu] = hcoor[mu] = xmu;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    int loidx = lg->oIndex(lcoor);
 | 
					 | 
				
			||||||
    int liidx = lg->iIndex(lcoor);
 | 
					 | 
				
			||||||
    int hoidx = hg->oIndex(hcoor);
 | 
					 | 
				
			||||||
    int hiidx = hg->iIndex(hcoor);
 | 
					 | 
				
			||||||
    int* tt = table + 4*idx;
 | 
					 | 
				
			||||||
    tt[0] = loidx;
 | 
					 | 
				
			||||||
    tt[1] = liidx;
 | 
					 | 
				
			||||||
    tt[2] = hoidx;
 | 
					 | 
				
			||||||
    tt[3] = hiidx;
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
   
 | 
					 | 
				
			||||||
  int* table_d = (int*)acceleratorAllocDevice(tbytes);
 | 
					 | 
				
			||||||
  acceleratorCopyToDevice(table,table_d,tbytes);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef typename vobj::vector_type vector_type;
 | 
					 | 
				
			||||||
  typedef typename vobj::scalar_type scalar_type;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  autoView(lowDim_v,lowDim,AcceleratorRead);
 | 
					 | 
				
			||||||
  autoView(higherDim_v,higherDim,AcceleratorWrite);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  accelerator_for(idx,nsite,1,{
 | 
					 | 
				
			||||||
      static const int words=sizeof(vobj)/sizeof(vector_type);
 | 
					 | 
				
			||||||
      int* tt = table_d + 4*idx;
 | 
					 | 
				
			||||||
      int from_oidx = *tt++;
 | 
					 | 
				
			||||||
      int from_lane = *tt++;
 | 
					 | 
				
			||||||
      int to_oidx = *tt++;
 | 
					 | 
				
			||||||
      int to_lane = *tt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      const vector_type* from = (const vector_type *)&lowDim_v[from_oidx];
 | 
					 | 
				
			||||||
      vector_type* to = (vector_type *)&higherDim_v[to_oidx];
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      scalar_type stmp;
 | 
					 | 
				
			||||||
      for(int w=0;w<words;w++){
 | 
					 | 
				
			||||||
	stmp = getlane(from[w], from_lane);
 | 
					 | 
				
			||||||
	putlane(to[w], stmp, to_lane);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  acceleratorFreeDevice(table_d);    
 | 
					 | 
				
			||||||
  free(table);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
  // the above should guarantee that the operations are local
 | 
					  // the above should guarantee that the operations are local
 | 
				
			||||||
  autoView(lowDimv,lowDim,CpuRead);
 | 
					  autoView(lowDimv,lowDim,CpuRead);
 | 
				
			||||||
  autoView(higherDimv,higherDim,CpuWrite);
 | 
					  autoView(higherDimv,higherDim,CpuWrite);
 | 
				
			||||||
@@ -987,7 +866,6 @@ void InsertSliceLocal(const Lattice<vobj> &lowDim, Lattice<vobj> & higherDim,int
 | 
				
			|||||||
      pokeLocalSite(s,higherDimv,hcoor);
 | 
					      pokeLocalSite(s,higherDimv,hcoor);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,7 +45,6 @@ public:
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
  // Host only
 | 
					  // Host only
 | 
				
			||||||
  GridBase * getGrid(void) const { return _grid; };
 | 
					  GridBase * getGrid(void) const { return _grid; };
 | 
				
			||||||
  vobj* getHostPointer(void) const { return _odata; };
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/////////////////////////////////////////////////////////////////////////////////////////
 | 
					/////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,32 +26,14 @@ Author: Peter Boyle pboyle@bnl.gov
 | 
				
			|||||||
/*  END LEGAL */
 | 
					/*  END LEGAL */
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include<Grid/cshift/Cshift.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_BEGIN(Grid);
 | 
					NAMESPACE_BEGIN(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//Allow the user to specify how the C-shift is performed, e.g. to respect the appropriate boundary conditions
 | 
					 | 
				
			||||||
template<typename vobj>
 | 
					 | 
				
			||||||
struct CshiftImplBase{
 | 
					 | 
				
			||||||
  virtual Lattice<vobj> Cshift(const Lattice<vobj> &in, int dir, int shift) const = 0;
 | 
					 | 
				
			||||||
  virtual ~CshiftImplBase(){}
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
template<typename vobj>
 | 
					 | 
				
			||||||
struct CshiftImplDefault: public CshiftImplBase<vobj>{
 | 
					 | 
				
			||||||
  Lattice<vobj> Cshift(const Lattice<vobj> &in, int dir, int shift) const override{ return Grid::Cshift(in,dir,shift); }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
template<typename Gimpl>
 | 
					 | 
				
			||||||
struct CshiftImplGauge: public CshiftImplBase<typename Gimpl::GaugeLinkField::vector_object>{
 | 
					 | 
				
			||||||
  typename Gimpl::GaugeLinkField Cshift(const typename Gimpl::GaugeLinkField &in, int dir, int shift) const override{ return Gimpl::CshiftLink(in,dir,shift); }
 | 
					 | 
				
			||||||
};  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class PaddedCell {
 | 
					class PaddedCell {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  GridCartesian * unpadded_grid;
 | 
					  GridCartesian * unpadded_grid;
 | 
				
			||||||
  int dims;
 | 
					  int dims;
 | 
				
			||||||
  int depth;
 | 
					  int depth;
 | 
				
			||||||
  std::vector<GridCartesian *> grids;
 | 
					  std::vector<GridCartesian *> grids;
 | 
				
			||||||
 | 
					 | 
				
			||||||
  ~PaddedCell()
 | 
					  ~PaddedCell()
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    DeleteGrids();
 | 
					    DeleteGrids();
 | 
				
			||||||
@@ -95,7 +77,7 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
  template<class vobj>
 | 
					  template<class vobj>
 | 
				
			||||||
  inline Lattice<vobj> Extract(const Lattice<vobj> &in) const
 | 
					  inline Lattice<vobj> Extract(Lattice<vobj> &in)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    Lattice<vobj> out(unpadded_grid);
 | 
					    Lattice<vobj> out(unpadded_grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -106,19 +88,19 @@ public:
 | 
				
			|||||||
    return out;
 | 
					    return out;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  template<class vobj>
 | 
					  template<class vobj>
 | 
				
			||||||
  inline Lattice<vobj> Exchange(const Lattice<vobj> &in, const CshiftImplBase<vobj> &cshift = CshiftImplDefault<vobj>()) const
 | 
					  inline Lattice<vobj> Exchange(Lattice<vobj> &in)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    GridBase *old_grid = in.Grid();
 | 
					    GridBase *old_grid = in.Grid();
 | 
				
			||||||
    int dims = old_grid->Nd();
 | 
					    int dims = old_grid->Nd();
 | 
				
			||||||
    Lattice<vobj> tmp = in;
 | 
					    Lattice<vobj> tmp = in;
 | 
				
			||||||
    for(int d=0;d<dims;d++){
 | 
					    for(int d=0;d<dims;d++){
 | 
				
			||||||
      tmp = Expand(d,tmp,cshift); // rvalue && assignment
 | 
					      tmp = Expand(d,tmp); // rvalue && assignment
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return tmp;
 | 
					    return tmp;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // expand up one dim at a time
 | 
					  // expand up one dim at a time
 | 
				
			||||||
  template<class vobj>
 | 
					  template<class vobj>
 | 
				
			||||||
  inline Lattice<vobj> Expand(int dim, const Lattice<vobj> &in, const CshiftImplBase<vobj> &cshift = CshiftImplDefault<vobj>()) const
 | 
					  inline Lattice<vobj> Expand(int dim,Lattice<vobj> &in)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    GridBase *old_grid = in.Grid();
 | 
					    GridBase *old_grid = in.Grid();
 | 
				
			||||||
    GridCartesian *new_grid = grids[dim];//These are new grids
 | 
					    GridCartesian *new_grid = grids[dim];//These are new grids
 | 
				
			||||||
@@ -130,40 +112,20 @@ public:
 | 
				
			|||||||
    else       conformable(old_grid,grids[dim-1]);
 | 
					    else       conformable(old_grid,grids[dim-1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::cout << " dim "<<dim<<" local "<<local << " padding to "<<plocal<<std::endl;
 | 
					    std::cout << " dim "<<dim<<" local "<<local << " padding to "<<plocal<<std::endl;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    double tins=0, tshift=0;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    // Middle bit
 | 
					    // Middle bit
 | 
				
			||||||
    double t = usecond();
 | 
					 | 
				
			||||||
    for(int x=0;x<local[dim];x++){
 | 
					    for(int x=0;x<local[dim];x++){
 | 
				
			||||||
      InsertSliceLocal(in,padded,x,depth+x,dim);
 | 
					      InsertSliceLocal(in,padded,x,depth+x,dim);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    tins += usecond() - t;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    // High bit
 | 
					    // High bit
 | 
				
			||||||
    t = usecond();
 | 
					    shifted = Cshift(in,dim,depth);
 | 
				
			||||||
    shifted = cshift.Cshift(in,dim,depth);
 | 
					 | 
				
			||||||
    tshift += usecond() - t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    t=usecond();
 | 
					 | 
				
			||||||
    for(int x=0;x<depth;x++){
 | 
					    for(int x=0;x<depth;x++){
 | 
				
			||||||
      InsertSliceLocal(shifted,padded,local[dim]-depth+x,depth+local[dim]+x,dim);
 | 
					      InsertSliceLocal(shifted,padded,local[dim]-depth+x,depth+local[dim]+x,dim);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    tins += usecond() - t;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    // Low bit
 | 
					    // Low bit
 | 
				
			||||||
    t = usecond();
 | 
					    shifted = Cshift(in,dim,-depth);
 | 
				
			||||||
    shifted = cshift.Cshift(in,dim,-depth);
 | 
					 | 
				
			||||||
    tshift += usecond() - t;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    t = usecond();
 | 
					 | 
				
			||||||
    for(int x=0;x<depth;x++){
 | 
					    for(int x=0;x<depth;x++){
 | 
				
			||||||
      InsertSliceLocal(shifted,padded,x,x,dim);
 | 
					      InsertSliceLocal(shifted,padded,x,x,dim);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    tins += usecond() - t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    std::cout << GridLogPerformance << "PaddedCell::Expand timings: cshift:" << tshift/1000 << "ms, insert-slice:" << tins/1000 << "ms" << std::endl;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    return padded;
 | 
					    return padded;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,22 +129,6 @@ public:
 | 
				
			|||||||
  virtual ~Action(){}
 | 
					  virtual ~Action(){}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <class GaugeField >
 | 
					 | 
				
			||||||
class EmptyAction : public Action <GaugeField>
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  virtual void refresh(const GaugeField& U, GridSerialRNG &sRNG, GridParallelRNG& pRNG) { assert(0);}; // refresh pseudofermions
 | 
					 | 
				
			||||||
  virtual RealD S(const GaugeField& U) { return 0.0;};                             // evaluate the action
 | 
					 | 
				
			||||||
  virtual void deriv(const GaugeField& U, GaugeField& dSdU) { assert(0); };        // evaluate the action derivative
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ///////////////////////////////
 | 
					 | 
				
			||||||
  // Logging
 | 
					 | 
				
			||||||
  ///////////////////////////////
 | 
					 | 
				
			||||||
  virtual std::string action_name()    { return std::string("Level Force Log"); };
 | 
					 | 
				
			||||||
  virtual std::string LogParameters()  { return std::string("No parameters");};
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // ACTION_BASE_H
 | 
					#endif // ACTION_BASE_H
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -126,16 +126,6 @@ typedef WilsonFermion<WilsonTwoIndexSymmetricImplD> WilsonTwoIndexSymmetricFermi
 | 
				
			|||||||
typedef WilsonFermion<WilsonTwoIndexAntiSymmetricImplF> WilsonTwoIndexAntiSymmetricFermionF;
 | 
					typedef WilsonFermion<WilsonTwoIndexAntiSymmetricImplF> WilsonTwoIndexAntiSymmetricFermionF;
 | 
				
			||||||
typedef WilsonFermion<WilsonTwoIndexAntiSymmetricImplD> WilsonTwoIndexAntiSymmetricFermionD;
 | 
					typedef WilsonFermion<WilsonTwoIndexAntiSymmetricImplD> WilsonTwoIndexAntiSymmetricFermionD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Sp(2n)
 | 
					 | 
				
			||||||
typedef WilsonFermion<SpWilsonImplF> SpWilsonFermionF;
 | 
					 | 
				
			||||||
typedef WilsonFermion<SpWilsonImplD> SpWilsonFermionD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef WilsonFermion<SpWilsonTwoIndexAntiSymmetricImplF> SpWilsonTwoIndexAntiSymmetricFermionF;
 | 
					 | 
				
			||||||
typedef WilsonFermion<SpWilsonTwoIndexAntiSymmetricImplD> SpWilsonTwoIndexAntiSymmetricFermionD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef WilsonFermion<SpWilsonTwoIndexSymmetricImplF> SpWilsonTwoIndexSymmetricFermionF;
 | 
					 | 
				
			||||||
typedef WilsonFermion<SpWilsonTwoIndexSymmetricImplD> SpWilsonTwoIndexSymmetricFermionD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Twisted mass fermion
 | 
					// Twisted mass fermion
 | 
				
			||||||
typedef WilsonTMFermion<WilsonImplD2> WilsonTMFermionD2;
 | 
					typedef WilsonTMFermion<WilsonImplD2> WilsonTMFermionD2;
 | 
				
			||||||
typedef WilsonTMFermion<WilsonImplF> WilsonTMFermionF;
 | 
					typedef WilsonTMFermion<WilsonImplF> WilsonTMFermionF;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -261,22 +261,6 @@ typedef WilsonImpl<vComplex,  TwoIndexAntiSymmetricRepresentation, CoeffReal > W
 | 
				
			|||||||
typedef WilsonImpl<vComplexF, TwoIndexAntiSymmetricRepresentation, CoeffReal > WilsonTwoIndexAntiSymmetricImplF;  // Float
 | 
					typedef WilsonImpl<vComplexF, TwoIndexAntiSymmetricRepresentation, CoeffReal > WilsonTwoIndexAntiSymmetricImplF;  // Float
 | 
				
			||||||
typedef WilsonImpl<vComplexD, TwoIndexAntiSymmetricRepresentation, CoeffReal > WilsonTwoIndexAntiSymmetricImplD;  // Double
 | 
					typedef WilsonImpl<vComplexD, TwoIndexAntiSymmetricRepresentation, CoeffReal > WilsonTwoIndexAntiSymmetricImplD;  // Double
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//sp 2n
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplex,  SpFundamentalRepresentation, CoeffReal > SpWilsonImplR;  // Real.. whichever prec
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplexF, SpFundamentalRepresentation, CoeffReal > SpWilsonImplF;  // Float
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplexD, SpFundamentalRepresentation, CoeffReal > SpWilsonImplD;  // Double
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplex,  SpTwoIndexAntiSymmetricRepresentation, CoeffReal > SpWilsonTwoIndexAntiSymmetricImplR;  // Real.. whichever prec
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplexF, SpTwoIndexAntiSymmetricRepresentation, CoeffReal > SpWilsonTwoIndexAntiSymmetricImplF;  // Float
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplexD, SpTwoIndexAntiSymmetricRepresentation, CoeffReal > SpWilsonTwoIndexAntiSymmetricImplD;  // Double
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplex,  SpTwoIndexSymmetricRepresentation, CoeffReal > SpWilsonTwoIndexSymmetricImplR;  // Real.. whichever prec
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplexF, SpTwoIndexSymmetricRepresentation, CoeffReal > SpWilsonTwoIndexSymmetricImplF;  // Float
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplexD, SpTwoIndexSymmetricRepresentation, CoeffReal > SpWilsonTwoIndexSymmetricImplD;  // Double
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplex,  SpTwoIndexSymmetricRepresentation, CoeffReal > SpWilsonAdjImplR;  // Real.. whichever prec    // adj = 2indx symmetric for Sp(2N)
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplexF, SpTwoIndexSymmetricRepresentation, CoeffReal > SpWilsonAdjImplF;  // Float     // adj = 2indx symmetric for Sp(2N)
 | 
					 | 
				
			||||||
typedef WilsonImpl<vComplexD, SpTwoIndexSymmetricRepresentation, CoeffReal > SpWilsonAdjImplD;  // Double    // adj = 2indx symmetric for Sp(2N)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,8 +63,6 @@ public:
 | 
				
			|||||||
  virtual void MooeeDag(const FermionField &in, FermionField &out) ;
 | 
					  virtual void MooeeDag(const FermionField &in, FermionField &out) ;
 | 
				
			||||||
  virtual void MooeeInv(const FermionField &in, FermionField &out) ;
 | 
					  virtual void MooeeInv(const FermionField &in, FermionField &out) ;
 | 
				
			||||||
  virtual void MooeeInvDag(const FermionField &in, FermionField &out) ;
 | 
					  virtual void MooeeInvDag(const FermionField &in, FermionField &out) ;
 | 
				
			||||||
  virtual void M(const FermionField &in, FermionField &out) ;
 | 
					 | 
				
			||||||
  virtual void Mdag(const FermionField &in, FermionField &out) ;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  RealD mu; // TwistedMass parameter
 | 
					  RealD mu; // TwistedMass parameter
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -423,6 +423,7 @@ void WilsonKernels<Impl>::DhopDirKernel( StencilImpl &st, DoubledGaugeField &U,S
 | 
				
			|||||||
#define KERNEL_CALL(A) KERNEL_CALLNB(A); accelerator_barrier();
 | 
					#define KERNEL_CALL(A) KERNEL_CALLNB(A); accelerator_barrier();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define KERNEL_CALL_EXT(A)						\
 | 
					#define KERNEL_CALL_EXT(A)						\
 | 
				
			||||||
 | 
					  const uint64_t    NN = Nsite*Ls;					\
 | 
				
			||||||
  const uint64_t    sz = st.surface_list.size();			\
 | 
					  const uint64_t    sz = st.surface_list.size();			\
 | 
				
			||||||
  auto ptr = &st.surface_list[0];					\
 | 
					  auto ptr = &st.surface_list[0];					\
 | 
				
			||||||
  accelerator_forNB( ss, sz, Simd::Nsimd(), {				\
 | 
					  accelerator_forNB( ss, sz, Simd::Nsimd(), {				\
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -93,25 +93,5 @@ void WilsonTMFermion<Impl>::MooeeInvDag(const FermionField &in, FermionField &ou
 | 
				
			|||||||
  RealD b    = tm /sq;
 | 
					  RealD b    = tm /sq;
 | 
				
			||||||
  axpibg5x(out,in,a,b);
 | 
					  axpibg5x(out,in,a,b);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
template<class Impl>
 | 
					 | 
				
			||||||
void WilsonTMFermion<Impl>::M(const FermionField &in, FermionField &out) {
 | 
					 | 
				
			||||||
  out.Checkerboard() = in.Checkerboard();
 | 
					 | 
				
			||||||
  this->Dhop(in, out, DaggerNo);
 | 
					 | 
				
			||||||
  FermionField tmp(out.Grid());
 | 
					 | 
				
			||||||
  RealD a = 4.0+this->mass;
 | 
					 | 
				
			||||||
  RealD b = this->mu;
 | 
					 | 
				
			||||||
  axpibg5x(tmp,in,a,b);
 | 
					 | 
				
			||||||
  axpy(out, 1.0, tmp, out);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
template<class Impl>
 | 
					 | 
				
			||||||
void WilsonTMFermion<Impl>::Mdag(const FermionField &in, FermionField &out) {
 | 
					 | 
				
			||||||
  out.Checkerboard() = in.Checkerboard();
 | 
					 | 
				
			||||||
  this->Dhop(in, out, DaggerYes);
 | 
					 | 
				
			||||||
  FermionField tmp(out.Grid());
 | 
					 | 
				
			||||||
  RealD a = 4.0+this->mass;
 | 
					 | 
				
			||||||
  RealD b = -this->mu;
 | 
					 | 
				
			||||||
  axpibg5x(tmp,in,a,b);
 | 
					 | 
				
			||||||
  axpy(out, 1.0, tmp, out);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonCloverFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonKernelsInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonTMFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
#define IMPLEMENTATION SpWilsonImplD
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonCloverFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonKernelsInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonTMFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
#define IMPLEMENTATION SpWilsonImplF
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonCloverFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonKernelsInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonTMFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
#define IMPLEMENTATION SpWilsonTwoIndexAntiSymmetricImplD
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonCloverFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonKernelsInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonTMFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
#define IMPLEMENTATION SpWilsonTwoIndexAntiSymmetricImplF
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonCloverFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonKernelsInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonTMFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
#define IMPLEMENTATION SpWilsonTwoIndexSymmetricImplD
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonCloverFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonKernelsInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
../WilsonTMFermionInstantiation.cc.master
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
#define IMPLEMENTATION SpWilsonTwoIndexSymmetricImplF
 | 
					 | 
				
			||||||
@@ -10,18 +10,12 @@ WILSON_IMPL_LIST=" \
 | 
				
			|||||||
	   WilsonImplF \
 | 
						   WilsonImplF \
 | 
				
			||||||
	   WilsonImplD \
 | 
						   WilsonImplD \
 | 
				
			||||||
	   WilsonImplD2 \
 | 
						   WilsonImplD2 \
 | 
				
			||||||
	   SpWilsonImplF \
 | 
					 | 
				
			||||||
	   SpWilsonImplD \
 | 
					 | 
				
			||||||
	   WilsonAdjImplF \
 | 
						   WilsonAdjImplF \
 | 
				
			||||||
	   WilsonAdjImplD \
 | 
						   WilsonAdjImplD \
 | 
				
			||||||
	   WilsonTwoIndexSymmetricImplF \
 | 
						   WilsonTwoIndexSymmetricImplF \
 | 
				
			||||||
	   WilsonTwoIndexSymmetricImplD \
 | 
						   WilsonTwoIndexSymmetricImplD \
 | 
				
			||||||
	   WilsonTwoIndexAntiSymmetricImplF \
 | 
						   WilsonTwoIndexAntiSymmetricImplF \
 | 
				
			||||||
	   WilsonTwoIndexAntiSymmetricImplD \
 | 
						   WilsonTwoIndexAntiSymmetricImplD \
 | 
				
			||||||
	   SpWilsonTwoIndexAntiSymmetricImplF \
 | 
					 | 
				
			||||||
	   SpWilsonTwoIndexAntiSymmetricImplD \
 | 
					 | 
				
			||||||
	   SpWilsonTwoIndexSymmetricImplF \
 | 
					 | 
				
			||||||
	   SpWilsonTwoIndexSymmetricImplD \
 | 
					 | 
				
			||||||
	   GparityWilsonImplF \
 | 
						   GparityWilsonImplF \
 | 
				
			||||||
	   GparityWilsonImplD "
 | 
						   GparityWilsonImplD "
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,9 +39,6 @@ NAMESPACE_BEGIN(Grid);
 | 
				
			|||||||
typedef WilsonGaugeAction<PeriodicGimplR>          WilsonGaugeActionR;
 | 
					typedef WilsonGaugeAction<PeriodicGimplR>          WilsonGaugeActionR;
 | 
				
			||||||
typedef WilsonGaugeAction<PeriodicGimplF>          WilsonGaugeActionF;
 | 
					typedef WilsonGaugeAction<PeriodicGimplF>          WilsonGaugeActionF;
 | 
				
			||||||
typedef WilsonGaugeAction<PeriodicGimplD>          WilsonGaugeActionD;
 | 
					typedef WilsonGaugeAction<PeriodicGimplD>          WilsonGaugeActionD;
 | 
				
			||||||
typedef WilsonGaugeAction<SpPeriodicGimplR>        SpWilsonGaugeActionR;
 | 
					 | 
				
			||||||
typedef WilsonGaugeAction<SpPeriodicGimplF>        SpWilsonGaugeActionF;
 | 
					 | 
				
			||||||
typedef WilsonGaugeAction<SpPeriodicGimplD>        SpWilsonGaugeActionD;
 | 
					 | 
				
			||||||
typedef PlaqPlusRectangleAction<PeriodicGimplR>    PlaqPlusRectangleActionR;
 | 
					typedef PlaqPlusRectangleAction<PeriodicGimplR>    PlaqPlusRectangleActionR;
 | 
				
			||||||
typedef PlaqPlusRectangleAction<PeriodicGimplF>    PlaqPlusRectangleActionF;
 | 
					typedef PlaqPlusRectangleAction<PeriodicGimplF>    PlaqPlusRectangleActionF;
 | 
				
			||||||
typedef PlaqPlusRectangleAction<PeriodicGimplD>    PlaqPlusRectangleActionD;
 | 
					typedef PlaqPlusRectangleAction<PeriodicGimplD>    PlaqPlusRectangleActionD;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,7 +61,7 @@ NAMESPACE_BEGIN(Grid);
 | 
				
			|||||||
  typedef typename Impl::Field Field;
 | 
					  typedef typename Impl::Field Field;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// hardcodes the exponential approximation in the template
 | 
					// hardcodes the exponential approximation in the template
 | 
				
			||||||
template <class S, int Nrepresentation = Nc, int Nexp = 12, class Group = SU<Nc> > class GaugeImplTypes {
 | 
					template <class S, int Nrepresentation = Nc, int Nexp = 12 > class GaugeImplTypes {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  typedef S Simd;
 | 
					  typedef S Simd;
 | 
				
			||||||
  typedef typename Simd::scalar_type scalar_type;
 | 
					  typedef typename Simd::scalar_type scalar_type;
 | 
				
			||||||
@@ -78,6 +78,8 @@ public:
 | 
				
			|||||||
  typedef Lattice<SiteLink>    LinkField; 
 | 
					  typedef Lattice<SiteLink>    LinkField; 
 | 
				
			||||||
  typedef Lattice<SiteField>   Field;
 | 
					  typedef Lattice<SiteField>   Field;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef SU<Nrepresentation> Group;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Guido: we can probably separate the types from the HMC functions
 | 
					  // Guido: we can probably separate the types from the HMC functions
 | 
				
			||||||
  // this will create 2 kind of implementations
 | 
					  // this will create 2 kind of implementations
 | 
				
			||||||
  // probably confusing the users
 | 
					  // probably confusing the users
 | 
				
			||||||
@@ -117,7 +119,6 @@ public:
 | 
				
			|||||||
    //
 | 
					    //
 | 
				
			||||||
    LinkField Pmu(P.Grid());
 | 
					    LinkField Pmu(P.Grid());
 | 
				
			||||||
    Pmu = Zero();
 | 
					    Pmu = Zero();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int mu = 0; mu < Nd; mu++) {
 | 
					    for (int mu = 0; mu < Nd; mu++) {
 | 
				
			||||||
      Group::GaussianFundamentalLieAlgebraMatrix(pRNG, Pmu);
 | 
					      Group::GaussianFundamentalLieAlgebraMatrix(pRNG, Pmu);
 | 
				
			||||||
      RealD scale = ::sqrt(HMC_MOMENTUM_DENOMINATOR) ;
 | 
					      RealD scale = ::sqrt(HMC_MOMENTUM_DENOMINATOR) ;
 | 
				
			||||||
@@ -126,11 +127,7 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static inline Field projectForce(Field &P) {
 | 
					  static inline Field projectForce(Field &P) { return Ta(P); }
 | 
				
			||||||
      Field ret(P.Grid());
 | 
					 | 
				
			||||||
      Group::taProj(P, ret);
 | 
					 | 
				
			||||||
      return ret;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static inline void update_field(Field& P, Field& U, double ep){
 | 
					  static inline void update_field(Field& P, Field& U, double ep){
 | 
				
			||||||
    //static std::chrono::duration<double> diff;
 | 
					    //static std::chrono::duration<double> diff;
 | 
				
			||||||
@@ -140,8 +137,7 @@ public:
 | 
				
			|||||||
    autoView(P_v,P,AcceleratorRead);
 | 
					    autoView(P_v,P,AcceleratorRead);
 | 
				
			||||||
    accelerator_for(ss, P.Grid()->oSites(),1,{
 | 
					    accelerator_for(ss, P.Grid()->oSites(),1,{
 | 
				
			||||||
      for (int mu = 0; mu < Nd; mu++) {
 | 
					      for (int mu = 0; mu < Nd; mu++) {
 | 
				
			||||||
          U_v[ss](mu) = Exponentiate(P_v[ss](mu), ep, Nexp) * U_v[ss](mu);
 | 
					        U_v[ss](mu) = ProjectOnGroup(Exponentiate(P_v[ss](mu), ep, Nexp) * U_v[ss](mu));
 | 
				
			||||||
          U_v[ss](mu) = Group::ProjectOnGeneralGroup(U_v[ss](mu));
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
   //auto end = std::chrono::high_resolution_clock::now();
 | 
					   //auto end = std::chrono::high_resolution_clock::now();
 | 
				
			||||||
@@ -161,7 +157,7 @@ public:
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static inline void Project(Field &U) {
 | 
					  static inline void Project(Field &U) {
 | 
				
			||||||
    Group::ProjectOnSpecialGroup(U);
 | 
					    ProjectSUn(U);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static inline void HotConfiguration(GridParallelRNG &pRNG, Field &U) {
 | 
					  static inline void HotConfiguration(GridParallelRNG &pRNG, Field &U) {
 | 
				
			||||||
@@ -175,7 +171,6 @@ public:
 | 
				
			|||||||
  static inline void ColdConfiguration(GridParallelRNG &pRNG, Field &U) {
 | 
					  static inline void ColdConfiguration(GridParallelRNG &pRNG, Field &U) {
 | 
				
			||||||
    Group::ColdConfiguration(pRNG, U);
 | 
					    Group::ColdConfiguration(pRNG, U);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -183,17 +178,10 @@ typedef GaugeImplTypes<vComplex, Nc> GimplTypesR;
 | 
				
			|||||||
typedef GaugeImplTypes<vComplexF, Nc> GimplTypesF;
 | 
					typedef GaugeImplTypes<vComplexF, Nc> GimplTypesF;
 | 
				
			||||||
typedef GaugeImplTypes<vComplexD, Nc> GimplTypesD;
 | 
					typedef GaugeImplTypes<vComplexD, Nc> GimplTypesD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef GaugeImplTypes<vComplex, Nc, 12, Sp<Nc> > SpGimplTypesR;
 | 
					 | 
				
			||||||
typedef GaugeImplTypes<vComplexF, Nc, 12, Sp<Nc> > SpGimplTypesF;
 | 
					 | 
				
			||||||
typedef GaugeImplTypes<vComplexD, Nc, 12, Sp<Nc> > SpGimplTypesD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef GaugeImplTypes<vComplex, SU<Nc>::AdjointDimension> GimplAdjointTypesR;
 | 
					typedef GaugeImplTypes<vComplex, SU<Nc>::AdjointDimension> GimplAdjointTypesR;
 | 
				
			||||||
typedef GaugeImplTypes<vComplexF, SU<Nc>::AdjointDimension> GimplAdjointTypesF;
 | 
					typedef GaugeImplTypes<vComplexF, SU<Nc>::AdjointDimension> GimplAdjointTypesF;
 | 
				
			||||||
typedef GaugeImplTypes<vComplexD, SU<Nc>::AdjointDimension> GimplAdjointTypesD;
 | 
					typedef GaugeImplTypes<vComplexD, SU<Nc>::AdjointDimension> GimplAdjointTypesD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // GRID_GAUGE_IMPL_TYPES_H
 | 
					#endif // GRID_GAUGE_IMPL_TYPES_H
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -176,7 +176,7 @@ public:
 | 
				
			|||||||
      return PeriodicBC::CshiftLink(Link,mu,shift);
 | 
					      return PeriodicBC::CshiftLink(Link,mu,shift);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static inline void       setDirections(const std::vector<int> &conjDirs) { _conjDirs=conjDirs; }
 | 
					  static inline void       setDirections(std::vector<int> &conjDirs) { _conjDirs=conjDirs; }
 | 
				
			||||||
  static inline std::vector<int> getDirections(void) { return _conjDirs; }
 | 
					  static inline std::vector<int> getDirections(void) { return _conjDirs; }
 | 
				
			||||||
  static inline bool isPeriodicGaugeField(void) { return false; }
 | 
					  static inline bool isPeriodicGaugeField(void) { return false; }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -193,11 +193,6 @@ typedef ConjugateGaugeImpl<GimplTypesR> ConjugateGimplR; // Real.. whichever pre
 | 
				
			|||||||
typedef ConjugateGaugeImpl<GimplTypesF> ConjugateGimplF; // Float
 | 
					typedef ConjugateGaugeImpl<GimplTypesF> ConjugateGimplF; // Float
 | 
				
			||||||
typedef ConjugateGaugeImpl<GimplTypesD> ConjugateGimplD; // Double
 | 
					typedef ConjugateGaugeImpl<GimplTypesD> ConjugateGimplD; // Double
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef PeriodicGaugeImpl<SpGimplTypesR> SpPeriodicGimplR; // Real.. whichever prec
 | 
					 | 
				
			||||||
typedef PeriodicGaugeImpl<SpGimplTypesF> SpPeriodicGimplF; // Float
 | 
					 | 
				
			||||||
typedef PeriodicGaugeImpl<SpGimplTypesD> SpPeriodicGimplD; // Double
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,7 +43,7 @@ public:
 | 
				
			|||||||
private:
 | 
					private:
 | 
				
			||||||
  RealD c_plaq;
 | 
					  RealD c_plaq;
 | 
				
			||||||
  RealD c_rect;
 | 
					  RealD c_rect;
 | 
				
			||||||
  typename WilsonLoops<Gimpl>::StapleAndRectStapleAllWorkspace workspace;
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  PlaqPlusRectangleAction(RealD b,RealD c): c_plaq(b),c_rect(c){};
 | 
					  PlaqPlusRectangleAction(RealD b,RealD c): c_plaq(b),c_rect(c){};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -79,18 +79,27 @@ public:
 | 
				
			|||||||
    GridBase *grid = Umu.Grid();
 | 
					    GridBase *grid = Umu.Grid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::vector<GaugeLinkField> U (Nd,grid);
 | 
					    std::vector<GaugeLinkField> U (Nd,grid);
 | 
				
			||||||
 | 
					    std::vector<GaugeLinkField> U2(Nd,grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for(int mu=0;mu<Nd;mu++){
 | 
					    for(int mu=0;mu<Nd;mu++){
 | 
				
			||||||
      U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
 | 
					      U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
 | 
				
			||||||
 | 
					      WilsonLoops<Gimpl>::RectStapleDouble(U2[mu],U[mu],mu);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    std::vector<GaugeLinkField> RectStaple(Nd,grid), Staple(Nd,grid);
 | 
					 | 
				
			||||||
    WilsonLoops<Gimpl>::StapleAndRectStapleAll(Staple, RectStaple, U, workspace);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GaugeLinkField dSdU_mu(grid);
 | 
					    GaugeLinkField dSdU_mu(grid);
 | 
				
			||||||
    GaugeLinkField staple(grid);
 | 
					    GaugeLinkField staple(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int mu=0; mu < Nd; mu++){
 | 
					    for (int mu=0; mu < Nd; mu++){
 | 
				
			||||||
      dSdU_mu = Ta(U[mu]*Staple[mu])*factor_p;
 | 
					
 | 
				
			||||||
      dSdU_mu = dSdU_mu + Ta(U[mu]*RectStaple[mu])*factor_r;
 | 
					      // Staple in direction mu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      WilsonLoops<Gimpl>::Staple(staple,Umu,mu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      dSdU_mu = Ta(U[mu]*staple)*factor_p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      WilsonLoops<Gimpl>::RectStaple(Umu,staple,U2,U,mu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      dSdU_mu = dSdU_mu + Ta(U[mu]*staple)*factor_r;
 | 
				
			||||||
	  
 | 
						  
 | 
				
			||||||
      PokeIndex<LorentzIndex>(dSdU, dSdU_mu, mu);
 | 
					      PokeIndex<LorentzIndex>(dSdU, dSdU_mu, mu);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -225,18 +225,6 @@ template <class RepresentationsPolicy,
 | 
				
			|||||||
using GenericHMCRunnerHirep =
 | 
					using GenericHMCRunnerHirep =
 | 
				
			||||||
				     HMCWrapperTemplate<PeriodicGimplR, Integrator, RepresentationsPolicy>;
 | 
									     HMCWrapperTemplate<PeriodicGimplR, Integrator, RepresentationsPolicy>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// sp2n
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <template <typename, typename, typename> class Integrator>
 | 
					 | 
				
			||||||
using GenericSpHMCRunner = HMCWrapperTemplate<SpPeriodicGimplR, Integrator>;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class RepresentationsPolicy,
 | 
					 | 
				
			||||||
          template <typename, typename, typename> class Integrator>
 | 
					 | 
				
			||||||
using GenericSpHMCRunnerHirep =
 | 
					 | 
				
			||||||
                     HMCWrapperTemplate<SpPeriodicGimplR, Integrator, RepresentationsPolicy>;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class Implementation, class RepresentationsPolicy, 
 | 
					template <class Implementation, class RepresentationsPolicy, 
 | 
				
			||||||
          template <typename, typename, typename> class Integrator>
 | 
					          template <typename, typename, typename> class Integrator>
 | 
				
			||||||
using GenericHMCRunnerTemplate = HMCWrapperTemplate<Implementation, Integrator, RepresentationsPolicy>;
 | 
					using GenericHMCRunnerTemplate = HMCWrapperTemplate<Implementation, Integrator, RepresentationsPolicy>;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -87,8 +87,6 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const ActionSet<Field, RepresentationPolicy> as;
 | 
					  const ActionSet<Field, RepresentationPolicy> as;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ActionSet<Field,RepresentationPolicy> LevelForces;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  //Get a pointer to a shared static instance of the "do-nothing" momentum filter to serve as a default
 | 
					  //Get a pointer to a shared static instance of the "do-nothing" momentum filter to serve as a default
 | 
				
			||||||
  static MomentumFilterBase<MomentaField> const* getDefaultMomFilter(){ 
 | 
					  static MomentumFilterBase<MomentaField> const* getDefaultMomFilter(){ 
 | 
				
			||||||
    static MomentumFilterNone<MomentaField> filter;
 | 
					    static MomentumFilterNone<MomentaField> filter;
 | 
				
			||||||
@@ -126,9 +124,6 @@ public:
 | 
				
			|||||||
    // input U actually not used in the fundamental case
 | 
					    // input U actually not used in the fundamental case
 | 
				
			||||||
    // Fundamental updates, include smearing
 | 
					    // Fundamental updates, include smearing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert(as.size()==LevelForces.size());
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    Field level_force(U.Grid()); level_force =Zero();
 | 
					 | 
				
			||||||
    for (int a = 0; a < as[level].actions.size(); ++a) {
 | 
					    for (int a = 0; a < as[level].actions.size(); ++a) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      double start_full = usecond();
 | 
					      double start_full = usecond();
 | 
				
			||||||
@@ -150,9 +145,6 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      std::cout << GridLogIntegrator << " update_P : Level [" << level <<"]["<<a <<"] "<<name<<" dt "<<ep<<  std::endl;
 | 
					      std::cout << GridLogIntegrator << " update_P : Level [" << level <<"]["<<a <<"] "<<name<<" dt "<<ep<<  std::endl;
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      // track the total
 | 
					 | 
				
			||||||
      level_force = level_force+force;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      Real force_abs   = std::sqrt(norm2(force)/U.Grid()->gSites()); //average per-site norm.  nb. norm2(latt) = \sum_x norm2(latt[x]) 
 | 
					      Real force_abs   = std::sqrt(norm2(force)/U.Grid()->gSites()); //average per-site norm.  nb. norm2(latt) = \sum_x norm2(latt[x]) 
 | 
				
			||||||
      Real impulse_abs = force_abs * ep * HMC_MOMENTUM_DENOMINATOR;    
 | 
					      Real impulse_abs = force_abs * ep * HMC_MOMENTUM_DENOMINATOR;    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -175,16 +167,6 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      // total force
 | 
					 | 
				
			||||||
      Real force_abs   = std::sqrt(norm2(level_force)/U.Grid()->gSites()); //average per-site norm.  nb. norm2(latt) = \sum_x norm2(latt[x]) 
 | 
					 | 
				
			||||||
      Real impulse_abs = force_abs * ep * HMC_MOMENTUM_DENOMINATOR;    
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      Real force_max   = std::sqrt(maxLocalNorm2(level_force));
 | 
					 | 
				
			||||||
      Real impulse_max = force_max * ep * HMC_MOMENTUM_DENOMINATOR;    
 | 
					 | 
				
			||||||
      LevelForces[level].actions.at(0)->deriv_log(force_abs,force_max,impulse_abs,impulse_max);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Force from the other representations
 | 
					    // Force from the other representations
 | 
				
			||||||
    as[level].apply(update_P_hireps, Representations, Mom, U, ep);
 | 
					    as[level].apply(update_P_hireps, Representations, Mom, U, ep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -234,16 +216,6 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    //Default the momentum filter to "do-nothing"
 | 
					    //Default the momentum filter to "do-nothing"
 | 
				
			||||||
    MomFilter = getDefaultMomFilter();
 | 
					    MomFilter = getDefaultMomFilter();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int level = 0; level < as.size(); ++level) {
 | 
					 | 
				
			||||||
      int multiplier = as.at(level).multiplier;
 | 
					 | 
				
			||||||
      ActionLevel<Field> * Level = new ActionLevel<Field>(multiplier);
 | 
					 | 
				
			||||||
      Level->push_back(new EmptyAction<Field>); 
 | 
					 | 
				
			||||||
      LevelForces.push_back(*Level);
 | 
					 | 
				
			||||||
      // does it copy by value or reference??
 | 
					 | 
				
			||||||
      // - answer it copies by value, BUT the action level contains a reference that is NOT updated.
 | 
					 | 
				
			||||||
      // Unsafe code in Guido's area
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  virtual ~Integrator() {}
 | 
					  virtual ~Integrator() {}
 | 
				
			||||||
@@ -261,14 +233,10 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  void reset_timer(void)
 | 
					  void reset_timer(void)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    assert(as.size()==LevelForces.size());
 | 
					 | 
				
			||||||
    for (int level = 0; level < as.size(); ++level) {
 | 
					    for (int level = 0; level < as.size(); ++level) {
 | 
				
			||||||
      for (int actionID = 0; actionID < as[level].actions.size(); ++actionID) {
 | 
					      for (int actionID = 0; actionID < as[level].actions.size(); ++actionID) {
 | 
				
			||||||
        as[level].actions.at(actionID)->reset_timer();
 | 
					        as[level].actions.at(actionID)->reset_timer();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      int actionID=0;
 | 
					 | 
				
			||||||
      assert(LevelForces.at(level).actions.size()==1);
 | 
					 | 
				
			||||||
      LevelForces.at(level).actions.at(actionID)->reset_timer();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  void print_timer(void)
 | 
					  void print_timer(void)
 | 
				
			||||||
@@ -330,16 +298,6 @@ public:
 | 
				
			|||||||
		  <<" calls "     << as[level].actions.at(actionID)->deriv_num
 | 
							  <<" calls "     << as[level].actions.at(actionID)->deriv_num
 | 
				
			||||||
		  << std::endl;
 | 
							  << std::endl;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      int actionID=0;
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage 
 | 
					 | 
				
			||||||
		  << LevelForces[level].actions.at(actionID)->action_name()
 | 
					 | 
				
			||||||
		  <<"["<<level<<"]["<< actionID<<"] :\n\t\t "
 | 
					 | 
				
			||||||
		  <<" force max " << LevelForces[level].actions.at(actionID)->deriv_max_average()
 | 
					 | 
				
			||||||
		  <<" norm "      << LevelForces[level].actions.at(actionID)->deriv_norm_average()
 | 
					 | 
				
			||||||
		  <<" Fdt max  "  << LevelForces[level].actions.at(actionID)->Fdt_max_average()
 | 
					 | 
				
			||||||
		  <<" Fdt norm "  << LevelForces[level].actions.at(actionID)->Fdt_norm_average()
 | 
					 | 
				
			||||||
		  <<" calls "     << LevelForces[level].actions.at(actionID)->deriv_num
 | 
					 | 
				
			||||||
		  << std::endl;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    std::cout << GridLogMessage << ":::::::::::::::::::::::::::::::::::::::::"<< std::endl;
 | 
					    std::cout << GridLogMessage << ":::::::::::::::::::::::::::::::::::::::::"<< std::endl;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -361,13 +319,6 @@ public:
 | 
				
			|||||||
	std::cout << as[level].actions.at(actionID)->LogParameters();
 | 
						std::cout << as[level].actions.at(actionID)->LogParameters();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    std::cout << " [Integrator] Total Force loggers: "<< LevelForces.size() <<std::endl;
 | 
					 | 
				
			||||||
    for (int level = 0; level < LevelForces.size(); ++level) {
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << "[Integrator] ---- Level: "<< level << std::endl;
 | 
					 | 
				
			||||||
      for (int actionID = 0; actionID < LevelForces[level].actions.size(); ++actionID) {
 | 
					 | 
				
			||||||
	std::cout << GridLogMessage << "["<< LevelForces[level].actions.at(actionID)->action_name() << "] ID: " << actionID << std::endl;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << ":::::::::::::::::::::::::::::::::::::::::"<< std::endl;
 | 
					    std::cout << GridLogMessage << ":::::::::::::::::::::::::::::::::::::::::"<< std::endl;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -449,7 +400,6 @@ public:
 | 
				
			|||||||
  RealD S(Field& U) 
 | 
					  RealD S(Field& U) 
 | 
				
			||||||
  {  // here also U not used
 | 
					  {  // here also U not used
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert(as.size()==LevelForces.size());
 | 
					 | 
				
			||||||
    std::cout << GridLogIntegrator << "Integrator action\n";
 | 
					    std::cout << GridLogIntegrator << "Integrator action\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    RealD H = - FieldImplementation::FieldSquareNorm(P)/HMC_MOMENTUM_DENOMINATOR; // - trace (P*P)/denom
 | 
					    RealD H = - FieldImplementation::FieldSquareNorm(P)/HMC_MOMENTUM_DENOMINATOR; // - trace (P*P)/denom
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ NAMESPACE_BEGIN(Grid);
 | 
				
			|||||||
 * Empty since HMC updates already the fundamental representation 
 | 
					 * Empty since HMC updates already the fundamental representation 
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <int ncolour, class group_name>
 | 
					template <int ncolour>
 | 
				
			||||||
class FundamentalRep {
 | 
					class FundamentalRep {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  static const int Dimension = ncolour;
 | 
					  static const int Dimension = ncolour;
 | 
				
			||||||
@@ -21,7 +21,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // typdef to be used by the Representations class in HMC to get the
 | 
					  // typdef to be used by the Representations class in HMC to get the
 | 
				
			||||||
  // types for the higher representation fields
 | 
					  // types for the higher representation fields
 | 
				
			||||||
  typedef typename GaugeGroup<ncolour,group_name>::LatticeMatrix LatticeMatrix;
 | 
					  typedef typename SU<ncolour>::LatticeMatrix LatticeMatrix;
 | 
				
			||||||
  typedef LatticeGaugeField LatticeField;
 | 
					  typedef LatticeGaugeField LatticeField;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  explicit FundamentalRep(GridBase* grid) {} //do nothing
 | 
					  explicit FundamentalRep(GridBase* grid) {} //do nothing
 | 
				
			||||||
@@ -45,8 +45,7 @@ public:
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
typedef	 FundamentalRep<Nc,GroupName::SU> FundamentalRepresentation;
 | 
					typedef	 FundamentalRep<Nc> FundamentalRepresentation;
 | 
				
			||||||
typedef	 FundamentalRep<Nc,GroupName::Sp> SpFundamentalRepresentation;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
NAMESPACE_END(Grid);  
 | 
					NAMESPACE_END(Grid);  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,14 +20,14 @@ NAMESPACE_BEGIN(Grid);
 | 
				
			|||||||
 * in the SUnTwoIndex.h file
 | 
					 * in the SUnTwoIndex.h file
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <int ncolour, TwoIndexSymmetry S, class group_name = GroupName::SU>
 | 
					template <int ncolour, TwoIndexSymmetry S>
 | 
				
			||||||
class TwoIndexRep {
 | 
					class TwoIndexRep {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  // typdef to be used by the Representations class in HMC to get the
 | 
					  // typdef to be used by the Representations class in HMC to get the
 | 
				
			||||||
  // types for the higher representation fields
 | 
					  // types for the higher representation fields
 | 
				
			||||||
  typedef typename GaugeGroupTwoIndex<ncolour, S, group_name>::LatticeTwoIndexMatrix LatticeMatrix;
 | 
					  typedef typename SU_TwoIndex<ncolour, S>::LatticeTwoIndexMatrix LatticeMatrix;
 | 
				
			||||||
  typedef typename GaugeGroupTwoIndex<ncolour, S, group_name>::LatticeTwoIndexField LatticeField;
 | 
					  typedef typename SU_TwoIndex<ncolour, S>::LatticeTwoIndexField LatticeField;
 | 
				
			||||||
  static const int Dimension = GaugeGroupTwoIndex<ncolour,S,group_name>::Dimension;
 | 
					  static const int Dimension = ncolour * (ncolour + S) / 2;
 | 
				
			||||||
  static const bool isFundamental = false;
 | 
					  static const bool isFundamental = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  LatticeField U;
 | 
					  LatticeField U;
 | 
				
			||||||
@@ -43,10 +43,10 @@ public:
 | 
				
			|||||||
    U = Zero();
 | 
					    U = Zero();
 | 
				
			||||||
    LatticeColourMatrix tmp(Uin.Grid());
 | 
					    LatticeColourMatrix tmp(Uin.Grid());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Vector<typename GaugeGroup<ncolour,group_name>::Matrix> eij(Dimension);
 | 
					    Vector<typename SU<ncolour>::Matrix> eij(Dimension);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int a = 0; a < Dimension; a++)
 | 
					    for (int a = 0; a < Dimension; a++)
 | 
				
			||||||
      GaugeGroupTwoIndex<ncolour, S, group_name>::base(a, eij[a]);
 | 
					      SU_TwoIndex<ncolour, S>::base(a, eij[a]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int mu = 0; mu < Nd; mu++) {
 | 
					    for (int mu = 0; mu < Nd; mu++) {
 | 
				
			||||||
      auto Uin_mu = peekLorentz(Uin, mu);
 | 
					      auto Uin_mu = peekLorentz(Uin, mu);
 | 
				
			||||||
@@ -71,7 +71,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      out_mu = Zero();
 | 
					      out_mu = Zero();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector h(in.Grid());
 | 
					      typename SU<ncolour>::LatticeAlgebraVector h(in.Grid());
 | 
				
			||||||
      projectOnAlgebra(h, in_mu, double(Nc + 2 * S));  // factor T(r)/T(fund)
 | 
					      projectOnAlgebra(h, in_mu, double(Nc + 2 * S));  // factor T(r)/T(fund)
 | 
				
			||||||
      FundamentalLieAlgebraMatrix(h, out_mu);          // apply scale only once
 | 
					      FundamentalLieAlgebraMatrix(h, out_mu);          // apply scale only once
 | 
				
			||||||
      pokeLorentz(out, out_mu, mu);
 | 
					      pokeLorentz(out, out_mu, mu);
 | 
				
			||||||
@@ -80,23 +80,20 @@ public:
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  void projectOnAlgebra(typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector &h_out,
 | 
					  void projectOnAlgebra(typename SU<ncolour>::LatticeAlgebraVector &h_out,
 | 
				
			||||||
                        const LatticeMatrix &in, Real scale = 1.0) const {
 | 
					                        const LatticeMatrix &in, Real scale = 1.0) const {
 | 
				
			||||||
    GaugeGroupTwoIndex<ncolour, S,group_name>::projectOnAlgebra(h_out, in, scale);
 | 
					    SU_TwoIndex<ncolour, S>::projectOnAlgebra(h_out, in, scale);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void FundamentalLieAlgebraMatrix(
 | 
					  void FundamentalLieAlgebraMatrix(
 | 
				
			||||||
				   typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector &h,
 | 
									   typename SU<ncolour>::LatticeAlgebraVector &h,
 | 
				
			||||||
				   typename GaugeGroup<ncolour, group_name>::LatticeMatrix &out, Real scale = 1.0) const {
 | 
									   typename SU<ncolour>::LatticeMatrix &out, Real scale = 1.0) const {
 | 
				
			||||||
    GaugeGroup<ncolour,group_name>::FundamentalLieAlgebraMatrix(h, out, scale);
 | 
					    SU<ncolour>::FundamentalLieAlgebraMatrix(h, out, scale);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef TwoIndexRep<Nc, Symmetric, GroupName::SU> TwoIndexSymmetricRepresentation;
 | 
					typedef TwoIndexRep<Nc, Symmetric> TwoIndexSymmetricRepresentation;
 | 
				
			||||||
typedef TwoIndexRep<Nc, AntiSymmetric, GroupName::SU> TwoIndexAntiSymmetricRepresentation;
 | 
					typedef TwoIndexRep<Nc, AntiSymmetric> TwoIndexAntiSymmetricRepresentation;
 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef TwoIndexRep<Nc, Symmetric, GroupName::Sp> SpTwoIndexSymmetricRepresentation;
 | 
					 | 
				
			||||||
typedef TwoIndexRep<Nc, AntiSymmetric, GroupName::Sp> SpTwoIndexAntiSymmetricRepresentation;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,3 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
/*!
 | 
					/*!
 | 
				
			||||||
  @file GaugeConfiguration.h
 | 
					  @file GaugeConfiguration.h
 | 
				
			||||||
  @brief Declares the GaugeConfiguration class
 | 
					  @brief Declares the GaugeConfiguration class
 | 
				
			||||||
@@ -7,15 +6,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
NAMESPACE_BEGIN(Grid);
 | 
					NAMESPACE_BEGIN(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
template<class T> void Dump(const Lattice<T> & lat,
 | 
					 | 
				
			||||||
			    std::string s,
 | 
					 | 
				
			||||||
			    Coordinate site = Coordinate({0,0,0,0}))
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  typename T::scalar_object tmp;
 | 
					 | 
				
			||||||
  peekSite(tmp,lat,site);
 | 
					 | 
				
			||||||
  std::cout << " Dump "<<s<<" "<<tmp<<std::endl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/*!
 | 
					/*!
 | 
				
			||||||
  @brief Smeared configuration masked container
 | 
					  @brief Smeared configuration masked container
 | 
				
			||||||
  Modified for a multi-subset smearing (aka Luscher Flowed HMC)
 | 
					  Modified for a multi-subset smearing (aka Luscher Flowed HMC)
 | 
				
			||||||
@@ -38,101 +28,6 @@ private:
 | 
				
			|||||||
  typedef typename SU3Adjoint::LatticeAdjMatrix  AdjMatrixField;
 | 
					  typedef typename SU3Adjoint::LatticeAdjMatrix  AdjMatrixField;
 | 
				
			||||||
  typedef typename SU3Adjoint::LatticeAdjVector  AdjVectorField;
 | 
					  typedef typename SU3Adjoint::LatticeAdjVector  AdjVectorField;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void BaseSmearDerivative(GaugeField& SigmaTerm,
 | 
					 | 
				
			||||||
			   const GaugeField& iLambda,
 | 
					 | 
				
			||||||
			   const GaugeField& U,
 | 
					 | 
				
			||||||
			   int mmu, RealD rho)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    // Reference
 | 
					 | 
				
			||||||
    // Morningstar, Peardon, Phys.Rev.D69,054501(2004)
 | 
					 | 
				
			||||||
    // Equation 75
 | 
					 | 
				
			||||||
    // Computing Sigma_mu, derivative of S[fat links] with respect to the thin links
 | 
					 | 
				
			||||||
    // Output SigmaTerm
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    GridBase *grid = U.Grid();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    WilsonLoops<Gimpl> WL;
 | 
					 | 
				
			||||||
    GaugeLinkField staple(grid), u_tmp(grid);
 | 
					 | 
				
			||||||
    GaugeLinkField iLambda_mu(grid), iLambda_nu(grid);
 | 
					 | 
				
			||||||
    GaugeLinkField U_mu(grid), U_nu(grid);
 | 
					 | 
				
			||||||
    GaugeLinkField sh_field(grid), temp_Sigma(grid);
 | 
					 | 
				
			||||||
    Real rho_munu, rho_numu;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    rho_munu = rho;
 | 
					 | 
				
			||||||
    rho_numu = rho;
 | 
					 | 
				
			||||||
    for(int mu = 0; mu < Nd; ++mu){
 | 
					 | 
				
			||||||
      U_mu       = peekLorentz(      U, mu);
 | 
					 | 
				
			||||||
      iLambda_mu = peekLorentz(iLambda, mu);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      for(int nu = 0; nu < Nd; ++nu){
 | 
					 | 
				
			||||||
	if(nu==mu) continue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	U_nu       = peekLorentz(      U, nu);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Nd(nd-1) = 12 staples normally.
 | 
					 | 
				
			||||||
	// We must compute 6 of these
 | 
					 | 
				
			||||||
	// in FTHMC case
 | 
					 | 
				
			||||||
	if ( (mu==mmu)||(nu==mmu) )
 | 
					 | 
				
			||||||
	  WL.StapleUpper(staple, U, mu, nu);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if(nu==mmu) {
 | 
					 | 
				
			||||||
	  iLambda_nu = peekLorentz(iLambda, nu);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	  temp_Sigma = -rho_numu*staple*iLambda_nu;  //ok
 | 
					 | 
				
			||||||
	  //-r_numu*U_nu(x+mu)*Udag_mu(x+nu)*Udag_nu(x)*Lambda_nu(x)
 | 
					 | 
				
			||||||
	  Gimpl::AddLink(SigmaTerm, temp_Sigma, mu);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	  sh_field = Cshift(iLambda_nu, mu, 1);// general also for Gparity?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	  temp_Sigma = rho_numu*sh_field*staple; //ok
 | 
					 | 
				
			||||||
	  //r_numu*Lambda_nu(mu)*U_nu(x+mu)*Udag_mu(x+nu)*Udag_nu(x)
 | 
					 | 
				
			||||||
	  Gimpl::AddLink(SigmaTerm, temp_Sigma, mu);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ( mu == mmu ) { 
 | 
					 | 
				
			||||||
	  sh_field = Cshift(iLambda_mu, nu, 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	  temp_Sigma = -rho_munu*staple*U_nu*sh_field*adj(U_nu); //ok
 | 
					 | 
				
			||||||
	  //-r_munu*U_nu(x+mu)*Udag_mu(x+nu)*Lambda_mu(x+nu)*Udag_nu(x)
 | 
					 | 
				
			||||||
	  Gimpl::AddLink(SigmaTerm, temp_Sigma, mu);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//	staple = Zero();
 | 
					 | 
				
			||||||
	sh_field = Cshift(U_nu, mu, 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	temp_Sigma = Zero();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ( mu == mmu )
 | 
					 | 
				
			||||||
	  temp_Sigma = -rho_munu*adj(sh_field)*adj(U_mu)*iLambda_mu*U_nu;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ( nu == mmu ) {
 | 
					 | 
				
			||||||
	  temp_Sigma += rho_numu*adj(sh_field)*adj(U_mu)*iLambda_nu*U_nu;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	  u_tmp = adj(U_nu)*iLambda_nu;
 | 
					 | 
				
			||||||
	  sh_field = Cshift(u_tmp, mu, 1);
 | 
					 | 
				
			||||||
	  temp_Sigma += -rho_numu*sh_field*adj(U_mu)*U_nu;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	sh_field = Cshift(temp_Sigma, nu, -1);
 | 
					 | 
				
			||||||
	Gimpl::AddLink(SigmaTerm, sh_field, mu);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  void BaseSmear(GaugeLinkField& Cup, const GaugeField& U,int mu,RealD rho) {
 | 
					 | 
				
			||||||
    GridBase *grid = U.Grid();
 | 
					 | 
				
			||||||
    GaugeLinkField tmp_stpl(grid);
 | 
					 | 
				
			||||||
    WilsonLoops<Gimpl> WL;
 | 
					 | 
				
			||||||
    Cup = Zero();
 | 
					 | 
				
			||||||
    for(int nu=0; nu<Nd; ++nu){
 | 
					 | 
				
			||||||
      if (nu != mu) {
 | 
					 | 
				
			||||||
	// get the staple in direction mu, nu
 | 
					 | 
				
			||||||
	WL.Staple(tmp_stpl, U, mu, nu);  //nb staple conventions of IroIro and Grid differ by a dagger
 | 
					 | 
				
			||||||
	Cup += adj(tmp_stpl*rho);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  // Adjoint vector to GaugeField force
 | 
					  // Adjoint vector to GaugeField force
 | 
				
			||||||
  void InsertForce(GaugeField &Fdet,AdjVectorField &Fdet_nu,int nu)
 | 
					  void InsertForce(GaugeField &Fdet,AdjVectorField &Fdet_nu,int nu)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@@ -152,54 +47,27 @@ private:
 | 
				
			|||||||
    GaugeLinkField UtaU(PlaqL.Grid());
 | 
					    GaugeLinkField UtaU(PlaqL.Grid());
 | 
				
			||||||
    GaugeLinkField D(PlaqL.Grid());
 | 
					    GaugeLinkField D(PlaqL.Grid());
 | 
				
			||||||
    AdjMatrixField Dbc(PlaqL.Grid());
 | 
					    AdjMatrixField Dbc(PlaqL.Grid());
 | 
				
			||||||
    AdjMatrixField Dbc_opt(PlaqL.Grid());
 | 
					 | 
				
			||||||
    LatticeComplex tmp(PlaqL.Grid());
 | 
					    LatticeComplex tmp(PlaqL.Grid());
 | 
				
			||||||
    const int Ngen = SU3Adjoint::Dimension;
 | 
					    const int Ngen = SU3Adjoint::Dimension;
 | 
				
			||||||
    Complex ci(0,1);
 | 
					    Complex ci(0,1);
 | 
				
			||||||
    ColourMatrix   ta,tb,tc;
 | 
					    ColourMatrix   ta,tb,tc;
 | 
				
			||||||
    RealD t=0;
 | 
					    
 | 
				
			||||||
    RealD tp=0;
 | 
					 | 
				
			||||||
    RealD tta=0;
 | 
					 | 
				
			||||||
    RealD tpk=0;
 | 
					 | 
				
			||||||
    t-=usecond();
 | 
					 | 
				
			||||||
    for(int a=0;a<Ngen;a++) {
 | 
					    for(int a=0;a<Ngen;a++) {
 | 
				
			||||||
      tta-=usecond();
 | 
					 | 
				
			||||||
      SU3::generator(a, ta);
 | 
					      SU3::generator(a, ta);
 | 
				
			||||||
      ta = 2.0 * ci * ta;
 | 
					 | 
				
			||||||
      // Qlat Tb = 2i Tb^Grid
 | 
					      // Qlat Tb = 2i Tb^Grid
 | 
				
			||||||
      UtaU= adj(PlaqL)*ta*PlaqR; // 6ms
 | 
					      UtaU= 2.0*ci*adj(PlaqL)*ta*PlaqR;
 | 
				
			||||||
      tta+=usecond();
 | 
					 | 
				
			||||||
      ////////////////////////////////////////////
 | 
					 | 
				
			||||||
      // Could add this entire C-loop to a projection routine
 | 
					 | 
				
			||||||
      // for performance. Could also pick checkerboard on UtaU
 | 
					 | 
				
			||||||
      // and set checkerboard on result for 2x perf
 | 
					 | 
				
			||||||
      ////////////////////////////////////////////
 | 
					 | 
				
			||||||
      for(int c=0;c<Ngen;c++) {
 | 
					      for(int c=0;c<Ngen;c++) {
 | 
				
			||||||
	SU3::generator(c, tc);
 | 
						SU3::generator(c, tc);
 | 
				
			||||||
	tc = 2.0*ci*tc;
 | 
						D = Ta( (2.0)*ci*tc *UtaU);
 | 
				
			||||||
	tp-=usecond(); 
 | 
					 | 
				
			||||||
	D = Ta( tc *UtaU); // 2ms
 | 
					 | 
				
			||||||
#if 1
 | 
					 | 
				
			||||||
	SU3::LieAlgebraProject(Dbc_opt,D,c); // 5.5ms
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	for(int b=0;b<Ngen;b++){
 | 
						for(int b=0;b<Ngen;b++){
 | 
				
			||||||
	  SU3::generator(b, tb);
 | 
						  SU3::generator(b, tb);
 | 
				
			||||||
	  tmp =-trace(ci*tb*D); 
 | 
						  tmp =-trace(ci*tb*D); 
 | 
				
			||||||
	  PokeIndex<ColourIndex>(Dbc,tmp,b,c);  // Adjoint rep
 | 
						  PokeIndex<ColourIndex>(Dbc,tmp,b,c);  // Adjoint rep
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	tp+=usecond();
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      //      Dump(Dbc_opt,"Dbc_opt");
 | 
					      tmp = trace(MpInvJx * Dbc);
 | 
				
			||||||
      //      Dump(Dbc,"Dbc");
 | 
					 | 
				
			||||||
      tpk-=usecond();
 | 
					 | 
				
			||||||
      tmp = trace(MpInvJx * Dbc_opt);
 | 
					 | 
				
			||||||
      PokeIndex<ColourIndex>(Fdet2,tmp,a);
 | 
					      PokeIndex<ColourIndex>(Fdet2,tmp,a);
 | 
				
			||||||
      tpk+=usecond();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    t+=usecond();
 | 
					 | 
				
			||||||
    std::cout << GridLogPerformance << " Compute_MpInvJx_dNxxdSy " << t/1e3 << " ms  proj "<<tp/1e3<< " ms"
 | 
					 | 
				
			||||||
	      << " ta "<<tta/1e3<<" ms" << " poke "<<tpk/1e3<< " ms"<<std::endl;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  void ComputeNxy(const GaugeLinkField &PlaqL,const GaugeLinkField &PlaqR,AdjMatrixField &NxAd)
 | 
					  void ComputeNxy(const GaugeLinkField &PlaqL,const GaugeLinkField &PlaqR,AdjMatrixField &NxAd)
 | 
				
			||||||
@@ -211,17 +79,12 @@ private:
 | 
				
			|||||||
    ColourMatrix   tc;
 | 
					    ColourMatrix   tc;
 | 
				
			||||||
    for(int b=0;b<Ngen;b++) {
 | 
					    for(int b=0;b<Ngen;b++) {
 | 
				
			||||||
      SU3::generator(b, tb);
 | 
					      SU3::generator(b, tb);
 | 
				
			||||||
      tb = 2.0 * ci * tb;
 | 
					      Nx = (2.0)*Ta( adj(PlaqL)*ci*tb * PlaqR );
 | 
				
			||||||
      Nx = Ta( adj(PlaqL)*tb * PlaqR );
 | 
					 | 
				
			||||||
#if 1
 | 
					 | 
				
			||||||
      SU3::LieAlgebraProject(NxAd,Nx,b);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
      for(int c=0;c<Ngen;c++) {
 | 
					      for(int c=0;c<Ngen;c++) {
 | 
				
			||||||
	SU3::generator(c, tc);
 | 
						SU3::generator(c, tc);
 | 
				
			||||||
	auto tmp =closure( -trace(ci*tc*Nx)); 
 | 
						auto tmp =closure( -trace(ci*tc*Nx)); 
 | 
				
			||||||
	PokeIndex<ColourIndex>(NxAd,tmp,c,b); 
 | 
						PokeIndex<ColourIndex>(NxAd,tmp,c,b); 
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  void ApplyMask(GaugeField &U,int smr)
 | 
					  void ApplyMask(GaugeField &U,int smr)
 | 
				
			||||||
@@ -301,7 +164,8 @@ public:
 | 
				
			|||||||
    // Computes ALL the staples -- could compute one only and do it here
 | 
					    // Computes ALL the staples -- could compute one only and do it here
 | 
				
			||||||
    RealD time;
 | 
					    RealD time;
 | 
				
			||||||
    time=-usecond();
 | 
					    time=-usecond();
 | 
				
			||||||
    BaseSmear(Cmu, U,mu,rho);
 | 
					    this->StoutSmearing->BaseSmear(C, U);
 | 
				
			||||||
 | 
					    Cmu = peekLorentz(C, mu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //////////////////////////////////////////////////////////////////
 | 
					    //////////////////////////////////////////////////////////////////
 | 
				
			||||||
    // Assemble Luscher exp diff map J matrix 
 | 
					    // Assemble Luscher exp diff map J matrix 
 | 
				
			||||||
@@ -345,36 +209,6 @@ public:
 | 
				
			|||||||
    // dJ(x)/dxe
 | 
					    // dJ(x)/dxe
 | 
				
			||||||
    //////////////////////////////////////
 | 
					    //////////////////////////////////////
 | 
				
			||||||
    time=-usecond();
 | 
					    time=-usecond();
 | 
				
			||||||
#if 1
 | 
					 | 
				
			||||||
    std::vector<AdjMatrixField>  dJdX;    dJdX.resize(8,grid);
 | 
					 | 
				
			||||||
    std::vector<AdjMatrix> TRb_s; TRb_s.resize(8);
 | 
					 | 
				
			||||||
    AdjMatrixField tbXn(grid);
 | 
					 | 
				
			||||||
    AdjMatrixField sumXtbX(grid);
 | 
					 | 
				
			||||||
    AdjMatrixField t2(grid);
 | 
					 | 
				
			||||||
    AdjMatrixField dt2(grid);
 | 
					 | 
				
			||||||
    AdjMatrixField t3(grid);
 | 
					 | 
				
			||||||
    AdjMatrixField dt3(grid);
 | 
					 | 
				
			||||||
    AdjMatrixField aunit(grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for(int b=0;b<8;b++){
 | 
					 | 
				
			||||||
      SU3Adjoint::generator(b, TRb_s[b]);
 | 
					 | 
				
			||||||
      dJdX[b] = TRb_s[b];
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    aunit = ComplexD(1.0);
 | 
					 | 
				
			||||||
    // Could put into an accelerator_for
 | 
					 | 
				
			||||||
    X  = (-1.0)*ZxAd; 
 | 
					 | 
				
			||||||
    t2 = X;
 | 
					 | 
				
			||||||
    for (int j = 12; j > 1; --j) {
 | 
					 | 
				
			||||||
      t3  = t2*(1.0 / (j + 1))  + aunit;
 | 
					 | 
				
			||||||
      t2  = X * t3;
 | 
					 | 
				
			||||||
      for(int b=0;b<8;b++){
 | 
					 | 
				
			||||||
	dJdX[b]= TRb_s[b] * t3 + X * dJdX[b]*(1.0 / (j + 1));
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    for(int b=0;b<8;b++){
 | 
					 | 
				
			||||||
      dJdX[b] = -dJdX[b];
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    std::vector<AdjMatrixField>  dJdX;    dJdX.resize(8,grid);
 | 
					    std::vector<AdjMatrixField>  dJdX;    dJdX.resize(8,grid);
 | 
				
			||||||
    AdjMatrixField tbXn(grid);
 | 
					    AdjMatrixField tbXn(grid);
 | 
				
			||||||
    AdjMatrixField sumXtbX(grid);
 | 
					    AdjMatrixField sumXtbX(grid);
 | 
				
			||||||
@@ -390,7 +224,7 @@ public:
 | 
				
			|||||||
      X  = (-1.0)*ZxAd; 
 | 
					      X  = (-1.0)*ZxAd; 
 | 
				
			||||||
      t2 = X;
 | 
					      t2 = X;
 | 
				
			||||||
      dt2 = TRb;
 | 
					      dt2 = TRb;
 | 
				
			||||||
      for (int j = 12; j > 1; --j) {
 | 
					      for (int j = 20; j > 1; --j) {
 | 
				
			||||||
	t3 = t2*(1.0 / (j + 1))  + aunit;
 | 
						t3 = t2*(1.0 / (j + 1))  + aunit;
 | 
				
			||||||
	dt3 = dt2*(1.0 / (j + 1));
 | 
						dt3 = dt2*(1.0 / (j + 1));
 | 
				
			||||||
	t2 = X * t3;
 | 
						t2 = X * t3;
 | 
				
			||||||
@@ -398,7 +232,6 @@ public:
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      dJdX[b] = -dt2; 
 | 
					      dJdX[b] = -dt2; 
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif  
 | 
					 | 
				
			||||||
    time+=usecond();
 | 
					    time+=usecond();
 | 
				
			||||||
    std::cout << GridLogMessage << "dJx took "<<time<< " us"<<std::endl;
 | 
					    std::cout << GridLogMessage << "dJx took "<<time<< " us"<<std::endl;
 | 
				
			||||||
    /////////////////////////////////////////////////////////////////
 | 
					    /////////////////////////////////////////////////////////////////
 | 
				
			||||||
@@ -448,8 +281,8 @@ public:
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    for(int e =0 ; e<8 ; e++){
 | 
					    for(int e =0 ; e<8 ; e++){
 | 
				
			||||||
      LatticeComplexD tr(grid);
 | 
					      LatticeComplexD tr(grid);
 | 
				
			||||||
      //      ColourMatrix te;
 | 
					      ColourMatrix te;
 | 
				
			||||||
      //      SU3::generator(e, te);
 | 
					      SU3::generator(e, te);
 | 
				
			||||||
      tr = trace(dJdX[e] * nMpInv);
 | 
					      tr = trace(dJdX[e] * nMpInv);
 | 
				
			||||||
      pokeColour(dJdXe_nMpInv,tr,e);
 | 
					      pokeColour(dJdXe_nMpInv,tr,e);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -660,25 +493,20 @@ public:
 | 
				
			|||||||
    //////////////////////////////////////////////////////////////////
 | 
					    //////////////////////////////////////////////////////////////////
 | 
				
			||||||
    // Assemble the N matrix
 | 
					    // Assemble the N matrix
 | 
				
			||||||
    //////////////////////////////////////////////////////////////////
 | 
					    //////////////////////////////////////////////////////////////////
 | 
				
			||||||
    double rho=this->StoutSmearing->SmearRho[1];
 | 
					    // Computes ALL the staples -- could compute one only here
 | 
				
			||||||
    BaseSmear(Cmu, U,mu,rho);
 | 
					    this->StoutSmearing->BaseSmear(C, U);
 | 
				
			||||||
 | 
					    Cmu = peekLorentz(C, mu);
 | 
				
			||||||
    Umu = peekLorentz(U, mu);
 | 
					    Umu = peekLorentz(U, mu);
 | 
				
			||||||
    Complex ci(0,1);
 | 
					    Complex ci(0,1);
 | 
				
			||||||
    for(int b=0;b<Ngen;b++) {
 | 
					    for(int b=0;b<Ngen;b++) {
 | 
				
			||||||
      SU3::generator(b, Tb);
 | 
					      SU3::generator(b, Tb);
 | 
				
			||||||
      // Qlat Tb = 2i Tb^Grid
 | 
					      // Qlat Tb = 2i Tb^Grid
 | 
				
			||||||
      Nb = (2.0)*Ta( ci*Tb * Umu * adj(Cmu));
 | 
					      Nb = (2.0)*Ta( ci*Tb * Umu * adj(Cmu));
 | 
				
			||||||
      // FIXME -- replace this with LieAlgebraProject
 | 
					 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
      SU3::LieAlgebraProject(Ncb,tmp,b);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
      for(int c=0;c<Ngen;c++) {
 | 
					      for(int c=0;c<Ngen;c++) {
 | 
				
			||||||
	SU3::generator(c, Tc);
 | 
						SU3::generator(c, Tc);
 | 
				
			||||||
	auto tmp = -trace(ci*Tc*Nb); // Luchang's norm: (2Tc) (2Td) N^db = -2 delta cd N^db // - was important
 | 
						auto tmp = -trace(ci*Tc*Nb); // Luchang's norm: (2Tc) (2Td) N^db = -2 delta cd N^db // - was important
 | 
				
			||||||
	PokeIndex<ColourIndex>(Ncb,tmp,c,b); 
 | 
						PokeIndex<ColourIndex>(Ncb,tmp,c,b); 
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    }      
 | 
					    }      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //////////////////////////////////////////////////////////////////
 | 
					    //////////////////////////////////////////////////////////////////
 | 
				
			||||||
@@ -865,7 +693,7 @@ private:
 | 
				
			|||||||
					  const GaugeField& GaugeK,int level) 
 | 
										  const GaugeField& GaugeK,int level) 
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    GridBase* grid = GaugeK.Grid();
 | 
					    GridBase* grid = GaugeK.Grid();
 | 
				
			||||||
    GaugeField SigmaK(grid), iLambda(grid);
 | 
					    GaugeField C(grid), SigmaK(grid), iLambda(grid);
 | 
				
			||||||
    GaugeField SigmaKPrimeA(grid);
 | 
					    GaugeField SigmaKPrimeA(grid);
 | 
				
			||||||
    GaugeField SigmaKPrimeB(grid);
 | 
					    GaugeField SigmaKPrimeB(grid);
 | 
				
			||||||
    GaugeLinkField iLambda_mu(grid);
 | 
					    GaugeLinkField iLambda_mu(grid);
 | 
				
			||||||
@@ -873,11 +701,7 @@ private:
 | 
				
			|||||||
    GaugeLinkField SigmaKPrime_mu(grid);
 | 
					    GaugeLinkField SigmaKPrime_mu(grid);
 | 
				
			||||||
    GaugeLinkField GaugeKmu(grid), Cmu(grid);
 | 
					    GaugeLinkField GaugeKmu(grid), Cmu(grid);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    int mmu= (level/2) %Nd;
 | 
					    this->StoutSmearing->BaseSmear(C, GaugeK);
 | 
				
			||||||
    int cb= (level%2);
 | 
					 | 
				
			||||||
    double rho=this->StoutSmearing->SmearRho[1];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Can override this to do one direction only.
 | 
					 | 
				
			||||||
    SigmaK = Zero();
 | 
					    SigmaK = Zero();
 | 
				
			||||||
    iLambda = Zero();
 | 
					    iLambda = Zero();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -888,38 +712,18 @@ private:
 | 
				
			|||||||
    // Could get away with computing only one polarisation here
 | 
					    // Could get away with computing only one polarisation here
 | 
				
			||||||
    // int mu= (smr/2) %Nd;
 | 
					    // int mu= (smr/2) %Nd;
 | 
				
			||||||
    // SigmaKprime_A has only one component
 | 
					    // SigmaKprime_A has only one component
 | 
				
			||||||
#if 0
 | 
					    for (int mu = 0; mu < Nd; mu++)
 | 
				
			||||||
    BaseSmear(Cmu, GaugeK,mu,rho);
 | 
					 | 
				
			||||||
    GaugeKmu = peekLorentz(GaugeK, mu);
 | 
					 | 
				
			||||||
    SigmaKPrime_mu = peekLorentz(SigmaKPrimeA, mu);
 | 
					 | 
				
			||||||
    iQ = Ta(Cmu * adj(GaugeKmu));
 | 
					 | 
				
			||||||
    this->set_iLambda(iLambda_mu, e_iQ, iQ, SigmaKPrime_mu, GaugeKmu);
 | 
					 | 
				
			||||||
    pokeLorentz(SigmaK, SigmaKPrime_mu * e_iQ + adj(Cmu) * iLambda_mu, mu);
 | 
					 | 
				
			||||||
    pokeLorentz(iLambda, iLambda_mu, mu);
 | 
					 | 
				
			||||||
    BaseSmearDerivative(SigmaK, iLambda,GaugeK,mu,rho);  // derivative of SmearBase
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    //    GaugeField C(grid);
 | 
					 | 
				
			||||||
    //    this->StoutSmearing->BaseSmear(C, GaugeK);
 | 
					 | 
				
			||||||
    //    for (int mu = 0; mu < Nd; mu++)
 | 
					 | 
				
			||||||
    int mu =mmu;
 | 
					 | 
				
			||||||
    BaseSmear(Cmu, GaugeK,mu,rho);
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      // Cmu = peekLorentz(C, mu);
 | 
					      Cmu = peekLorentz(C, mu);
 | 
				
			||||||
      GaugeKmu = peekLorentz(GaugeK, mu);
 | 
					      GaugeKmu = peekLorentz(GaugeK, mu);
 | 
				
			||||||
      SigmaKPrime_mu = peekLorentz(SigmaKPrimeA, mu);
 | 
					      SigmaKPrime_mu = peekLorentz(SigmaKPrimeA, mu);
 | 
				
			||||||
      iQ = Ta(Cmu * adj(GaugeKmu));
 | 
					      iQ = Ta(Cmu * adj(GaugeKmu));
 | 
				
			||||||
      this->set_iLambda(iLambda_mu, e_iQ, iQ, SigmaKPrime_mu, GaugeKmu);
 | 
					      this->set_iLambda(iLambda_mu, e_iQ, iQ, SigmaKPrime_mu, GaugeKmu);
 | 
				
			||||||
      pokeLorentz(SigmaK, SigmaKPrime_mu * e_iQ + adj(Cmu) * iLambda_mu, mu);
 | 
					      pokeLorentz(SigmaK, SigmaKPrime_mu * e_iQ + adj(Cmu) * iLambda_mu, mu);
 | 
				
			||||||
      pokeLorentz(iLambda, iLambda_mu, mu);
 | 
					      pokeLorentz(iLambda, iLambda_mu, mu);
 | 
				
			||||||
      std::cout << " mu "<<mu<<" SigmaKPrime_mu"<<norm2(SigmaKPrime_mu)<< " iLambda_mu " <<norm2(iLambda_mu)<<std::endl;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    //    GaugeField SigmaKcopy(grid);
 | 
					    this->StoutSmearing->derivative(SigmaK, iLambda,GaugeK);  // derivative of SmearBase
 | 
				
			||||||
    //    SigmaKcopy = SigmaK;
 | 
					
 | 
				
			||||||
    BaseSmearDerivative(SigmaK, iLambda,GaugeK,mu,rho);  // derivative of SmearBase
 | 
					 | 
				
			||||||
    //    this->StoutSmearing->derivative(SigmaK, iLambda,GaugeK);  // derivative of SmearBase
 | 
					 | 
				
			||||||
    //    SigmaKcopy = SigmaKcopy - SigmaK;
 | 
					 | 
				
			||||||
    //    std::cout << " BaseSmearDerivative fast path error" <<norm2(SigmaKcopy)<<std::endl;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    ////////////////////////////////////////////////////////////////////////////////////
 | 
					    ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
    // propagate the rest of the force as identity map, just add back
 | 
					    // propagate the rest of the force as identity map, just add back
 | 
				
			||||||
    ////////////////////////////////////////////////////////////////////////////////////
 | 
					    ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,7 +69,7 @@ public:
 | 
				
			|||||||
  /*! Construct stout smearing object from explicitly specified rho matrix */
 | 
					  /*! Construct stout smearing object from explicitly specified rho matrix */
 | 
				
			||||||
  Smear_Stout(const std::vector<double>& rho_)
 | 
					  Smear_Stout(const std::vector<double>& rho_)
 | 
				
			||||||
    : OwnedBase{new Smear_APE<Gimpl>(rho_)}, SmearBase{OwnedBase.get()} {
 | 
					    : OwnedBase{new Smear_APE<Gimpl>(rho_)}, SmearBase{OwnedBase.get()} {
 | 
				
			||||||
    std::cout << GridLogDebug << "Stout smearing constructor : Smear_Stout(const std::vector<double>& " << rho_ << " )" << std::endl;
 | 
					    std::cout << GridLogDebug << "Stout smearing constructor : Smear_Stout(const std::vector<double>& " << rho_ << " )" << std::endl
 | 
				
			||||||
    assert(Nc == 3 && "Stout smearing currently implemented only for Nc==3");
 | 
					    assert(Nc == 3 && "Stout smearing currently implemented only for Nc==3");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,14 +37,13 @@ NAMESPACE_BEGIN(Grid);
 | 
				
			|||||||
// Make these members of an Impl class for BC's.
 | 
					// Make these members of an Impl class for BC's.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace PeriodicBC { 
 | 
					namespace PeriodicBC { 
 | 
				
			||||||
  //Out(x) = Link(x)*field(x+mu)
 | 
					
 | 
				
			||||||
  template<class covariant,class gauge> Lattice<covariant> CovShiftForward(const Lattice<gauge> &Link, 
 | 
					  template<class covariant,class gauge> Lattice<covariant> CovShiftForward(const Lattice<gauge> &Link, 
 | 
				
			||||||
									   int mu,
 | 
														   int mu,
 | 
				
			||||||
									   const Lattice<covariant> &field)
 | 
														   const Lattice<covariant> &field)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    return Link*Cshift(field,mu,1);// moves towards negative mu
 | 
					    return Link*Cshift(field,mu,1);// moves towards negative mu
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  //Out(x) = Link^dag(x-mu)*field(x-mu)
 | 
					 | 
				
			||||||
  template<class covariant,class gauge> Lattice<covariant> CovShiftBackward(const Lattice<gauge> &Link, 
 | 
					  template<class covariant,class gauge> Lattice<covariant> CovShiftBackward(const Lattice<gauge> &Link, 
 | 
				
			||||||
									    int mu,
 | 
														    int mu,
 | 
				
			||||||
									    const Lattice<covariant> &field)
 | 
														    const Lattice<covariant> &field)
 | 
				
			||||||
@@ -53,19 +52,19 @@ namespace PeriodicBC {
 | 
				
			|||||||
    tmp = adj(Link)*field;
 | 
					    tmp = adj(Link)*field;
 | 
				
			||||||
    return Cshift(tmp,mu,-1);// moves towards positive mu
 | 
					    return Cshift(tmp,mu,-1);// moves towards positive mu
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  //Out(x) = Link^dag(x-mu)
 | 
					
 | 
				
			||||||
  template<class gauge> Lattice<gauge>
 | 
					  template<class gauge> Lattice<gauge>
 | 
				
			||||||
  CovShiftIdentityBackward(const Lattice<gauge> &Link, int mu) 
 | 
					  CovShiftIdentityBackward(const Lattice<gauge> &Link, int mu) 
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    return Cshift(adj(Link), mu, -1);
 | 
					    return Cshift(adj(Link), mu, -1);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  //Out(x) = Link(x)
 | 
					
 | 
				
			||||||
  template<class gauge> Lattice<gauge>
 | 
					  template<class gauge> Lattice<gauge>
 | 
				
			||||||
  CovShiftIdentityForward(const Lattice<gauge> &Link, int mu)
 | 
					  CovShiftIdentityForward(const Lattice<gauge> &Link, int mu)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    return Link;
 | 
					    return Link;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  //Link(x) = Link(x+mu)
 | 
					
 | 
				
			||||||
  template<class gauge> Lattice<gauge>
 | 
					  template<class gauge> Lattice<gauge>
 | 
				
			||||||
  ShiftStaple(const Lattice<gauge> &Link, int mu)
 | 
					  ShiftStaple(const Lattice<gauge> &Link, int mu)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,528 +0,0 @@
 | 
				
			|||||||
/*************************************************************************************
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Grid physics library, www.github.com/paboyle/Grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Source file: ./lib/qcd/utils/GaugeGroup.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Copyright (C) 2015
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
 | 
					 | 
				
			||||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
 | 
					 | 
				
			||||||
Author: neo <cossu@post.kek.jp>
 | 
					 | 
				
			||||||
Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is free software; you can redistribute it and/or modify
 | 
					 | 
				
			||||||
it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
the Free Software Foundation; either version 2 of the License, or
 | 
					 | 
				
			||||||
(at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You should have received a copy of the GNU General Public License along
 | 
					 | 
				
			||||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
					 | 
				
			||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
See the full license in the file "LICENSE" in the top level distribution
 | 
					 | 
				
			||||||
directory
 | 
					 | 
				
			||||||
*************************************************************************************/
 | 
					 | 
				
			||||||
/*  END LEGAL */
 | 
					 | 
				
			||||||
#ifndef QCD_UTIL_GAUGEGROUP_H
 | 
					 | 
				
			||||||
#define QCD_UTIL_GAUGEGROUP_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Important detail: nvcc requires all template parameters to have names.
 | 
					 | 
				
			||||||
// This is the only reason why the second template parameter has a name.
 | 
					 | 
				
			||||||
#define ONLY_IF_SU                                                       \
 | 
					 | 
				
			||||||
  typename dummy_name = group_name,                                      \
 | 
					 | 
				
			||||||
           typename named_dummy = std::enable_if_t <                                 \
 | 
					 | 
				
			||||||
                          std::is_same<dummy_name, group_name>::value && \
 | 
					 | 
				
			||||||
                      is_su<dummy_name>::value >
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define ONLY_IF_Sp                                                       \
 | 
					 | 
				
			||||||
  typename dummy_name = group_name,                                      \
 | 
					 | 
				
			||||||
           typename named_dummy = std::enable_if_t <                                 \
 | 
					 | 
				
			||||||
                          std::is_same<dummy_name, group_name>::value && \
 | 
					 | 
				
			||||||
                      is_sp<dummy_name>::value >
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_BEGIN(Grid);
 | 
					 | 
				
			||||||
namespace GroupName {
 | 
					 | 
				
			||||||
class SU {};
 | 
					 | 
				
			||||||
class Sp {};
 | 
					 | 
				
			||||||
}  // namespace GroupName
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <typename group_name>
 | 
					 | 
				
			||||||
struct is_su {
 | 
					 | 
				
			||||||
  static const bool value = false;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <>
 | 
					 | 
				
			||||||
struct is_su<GroupName::SU> {
 | 
					 | 
				
			||||||
  static const bool value = true;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <typename group_name>
 | 
					 | 
				
			||||||
struct is_sp {
 | 
					 | 
				
			||||||
  static const bool value = false;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <>
 | 
					 | 
				
			||||||
struct is_sp<GroupName::Sp> {
 | 
					 | 
				
			||||||
  static const bool value = true;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <typename group_name>
 | 
					 | 
				
			||||||
constexpr int compute_adjoint_dimension(int ncolour);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <>
 | 
					 | 
				
			||||||
constexpr int compute_adjoint_dimension<GroupName::SU>(int ncolour) {
 | 
					 | 
				
			||||||
  return ncolour * ncolour - 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <>
 | 
					 | 
				
			||||||
constexpr int compute_adjoint_dimension<GroupName::Sp>(int ncolour) {
 | 
					 | 
				
			||||||
  return ncolour / 2 * (ncolour + 1);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <int ncolour, class group_name>
 | 
					 | 
				
			||||||
class GaugeGroup {
 | 
					 | 
				
			||||||
 public:
 | 
					 | 
				
			||||||
  static const int Dimension = ncolour;
 | 
					 | 
				
			||||||
  static const int AdjointDimension =
 | 
					 | 
				
			||||||
      compute_adjoint_dimension<group_name>(ncolour);
 | 
					 | 
				
			||||||
  static const int AlgebraDimension =
 | 
					 | 
				
			||||||
      compute_adjoint_dimension<group_name>(ncolour);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <typename vtype>
 | 
					 | 
				
			||||||
  using iSU2Matrix = iScalar<iScalar<iMatrix<vtype, 2> > >;
 | 
					 | 
				
			||||||
  template <typename vtype>
 | 
					 | 
				
			||||||
  using iGroupMatrix = iScalar<iScalar<iMatrix<vtype, ncolour> > >;
 | 
					 | 
				
			||||||
  template <typename vtype>
 | 
					 | 
				
			||||||
  using iAlgebraVector = iScalar<iScalar<iVector<vtype, AdjointDimension> > >;
 | 
					 | 
				
			||||||
  template <typename vtype>
 | 
					 | 
				
			||||||
  using iSUnAlgebraMatrix =
 | 
					 | 
				
			||||||
    iScalar<iScalar<iMatrix<vtype, AdjointDimension> > >;
 | 
					 | 
				
			||||||
  static int su2subgroups(void) { return su2subgroups(group_name()); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Types can be accessed as SU<2>::Matrix , SU<2>::vSUnMatrix,
 | 
					 | 
				
			||||||
  // SU<2>::LatticeMatrix etc...
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<Complex> Matrix;
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<ComplexF> MatrixF;
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<ComplexD> MatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<vComplex> vMatrix;
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<vComplexF> vMatrixF;
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<vComplexD> vMatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // For the projectors to the algebra
 | 
					 | 
				
			||||||
  // these should be real...
 | 
					 | 
				
			||||||
  // keeping complex for consistency with the SIMD vector types
 | 
					 | 
				
			||||||
  typedef iAlgebraVector<Complex> AlgebraVector;
 | 
					 | 
				
			||||||
  typedef iAlgebraVector<ComplexF> AlgebraVectorF;
 | 
					 | 
				
			||||||
  typedef iAlgebraVector<ComplexD> AlgebraVectorD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef iAlgebraVector<vComplex> vAlgebraVector;
 | 
					 | 
				
			||||||
  typedef iAlgebraVector<vComplexF> vAlgebraVectorF;
 | 
					 | 
				
			||||||
  typedef iAlgebraVector<vComplexD> vAlgebraVectorD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Lattice<vMatrix> LatticeMatrix;
 | 
					 | 
				
			||||||
  typedef Lattice<vMatrixF> LatticeMatrixF;
 | 
					 | 
				
			||||||
  typedef Lattice<vMatrixD> LatticeMatrixD;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  typedef Lattice<vAlgebraVector> LatticeAlgebraVector;
 | 
					 | 
				
			||||||
  typedef Lattice<vAlgebraVectorF> LatticeAlgebraVectorF;
 | 
					 | 
				
			||||||
  typedef Lattice<vAlgebraVectorD> LatticeAlgebraVectorD;
 | 
					 | 
				
			||||||
   
 | 
					 | 
				
			||||||
  typedef iSUnAlgebraMatrix<vComplex>  vAlgebraMatrix;
 | 
					 | 
				
			||||||
  typedef iSUnAlgebraMatrix<vComplexF> vAlgebraMatrixF;
 | 
					 | 
				
			||||||
  typedef iSUnAlgebraMatrix<vComplexD> vAlgebraMatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Lattice<vAlgebraMatrix>  LatticeAlgebraMatrix;
 | 
					 | 
				
			||||||
  typedef Lattice<vAlgebraMatrixF> LatticeAlgebraMatrixF;
 | 
					 | 
				
			||||||
  typedef Lattice<vAlgebraMatrixD> LatticeAlgebraMatrixD;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef iSU2Matrix<Complex> SU2Matrix;
 | 
					 | 
				
			||||||
  typedef iSU2Matrix<ComplexF> SU2MatrixF;
 | 
					 | 
				
			||||||
  typedef iSU2Matrix<ComplexD> SU2MatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef iSU2Matrix<vComplex> vSU2Matrix;
 | 
					 | 
				
			||||||
  typedef iSU2Matrix<vComplexF> vSU2MatrixF;
 | 
					 | 
				
			||||||
  typedef iSU2Matrix<vComplexD> vSU2MatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Lattice<vSU2Matrix> LatticeSU2Matrix;
 | 
					 | 
				
			||||||
  typedef Lattice<vSU2MatrixF> LatticeSU2MatrixF;
 | 
					 | 
				
			||||||
  typedef Lattice<vSU2MatrixD> LatticeSU2MatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Private implementation details are specified in the following files:
 | 
					 | 
				
			||||||
  // Grid/qcd/utils/SUn.impl
 | 
					 | 
				
			||||||
  // Grid/qcd/utils/SUn.impl
 | 
					 | 
				
			||||||
  // The public part of the interface follows below and refers to these
 | 
					 | 
				
			||||||
  // private member functions.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <Grid/qcd/utils/SUn.impl.h>
 | 
					 | 
				
			||||||
#include <Grid/qcd/utils/Sp2n.impl.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 public:
 | 
					 | 
				
			||||||
  template <class cplx>
 | 
					 | 
				
			||||||
  static void generator(int lieIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
    return generator(lieIndex, ta, group_name());
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static accelerator_inline void su2SubGroupIndex(int &i1, int &i2, int su2_index) {
 | 
					 | 
				
			||||||
    return su2SubGroupIndex(i1, i2, su2_index, group_name());
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static void testGenerators(void) { testGenerators(group_name()); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static void printGenerators(void) {
 | 
					 | 
				
			||||||
    for (int gen = 0; gen < AlgebraDimension; gen++) {
 | 
					 | 
				
			||||||
      Matrix ta;
 | 
					 | 
				
			||||||
      generator(gen, ta);
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
 | 
					 | 
				
			||||||
                << std::endl;
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << ta << std::endl;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <typename LatticeMatrixType>
 | 
					 | 
				
			||||||
  static void LieRandomize(GridParallelRNG &pRNG, LatticeMatrixType &out,
 | 
					 | 
				
			||||||
                           double scale = 1.0) {
 | 
					 | 
				
			||||||
    GridBase *grid = out.Grid();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    typedef typename LatticeMatrixType::vector_type vector_type;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    typedef iSinglet<vector_type> vTComplexType;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    typedef Lattice<vTComplexType> LatticeComplexType;
 | 
					 | 
				
			||||||
    typedef typename GridTypeMapper<
 | 
					 | 
				
			||||||
        typename LatticeMatrixType::vector_object>::scalar_object MatrixType;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LatticeComplexType ca(grid);
 | 
					 | 
				
			||||||
    LatticeMatrixType lie(grid);
 | 
					 | 
				
			||||||
    LatticeMatrixType la(grid);
 | 
					 | 
				
			||||||
    ComplexD ci(0.0, scale);
 | 
					 | 
				
			||||||
    MatrixType ta;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    lie = Zero();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int a = 0; a < AlgebraDimension; a++) {
 | 
					 | 
				
			||||||
      random(pRNG, ca);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      ca = (ca + conjugate(ca)) * 0.5;
 | 
					 | 
				
			||||||
      ca = ca - 0.5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      generator(a, ta);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      la = ci * ca * ta;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      lie = lie + la;  // e^{i la ta}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    taExp(lie, out);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static void GaussianFundamentalLieAlgebraMatrix(GridParallelRNG &pRNG,
 | 
					 | 
				
			||||||
                                                  LatticeMatrix &out,
 | 
					 | 
				
			||||||
                                                  Real scale = 1.0) {
 | 
					 | 
				
			||||||
    GridBase *grid = out.Grid();
 | 
					 | 
				
			||||||
    LatticeReal ca(grid);
 | 
					 | 
				
			||||||
    LatticeMatrix la(grid);
 | 
					 | 
				
			||||||
    Complex ci(0.0, scale);
 | 
					 | 
				
			||||||
    Matrix ta;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    out = Zero();
 | 
					 | 
				
			||||||
    for (int a = 0; a < AlgebraDimension; a++) {
 | 
					 | 
				
			||||||
      gaussian(pRNG, ca);
 | 
					 | 
				
			||||||
      generator(a, ta);
 | 
					 | 
				
			||||||
      la = toComplex(ca) * ta;
 | 
					 | 
				
			||||||
      out += la;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    out *= ci;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static void FundamentalLieAlgebraMatrix(const LatticeAlgebraVector &h,
 | 
					 | 
				
			||||||
                                          LatticeMatrix &out,
 | 
					 | 
				
			||||||
                                          Real scale = 1.0) {
 | 
					 | 
				
			||||||
    conformable(h, out);
 | 
					 | 
				
			||||||
    GridBase *grid = out.Grid();
 | 
					 | 
				
			||||||
    LatticeMatrix la(grid);
 | 
					 | 
				
			||||||
    Matrix ta;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    out = Zero();
 | 
					 | 
				
			||||||
    for (int a = 0; a < AlgebraDimension; a++) {
 | 
					 | 
				
			||||||
      generator(a, ta);
 | 
					 | 
				
			||||||
      la = peekColour(h, a) * timesI(ta) * scale;
 | 
					 | 
				
			||||||
      out += la;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Projects the algebra components a lattice matrix (of dimension ncol*ncol -1
 | 
					 | 
				
			||||||
  // ) inverse operation: FundamentalLieAlgebraMatrix
 | 
					 | 
				
			||||||
  static void projectOnAlgebra(LatticeAlgebraVector &h_out,
 | 
					 | 
				
			||||||
                               const LatticeMatrix &in, Real scale = 1.0) {
 | 
					 | 
				
			||||||
    conformable(h_out, in);
 | 
					 | 
				
			||||||
    h_out = Zero();
 | 
					 | 
				
			||||||
    Matrix Ta;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int a = 0; a < AlgebraDimension; a++) {
 | 
					 | 
				
			||||||
      generator(a, Ta);
 | 
					 | 
				
			||||||
      pokeColour(h_out, -2.0 * (trace(timesI(Ta) * in)) * scale, a);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   
 | 
					 | 
				
			||||||
  template <class vtype>
 | 
					 | 
				
			||||||
  accelerator_inline static iScalar<vtype> ProjectOnGeneralGroup(const iScalar<vtype> &r) {
 | 
					 | 
				
			||||||
    return ProjectOnGeneralGroup(r, group_name());
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <class vtype, int N>
 | 
					 | 
				
			||||||
  accelerator_inline static iVector<vtype,N> ProjectOnGeneralGroup(const iVector<vtype,N> &r) {
 | 
					 | 
				
			||||||
    return ProjectOnGeneralGroup(r, group_name());
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
 | 
					 | 
				
			||||||
  accelerator_inline static iMatrix<vtype,N> ProjectOnGeneralGroup(const iMatrix<vtype,N> &arg) {
 | 
					 | 
				
			||||||
    return ProjectOnGeneralGroup(arg, group_name());
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <int N,class vComplex_t>                  // Projects on the general groups U(N), Sp(2N)xZ2 i.e. determinant is allowed a complex phase.
 | 
					 | 
				
			||||||
  static void ProjectOnGeneralGroup(Lattice<iVector<iScalar<iMatrix<vComplex_t, N> >, Nd> > &U) {
 | 
					 | 
				
			||||||
    for (int mu = 0; mu < Nd; mu++) {
 | 
					 | 
				
			||||||
      auto Umu = PeekIndex<LorentzIndex>(U, mu);
 | 
					 | 
				
			||||||
      Umu = ProjectOnGeneralGroup(Umu);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
       
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  template <int N,class vComplex_t>
 | 
					 | 
				
			||||||
  static Lattice<iScalar<iScalar<iMatrix<vComplex_t, N> > > > ProjectOnGeneralGroup(const Lattice<iScalar<iScalar<iMatrix<vComplex_t, N> > > > &Umu) {
 | 
					 | 
				
			||||||
    return ProjectOnGeneralGroup(Umu, group_name());
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <int N,class vComplex_t>       // Projects on SU(N), Sp(2N), with unit determinant, by first projecting on general group and then enforcing unit determinant
 | 
					 | 
				
			||||||
  static void ProjectOnSpecialGroup(Lattice<iScalar<iScalar<iMatrix<vComplex_t, N> > > > &Umu) {
 | 
					 | 
				
			||||||
       Umu = ProjectOnGeneralGroup(Umu);
 | 
					 | 
				
			||||||
       auto det = Determinant(Umu);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
       det = conjugate(det);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
       for (int i = 0; i < N; i++) {
 | 
					 | 
				
			||||||
           auto element = PeekIndex<ColourIndex>(Umu, N - 1, i);
 | 
					 | 
				
			||||||
           element = element * det;
 | 
					 | 
				
			||||||
           PokeIndex<ColourIndex>(Umu, element, Nc - 1, i);
 | 
					 | 
				
			||||||
       }
 | 
					 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <int N,class vComplex_t>    // reunitarise, resimplectify... previously ProjectSUn
 | 
					 | 
				
			||||||
    static void ProjectOnSpecialGroup(Lattice<iVector<iScalar<iMatrix<vComplex_t, N> >, Nd> > &U) {
 | 
					 | 
				
			||||||
      // Reunitarise
 | 
					 | 
				
			||||||
      for (int mu = 0; mu < Nd; mu++) {
 | 
					 | 
				
			||||||
        auto Umu = PeekIndex<LorentzIndex>(U, mu);
 | 
					 | 
				
			||||||
        ProjectOnSpecialGroup(Umu);
 | 
					 | 
				
			||||||
        PokeIndex<LorentzIndex>(U, Umu, mu);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  template <typename GaugeField>
 | 
					 | 
				
			||||||
  static void HotConfiguration(GridParallelRNG &pRNG, GaugeField &out) {
 | 
					 | 
				
			||||||
    typedef typename GaugeField::vector_type vector_type;
 | 
					 | 
				
			||||||
    typedef iGroupMatrix<vector_type> vMatrixType;
 | 
					 | 
				
			||||||
    typedef Lattice<vMatrixType> LatticeMatrixType;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LatticeMatrixType Umu(out.Grid());
 | 
					 | 
				
			||||||
    LatticeMatrixType tmp(out.Grid());
 | 
					 | 
				
			||||||
    for (int mu = 0; mu < Nd; mu++) {
 | 
					 | 
				
			||||||
      //      LieRandomize(pRNG, Umu, 1.0);
 | 
					 | 
				
			||||||
      //      PokeIndex<LorentzIndex>(out, Umu, mu);
 | 
					 | 
				
			||||||
      gaussian(pRNG,Umu);
 | 
					 | 
				
			||||||
      tmp = Ta(Umu);
 | 
					 | 
				
			||||||
      taExp(tmp,Umu);
 | 
					 | 
				
			||||||
      ProjectOnSpecialGroup(Umu);
 | 
					 | 
				
			||||||
      //      ProjectSUn(Umu);
 | 
					 | 
				
			||||||
      PokeIndex<LorentzIndex>(out, Umu, mu);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  template <typename GaugeField>
 | 
					 | 
				
			||||||
  static void TepidConfiguration(GridParallelRNG &pRNG, GaugeField &out) {
 | 
					 | 
				
			||||||
    typedef typename GaugeField::vector_type vector_type;
 | 
					 | 
				
			||||||
    typedef iGroupMatrix<vector_type> vMatrixType;
 | 
					 | 
				
			||||||
    typedef Lattice<vMatrixType> LatticeMatrixType;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LatticeMatrixType Umu(out.Grid());
 | 
					 | 
				
			||||||
    for (int mu = 0; mu < Nd; mu++) {
 | 
					 | 
				
			||||||
      LieRandomize(pRNG, Umu, 0.01);
 | 
					 | 
				
			||||||
      PokeIndex<LorentzIndex>(out, Umu, mu);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  template <typename GaugeField>
 | 
					 | 
				
			||||||
  static void ColdConfiguration(GaugeField &out) {
 | 
					 | 
				
			||||||
    typedef typename GaugeField::vector_type vector_type;
 | 
					 | 
				
			||||||
    typedef iGroupMatrix<vector_type> vMatrixType;
 | 
					 | 
				
			||||||
    typedef Lattice<vMatrixType> LatticeMatrixType;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LatticeMatrixType Umu(out.Grid());
 | 
					 | 
				
			||||||
    Umu = 1.0;
 | 
					 | 
				
			||||||
    for (int mu = 0; mu < Nd; mu++) {
 | 
					 | 
				
			||||||
      PokeIndex<LorentzIndex>(out, Umu, mu);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  template <typename GaugeField>
 | 
					 | 
				
			||||||
  static void ColdConfiguration(GridParallelRNG &pRNG, GaugeField &out) {
 | 
					 | 
				
			||||||
    ColdConfiguration(out);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <typename LatticeMatrixType>
 | 
					 | 
				
			||||||
  static void taProj(const LatticeMatrixType &in, LatticeMatrixType &out) {
 | 
					 | 
				
			||||||
    taProj(in, out, group_name());
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  template <typename LatticeMatrixType>
 | 
					 | 
				
			||||||
  static void taExp(const LatticeMatrixType &x, LatticeMatrixType &ex) {
 | 
					 | 
				
			||||||
    typedef typename LatticeMatrixType::scalar_type ComplexType;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LatticeMatrixType xn(x.Grid());
 | 
					 | 
				
			||||||
    RealD nfac = 1.0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    xn = x;
 | 
					 | 
				
			||||||
    ex = xn + ComplexType(1.0);  // 1+x
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Do a 12th order exponentiation
 | 
					 | 
				
			||||||
    for (int i = 2; i <= 12; ++i) {
 | 
					 | 
				
			||||||
      nfac = nfac / RealD(i);  // 1/2, 1/2.3 ...
 | 
					 | 
				
			||||||
      xn = xn * x;             // x2, x3,x4....
 | 
					 | 
				
			||||||
      ex = ex + xn * nfac;     // x2/2!, x3/3!....
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Ta are hermitian (?)
 | 
					 | 
				
			||||||
// Anti herm is i Ta basis
 | 
					 | 
				
			||||||
static void LieAlgebraProject(LatticeAlgebraMatrix &out,const LatticeMatrix &in, int b)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  conformable(in, out);
 | 
					 | 
				
			||||||
  GridBase *grid = out.Grid();
 | 
					 | 
				
			||||||
  LatticeComplex tmp(grid);
 | 
					 | 
				
			||||||
  Matrix ta;
 | 
					 | 
				
			||||||
  // Using Luchang's projection convention
 | 
					 | 
				
			||||||
  //  2 Tr{Ta Tb} A_b= 2/2 delta ab A_b = A_a
 | 
					 | 
				
			||||||
  autoView(out_v,out,AcceleratorWrite);
 | 
					 | 
				
			||||||
  autoView(in_v,in,AcceleratorRead);
 | 
					 | 
				
			||||||
  int N = ncolour;
 | 
					 | 
				
			||||||
  int NNm1 = N * (N - 1);
 | 
					 | 
				
			||||||
  int hNNm1= NNm1/2;
 | 
					 | 
				
			||||||
  RealD sqrt_2 = sqrt(2.0);
 | 
					 | 
				
			||||||
  Complex ci(0.0,1.0);
 | 
					 | 
				
			||||||
  for(int su2Index=0;su2Index<hNNm1;su2Index++){
 | 
					 | 
				
			||||||
    int i1, i2;
 | 
					 | 
				
			||||||
    su2SubGroupIndex(i1, i2, su2Index);
 | 
					 | 
				
			||||||
    int ax = su2Index*2;
 | 
					 | 
				
			||||||
    int ay = su2Index*2+1;
 | 
					 | 
				
			||||||
    accelerator_for(ss,grid->oSites(),1,{
 | 
					 | 
				
			||||||
	// in is traceless ANTI-hermitian whereas Grid generators are Hermitian.
 | 
					 | 
				
			||||||
	// trace( Ta x Ci in)
 | 
					 | 
				
			||||||
	// Bet I need to move to real part with mult by -i
 | 
					 | 
				
			||||||
	out_v[ss]()()(ax,b) = 0.5*(real(in_v[ss]()()(i2,i1)) - real(in_v[ss]()()(i1,i2)));
 | 
					 | 
				
			||||||
	out_v[ss]()()(ay,b) = 0.5*(imag(in_v[ss]()()(i1,i2)) + imag(in_v[ss]()()(i2,i1)));
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  for(int diagIndex=0;diagIndex<N-1;diagIndex++){
 | 
					 | 
				
			||||||
    int k = diagIndex + 1; // diagIndex starts from 0
 | 
					 | 
				
			||||||
    int a = NNm1+diagIndex;
 | 
					 | 
				
			||||||
    RealD scale = 1.0/sqrt(2.0*k*(k+1));
 | 
					 | 
				
			||||||
    accelerator_for(ss,grid->oSites(),vComplex::Nsimd(),{
 | 
					 | 
				
			||||||
	auto tmp = in_v[ss]()()(0,0);
 | 
					 | 
				
			||||||
	for(int i=1;i<k;i++){
 | 
					 | 
				
			||||||
	  tmp=tmp+in_v[ss]()()(i,i);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	tmp = tmp - in_v[ss]()()(k,k)*k;
 | 
					 | 
				
			||||||
	out_v[ss]()()(a,b) =imag(tmp) * scale;
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
template <int ncolour>
 | 
					 | 
				
			||||||
using SU = GaugeGroup<ncolour, GroupName::SU>;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <int ncolour>
 | 
					 | 
				
			||||||
using Sp = GaugeGroup<ncolour, GroupName::Sp>;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef SU<2> SU2;
 | 
					 | 
				
			||||||
typedef SU<3> SU3;
 | 
					 | 
				
			||||||
typedef SU<4> SU4;
 | 
					 | 
				
			||||||
typedef SU<5> SU5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef SU<Nc> FundamentalMatrices;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
typedef Sp<2> Sp2;
 | 
					 | 
				
			||||||
typedef Sp<4> Sp4;
 | 
					 | 
				
			||||||
typedef Sp<6> Sp6;
 | 
					 | 
				
			||||||
typedef Sp<8> Sp8;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <int N,class vComplex_t>
 | 
					 | 
				
			||||||
static void ProjectSUn(Lattice<iScalar<iScalar<iMatrix<vComplex_t, N> > > > &Umu)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GaugeGroup<N,GroupName::SU>::ProjectOnSpecialGroup(Umu);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
template <int N,class vComplex_t>
 | 
					 | 
				
			||||||
static void ProjectSUn(Lattice<iVector<iScalar<iMatrix<vComplex_t, N> >,Nd> > &U)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GaugeGroup<N,GroupName::SU>::ProjectOnSpecialGroup(U);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
template <int N,class vComplex_t>
 | 
					 | 
				
			||||||
static void ProjectSpn(Lattice<iScalar<iScalar<iMatrix<vComplex_t, N> > > > &Umu)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GaugeGroup<N,GroupName::Sp>::ProjectOnSpecialGroup(Umu);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
template <int N,class vComplex_t>
 | 
					 | 
				
			||||||
static void ProjectSpn(Lattice<iVector<iScalar<iMatrix<vComplex_t, N> >,Nd> > &U)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GaugeGroup<N,GroupName::Sp>::ProjectOnSpecialGroup(U);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Explicit specialisation for SU(3).
 | 
					 | 
				
			||||||
static void ProjectSU3(Lattice<iScalar<iScalar<iMatrix<vComplexD, 3> > > > &Umu)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  GridBase *grid = Umu.Grid();
 | 
					 | 
				
			||||||
  const int x = 0;
 | 
					 | 
				
			||||||
  const int y = 1;
 | 
					 | 
				
			||||||
  const int z = 2;
 | 
					 | 
				
			||||||
  // Reunitarise
 | 
					 | 
				
			||||||
  Umu = ProjectOnGroup(Umu);
 | 
					 | 
				
			||||||
  autoView(Umu_v, Umu, CpuWrite);
 | 
					 | 
				
			||||||
  thread_for(ss, grid->oSites(), {
 | 
					 | 
				
			||||||
    auto cm = Umu_v[ss];
 | 
					 | 
				
			||||||
    cm()()(2, x) = adj(cm()()(0, y) * cm()()(1, z) -
 | 
					 | 
				
			||||||
                       cm()()(0, z) * cm()()(1, y));  // x= yz-zy
 | 
					 | 
				
			||||||
    cm()()(2, y) = adj(cm()()(0, z) * cm()()(1, x) -
 | 
					 | 
				
			||||||
                       cm()()(0, x) * cm()()(1, z));  // y= zx-xz
 | 
					 | 
				
			||||||
    cm()()(2, z) = adj(cm()()(0, x) * cm()()(1, y) -
 | 
					 | 
				
			||||||
                       cm()()(0, y) * cm()()(1, x));  // z= xy-yx
 | 
					 | 
				
			||||||
    Umu_v[ss] = cm;
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
static void ProjectSU3(Lattice<iVector<iScalar<iMatrix<vComplexD, 3> >, Nd> > &U)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  GridBase *grid = U.Grid();
 | 
					 | 
				
			||||||
  // Reunitarise
 | 
					 | 
				
			||||||
  for (int mu = 0; mu < Nd; mu++) {
 | 
					 | 
				
			||||||
    auto Umu = PeekIndex<LorentzIndex>(U, mu);
 | 
					 | 
				
			||||||
    Umu = ProjectOnGroup(Umu);
 | 
					 | 
				
			||||||
    ProjectSU3(Umu);
 | 
					 | 
				
			||||||
    PokeIndex<LorentzIndex>(U, Umu, mu);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@@ -1,371 +0,0 @@
 | 
				
			|||||||
////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// * Two index representation generators
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// * Normalisation for the fundamental generators:
 | 
					 | 
				
			||||||
//   trace ta tb = 1/2 delta_ab = T_F delta_ab
 | 
					 | 
				
			||||||
//   T_F = 1/2  for SU(N) groups
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//   base for NxN two index (anti-symmetric) matrices
 | 
					 | 
				
			||||||
//   normalized to 1 (d_ij is the kroenecker delta)
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//   (e^(ij)_{kl} = 1 / sqrt(2) (d_ik d_jl +/- d_jk d_il)
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//   Then the generators are written as
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//   (iT_a)^(ij)(lk) = i * ( tr[e^(ij)^dag e^(lk) T^trasp_a] +
 | 
					 | 
				
			||||||
//   tr[e^(lk)e^(ij)^dag T_a] )  //
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Authors: David Preti, Guido Cossu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef QCD_UTIL_GAUGEGROUPTWOINDEX_H
 | 
					 | 
				
			||||||
#define QCD_UTIL_GAUGEGROUPTWOINDEX_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_BEGIN(Grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
enum TwoIndexSymmetry { Symmetric = 1, AntiSymmetric = -1 };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
constexpr inline Real delta(int a, int b) { return (a == b) ? 1.0 : 0.0; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace detail {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, int nc, TwoIndexSymmetry S>
 | 
					 | 
				
			||||||
struct baseOffDiagonalSpHelper;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, int nc>
 | 
					 | 
				
			||||||
struct baseOffDiagonalSpHelper<cplx, nc, AntiSymmetric> {
 | 
					 | 
				
			||||||
  static const int ngroup = nc / 2;
 | 
					 | 
				
			||||||
  static void baseOffDiagonalSp(int i, int j, iScalar<iScalar<iMatrix<cplx, nc> > > &eij) {
 | 
					 | 
				
			||||||
    eij = Zero();
 | 
					 | 
				
			||||||
    RealD tmp;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if ((i == ngroup + j) && (1 <= j) && (j < ngroup)) {
 | 
					 | 
				
			||||||
      for (int k = 0; k < j+1; k++) {
 | 
					 | 
				
			||||||
        if (k < j) {
 | 
					 | 
				
			||||||
          tmp = 1 / sqrt(j * (j + 1));
 | 
					 | 
				
			||||||
          eij()()(k, k + ngroup) = tmp;
 | 
					 | 
				
			||||||
          eij()()(k + ngroup, k) = -tmp;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (k == j) {
 | 
					 | 
				
			||||||
          tmp = -j / sqrt(j * (j + 1));
 | 
					 | 
				
			||||||
          eij()()(k, k + ngroup) = tmp;
 | 
					 | 
				
			||||||
          eij()()(k + ngroup, k) = -tmp;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    else if (i != ngroup + j) {
 | 
					 | 
				
			||||||
      for (int k = 0; k < nc; k++)
 | 
					 | 
				
			||||||
        for (int l = 0; l < nc; l++) {
 | 
					 | 
				
			||||||
          eij()()(l, k) =
 | 
					 | 
				
			||||||
              delta(i, k) * delta(j, l) - delta(j, k) * delta(i, l);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    RealD nrm = 1. / std::sqrt(2.0);
 | 
					 | 
				
			||||||
    eij = eij * nrm;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, int nc>
 | 
					 | 
				
			||||||
struct baseOffDiagonalSpHelper<cplx, nc, Symmetric> {
 | 
					 | 
				
			||||||
  static void baseOffDiagonalSp(int i, int j, iScalar<iScalar<iMatrix<cplx, nc> > > &eij) {
 | 
					 | 
				
			||||||
    eij = Zero();
 | 
					 | 
				
			||||||
    for (int k = 0; k < nc; k++)
 | 
					 | 
				
			||||||
      for (int l = 0; l < nc; l++)
 | 
					 | 
				
			||||||
        eij()()(l, k) =
 | 
					 | 
				
			||||||
            delta(i, k) * delta(j, l) + delta(j, k) * delta(i, l);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    RealD nrm = 1. / std::sqrt(2.0);
 | 
					 | 
				
			||||||
    eij = eij * nrm;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}   // closing detail namespace
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <int ncolour, TwoIndexSymmetry S, class group_name>
 | 
					 | 
				
			||||||
class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
 | 
					 | 
				
			||||||
 public:
 | 
					 | 
				
			||||||
  // The chosen convention is that we are taking ncolour to be N in SU<N> but 2N
 | 
					 | 
				
			||||||
  // in Sp(2N). ngroup is equal to N for SU but 2N/2 = N for Sp(2N).
 | 
					 | 
				
			||||||
  static_assert(std::is_same<group_name, GroupName::SU>::value or
 | 
					 | 
				
			||||||
                    std::is_same<group_name, GroupName::Sp>::value,
 | 
					 | 
				
			||||||
                "ngroup is only implemented for SU and Sp currently.");
 | 
					 | 
				
			||||||
  static const int ngroup =
 | 
					 | 
				
			||||||
      std::is_same<group_name, GroupName::SU>::value ? ncolour : ncolour / 2;
 | 
					 | 
				
			||||||
  static const int Dimension =
 | 
					 | 
				
			||||||
      (ncolour * (ncolour + S) / 2) + (std::is_same<group_name, GroupName::Sp>::value ? (S - 1) / 2 : 0);
 | 
					 | 
				
			||||||
  static const int DimensionAS =
 | 
					 | 
				
			||||||
      (ncolour * (ncolour - 1) / 2) + (std::is_same<group_name, GroupName::Sp>::value ? (- 1) : 0);
 | 
					 | 
				
			||||||
  static const int DimensionS =
 | 
					 | 
				
			||||||
      ncolour * (ncolour + 1) / 2;
 | 
					 | 
				
			||||||
  static const int NumGenerators =
 | 
					 | 
				
			||||||
      GaugeGroup<ncolour, group_name>::AlgebraDimension;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <typename vtype>
 | 
					 | 
				
			||||||
  using iGroupTwoIndexMatrix = iScalar<iScalar<iMatrix<vtype, Dimension> > >;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef iGroupTwoIndexMatrix<Complex> TIMatrix;
 | 
					 | 
				
			||||||
  typedef iGroupTwoIndexMatrix<ComplexF> TIMatrixF;
 | 
					 | 
				
			||||||
  typedef iGroupTwoIndexMatrix<ComplexD> TIMatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef iGroupTwoIndexMatrix<vComplex> vTIMatrix;
 | 
					 | 
				
			||||||
  typedef iGroupTwoIndexMatrix<vComplexF> vTIMatrixF;
 | 
					 | 
				
			||||||
  typedef iGroupTwoIndexMatrix<vComplexD> vTIMatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Lattice<vTIMatrix> LatticeTwoIndexMatrix;
 | 
					 | 
				
			||||||
  typedef Lattice<vTIMatrixF> LatticeTwoIndexMatrixF;
 | 
					 | 
				
			||||||
  typedef Lattice<vTIMatrixD> LatticeTwoIndexMatrixD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Lattice<iVector<iScalar<iMatrix<vComplex, Dimension> >, Nd> >
 | 
					 | 
				
			||||||
      LatticeTwoIndexField;
 | 
					 | 
				
			||||||
  typedef Lattice<iVector<iScalar<iMatrix<vComplexF, Dimension> >, Nd> >
 | 
					 | 
				
			||||||
      LatticeTwoIndexFieldF;
 | 
					 | 
				
			||||||
  typedef Lattice<iVector<iScalar<iMatrix<vComplexD, Dimension> >, Nd> >
 | 
					 | 
				
			||||||
      LatticeTwoIndexFieldD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <typename vtype>
 | 
					 | 
				
			||||||
  using iGroupMatrix = iScalar<iScalar<iMatrix<vtype, ncolour> > >;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<Complex> Matrix;
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<ComplexF> MatrixF;
 | 
					 | 
				
			||||||
  typedef iGroupMatrix<ComplexD> MatrixD;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
  template <class cplx>
 | 
					 | 
				
			||||||
  static void baseDiagonal(int Index, iGroupMatrix<cplx> &eij) {
 | 
					 | 
				
			||||||
    eij = Zero();
 | 
					 | 
				
			||||||
    eij()()(Index - ncolour * (ncolour - 1) / 2,
 | 
					 | 
				
			||||||
            Index - ncolour * (ncolour - 1) / 2) = 1.0;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  template <class cplx>
 | 
					 | 
				
			||||||
  static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij, GroupName::SU) {
 | 
					 | 
				
			||||||
    eij = Zero();
 | 
					 | 
				
			||||||
    for (int k = 0; k < ncolour; k++)
 | 
					 | 
				
			||||||
      for (int l = 0; l < ncolour; l++)
 | 
					 | 
				
			||||||
        eij()()(l, k) =
 | 
					 | 
				
			||||||
            delta(i, k) * delta(j, l) + S * delta(j, k) * delta(i, l);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    RealD nrm = 1. / std::sqrt(2.0);
 | 
					 | 
				
			||||||
    eij = eij * nrm;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  template <class cplx>
 | 
					 | 
				
			||||||
  static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij, GroupName::Sp) {
 | 
					 | 
				
			||||||
    detail::baseOffDiagonalSpHelper<cplx, ncolour, S>::baseOffDiagonalSp(i, j, eij);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  template <class cplx>
 | 
					 | 
				
			||||||
  static void base(int Index, iGroupMatrix<cplx> &eij) {
 | 
					 | 
				
			||||||
  // returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R
 | 
					 | 
				
			||||||
    assert(Index < Dimension);
 | 
					 | 
				
			||||||
    eij = Zero();
 | 
					 | 
				
			||||||
  // for the linearisation of the 2 indexes
 | 
					 | 
				
			||||||
    static int a[ncolour * (ncolour - 1) / 2][2];  // store the a <-> i,j
 | 
					 | 
				
			||||||
    static bool filled = false;
 | 
					 | 
				
			||||||
    if (!filled) {
 | 
					 | 
				
			||||||
      int counter = 0;
 | 
					 | 
				
			||||||
      for (int i = 1; i < ncolour; i++) {
 | 
					 | 
				
			||||||
      for (int j = 0; j < i; j++) {
 | 
					 | 
				
			||||||
        if (std::is_same<group_name, GroupName::Sp>::value)
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            if (j==0 && i==ngroup+j && S==-1) {
 | 
					 | 
				
			||||||
            //std::cout << "skipping" << std::endl; // for Sp2n this vanishes identically.
 | 
					 | 
				
			||||||
              j = j+1;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          a[counter][0] = i;
 | 
					 | 
				
			||||||
          a[counter][1] = j;
 | 
					 | 
				
			||||||
          counter++;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      filled = true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (Index < ncolour*ncolour - DimensionS)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      baseOffDiagonal(a[Index][0], a[Index][1], eij, group_name());
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      baseDiagonal(Index, eij);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  static void printBase(void) {
 | 
					 | 
				
			||||||
    for (int gen = 0; gen < Dimension; gen++) {
 | 
					 | 
				
			||||||
      Matrix tmp;
 | 
					 | 
				
			||||||
      base(gen, tmp);
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
 | 
					 | 
				
			||||||
                << std::endl;
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << tmp << std::endl;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <class cplx>
 | 
					 | 
				
			||||||
  static void generator(int Index, iGroupTwoIndexMatrix<cplx> &i2indTa) {
 | 
					 | 
				
			||||||
    Vector<iGroupMatrix<cplx> > ta(NumGenerators);
 | 
					 | 
				
			||||||
    Vector<iGroupMatrix<cplx> > eij(Dimension);
 | 
					 | 
				
			||||||
    iGroupMatrix<cplx> tmp;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int a = 0; a < NumGenerators; a++)
 | 
					 | 
				
			||||||
      GaugeGroup<ncolour, group_name>::generator(a, ta[a]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int a = 0; a < Dimension; a++) base(a, eij[a]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int a = 0; a < Dimension; a++) {
 | 
					 | 
				
			||||||
      tmp = transpose(eij[a]*ta[Index]) + transpose(eij[a]) * ta[Index];
 | 
					 | 
				
			||||||
      for (int b = 0; b < Dimension; b++) {
 | 
					 | 
				
			||||||
        Complex iTr = TensorRemove(timesI(trace(tmp * eij[b])));
 | 
					 | 
				
			||||||
        i2indTa()()(a, b) = iTr;
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static void printGenerators(void) {
 | 
					 | 
				
			||||||
    for (int gen = 0; gen < NumGenerators; gen++) {
 | 
					 | 
				
			||||||
      TIMatrix i2indTa;
 | 
					 | 
				
			||||||
      generator(gen, i2indTa);
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
 | 
					 | 
				
			||||||
                << std::endl;
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << i2indTa << std::endl;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static void testGenerators(void) {
 | 
					 | 
				
			||||||
    TIMatrix i2indTa, i2indTb;
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << "2IndexRep - Checking if traceless"
 | 
					 | 
				
			||||||
              << std::endl;
 | 
					 | 
				
			||||||
    for (int a = 0; a < NumGenerators; a++) {
 | 
					 | 
				
			||||||
      generator(a, i2indTa);
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << a << std::endl;
 | 
					 | 
				
			||||||
      assert(norm2(trace(i2indTa)) < 1.0e-6);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << "2IndexRep - Checking if antihermitean"
 | 
					 | 
				
			||||||
              << std::endl;
 | 
					 | 
				
			||||||
    for (int a = 0; a < NumGenerators; a++) {
 | 
					 | 
				
			||||||
      generator(a, i2indTa);
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << a << std::endl;
 | 
					 | 
				
			||||||
      assert(norm2(adj(i2indTa) + i2indTa) < 1.0e-6);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << std::endl;
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage
 | 
					 | 
				
			||||||
              << "2IndexRep - Checking Tr[Ta*Tb]=delta(a,b)*(N +- 2)/2"
 | 
					 | 
				
			||||||
              << std::endl;
 | 
					 | 
				
			||||||
    for (int a = 0; a < NumGenerators; a++) {
 | 
					 | 
				
			||||||
      for (int b = 0; b < NumGenerators; b++) {
 | 
					 | 
				
			||||||
        generator(a, i2indTa);
 | 
					 | 
				
			||||||
        generator(b, i2indTb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // generator returns iTa, so we need a minus sign here
 | 
					 | 
				
			||||||
        Complex Tr = -TensorRemove(trace(i2indTa * i2indTb));
 | 
					 | 
				
			||||||
        std::cout << GridLogMessage << "a=" << a << "b=" << b << "Tr=" << Tr
 | 
					 | 
				
			||||||
                  << std::endl;
 | 
					 | 
				
			||||||
        if (a == b) {
 | 
					 | 
				
			||||||
          assert(real(Tr) - ((ncolour + S * 2) * 0.5) < 1e-8);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
          assert(real(Tr) < 1e-8);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        assert(imag(Tr) < 1e-8);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << std::endl;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static void TwoIndexLieAlgebraMatrix(
 | 
					 | 
				
			||||||
      const typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector &h,
 | 
					 | 
				
			||||||
      LatticeTwoIndexMatrix &out, Real scale = 1.0) {
 | 
					 | 
				
			||||||
    conformable(h, out);
 | 
					 | 
				
			||||||
    GridBase *grid = out.Grid();
 | 
					 | 
				
			||||||
    LatticeTwoIndexMatrix la(grid);
 | 
					 | 
				
			||||||
    TIMatrix i2indTa;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    out = Zero();
 | 
					 | 
				
			||||||
    for (int a = 0; a < NumGenerators; a++) {
 | 
					 | 
				
			||||||
      generator(a, i2indTa);
 | 
					 | 
				
			||||||
      la = peekColour(h, a) * i2indTa;
 | 
					 | 
				
			||||||
      out += la;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    out *= scale;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Projects the algebra components
 | 
					 | 
				
			||||||
  // of a lattice matrix ( of dimension ncol*ncol -1 )
 | 
					 | 
				
			||||||
  static void projectOnAlgebra(
 | 
					 | 
				
			||||||
      typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector &h_out,
 | 
					 | 
				
			||||||
      const LatticeTwoIndexMatrix &in, Real scale = 1.0) {
 | 
					 | 
				
			||||||
    conformable(h_out, in);
 | 
					 | 
				
			||||||
    h_out = Zero();
 | 
					 | 
				
			||||||
    TIMatrix i2indTa;
 | 
					 | 
				
			||||||
    Real coefficient = -2.0 / (ncolour + 2 * S) * scale;
 | 
					 | 
				
			||||||
    // 2/(Nc +/- 2) for the normalization of the trace in the two index rep
 | 
					 | 
				
			||||||
    for (int a = 0; a < NumGenerators; a++) {
 | 
					 | 
				
			||||||
      generator(a, i2indTa);
 | 
					 | 
				
			||||||
      pokeColour(h_out, real(trace(i2indTa * in)) * coefficient, a);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // a projector that keeps the generators stored to avoid the overhead of
 | 
					 | 
				
			||||||
  // recomputing them
 | 
					 | 
				
			||||||
  static void projector(
 | 
					 | 
				
			||||||
      typename GaugeGroup<ncolour, group_name>::LatticeAlgebraVector &h_out,
 | 
					 | 
				
			||||||
      const LatticeTwoIndexMatrix &in, Real scale = 1.0) {
 | 
					 | 
				
			||||||
    conformable(h_out, in);
 | 
					 | 
				
			||||||
    // to store the generators
 | 
					 | 
				
			||||||
    static std::vector<TIMatrix> i2indTa(NumGenerators);
 | 
					 | 
				
			||||||
    h_out = Zero();
 | 
					 | 
				
			||||||
    static bool precalculated = false;
 | 
					 | 
				
			||||||
    if (!precalculated) {
 | 
					 | 
				
			||||||
      precalculated = true;
 | 
					 | 
				
			||||||
      for (int a = 0; a < NumGenerators; a++) generator(a, i2indTa[a]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Real coefficient =
 | 
					 | 
				
			||||||
        -2.0 / (ncolour + 2 * S) * scale;  // 2/(Nc +/- 2) for the normalization
 | 
					 | 
				
			||||||
    // of the trace in the two index rep
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (int a = 0; a < NumGenerators; a++) {
 | 
					 | 
				
			||||||
      auto tmp = real(trace(i2indTa[a] * in)) * coefficient;
 | 
					 | 
				
			||||||
      pokeColour(h_out, tmp, a);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <int ncolour, TwoIndexSymmetry S>
 | 
					 | 
				
			||||||
using SU_TwoIndex = GaugeGroupTwoIndex<ncolour, S, GroupName::SU>;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Some useful type names
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<Nc, Symmetric> TwoIndexSymmMatrices;
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<Nc, AntiSymmetric> TwoIndexAntiSymmMatrices;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<2, Symmetric> SU2TwoIndexSymm;
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<3, Symmetric> SU3TwoIndexSymm;
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<4, Symmetric> SU4TwoIndexSymm;
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<5, Symmetric> SU5TwoIndexSymm;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<2, AntiSymmetric> SU2TwoIndexAntiSymm;
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<3, AntiSymmetric> SU3TwoIndexAntiSymm;
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<4, AntiSymmetric> SU4TwoIndexAntiSymm;
 | 
					 | 
				
			||||||
typedef SU_TwoIndex<5, AntiSymmetric> SU5TwoIndexAntiSymm;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <int ncolour, TwoIndexSymmetry S>
 | 
					 | 
				
			||||||
using Sp_TwoIndex = GaugeGroupTwoIndex<ncolour, S, GroupName::Sp>;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef Sp_TwoIndex<Nc, Symmetric> SpTwoIndexSymmMatrices;
 | 
					 | 
				
			||||||
typedef Sp_TwoIndex<Nc, AntiSymmetric> SpTwoIndexAntiSymmMatrices;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef Sp_TwoIndex<2, Symmetric> Sp2TwoIndexSymm;
 | 
					 | 
				
			||||||
typedef Sp_TwoIndex<4, Symmetric> Sp4TwoIndexSymm;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef Sp_TwoIndex<4, AntiSymmetric> Sp4TwoIndexAntiSymm;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
							
								
								
									
										930
									
								
								Grid/qcd/utils/SUn.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										930
									
								
								Grid/qcd/utils/SUn.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,930 @@
 | 
				
			|||||||
 | 
					/*************************************************************************************
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Grid physics library, www.github.com/paboyle/Grid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Source file: ./lib/qcd/utils/SUn.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Copyright (C) 2015
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
 | 
				
			||||||
 | 
					Author: Peter Boyle <paboyle@ph.ed.ac.uk>
 | 
				
			||||||
 | 
					Author: neo <cossu@post.kek.jp>
 | 
				
			||||||
 | 
					Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This program is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					the Free Software Foundation; either version 2 of the License, or
 | 
				
			||||||
 | 
					(at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You should have received a copy of the GNU General Public License along
 | 
				
			||||||
 | 
					with this program; if not, write to the Free Software Foundation, Inc.,
 | 
				
			||||||
 | 
					51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					See the full license in the file "LICENSE" in the top level distribution
 | 
				
			||||||
 | 
					directory
 | 
				
			||||||
 | 
					*************************************************************************************/
 | 
				
			||||||
 | 
								   /*  END LEGAL */
 | 
				
			||||||
 | 
					#ifndef QCD_UTIL_SUN_H
 | 
				
			||||||
 | 
					#define QCD_UTIL_SUN_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NAMESPACE_BEGIN(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template<int N, class Vec>
 | 
				
			||||||
 | 
					Lattice<iScalar<iScalar<iScalar<Vec> > > > Determinant(const Lattice<iScalar<iScalar<iMatrix<Vec, N> > > > &Umu)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GridBase *grid=Umu.Grid();
 | 
				
			||||||
 | 
					  auto lvol = grid->lSites();
 | 
				
			||||||
 | 
					  Lattice<iScalar<iScalar<iScalar<Vec> > > > ret(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  autoView(Umu_v,Umu,CpuRead);
 | 
				
			||||||
 | 
					  autoView(ret_v,ret,CpuWrite);
 | 
				
			||||||
 | 
					  thread_for(site,lvol,{
 | 
				
			||||||
 | 
					    Eigen::MatrixXcd EigenU = Eigen::MatrixXcd::Zero(N,N);
 | 
				
			||||||
 | 
					    Coordinate lcoor;
 | 
				
			||||||
 | 
					    grid->LocalIndexToLocalCoor(site, lcoor);
 | 
				
			||||||
 | 
					    iScalar<iScalar<iMatrix<ComplexD, N> > > Us;
 | 
				
			||||||
 | 
					    peekLocalSite(Us, Umu_v, lcoor);
 | 
				
			||||||
 | 
					    for(int i=0;i<N;i++){
 | 
				
			||||||
 | 
					      for(int j=0;j<N;j++){
 | 
				
			||||||
 | 
						EigenU(i,j) = Us()()(i,j);
 | 
				
			||||||
 | 
					      }}
 | 
				
			||||||
 | 
					    ComplexD detD  = EigenU.determinant();
 | 
				
			||||||
 | 
					    typename Vec::scalar_type det(detD.real(),detD.imag());
 | 
				
			||||||
 | 
					    pokeLocalSite(det,ret_v,lcoor);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					  return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template<int N, class Vec>
 | 
				
			||||||
 | 
					static void ProjectSUn(Lattice<iScalar<iScalar<iMatrix<Vec, N> > > > &Umu)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  Umu      = ProjectOnGroup(Umu);
 | 
				
			||||||
 | 
					  auto det = Determinant(Umu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  det = conjugate(det);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for(int i=0;i<N;i++){
 | 
				
			||||||
 | 
					    auto element = PeekIndex<ColourIndex>(Umu,N-1,i);
 | 
				
			||||||
 | 
					    element = element * det;
 | 
				
			||||||
 | 
					    PokeIndex<ColourIndex>(Umu,element,Nc-1,i);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					template<int N,class Vec>
 | 
				
			||||||
 | 
					static void ProjectSUn(Lattice<iVector<iScalar<iMatrix<Vec, N> >,Nd> > &U)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GridBase *grid=U.Grid();
 | 
				
			||||||
 | 
					  // Reunitarise
 | 
				
			||||||
 | 
					  for(int mu=0;mu<Nd;mu++){
 | 
				
			||||||
 | 
					    auto Umu = PeekIndex<LorentzIndex>(U,mu);
 | 
				
			||||||
 | 
					    Umu      = ProjectOnGroup(Umu);
 | 
				
			||||||
 | 
					    ProjectSUn(Umu);
 | 
				
			||||||
 | 
					    PokeIndex<LorentzIndex>(U,Umu,mu);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <int ncolour>
 | 
				
			||||||
 | 
					class SU {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  static const int Dimension = ncolour;
 | 
				
			||||||
 | 
					  static const int AdjointDimension = ncolour * ncolour - 1;
 | 
				
			||||||
 | 
					  static int su2subgroups(void) { return (ncolour * (ncolour - 1)) / 2; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <typename vtype>
 | 
				
			||||||
 | 
					  using iSUnMatrix = iScalar<iScalar<iMatrix<vtype, ncolour> > >;
 | 
				
			||||||
 | 
					  template <typename vtype>
 | 
				
			||||||
 | 
					  using iSU2Matrix = iScalar<iScalar<iMatrix<vtype, 2> > >;
 | 
				
			||||||
 | 
					  template <typename vtype>
 | 
				
			||||||
 | 
					  using iSUnAlgebraVector =
 | 
				
			||||||
 | 
					    iScalar<iScalar<iVector<vtype, AdjointDimension> > >;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  // Types can be accessed as SU<2>::Matrix , SU<2>::vSUnMatrix,
 | 
				
			||||||
 | 
					  // SU<2>::LatticeMatrix etc...
 | 
				
			||||||
 | 
					  //////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<Complex> Matrix;
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<ComplexF> MatrixF;
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<ComplexD> MatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<vComplex> vMatrix;
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<vComplexF> vMatrixF;
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<vComplexD> vMatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // For the projectors to the algebra
 | 
				
			||||||
 | 
					  // these should be real...
 | 
				
			||||||
 | 
					  // keeping complex for consistency with the SIMD vector types
 | 
				
			||||||
 | 
					  typedef iSUnAlgebraVector<Complex> AlgebraVector;
 | 
				
			||||||
 | 
					  typedef iSUnAlgebraVector<ComplexF> AlgebraVectorF;
 | 
				
			||||||
 | 
					  typedef iSUnAlgebraVector<ComplexD> AlgebraVectorD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef iSUnAlgebraVector<vComplex> vAlgebraVector;
 | 
				
			||||||
 | 
					  typedef iSUnAlgebraVector<vComplexF> vAlgebraVectorF;
 | 
				
			||||||
 | 
					  typedef iSUnAlgebraVector<vComplexD> vAlgebraVectorD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef Lattice<vMatrix> LatticeMatrix;
 | 
				
			||||||
 | 
					  typedef Lattice<vMatrixF> LatticeMatrixF;
 | 
				
			||||||
 | 
					  typedef Lattice<vMatrixD> LatticeMatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef Lattice<vAlgebraVector> LatticeAlgebraVector;
 | 
				
			||||||
 | 
					  typedef Lattice<vAlgebraVectorF> LatticeAlgebraVectorF;
 | 
				
			||||||
 | 
					  typedef Lattice<vAlgebraVectorD> LatticeAlgebraVectorD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef iSU2Matrix<Complex> SU2Matrix;
 | 
				
			||||||
 | 
					  typedef iSU2Matrix<ComplexF> SU2MatrixF;
 | 
				
			||||||
 | 
					  typedef iSU2Matrix<ComplexD> SU2MatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef iSU2Matrix<vComplex> vSU2Matrix;
 | 
				
			||||||
 | 
					  typedef iSU2Matrix<vComplexF> vSU2MatrixF;
 | 
				
			||||||
 | 
					  typedef iSU2Matrix<vComplexD> vSU2MatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef Lattice<vSU2Matrix> LatticeSU2Matrix;
 | 
				
			||||||
 | 
					  typedef Lattice<vSU2MatrixF> LatticeSU2MatrixF;
 | 
				
			||||||
 | 
					  typedef Lattice<vSU2MatrixD> LatticeSU2MatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  // There are N^2-1 generators for SU(N).
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // We take a traceless hermitian generator basis as follows
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // * Normalisation: trace ta tb = 1/2 delta_ab = T_F delta_ab
 | 
				
			||||||
 | 
					  //   T_F = 1/2  for SU(N) groups
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // * Off diagonal
 | 
				
			||||||
 | 
					  //    - pairs of rows i1,i2 behaving like pauli matrices signma_x, sigma_y
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //    - there are (Nc-1-i1) slots for i2 on each row [ x  0  x ]
 | 
				
			||||||
 | 
					  //      direct count off each row
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //    - Sum of all pairs is Nc(Nc-1)/2: proof arithmetic series
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //      (Nc-1) + (Nc-2)+...  1      ==> Nc*(Nc-1)/2
 | 
				
			||||||
 | 
					  //      1+ 2+          +   + Nc-1
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //    - There are 2 x Nc (Nc-1)/ 2 of these = Nc^2 - Nc
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //    - We enumerate the row-col pairs.
 | 
				
			||||||
 | 
					  //    - for each row col pair there is a (sigma_x) and a (sigma_y) like
 | 
				
			||||||
 | 
					  //    generator
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //   t^a_ij = { in 0.. Nc(Nc-1)/2 -1} =>  1/2(delta_{i,i1} delta_{j,i2} +
 | 
				
			||||||
 | 
					  //   delta_{i,i1} delta_{j,i2})
 | 
				
			||||||
 | 
					  //   t^a_ij = { in Nc(Nc-1)/2 ... Nc(Nc-1) - 1} =>  i/2( delta_{i,i1}
 | 
				
			||||||
 | 
					  //   delta_{j,i2} - i delta_{i,i1} delta_{j,i2})
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // * Diagonal; must be traceless and normalised
 | 
				
			||||||
 | 
					  //   - Sequence is
 | 
				
			||||||
 | 
					  //   N  (1,-1,0,0...)
 | 
				
			||||||
 | 
					  //   N  (1, 1,-2,0...)
 | 
				
			||||||
 | 
					  //   N  (1, 1, 1,-3,0...)
 | 
				
			||||||
 | 
					  //   N  (1, 1, 1, 1,-4,0...)
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //   where 1/2 = N^2 (1+.. m^2)etc.... for the m-th diagonal generator
 | 
				
			||||||
 | 
					  //   NB this gives the famous SU3 result for su2 index 8
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //   N= sqrt(1/2 . 1/6 ) = 1/2 . 1/sqrt(3)
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  //   ( 1      )
 | 
				
			||||||
 | 
					  //   (    1   ) / sqrt(3) /2  = 1/2 lambda_8
 | 
				
			||||||
 | 
					  //   (      -2)
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  ////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  template <class cplx>
 | 
				
			||||||
 | 
					  static void generator(int lieIndex, iSUnMatrix<cplx> &ta) {
 | 
				
			||||||
 | 
					    // map lie index to which type of generator
 | 
				
			||||||
 | 
					    int diagIndex;
 | 
				
			||||||
 | 
					    int su2Index;
 | 
				
			||||||
 | 
					    int sigxy;
 | 
				
			||||||
 | 
					    int NNm1 = ncolour * (ncolour - 1);
 | 
				
			||||||
 | 
					    if (lieIndex >= NNm1) {
 | 
				
			||||||
 | 
					      diagIndex = lieIndex - NNm1;
 | 
				
			||||||
 | 
					      generatorDiagonal(diagIndex, ta);
 | 
				
			||||||
 | 
					      return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    sigxy = lieIndex & 0x1;  // even or odd
 | 
				
			||||||
 | 
					    su2Index = lieIndex >> 1;
 | 
				
			||||||
 | 
					    if (sigxy)
 | 
				
			||||||
 | 
					      generatorSigmaY(su2Index, ta);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      generatorSigmaX(su2Index, ta);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  template <class cplx>
 | 
				
			||||||
 | 
					  static void generatorSigmaY(int su2Index, iSUnMatrix<cplx> &ta) {
 | 
				
			||||||
 | 
					    ta = Zero();
 | 
				
			||||||
 | 
					    int i1, i2;
 | 
				
			||||||
 | 
					    su2SubGroupIndex(i1, i2, su2Index);
 | 
				
			||||||
 | 
					    ta()()(i1, i2) = 1.0;
 | 
				
			||||||
 | 
					    ta()()(i2, i1) = 1.0;
 | 
				
			||||||
 | 
					    ta = ta * 0.5;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  template <class cplx>
 | 
				
			||||||
 | 
					  static void generatorSigmaX(int su2Index, iSUnMatrix<cplx> &ta) {
 | 
				
			||||||
 | 
					    ta = Zero();
 | 
				
			||||||
 | 
					    cplx i(0.0, 1.0);
 | 
				
			||||||
 | 
					    int i1, i2;
 | 
				
			||||||
 | 
					    su2SubGroupIndex(i1, i2, su2Index);
 | 
				
			||||||
 | 
					    ta()()(i1, i2) = i;
 | 
				
			||||||
 | 
					    ta()()(i2, i1) = -i;
 | 
				
			||||||
 | 
					    ta = ta * 0.5;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <class cplx>
 | 
				
			||||||
 | 
					  static void generatorDiagonal(int diagIndex, iSUnMatrix<cplx> &ta) {
 | 
				
			||||||
 | 
					    // diag ({1, 1, ..., 1}(k-times), -k, 0, 0, ...)
 | 
				
			||||||
 | 
					    ta = Zero();
 | 
				
			||||||
 | 
					    int k = diagIndex + 1;                  // diagIndex starts from 0
 | 
				
			||||||
 | 
					    for (int i = 0; i <= diagIndex; i++) {  // k iterations
 | 
				
			||||||
 | 
					      ta()()(i, i) = 1.0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    ta()()(k, k) = -k;  // indexing starts from 0
 | 
				
			||||||
 | 
					    RealD nrm = 1.0 / std::sqrt(2.0 * k * (k + 1));
 | 
				
			||||||
 | 
					    ta = ta * nrm;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  // Map a su2 subgroup number to the pair of rows that are non zero
 | 
				
			||||||
 | 
					  ////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  static void su2SubGroupIndex(int &i1, int &i2, int su2_index) {
 | 
				
			||||||
 | 
					    assert((su2_index >= 0) && (su2_index < (ncolour * (ncolour - 1)) / 2));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int spare = su2_index;
 | 
				
			||||||
 | 
					    for (i1 = 0; spare >= (ncolour - 1 - i1); i1++) {
 | 
				
			||||||
 | 
					      spare = spare - (ncolour - 1 - i1);  // remove the Nc-1-i1 terms
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    i2 = i1 + 1 + spare;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  // Pull out a subgroup and project on to real coeffs x pauli basis
 | 
				
			||||||
 | 
					  //////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  template <class vcplx>
 | 
				
			||||||
 | 
					  static void su2Extract(Lattice<iSinglet<vcplx> > &Determinant,
 | 
				
			||||||
 | 
					                         Lattice<iSU2Matrix<vcplx> > &subgroup,
 | 
				
			||||||
 | 
					                         const Lattice<iSUnMatrix<vcplx> > &source,
 | 
				
			||||||
 | 
					                         int su2_index) {
 | 
				
			||||||
 | 
					    GridBase *grid(source.Grid());
 | 
				
			||||||
 | 
					    conformable(subgroup, source);
 | 
				
			||||||
 | 
					    conformable(subgroup, Determinant);
 | 
				
			||||||
 | 
					    int i0, i1;
 | 
				
			||||||
 | 
					    su2SubGroupIndex(i0, i1, su2_index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    autoView( subgroup_v , subgroup,AcceleratorWrite);
 | 
				
			||||||
 | 
					    autoView( source_v   , source,AcceleratorRead);
 | 
				
			||||||
 | 
					    autoView( Determinant_v , Determinant,AcceleratorWrite);
 | 
				
			||||||
 | 
					    accelerator_for(ss, grid->oSites(), 1, {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      subgroup_v[ss]()()(0, 0) = source_v[ss]()()(i0, i0);
 | 
				
			||||||
 | 
					      subgroup_v[ss]()()(0, 1) = source_v[ss]()()(i0, i1);
 | 
				
			||||||
 | 
					      subgroup_v[ss]()()(1, 0) = source_v[ss]()()(i1, i0);
 | 
				
			||||||
 | 
					      subgroup_v[ss]()()(1, 1) = source_v[ss]()()(i1, i1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      iSU2Matrix<vcplx> Sigma = subgroup_v[ss];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Sigma = Sigma - adj(Sigma) + trace(adj(Sigma));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      subgroup_v[ss] = Sigma;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // this should be purely real
 | 
				
			||||||
 | 
					      Determinant_v[ss] =
 | 
				
			||||||
 | 
						Sigma()()(0, 0) * Sigma()()(1, 1) - Sigma()()(0, 1) * Sigma()()(1, 0);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  // Set matrix to one and insert a pauli subgroup
 | 
				
			||||||
 | 
					  //////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					  template <class vcplx>
 | 
				
			||||||
 | 
					  static void su2Insert(const Lattice<iSU2Matrix<vcplx> > &subgroup,
 | 
				
			||||||
 | 
					                        Lattice<iSUnMatrix<vcplx> > &dest, int su2_index) {
 | 
				
			||||||
 | 
					    GridBase *grid(dest.Grid());
 | 
				
			||||||
 | 
					    conformable(subgroup, dest);
 | 
				
			||||||
 | 
					    int i0, i1;
 | 
				
			||||||
 | 
					    su2SubGroupIndex(i0, i1, su2_index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dest = 1.0;  // start out with identity
 | 
				
			||||||
 | 
					    autoView( dest_v , dest, AcceleratorWrite);
 | 
				
			||||||
 | 
					    autoView( subgroup_v, subgroup, AcceleratorRead);
 | 
				
			||||||
 | 
					    accelerator_for(ss, grid->oSites(),1,
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      dest_v[ss]()()(i0, i0) = subgroup_v[ss]()()(0, 0);
 | 
				
			||||||
 | 
					      dest_v[ss]()()(i0, i1) = subgroup_v[ss]()()(0, 1);
 | 
				
			||||||
 | 
					      dest_v[ss]()()(i1, i0) = subgroup_v[ss]()()(1, 0);
 | 
				
			||||||
 | 
					      dest_v[ss]()()(i1, i1) = subgroup_v[ss]()()(1, 1);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ///////////////////////////////////////////////
 | 
				
			||||||
 | 
					  // Generate e^{ Re Tr Staple Link} dlink
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // *** Note Staple should be appropriate linear compbination between all
 | 
				
			||||||
 | 
					  // staples.
 | 
				
			||||||
 | 
					  // *** If already by beta pass coefficient 1.0.
 | 
				
			||||||
 | 
					  // *** This routine applies the additional 1/Nc factor that comes after trace
 | 
				
			||||||
 | 
					  // in action.
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  ///////////////////////////////////////////////
 | 
				
			||||||
 | 
					  static void SubGroupHeatBath(GridSerialRNG &sRNG, GridParallelRNG &pRNG,
 | 
				
			||||||
 | 
								       RealD beta,  // coeff multiplying staple in action (with no 1/Nc)
 | 
				
			||||||
 | 
								       LatticeMatrix &link,
 | 
				
			||||||
 | 
								       const LatticeMatrix &barestaple,  // multiplied by action coeffs so th
 | 
				
			||||||
 | 
								       int su2_subgroup, int nheatbath, LatticeInteger &wheremask) 
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    GridBase *grid = link.Grid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const RealD twopi = 2.0 * M_PI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeMatrix staple(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    staple = barestaple * (beta / ncolour);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeMatrix V(grid);
 | 
				
			||||||
 | 
					    V = link * staple;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Subgroup manipulation in the lie algebra space
 | 
				
			||||||
 | 
					    LatticeSU2Matrix u(grid);  // Kennedy pendleton "u" real projected normalised Sigma
 | 
				
			||||||
 | 
					    LatticeSU2Matrix uinv(grid);
 | 
				
			||||||
 | 
					    LatticeSU2Matrix ua(grid);  // a in pauli form
 | 
				
			||||||
 | 
					    LatticeSU2Matrix b(grid);   // rotated matrix after hb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Some handy constant fields
 | 
				
			||||||
 | 
					    LatticeComplex ones(grid);
 | 
				
			||||||
 | 
					    ones = 1.0;
 | 
				
			||||||
 | 
					    LatticeComplex zeros(grid);
 | 
				
			||||||
 | 
					    zeros = Zero();
 | 
				
			||||||
 | 
					    LatticeReal rones(grid);
 | 
				
			||||||
 | 
					    rones = 1.0;
 | 
				
			||||||
 | 
					    LatticeReal rzeros(grid);
 | 
				
			||||||
 | 
					    rzeros = Zero();
 | 
				
			||||||
 | 
					    LatticeComplex udet(grid);  // determinant of real(staple)
 | 
				
			||||||
 | 
					    LatticeInteger mask_true(grid);
 | 
				
			||||||
 | 
					    mask_true = 1;
 | 
				
			||||||
 | 
					    LatticeInteger mask_false(grid);
 | 
				
			||||||
 | 
					    mask_false = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					      PLB 156 P393 (1985) (Kennedy and Pendleton)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Note: absorb "beta" into the def of sigma compared to KP paper; staple
 | 
				
			||||||
 | 
					      passed to this routine has "beta" already multiplied in
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Action linear in links h and of form:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      beta S = beta  Sum_p (1 - 1/Nc Re Tr Plaq )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Writing Sigma = 1/Nc (beta Sigma') where sum over staples is "Sigma' "
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      beta S = const - beta/Nc Re Tr h Sigma'
 | 
				
			||||||
 | 
					      = const - Re Tr h Sigma
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Decompose h and Sigma into (1, sigma_j) ; h_i real, h^2=1, Sigma_i complex
 | 
				
			||||||
 | 
					      arbitrary.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Tr h Sigma = h_i Sigma_j Tr (sigma_i sigma_j)  = h_i Sigma_j 2 delta_ij
 | 
				
			||||||
 | 
					      Re Tr h Sigma = 2 h_j Re Sigma_j
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Normalised re Sigma_j = xi u_j
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      With u_j a unit vector and U can be in SU(2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Re Tr h Sigma = 2 h_j Re Sigma_j = 2 xi (h.u)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      4xi^2 = Det [ Sig - Sig^dag  + 1 Tr Sigdag]
 | 
				
			||||||
 | 
					      u   = 1/2xi [ Sig - Sig^dag  + 1 Tr Sigdag]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      xi = sqrt(Det)/2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Write a= u h in SU(2); a has pauli decomp a_j;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Note: Product b' xi is unvariant because scaling Sigma leaves
 | 
				
			||||||
 | 
					      normalised vector "u" fixed; Can rescale Sigma so b' = 1.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					    // Real part of Pauli decomposition
 | 
				
			||||||
 | 
					    // Note a subgroup can project to zero in cold start
 | 
				
			||||||
 | 
					    ////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					    su2Extract(udet, u, V, su2_subgroup);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					    // Normalising this vector if possible; else identity
 | 
				
			||||||
 | 
					    //////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					    LatticeComplex xi(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeSU2Matrix lident(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SU2Matrix ident = Complex(1.0);
 | 
				
			||||||
 | 
					    SU2Matrix pauli1;
 | 
				
			||||||
 | 
					    SU<2>::generator(0, pauli1);
 | 
				
			||||||
 | 
					    SU2Matrix pauli2;
 | 
				
			||||||
 | 
					    SU<2>::generator(1, pauli2);
 | 
				
			||||||
 | 
					    SU2Matrix pauli3;
 | 
				
			||||||
 | 
					    SU<2>::generator(2, pauli3);
 | 
				
			||||||
 | 
					    pauli1 = timesI(pauli1) * 2.0;
 | 
				
			||||||
 | 
					    pauli2 = timesI(pauli2) * 2.0;
 | 
				
			||||||
 | 
					    pauli3 = timesI(pauli3) * 2.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeComplex cone(grid);
 | 
				
			||||||
 | 
					    LatticeReal adet(grid);
 | 
				
			||||||
 | 
					    adet = abs(toReal(udet));
 | 
				
			||||||
 | 
					    lident = Complex(1.0);
 | 
				
			||||||
 | 
					    cone = Complex(1.0);
 | 
				
			||||||
 | 
					    Real machine_epsilon = 1.0e-7;
 | 
				
			||||||
 | 
					    u = where(adet > machine_epsilon, u, lident);
 | 
				
			||||||
 | 
					    udet = where(adet > machine_epsilon, udet, cone);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    xi = 0.5 * sqrt(udet);  // 4xi^2 = Det [ Sig - Sig^dag  + 1 Tr Sigdag]
 | 
				
			||||||
 | 
					    u = 0.5 * u *
 | 
				
			||||||
 | 
					      pow(xi, -1.0);  //  u   = 1/2xi [ Sig - Sig^dag  + 1 Tr Sigdag]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Debug test for sanity
 | 
				
			||||||
 | 
					    uinv = adj(u);
 | 
				
			||||||
 | 
					    b = u * uinv - 1.0;
 | 
				
			||||||
 | 
					    assert(norm2(b) < 1.0e-4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					      Measure: Haar measure dh has d^4a delta(1-|a^2|)
 | 
				
			||||||
 | 
					      In polars:
 | 
				
			||||||
 | 
					      da = da0 r^2 sin theta dr dtheta dphi delta( 1 - r^2 -a0^2)
 | 
				
			||||||
 | 
					      = da0 r^2 sin theta dr dtheta dphi delta( (sqrt(1-a0^) - r)(sqrt(1-a0^) +
 | 
				
			||||||
 | 
					      r) )
 | 
				
			||||||
 | 
					      = da0 r/2 sin theta dr dtheta dphi delta( (sqrt(1-a0^) - r) )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Action factor Q(h) dh  = e^-S[h]  dh =  e^{  xi Tr uh} dh    // beta enters
 | 
				
			||||||
 | 
					      through xi
 | 
				
			||||||
 | 
					      =  e^{2 xi (h.u)} dh
 | 
				
			||||||
 | 
					      =  e^{2 xi h0u0}.e^{2 xi h1u1}.e^{2 xi
 | 
				
			||||||
 | 
					      h2u2}.e^{2 xi h3u3} dh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Therefore for each site, take xi for that site
 | 
				
			||||||
 | 
					      i) generate  |a0|<1 with dist
 | 
				
			||||||
 | 
					      (1-a0^2)^0.5 e^{2 xi a0 } da0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Take alpha = 2 xi  = 2 xi [ recall 2 beta/Nc unmod staple norm]; hence 2.0/Nc
 | 
				
			||||||
 | 
					      factor in Chroma ]
 | 
				
			||||||
 | 
					      A. Generate two uniformly distributed pseudo-random numbers R and R', R'',
 | 
				
			||||||
 | 
					      R''' in the unit interval;
 | 
				
			||||||
 | 
					      B. Set X = -(ln R)/alpha, X' =-(ln R')/alpha;
 | 
				
			||||||
 | 
					      C. Set C = cos^2(2pi R"), with R" another uniform random number in [0,1] ;
 | 
				
			||||||
 | 
					      D. Set A = XC;
 | 
				
			||||||
 | 
					      E. Let d  = X'+A;
 | 
				
			||||||
 | 
					      F. If R'''^2 :> 1 - 0.5 d,  go back to A;
 | 
				
			||||||
 | 
					      G. Set a0 = 1 - d;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      Note that in step D setting B ~ X - A and using B in place of A in step E will
 | 
				
			||||||
 | 
					      generate a second independent a 0 value.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					    // count the number of sites by picking "1"'s out of hat
 | 
				
			||||||
 | 
					    /////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					    Integer hit = 0;
 | 
				
			||||||
 | 
					    LatticeReal rtmp(grid);
 | 
				
			||||||
 | 
					    rtmp = where(wheremask, rones, rzeros);
 | 
				
			||||||
 | 
					    RealD numSites = sum(rtmp);
 | 
				
			||||||
 | 
					    RealD numAccepted;
 | 
				
			||||||
 | 
					    LatticeInteger Accepted(grid);
 | 
				
			||||||
 | 
					    Accepted = Zero();
 | 
				
			||||||
 | 
					    LatticeInteger newlyAccepted(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::vector<LatticeReal> xr(4, grid);
 | 
				
			||||||
 | 
					    std::vector<LatticeReal> a(4, grid);
 | 
				
			||||||
 | 
					    LatticeReal d(grid);
 | 
				
			||||||
 | 
					    d = Zero();
 | 
				
			||||||
 | 
					    LatticeReal alpha(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //    std::cout<<GridLogMessage<<"xi "<<xi <<std::endl;
 | 
				
			||||||
 | 
					    xi = 2.0 *xi;
 | 
				
			||||||
 | 
					    alpha = toReal(xi);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    do {
 | 
				
			||||||
 | 
					      // A. Generate two uniformly distributed pseudo-random numbers R and R',
 | 
				
			||||||
 | 
					      // R'', R''' in the unit interval;
 | 
				
			||||||
 | 
					      random(pRNG, xr[0]);
 | 
				
			||||||
 | 
					      random(pRNG, xr[1]);
 | 
				
			||||||
 | 
					      random(pRNG, xr[2]);
 | 
				
			||||||
 | 
					      random(pRNG, xr[3]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // B. Set X = - ln R/alpha, X' = -ln R'/alpha
 | 
				
			||||||
 | 
					      xr[1] = -log(xr[1]) / alpha;
 | 
				
			||||||
 | 
					      xr[2] = -log(xr[2]) / alpha;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // C. Set C = cos^2(2piR'')
 | 
				
			||||||
 | 
					      xr[3] = cos(xr[3] * twopi);
 | 
				
			||||||
 | 
					      xr[3] = xr[3] * xr[3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      LatticeReal xrsq(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // D. Set A = XC;
 | 
				
			||||||
 | 
					      // E. Let d  = X'+A;
 | 
				
			||||||
 | 
					      xrsq = xr[2] + xr[1] * xr[3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      d = where(Accepted, d, xr[2] + xr[1] * xr[3]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // F. If R'''^2 :> 1 - 0.5 d,  go back to A;
 | 
				
			||||||
 | 
					      LatticeReal thresh(grid);
 | 
				
			||||||
 | 
					      thresh = 1.0 - d * 0.5;
 | 
				
			||||||
 | 
					      xrsq = xr[0] * xr[0];
 | 
				
			||||||
 | 
					      LatticeInteger ione(grid);
 | 
				
			||||||
 | 
					      ione = 1;
 | 
				
			||||||
 | 
					      LatticeInteger izero(grid);
 | 
				
			||||||
 | 
					      izero = Zero();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      newlyAccepted = where(xrsq < thresh, ione, izero);
 | 
				
			||||||
 | 
					      Accepted = where(newlyAccepted, newlyAccepted, Accepted);
 | 
				
			||||||
 | 
					      Accepted = where(wheremask, Accepted, izero);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // FIXME need an iSum for integer to avoid overload on return type??
 | 
				
			||||||
 | 
					      rtmp = where(Accepted, rones, rzeros);
 | 
				
			||||||
 | 
					      numAccepted = sum(rtmp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      hit++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    } while ((numAccepted < numSites) && (hit < nheatbath));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // G. Set a0 = 1 - d;
 | 
				
			||||||
 | 
					    a[0] = Zero();
 | 
				
			||||||
 | 
					    a[0] = where(wheremask, 1.0 - d, a[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //////////////////////////////////////////
 | 
				
			||||||
 | 
					    //    ii) generate a_i uniform on two sphere radius (1-a0^2)^0.5
 | 
				
			||||||
 | 
					    //////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeReal a123mag(grid);
 | 
				
			||||||
 | 
					    a123mag = sqrt(abs(1.0 - a[0] * a[0]));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeReal cos_theta(grid);
 | 
				
			||||||
 | 
					    LatticeReal sin_theta(grid);
 | 
				
			||||||
 | 
					    LatticeReal phi(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    random(pRNG, phi);
 | 
				
			||||||
 | 
					    phi = phi * twopi;  // uniform in [0,2pi]
 | 
				
			||||||
 | 
					    random(pRNG, cos_theta);
 | 
				
			||||||
 | 
					    cos_theta = (cos_theta * 2.0) - 1.0;  // uniform in [-1,1]
 | 
				
			||||||
 | 
					    sin_theta = sqrt(abs(1.0 - cos_theta * cos_theta));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    a[1] = a123mag * sin_theta * cos(phi);
 | 
				
			||||||
 | 
					    a[2] = a123mag * sin_theta * sin(phi);
 | 
				
			||||||
 | 
					    a[3] = a123mag * cos_theta;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ua = toComplex(a[0]) * ident  + toComplex(a[1]) * pauli1 +
 | 
				
			||||||
 | 
					         toComplex(a[2]) * pauli2 + toComplex(a[3]) * pauli3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    b = 1.0;
 | 
				
			||||||
 | 
					    b = where(wheremask, uinv * ua, b);
 | 
				
			||||||
 | 
					    su2Insert(b, V, su2_subgroup);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // mask the assignment back based on Accptance
 | 
				
			||||||
 | 
					    link = where(Accepted, V * link, link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //////////////////////////////
 | 
				
			||||||
 | 
					    // Debug Checks
 | 
				
			||||||
 | 
					    // SU2 check
 | 
				
			||||||
 | 
					    LatticeSU2Matrix check(grid);  // rotated matrix after hb
 | 
				
			||||||
 | 
					    u = Zero();
 | 
				
			||||||
 | 
					    check = ua * adj(ua) - 1.0;
 | 
				
			||||||
 | 
					    check = where(Accepted, check, u);
 | 
				
			||||||
 | 
					    assert(norm2(check) < 1.0e-4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    check = b * adj(b) - 1.0;
 | 
				
			||||||
 | 
					    check = where(Accepted, check, u);
 | 
				
			||||||
 | 
					    assert(norm2(check) < 1.0e-4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeMatrix Vcheck(grid);
 | 
				
			||||||
 | 
					    Vcheck = Zero();
 | 
				
			||||||
 | 
					    Vcheck = where(Accepted, V * adj(V) - 1.0, Vcheck);
 | 
				
			||||||
 | 
					    //    std::cout<<GridLogMessage << "SU3 check " <<norm2(Vcheck)<<std::endl;
 | 
				
			||||||
 | 
					    assert(norm2(Vcheck) < 1.0e-4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Verify the link stays in SU(3)
 | 
				
			||||||
 | 
					    //    std::cout<<GridLogMessage <<"Checking the modified link"<<std::endl;
 | 
				
			||||||
 | 
					    Vcheck = link * adj(link) - 1.0;
 | 
				
			||||||
 | 
					    assert(norm2(Vcheck) < 1.0e-4);
 | 
				
			||||||
 | 
					    /////////////////////////////////
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void printGenerators(void) {
 | 
				
			||||||
 | 
					    for (int gen = 0; gen < AdjointDimension; gen++) {
 | 
				
			||||||
 | 
					      Matrix ta;
 | 
				
			||||||
 | 
					      generator(gen, ta);
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
 | 
				
			||||||
 | 
					                << std::endl;
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << ta << std::endl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void testGenerators(void) {
 | 
				
			||||||
 | 
					    Matrix ta;
 | 
				
			||||||
 | 
					    Matrix tb;
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage
 | 
				
			||||||
 | 
					              << "Fundamental - Checking trace ta tb is 0.5 delta_ab"
 | 
				
			||||||
 | 
					              << std::endl;
 | 
				
			||||||
 | 
					    for (int a = 0; a < AdjointDimension; a++) {
 | 
				
			||||||
 | 
					      for (int b = 0; b < AdjointDimension; b++) {
 | 
				
			||||||
 | 
					        generator(a, ta);
 | 
				
			||||||
 | 
					        generator(b, tb);
 | 
				
			||||||
 | 
					        Complex tr = TensorRemove(trace(ta * tb));
 | 
				
			||||||
 | 
					        std::cout << GridLogMessage << "(" << a << "," << b << ") =  " << tr
 | 
				
			||||||
 | 
					                  << std::endl;
 | 
				
			||||||
 | 
					        if (a == b) assert(abs(tr - Complex(0.5)) < 1.0e-6);
 | 
				
			||||||
 | 
					        if (a != b) assert(abs(tr) < 1.0e-6);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << std::endl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << "Fundamental - Checking if hermitian"
 | 
				
			||||||
 | 
					              << std::endl;
 | 
				
			||||||
 | 
					    for (int a = 0; a < AdjointDimension; a++) {
 | 
				
			||||||
 | 
					      generator(a, ta);
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << a << std::endl;
 | 
				
			||||||
 | 
					      assert(norm2(ta - adj(ta)) < 1.0e-6);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << "Fundamental - Checking if traceless"
 | 
				
			||||||
 | 
					              << std::endl;
 | 
				
			||||||
 | 
					    for (int a = 0; a < AdjointDimension; a++) {
 | 
				
			||||||
 | 
					      generator(a, ta);
 | 
				
			||||||
 | 
					      Complex tr = TensorRemove(trace(ta));
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << a << " " << std::endl;
 | 
				
			||||||
 | 
					      assert(abs(tr) < 1.0e-6);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << std::endl;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // reunitarise??
 | 
				
			||||||
 | 
					  template <typename LatticeMatrixType>
 | 
				
			||||||
 | 
					  static void LieRandomize(GridParallelRNG &pRNG, LatticeMatrixType &out, double scale = 1.0) 
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    GridBase *grid = out.Grid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    typedef typename LatticeMatrixType::vector_type vector_type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    typedef iSinglet<vector_type> vTComplexType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    typedef Lattice<vTComplexType> LatticeComplexType;
 | 
				
			||||||
 | 
					    typedef typename GridTypeMapper<typename LatticeMatrixType::vector_object>::scalar_object MatrixType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeComplexType ca(grid);
 | 
				
			||||||
 | 
					    LatticeMatrixType lie(grid);
 | 
				
			||||||
 | 
					    LatticeMatrixType la(grid);
 | 
				
			||||||
 | 
					    ComplexD ci(0.0, scale);
 | 
				
			||||||
 | 
					    //    ComplexD cone(1.0, 0.0);
 | 
				
			||||||
 | 
					    MatrixType ta;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    lie = Zero();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int a = 0; a < AdjointDimension; a++) {
 | 
				
			||||||
 | 
					      random(pRNG, ca);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      ca = (ca + conjugate(ca)) * 0.5;
 | 
				
			||||||
 | 
					      ca = ca - 0.5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      generator(a, ta);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      la = ci * ca * ta;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      lie = lie + la;  // e^{i la ta}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    taExp(lie, out);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void GaussianFundamentalLieAlgebraMatrix(GridParallelRNG &pRNG,
 | 
				
			||||||
 | 
					                                                  LatticeMatrix &out,
 | 
				
			||||||
 | 
					                                                  Real scale = 1.0) {
 | 
				
			||||||
 | 
					    GridBase *grid = out.Grid();
 | 
				
			||||||
 | 
					    LatticeReal ca(grid);
 | 
				
			||||||
 | 
					    LatticeMatrix la(grid);
 | 
				
			||||||
 | 
					    Complex ci(0.0, scale);
 | 
				
			||||||
 | 
					    Matrix ta;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    out = Zero();
 | 
				
			||||||
 | 
					    for (int a = 0; a < AdjointDimension; a++) {
 | 
				
			||||||
 | 
					      gaussian(pRNG, ca);
 | 
				
			||||||
 | 
					      generator(a, ta);
 | 
				
			||||||
 | 
					      la = toComplex(ca) * ta;
 | 
				
			||||||
 | 
					      out += la;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    out *= ci;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void FundamentalLieAlgebraMatrix(const LatticeAlgebraVector &h,
 | 
				
			||||||
 | 
					                                          LatticeMatrix &out,
 | 
				
			||||||
 | 
					                                          Real scale = 1.0) {
 | 
				
			||||||
 | 
					    conformable(h, out);
 | 
				
			||||||
 | 
					    GridBase *grid = out.Grid();
 | 
				
			||||||
 | 
					    LatticeMatrix la(grid);
 | 
				
			||||||
 | 
					    Matrix ta;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    out = Zero();
 | 
				
			||||||
 | 
					    for (int a = 0; a < AdjointDimension; a++) {
 | 
				
			||||||
 | 
					      generator(a, ta);
 | 
				
			||||||
 | 
					      la = peekColour(h, a) * timesI(ta) * scale;
 | 
				
			||||||
 | 
					      out += la;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Fundamental rep gauge xform
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					  template<typename Fundamental,typename GaugeMat>
 | 
				
			||||||
 | 
					  static void GaugeTransformFundamental( Fundamental &ferm, GaugeMat &g){
 | 
				
			||||||
 | 
					    GridBase *grid = ferm._grid;
 | 
				
			||||||
 | 
					    conformable(grid,g._grid);
 | 
				
			||||||
 | 
					    ferm = g*ferm;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Adjoint rep gauge xform
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template<typename Gimpl>
 | 
				
			||||||
 | 
					  static void GaugeTransform(typename Gimpl::GaugeField &Umu, typename Gimpl::GaugeLinkField &g){
 | 
				
			||||||
 | 
					    GridBase *grid = Umu.Grid();
 | 
				
			||||||
 | 
					    conformable(grid,g.Grid());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    typename Gimpl::GaugeLinkField U(grid);
 | 
				
			||||||
 | 
					    typename Gimpl::GaugeLinkField ag(grid); ag = adj(g);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for(int mu=0;mu<Nd;mu++){
 | 
				
			||||||
 | 
					      U= PeekIndex<LorentzIndex>(Umu,mu);
 | 
				
			||||||
 | 
					      U = g*U*Gimpl::CshiftLink(ag, mu, 1); //BC-aware
 | 
				
			||||||
 | 
					      PokeIndex<LorentzIndex>(Umu,U,mu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  template<typename Gimpl>
 | 
				
			||||||
 | 
					  static void GaugeTransform( std::vector<typename Gimpl::GaugeLinkField> &U, typename Gimpl::GaugeLinkField &g){
 | 
				
			||||||
 | 
					    GridBase *grid = g.Grid();
 | 
				
			||||||
 | 
					    typename Gimpl::GaugeLinkField ag(grid); ag = adj(g);
 | 
				
			||||||
 | 
					    for(int mu=0;mu<Nd;mu++){
 | 
				
			||||||
 | 
					      U[mu] = g*U[mu]*Gimpl::CshiftLink(ag, mu, 1); //BC-aware
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  template<typename Gimpl>
 | 
				
			||||||
 | 
					  static void RandomGaugeTransform(GridParallelRNG &pRNG, typename Gimpl::GaugeField &Umu, typename Gimpl::GaugeLinkField &g){
 | 
				
			||||||
 | 
					    LieRandomize(pRNG,g,1.0);
 | 
				
			||||||
 | 
					    GaugeTransform<Gimpl>(Umu,g);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Projects the algebra components a lattice matrix (of dimension ncol*ncol -1 )
 | 
				
			||||||
 | 
					  // inverse operation: FundamentalLieAlgebraMatrix
 | 
				
			||||||
 | 
					  static void projectOnAlgebra(LatticeAlgebraVector &h_out, const LatticeMatrix &in, Real scale = 1.0) {
 | 
				
			||||||
 | 
					    conformable(h_out, in);
 | 
				
			||||||
 | 
					    h_out = Zero();
 | 
				
			||||||
 | 
					    Matrix Ta;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int a = 0; a < AdjointDimension; a++) {
 | 
				
			||||||
 | 
					      generator(a, Ta);
 | 
				
			||||||
 | 
					      pokeColour(h_out, - 2.0 * (trace(timesI(Ta) * in)) * scale, a);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <typename GaugeField>
 | 
				
			||||||
 | 
					  static void HotConfiguration(GridParallelRNG &pRNG, GaugeField &out) {
 | 
				
			||||||
 | 
					    typedef typename GaugeField::vector_type vector_type;
 | 
				
			||||||
 | 
					    typedef iSUnMatrix<vector_type> vMatrixType;
 | 
				
			||||||
 | 
					    typedef Lattice<vMatrixType> LatticeMatrixType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeMatrixType Umu(out.Grid());
 | 
				
			||||||
 | 
					    LatticeMatrixType tmp(out.Grid());
 | 
				
			||||||
 | 
					    for (int mu = 0; mu < Nd; mu++) {
 | 
				
			||||||
 | 
					      //      LieRandomize(pRNG, Umu, 1.0);
 | 
				
			||||||
 | 
					      //      PokeIndex<LorentzIndex>(out, Umu, mu);
 | 
				
			||||||
 | 
					      gaussian(pRNG,Umu);
 | 
				
			||||||
 | 
					      tmp = Ta(Umu);
 | 
				
			||||||
 | 
					      taExp(tmp,Umu);
 | 
				
			||||||
 | 
					      ProjectSUn(Umu);
 | 
				
			||||||
 | 
					      PokeIndex<LorentzIndex>(out, Umu, mu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  template<typename GaugeField>
 | 
				
			||||||
 | 
					  static void TepidConfiguration(GridParallelRNG &pRNG,GaugeField &out){
 | 
				
			||||||
 | 
					    typedef typename GaugeField::vector_type vector_type;
 | 
				
			||||||
 | 
					    typedef iSUnMatrix<vector_type> vMatrixType;
 | 
				
			||||||
 | 
					    typedef Lattice<vMatrixType> LatticeMatrixType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeMatrixType Umu(out.Grid());
 | 
				
			||||||
 | 
					    for(int mu=0;mu<Nd;mu++){
 | 
				
			||||||
 | 
					      LieRandomize(pRNG,Umu,0.01);
 | 
				
			||||||
 | 
					      PokeIndex<LorentzIndex>(out,Umu,mu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  template<typename GaugeField>
 | 
				
			||||||
 | 
					  static void ColdConfiguration(GaugeField &out){
 | 
				
			||||||
 | 
					    typedef typename GaugeField::vector_type vector_type;
 | 
				
			||||||
 | 
					    typedef iSUnMatrix<vector_type> vMatrixType;
 | 
				
			||||||
 | 
					    typedef Lattice<vMatrixType> LatticeMatrixType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeMatrixType Umu(out.Grid());
 | 
				
			||||||
 | 
					    Umu=1.0;
 | 
				
			||||||
 | 
					    for(int mu=0;mu<Nd;mu++){
 | 
				
			||||||
 | 
					      PokeIndex<LorentzIndex>(out,Umu,mu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  template<typename GaugeField>
 | 
				
			||||||
 | 
					  static void ColdConfiguration(GridParallelRNG &pRNG,GaugeField &out){
 | 
				
			||||||
 | 
					    ColdConfiguration(out);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template<typename LatticeMatrixType>
 | 
				
			||||||
 | 
					  static void taProj( const LatticeMatrixType &in,  LatticeMatrixType &out){
 | 
				
			||||||
 | 
					    out = Ta(in);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  template <typename LatticeMatrixType>
 | 
				
			||||||
 | 
					  static void taExp(const LatticeMatrixType &x, LatticeMatrixType &ex) {
 | 
				
			||||||
 | 
					    typedef typename LatticeMatrixType::scalar_type ComplexType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    LatticeMatrixType xn(x.Grid());
 | 
				
			||||||
 | 
					    RealD nfac = 1.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    xn = x;
 | 
				
			||||||
 | 
					    ex = xn + ComplexType(1.0);  // 1+x
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Do a 12th order exponentiation
 | 
				
			||||||
 | 
					    for (int i = 2; i <= 12; ++i) {
 | 
				
			||||||
 | 
					      nfac = nfac / RealD(i);  // 1/2, 1/2.3 ...
 | 
				
			||||||
 | 
					      xn = xn * x;             // x2, x3,x4....
 | 
				
			||||||
 | 
					      ex = ex + xn * nfac;     // x2/2!, x3/3!....
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template<int N>
 | 
				
			||||||
 | 
					Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > Inverse(const Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GridBase *grid=Umu.Grid();
 | 
				
			||||||
 | 
					  auto lvol = grid->lSites();
 | 
				
			||||||
 | 
					  Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > ret(grid);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  autoView(Umu_v,Umu,CpuRead);
 | 
				
			||||||
 | 
					  autoView(ret_v,ret,CpuWrite);
 | 
				
			||||||
 | 
					  thread_for(site,lvol,{
 | 
				
			||||||
 | 
					    Eigen::MatrixXcd EigenU = Eigen::MatrixXcd::Zero(N,N);
 | 
				
			||||||
 | 
					    Coordinate lcoor;
 | 
				
			||||||
 | 
					    grid->LocalIndexToLocalCoor(site, lcoor);
 | 
				
			||||||
 | 
					    iScalar<iScalar<iMatrix<ComplexD, N> > > Us;
 | 
				
			||||||
 | 
					    iScalar<iScalar<iMatrix<ComplexD, N> > > Ui;
 | 
				
			||||||
 | 
					    peekLocalSite(Us, Umu_v, lcoor);
 | 
				
			||||||
 | 
					    for(int i=0;i<N;i++){
 | 
				
			||||||
 | 
					      for(int j=0;j<N;j++){
 | 
				
			||||||
 | 
						EigenU(i,j) = Us()()(i,j);
 | 
				
			||||||
 | 
					      }}
 | 
				
			||||||
 | 
					    Eigen::MatrixXcd EigenUinv = EigenU.inverse();
 | 
				
			||||||
 | 
					    for(int i=0;i<N;i++){
 | 
				
			||||||
 | 
					      for(int j=0;j<N;j++){
 | 
				
			||||||
 | 
						Ui()()(i,j) = EigenUinv(i,j);
 | 
				
			||||||
 | 
					      }}
 | 
				
			||||||
 | 
					    pokeLocalSite(Ui,ret_v,lcoor);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					  return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					// Explicit specialisation for SU(3).
 | 
				
			||||||
 | 
					// Explicit specialisation for SU(3).
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					ProjectSU3 (Lattice<iScalar<iScalar<iMatrix<vComplexD, 3> > > > &Umu)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GridBase *grid=Umu.Grid();
 | 
				
			||||||
 | 
					  const int x=0;
 | 
				
			||||||
 | 
					  const int y=1;
 | 
				
			||||||
 | 
					  const int z=2;
 | 
				
			||||||
 | 
					  // Reunitarise
 | 
				
			||||||
 | 
					  Umu = ProjectOnGroup(Umu);
 | 
				
			||||||
 | 
					  autoView(Umu_v,Umu,CpuWrite);
 | 
				
			||||||
 | 
					  thread_for(ss,grid->oSites(),{
 | 
				
			||||||
 | 
					      auto cm = Umu_v[ss];
 | 
				
			||||||
 | 
					      cm()()(2,x) = adj(cm()()(0,y)*cm()()(1,z)-cm()()(0,z)*cm()()(1,y)); //x= yz-zy
 | 
				
			||||||
 | 
					      cm()()(2,y) = adj(cm()()(0,z)*cm()()(1,x)-cm()()(0,x)*cm()()(1,z)); //y= zx-xz
 | 
				
			||||||
 | 
					      cm()()(2,z) = adj(cm()()(0,x)*cm()()(1,y)-cm()()(0,y)*cm()()(1,x)); //z= xy-yx
 | 
				
			||||||
 | 
					      Umu_v[ss]=cm;
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					static void ProjectSU3(Lattice<iVector<iScalar<iMatrix<vComplexD, 3> >,Nd> > &U)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  GridBase *grid=U.Grid();
 | 
				
			||||||
 | 
					  // Reunitarise
 | 
				
			||||||
 | 
					  for(int mu=0;mu<Nd;mu++){
 | 
				
			||||||
 | 
					    auto Umu = PeekIndex<LorentzIndex>(U,mu);
 | 
				
			||||||
 | 
					    Umu      = ProjectOnGroup(Umu);
 | 
				
			||||||
 | 
					    ProjectSU3(Umu);
 | 
				
			||||||
 | 
					    PokeIndex<LorentzIndex>(U,Umu,mu);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef SU<2> SU2;
 | 
				
			||||||
 | 
					typedef SU<3> SU3;
 | 
				
			||||||
 | 
					typedef SU<4> SU4;
 | 
				
			||||||
 | 
					typedef SU<5> SU5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef SU<Nc> FundamentalMatrices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
@@ -1,580 +0,0 @@
 | 
				
			|||||||
// This file is #included into the body of the class template definition of
 | 
					 | 
				
			||||||
// GaugeGroup. So, image there to be
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// template <int ncolour, class group_name>
 | 
					 | 
				
			||||||
// class GaugeGroup {
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// around it.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Please note that the unconventional file extension makes sure that it
 | 
					 | 
				
			||||||
// doesn't get found by the scripts/filelist during bootstrapping.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <ONLY_IF_SU>
 | 
					 | 
				
			||||||
static int su2subgroups(GroupName::SU) { return (ncolour * (ncolour - 1)) / 2; }
 | 
					 | 
				
			||||||
////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// There are N^2-1 generators for SU(N).
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// We take a traceless hermitian generator basis as follows
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// * Normalisation: trace ta tb = 1/2 delta_ab = T_F delta_ab
 | 
					 | 
				
			||||||
//   T_F = 1/2  for SU(N) groups
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// * Off diagonal
 | 
					 | 
				
			||||||
//    - pairs of rows i1,i2 behaving like pauli matrices signma_x, sigma_y
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//    - there are (Nc-1-i1) slots for i2 on each row [ x  0  x ]
 | 
					 | 
				
			||||||
//      direct count off each row
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//    - Sum of all pairs is Nc(Nc-1)/2: proof arithmetic series
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//      (Nc-1) + (Nc-2)+...  1      ==> Nc*(Nc-1)/2
 | 
					 | 
				
			||||||
//      1+ 2+          +   + Nc-1
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//    - There are 2 x Nc (Nc-1)/ 2 of these = Nc^2 - Nc
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//    - We enumerate the row-col pairs.
 | 
					 | 
				
			||||||
//    - for each row col pair there is a (sigma_x) and a (sigma_y) like
 | 
					 | 
				
			||||||
//    generator
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//   t^a_ij = { in 0.. Nc(Nc-1)/2 -1} =>  1/2(delta_{i,i1} delta_{j,i2} +
 | 
					 | 
				
			||||||
//   delta_{i,i1} delta_{j,i2})
 | 
					 | 
				
			||||||
//   t^a_ij = { in Nc(Nc-1)/2 ... Nc(Nc-1) - 1} =>  i/2( delta_{i,i1}
 | 
					 | 
				
			||||||
//   delta_{j,i2} - i delta_{i,i1} delta_{j,i2})
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// * Diagonal; must be traceless and normalised
 | 
					 | 
				
			||||||
//   - Sequence is
 | 
					 | 
				
			||||||
//   N  (1,-1,0,0...)
 | 
					 | 
				
			||||||
//   N  (1, 1,-2,0...)
 | 
					 | 
				
			||||||
//   N  (1, 1, 1,-3,0...)
 | 
					 | 
				
			||||||
//   N  (1, 1, 1, 1,-4,0...)
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//   where 1/2 = N^2 (1+.. m^2)etc.... for the m-th diagonal generator
 | 
					 | 
				
			||||||
//   NB this gives the famous SU3 result for su2 index 8
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//   N= sqrt(1/2 . 1/6 ) = 1/2 . 1/sqrt(3)
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//   ( 1      )
 | 
					 | 
				
			||||||
//   (    1   ) / sqrt(3) /2  = 1/2 lambda_8
 | 
					 | 
				
			||||||
//   (      -2)
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_SU>
 | 
					 | 
				
			||||||
static void generator(int lieIndex, iGroupMatrix<cplx> &ta, GroupName::SU) {
 | 
					 | 
				
			||||||
  // map lie index to which type of generator
 | 
					 | 
				
			||||||
  int diagIndex;
 | 
					 | 
				
			||||||
  int su2Index;
 | 
					 | 
				
			||||||
  int sigxy;
 | 
					 | 
				
			||||||
  int NNm1 = ncolour * (ncolour - 1);
 | 
					 | 
				
			||||||
  if (lieIndex >= NNm1) {
 | 
					 | 
				
			||||||
    diagIndex = lieIndex - NNm1;
 | 
					 | 
				
			||||||
    generatorDiagonal(diagIndex, ta);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  sigxy = lieIndex & 0x1;  // even or odd
 | 
					 | 
				
			||||||
  su2Index = lieIndex >> 1;
 | 
					 | 
				
			||||||
  if (sigxy)
 | 
					 | 
				
			||||||
    generatorSigmaY(su2Index, ta);
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    generatorSigmaX(su2Index, ta);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_SU>
 | 
					 | 
				
			||||||
static void generatorSigmaY(int su2Index, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  int i1, i2;
 | 
					 | 
				
			||||||
  su2SubGroupIndex(i1, i2, su2Index);
 | 
					 | 
				
			||||||
  ta()()(i1, i2) = 1.0;
 | 
					 | 
				
			||||||
  ta()()(i2, i1) = 1.0;
 | 
					 | 
				
			||||||
  ta = ta * 0.5;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_SU>
 | 
					 | 
				
			||||||
static void generatorSigmaX(int su2Index, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  cplx i(0.0, 1.0);
 | 
					 | 
				
			||||||
  int i1, i2;
 | 
					 | 
				
			||||||
  su2SubGroupIndex(i1, i2, su2Index);
 | 
					 | 
				
			||||||
  ta()()(i1, i2) = i;
 | 
					 | 
				
			||||||
  ta()()(i2, i1) = -i;
 | 
					 | 
				
			||||||
  ta = ta * 0.5;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_SU>
 | 
					 | 
				
			||||||
static void generatorDiagonal(int diagIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  // diag ({1, 1, ..., 1}(k-times), -k, 0, 0, ...)
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  int k = diagIndex + 1;                  // diagIndex starts from 0
 | 
					 | 
				
			||||||
  for (int i = 0; i <= diagIndex; i++) {  // k iterations
 | 
					 | 
				
			||||||
    ta()()(i, i) = 1.0;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  ta()()(k, k) = -k;  // indexing starts from 0
 | 
					 | 
				
			||||||
  RealD nrm = 1.0 / std::sqrt(2.0 * k * (k + 1));
 | 
					 | 
				
			||||||
  ta = ta * nrm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// Map a su2 subgroup number to the pair of rows that are non zero
 | 
					 | 
				
			||||||
////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
static void su2SubGroupIndex(int &i1, int &i2, int su2_index, GroupName::SU) {
 | 
					 | 
				
			||||||
  assert((su2_index >= 0) && (su2_index < (ncolour * (ncolour - 1)) / 2));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int spare = su2_index;
 | 
					 | 
				
			||||||
  for (i1 = 0; spare >= (ncolour - 1 - i1); i1++) {
 | 
					 | 
				
			||||||
    spare = spare - (ncolour - 1 - i1);  // remove the Nc-1-i1 terms
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  i2 = i1 + 1 + spare;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
//////////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// Pull out a subgroup and project on to real coeffs x pauli basis
 | 
					 | 
				
			||||||
//////////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
template <class vcplx, ONLY_IF_SU>
 | 
					 | 
				
			||||||
static void su2Extract(Lattice<iSinglet<vcplx> > &Determinant,
 | 
					 | 
				
			||||||
                       Lattice<iSU2Matrix<vcplx> > &subgroup,
 | 
					 | 
				
			||||||
                       const Lattice<iGroupMatrix<vcplx> > &source,
 | 
					 | 
				
			||||||
                       int su2_index) {
 | 
					 | 
				
			||||||
  GridBase *grid(source.Grid());
 | 
					 | 
				
			||||||
  conformable(subgroup, source);
 | 
					 | 
				
			||||||
  conformable(subgroup, Determinant);
 | 
					 | 
				
			||||||
  int i0, i1;
 | 
					 | 
				
			||||||
  su2SubGroupIndex(i0, i1, su2_index);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  autoView(subgroup_v, subgroup, AcceleratorWrite);
 | 
					 | 
				
			||||||
  autoView(source_v, source, AcceleratorRead);
 | 
					 | 
				
			||||||
  autoView(Determinant_v, Determinant, AcceleratorWrite);
 | 
					 | 
				
			||||||
  accelerator_for(ss, grid->oSites(), 1, {
 | 
					 | 
				
			||||||
    subgroup_v[ss]()()(0, 0) = source_v[ss]()()(i0, i0);
 | 
					 | 
				
			||||||
    subgroup_v[ss]()()(0, 1) = source_v[ss]()()(i0, i1);
 | 
					 | 
				
			||||||
    subgroup_v[ss]()()(1, 0) = source_v[ss]()()(i1, i0);
 | 
					 | 
				
			||||||
    subgroup_v[ss]()()(1, 1) = source_v[ss]()()(i1, i1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    iSU2Matrix<vcplx> Sigma = subgroup_v[ss];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Sigma = Sigma - adj(Sigma) + trace(adj(Sigma));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    subgroup_v[ss] = Sigma;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // this should be purely real
 | 
					 | 
				
			||||||
    Determinant_v[ss] =
 | 
					 | 
				
			||||||
        Sigma()()(0, 0) * Sigma()()(1, 1) - Sigma()()(0, 1) * Sigma()()(1, 0);
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//////////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// Set matrix to one and insert a pauli subgroup
 | 
					 | 
				
			||||||
//////////////////////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
template <class vcplx, ONLY_IF_SU>
 | 
					 | 
				
			||||||
static void su2Insert(const Lattice<iSU2Matrix<vcplx> > &subgroup,
 | 
					 | 
				
			||||||
                      Lattice<iGroupMatrix<vcplx> > &dest, int su2_index) {
 | 
					 | 
				
			||||||
  GridBase *grid(dest.Grid());
 | 
					 | 
				
			||||||
  conformable(subgroup, dest);
 | 
					 | 
				
			||||||
  int i0, i1;
 | 
					 | 
				
			||||||
  su2SubGroupIndex(i0, i1, su2_index);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  dest = 1.0;  // start out with identity
 | 
					 | 
				
			||||||
  autoView(dest_v, dest, AcceleratorWrite);
 | 
					 | 
				
			||||||
  autoView(subgroup_v, subgroup, AcceleratorRead);
 | 
					 | 
				
			||||||
  accelerator_for(ss, grid->oSites(), 1, {
 | 
					 | 
				
			||||||
    dest_v[ss]()()(i0, i0) = subgroup_v[ss]()()(0, 0);
 | 
					 | 
				
			||||||
    dest_v[ss]()()(i0, i1) = subgroup_v[ss]()()(0, 1);
 | 
					 | 
				
			||||||
    dest_v[ss]()()(i1, i0) = subgroup_v[ss]()()(1, 0);
 | 
					 | 
				
			||||||
    dest_v[ss]()()(i1, i1) = subgroup_v[ss]()()(1, 1);
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
///////////////////////////////////////////////
 | 
					 | 
				
			||||||
// Generate e^{ Re Tr Staple Link} dlink
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// *** Note Staple should be appropriate linear compbination between all
 | 
					 | 
				
			||||||
// staples.
 | 
					 | 
				
			||||||
// *** If already by beta pass coefficient 1.0.
 | 
					 | 
				
			||||||
// *** This routine applies the additional 1/Nc factor that comes after trace
 | 
					 | 
				
			||||||
// in action.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
///////////////////////////////////////////////
 | 
					 | 
				
			||||||
template <ONLY_IF_SU>
 | 
					 | 
				
			||||||
static void SubGroupHeatBath(
 | 
					 | 
				
			||||||
    GridSerialRNG &sRNG, GridParallelRNG &pRNG,
 | 
					 | 
				
			||||||
    RealD beta,  // coeff multiplying staple in action (with no 1/Nc)
 | 
					 | 
				
			||||||
    LatticeMatrix &link,
 | 
					 | 
				
			||||||
    const LatticeMatrix &barestaple,  // multiplied by action coeffs so th
 | 
					 | 
				
			||||||
    int su2_subgroup, int nheatbath, LatticeInteger &wheremask) {
 | 
					 | 
				
			||||||
  GridBase *grid = link.Grid();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const RealD twopi = 2.0 * M_PI;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  LatticeMatrix staple(grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  staple = barestaple * (beta / ncolour);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  LatticeMatrix V(grid);
 | 
					 | 
				
			||||||
  V = link * staple;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Subgroup manipulation in the lie algebra space
 | 
					 | 
				
			||||||
  LatticeSU2Matrix u(
 | 
					 | 
				
			||||||
      grid);  // Kennedy pendleton "u" real projected normalised Sigma
 | 
					 | 
				
			||||||
  LatticeSU2Matrix uinv(grid);
 | 
					 | 
				
			||||||
  LatticeSU2Matrix ua(grid);  // a in pauli form
 | 
					 | 
				
			||||||
  LatticeSU2Matrix b(grid);   // rotated matrix after hb
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Some handy constant fields
 | 
					 | 
				
			||||||
  LatticeComplex ones(grid);
 | 
					 | 
				
			||||||
  ones = 1.0;
 | 
					 | 
				
			||||||
  LatticeComplex zeros(grid);
 | 
					 | 
				
			||||||
  zeros = Zero();
 | 
					 | 
				
			||||||
  LatticeReal rones(grid);
 | 
					 | 
				
			||||||
  rones = 1.0;
 | 
					 | 
				
			||||||
  LatticeReal rzeros(grid);
 | 
					 | 
				
			||||||
  rzeros = Zero();
 | 
					 | 
				
			||||||
  LatticeComplex udet(grid);  // determinant of real(staple)
 | 
					 | 
				
			||||||
  LatticeInteger mask_true(grid);
 | 
					 | 
				
			||||||
  mask_true = 1;
 | 
					 | 
				
			||||||
  LatticeInteger mask_false(grid);
 | 
					 | 
				
			||||||
  mask_false = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /*
 | 
					 | 
				
			||||||
    PLB 156 P393 (1985) (Kennedy and Pendleton)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Note: absorb "beta" into the def of sigma compared to KP paper; staple
 | 
					 | 
				
			||||||
    passed to this routine has "beta" already multiplied in
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Action linear in links h and of form:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    beta S = beta  Sum_p (1 - 1/Nc Re Tr Plaq )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Writing Sigma = 1/Nc (beta Sigma') where sum over staples is "Sigma' "
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    beta S = const - beta/Nc Re Tr h Sigma'
 | 
					 | 
				
			||||||
    = const - Re Tr h Sigma
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Decompose h and Sigma into (1, sigma_j) ; h_i real, h^2=1, Sigma_i complex
 | 
					 | 
				
			||||||
    arbitrary.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Tr h Sigma = h_i Sigma_j Tr (sigma_i sigma_j)  = h_i Sigma_j 2 delta_ij
 | 
					 | 
				
			||||||
    Re Tr h Sigma = 2 h_j Re Sigma_j
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Normalised re Sigma_j = xi u_j
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    With u_j a unit vector and U can be in SU(2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Re Tr h Sigma = 2 h_j Re Sigma_j = 2 xi (h.u)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    4xi^2 = Det [ Sig - Sig^dag  + 1 Tr Sigdag]
 | 
					 | 
				
			||||||
    u   = 1/2xi [ Sig - Sig^dag  + 1 Tr Sigdag]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    xi = sqrt(Det)/2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Write a= u h in SU(2); a has pauli decomp a_j;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Note: Product b' xi is unvariant because scaling Sigma leaves
 | 
					 | 
				
			||||||
    normalised vector "u" fixed; Can rescale Sigma so b' = 1.
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Real part of Pauli decomposition
 | 
					 | 
				
			||||||
  // Note a subgroup can project to zero in cold start
 | 
					 | 
				
			||||||
  ////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  su2Extract(udet, u, V, su2_subgroup);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Normalising this vector if possible; else identity
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  LatticeComplex xi(grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  LatticeSU2Matrix lident(grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  SU2Matrix ident = Complex(1.0);
 | 
					 | 
				
			||||||
  SU2Matrix pauli1;
 | 
					 | 
				
			||||||
  GaugeGroup<2, GroupName::SU>::generator(0, pauli1);
 | 
					 | 
				
			||||||
  SU2Matrix pauli2;
 | 
					 | 
				
			||||||
  GaugeGroup<2, GroupName::SU>::generator(1, pauli2);
 | 
					 | 
				
			||||||
  SU2Matrix pauli3;
 | 
					 | 
				
			||||||
  GaugeGroup<2, GroupName::SU>::generator(2, pauli3);
 | 
					 | 
				
			||||||
  pauli1 = timesI(pauli1) * 2.0;
 | 
					 | 
				
			||||||
  pauli2 = timesI(pauli2) * 2.0;
 | 
					 | 
				
			||||||
  pauli3 = timesI(pauli3) * 2.0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  LatticeComplex cone(grid);
 | 
					 | 
				
			||||||
  LatticeReal adet(grid);
 | 
					 | 
				
			||||||
  adet = abs(toReal(udet));
 | 
					 | 
				
			||||||
  lident = Complex(1.0);
 | 
					 | 
				
			||||||
  cone = Complex(1.0);
 | 
					 | 
				
			||||||
  Real machine_epsilon = 1.0e-7;
 | 
					 | 
				
			||||||
  u = where(adet > machine_epsilon, u, lident);
 | 
					 | 
				
			||||||
  udet = where(adet > machine_epsilon, udet, cone);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  xi = 0.5 * sqrt(udet);        // 4xi^2 = Det [ Sig - Sig^dag  + 1 Tr Sigdag]
 | 
					 | 
				
			||||||
  u = 0.5 * u * pow(xi, -1.0);  //  u   = 1/2xi [ Sig - Sig^dag  + 1 Tr Sigdag]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Debug test for sanity
 | 
					 | 
				
			||||||
  uinv = adj(u);
 | 
					 | 
				
			||||||
  b = u * uinv - 1.0;
 | 
					 | 
				
			||||||
  assert(norm2(b) < 1.0e-4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /*
 | 
					 | 
				
			||||||
    Measure: Haar measure dh has d^4a delta(1-|a^2|)
 | 
					 | 
				
			||||||
    In polars:
 | 
					 | 
				
			||||||
    da = da0 r^2 sin theta dr dtheta dphi delta( 1 - r^2 -a0^2)
 | 
					 | 
				
			||||||
    = da0 r^2 sin theta dr dtheta dphi delta( (sqrt(1-a0^) - r)(sqrt(1-a0^) +
 | 
					 | 
				
			||||||
    r) )
 | 
					 | 
				
			||||||
    = da0 r/2 sin theta dr dtheta dphi delta( (sqrt(1-a0^) - r) )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Action factor Q(h) dh  = e^-S[h]  dh =  e^{  xi Tr uh} dh    // beta
 | 
					 | 
				
			||||||
    enters through xi =  e^{2 xi (h.u)} dh =  e^{2 xi h0u0}.e^{2 xi h1u1}.e^{2
 | 
					 | 
				
			||||||
    xi h2u2}.e^{2 xi h3u3} dh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Therefore for each site, take xi for that site
 | 
					 | 
				
			||||||
    i) generate  |a0|<1 with dist
 | 
					 | 
				
			||||||
    (1-a0^2)^0.5 e^{2 xi a0 } da0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Take alpha = 2 xi  = 2 xi [ recall 2 beta/Nc unmod staple norm];
 | 
					 | 
				
			||||||
    hence 2.0/Nc factor in Chroma ] A. Generate two uniformly distributed
 | 
					 | 
				
			||||||
    pseudo-random numbers R and R', R'', R''' in the unit interval; B. Set X =
 | 
					 | 
				
			||||||
    -(ln R)/alpha, X' =-(ln R')/alpha; C. Set C = cos^2(2pi R"), with R"
 | 
					 | 
				
			||||||
    another uniform random number in [0,1] ; D. Set A = XC; E. Let d  = X'+A;
 | 
					 | 
				
			||||||
    F. If R'''^2 :> 1 - 0.5 d,  go back to A;
 | 
					 | 
				
			||||||
    G. Set a0 = 1 - d;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Note that in step D setting B ~ X - A and using B in place of A in step E
 | 
					 | 
				
			||||||
    will generate a second independent a 0 value.
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // count the number of sites by picking "1"'s out of hat
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  Integer hit = 0;
 | 
					 | 
				
			||||||
  LatticeReal rtmp(grid);
 | 
					 | 
				
			||||||
  rtmp = where(wheremask, rones, rzeros);
 | 
					 | 
				
			||||||
  RealD numSites = sum(rtmp);
 | 
					 | 
				
			||||||
  RealD numAccepted;
 | 
					 | 
				
			||||||
  LatticeInteger Accepted(grid);
 | 
					 | 
				
			||||||
  Accepted = Zero();
 | 
					 | 
				
			||||||
  LatticeInteger newlyAccepted(grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<LatticeReal> xr(4, grid);
 | 
					 | 
				
			||||||
  std::vector<LatticeReal> a(4, grid);
 | 
					 | 
				
			||||||
  LatticeReal d(grid);
 | 
					 | 
				
			||||||
  d = Zero();
 | 
					 | 
				
			||||||
  LatticeReal alpha(grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //    std::cout<<GridLogMessage<<"xi "<<xi <<std::endl;
 | 
					 | 
				
			||||||
  xi = 2.0 * xi;
 | 
					 | 
				
			||||||
  alpha = toReal(xi);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  do {
 | 
					 | 
				
			||||||
    // A. Generate two uniformly distributed pseudo-random numbers R and R',
 | 
					 | 
				
			||||||
    // R'', R''' in the unit interval;
 | 
					 | 
				
			||||||
    random(pRNG, xr[0]);
 | 
					 | 
				
			||||||
    random(pRNG, xr[1]);
 | 
					 | 
				
			||||||
    random(pRNG, xr[2]);
 | 
					 | 
				
			||||||
    random(pRNG, xr[3]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // B. Set X = - ln R/alpha, X' = -ln R'/alpha
 | 
					 | 
				
			||||||
    xr[1] = -log(xr[1]) / alpha;
 | 
					 | 
				
			||||||
    xr[2] = -log(xr[2]) / alpha;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // C. Set C = cos^2(2piR'')
 | 
					 | 
				
			||||||
    xr[3] = cos(xr[3] * twopi);
 | 
					 | 
				
			||||||
    xr[3] = xr[3] * xr[3];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LatticeReal xrsq(grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // D. Set A = XC;
 | 
					 | 
				
			||||||
    // E. Let d  = X'+A;
 | 
					 | 
				
			||||||
    xrsq = xr[2] + xr[1] * xr[3];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    d = where(Accepted, d, xr[2] + xr[1] * xr[3]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // F. If R'''^2 :> 1 - 0.5 d,  go back to A;
 | 
					 | 
				
			||||||
    LatticeReal thresh(grid);
 | 
					 | 
				
			||||||
    thresh = 1.0 - d * 0.5;
 | 
					 | 
				
			||||||
    xrsq = xr[0] * xr[0];
 | 
					 | 
				
			||||||
    LatticeInteger ione(grid);
 | 
					 | 
				
			||||||
    ione = 1;
 | 
					 | 
				
			||||||
    LatticeInteger izero(grid);
 | 
					 | 
				
			||||||
    izero = Zero();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    newlyAccepted = where(xrsq < thresh, ione, izero);
 | 
					 | 
				
			||||||
    Accepted = where(newlyAccepted, newlyAccepted, Accepted);
 | 
					 | 
				
			||||||
    Accepted = where(wheremask, Accepted, izero);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // FIXME need an iSum for integer to avoid overload on return type??
 | 
					 | 
				
			||||||
    rtmp = where(Accepted, rones, rzeros);
 | 
					 | 
				
			||||||
    numAccepted = sum(rtmp);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    hit++;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  } while ((numAccepted < numSites) && (hit < nheatbath));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // G. Set a0 = 1 - d;
 | 
					 | 
				
			||||||
  a[0] = Zero();
 | 
					 | 
				
			||||||
  a[0] = where(wheremask, 1.0 - d, a[0]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////////////////////
 | 
					 | 
				
			||||||
  //    ii) generate a_i uniform on two sphere radius (1-a0^2)^0.5
 | 
					 | 
				
			||||||
  //////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  LatticeReal a123mag(grid);
 | 
					 | 
				
			||||||
  a123mag = sqrt(abs(1.0 - a[0] * a[0]));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  LatticeReal cos_theta(grid);
 | 
					 | 
				
			||||||
  LatticeReal sin_theta(grid);
 | 
					 | 
				
			||||||
  LatticeReal phi(grid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  random(pRNG, phi);
 | 
					 | 
				
			||||||
  phi = phi * twopi;  // uniform in [0,2pi]
 | 
					 | 
				
			||||||
  random(pRNG, cos_theta);
 | 
					 | 
				
			||||||
  cos_theta = (cos_theta * 2.0) - 1.0;  // uniform in [-1,1]
 | 
					 | 
				
			||||||
  sin_theta = sqrt(abs(1.0 - cos_theta * cos_theta));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  a[1] = a123mag * sin_theta * cos(phi);
 | 
					 | 
				
			||||||
  a[2] = a123mag * sin_theta * sin(phi);
 | 
					 | 
				
			||||||
  a[3] = a123mag * cos_theta;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ua = toComplex(a[0]) * ident + toComplex(a[1]) * pauli1 +
 | 
					 | 
				
			||||||
       toComplex(a[2]) * pauli2 + toComplex(a[3]) * pauli3;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  b = 1.0;
 | 
					 | 
				
			||||||
  b = where(wheremask, uinv * ua, b);
 | 
					 | 
				
			||||||
  su2Insert(b, V, su2_subgroup);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // mask the assignment back based on Accptance
 | 
					 | 
				
			||||||
  link = where(Accepted, V * link, link);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////////
 | 
					 | 
				
			||||||
  // Debug Checks
 | 
					 | 
				
			||||||
  // SU2 check
 | 
					 | 
				
			||||||
  LatticeSU2Matrix check(grid);  // rotated matrix after hb
 | 
					 | 
				
			||||||
  u = Zero();
 | 
					 | 
				
			||||||
  check = ua * adj(ua) - 1.0;
 | 
					 | 
				
			||||||
  check = where(Accepted, check, u);
 | 
					 | 
				
			||||||
  assert(norm2(check) < 1.0e-4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  check = b * adj(b) - 1.0;
 | 
					 | 
				
			||||||
  check = where(Accepted, check, u);
 | 
					 | 
				
			||||||
  assert(norm2(check) < 1.0e-4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  LatticeMatrix Vcheck(grid);
 | 
					 | 
				
			||||||
  Vcheck = Zero();
 | 
					 | 
				
			||||||
  Vcheck = where(Accepted, V * adj(V) - 1.0, Vcheck);
 | 
					 | 
				
			||||||
  //    std::cout<<GridLogMessage << "SU3 check " <<norm2(Vcheck)<<std::endl;
 | 
					 | 
				
			||||||
  assert(norm2(Vcheck) < 1.0e-4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Verify the link stays in SU(3)
 | 
					 | 
				
			||||||
  //    std::cout<<GridLogMessage <<"Checking the modified link"<<std::endl;
 | 
					 | 
				
			||||||
  Vcheck = link * adj(link) - 1.0;
 | 
					 | 
				
			||||||
  assert(norm2(Vcheck) < 1.0e-4);
 | 
					 | 
				
			||||||
  /////////////////////////////////
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <ONLY_IF_SU>
 | 
					 | 
				
			||||||
static void testGenerators(GroupName::SU) {
 | 
					 | 
				
			||||||
  Matrix ta;
 | 
					 | 
				
			||||||
  Matrix tb;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage
 | 
					 | 
				
			||||||
            << "Fundamental - Checking trace ta tb is 0.5 delta_ab"
 | 
					 | 
				
			||||||
            << std::endl;
 | 
					 | 
				
			||||||
  for (int a = 0; a < AdjointDimension; a++) {
 | 
					 | 
				
			||||||
    for (int b = 0; b < AdjointDimension; b++) {
 | 
					 | 
				
			||||||
      generator(a, ta);
 | 
					 | 
				
			||||||
      generator(b, tb);
 | 
					 | 
				
			||||||
      Complex tr = TensorRemove(trace(ta * tb));
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << "(" << a << "," << b << ") =  " << tr
 | 
					 | 
				
			||||||
                << std::endl;
 | 
					 | 
				
			||||||
      if (a == b) assert(abs(tr - Complex(0.5)) < 1.0e-6);
 | 
					 | 
				
			||||||
      if (a != b) assert(abs(tr) < 1.0e-6);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << std::endl;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << "Fundamental - Checking if hermitian"
 | 
					 | 
				
			||||||
            << std::endl;
 | 
					 | 
				
			||||||
  for (int a = 0; a < AdjointDimension; a++) {
 | 
					 | 
				
			||||||
    generator(a, ta);
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << a << std::endl;
 | 
					 | 
				
			||||||
    assert(norm2(ta - adj(ta)) < 1.0e-6);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << "Fundamental - Checking if traceless"
 | 
					 | 
				
			||||||
            << std::endl;
 | 
					 | 
				
			||||||
  for (int a = 0; a < AdjointDimension; a++) {
 | 
					 | 
				
			||||||
    generator(a, ta);
 | 
					 | 
				
			||||||
    Complex tr = TensorRemove(trace(ta));
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << a << " " << std::endl;
 | 
					 | 
				
			||||||
    assert(abs(tr) < 1.0e-6);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << std::endl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <int N, class vtype>
 | 
					 | 
				
			||||||
static Lattice<iScalar<iScalar<iMatrix<vtype, N> > > >
 | 
					 | 
				
			||||||
ProjectOnGeneralGroup(const Lattice<iScalar<iScalar<iMatrix<vtype, N> > > > &Umu, GroupName::SU) {
 | 
					 | 
				
			||||||
  return ProjectOnGroup(Umu);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class vtype>
 | 
					 | 
				
			||||||
accelerator_inline static iScalar<vtype> ProjectOnGeneralGroup(const iScalar<vtype> &r, GroupName::SU) {
 | 
					 | 
				
			||||||
  return ProjectOnGroup(r);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class vtype, int N>
 | 
					 | 
				
			||||||
accelerator_inline static iVector<vtype,N> ProjectOnGeneralGroup(const iVector<vtype,N> &r, GroupName::SU) {
 | 
					 | 
				
			||||||
  return ProjectOnGroup(r);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
 | 
					 | 
				
			||||||
accelerator_inline static iMatrix<vtype,N> ProjectOnGeneralGroup(const iMatrix<vtype,N> &arg, GroupName::SU) {
 | 
					 | 
				
			||||||
  return ProjectOnGroup(arg);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <typename LatticeMatrixType>
 | 
					 | 
				
			||||||
static void taProj(const LatticeMatrixType &in, LatticeMatrixType &out, GroupName::SU) {
 | 
					 | 
				
			||||||
  out = Ta(in);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * Fundamental rep gauge xform
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
template<typename Fundamental,typename GaugeMat>
 | 
					 | 
				
			||||||
static void GaugeTransformFundamental( Fundamental &ferm, GaugeMat &g){
 | 
					 | 
				
			||||||
  GridBase *grid = ferm._grid;
 | 
					 | 
				
			||||||
  conformable(grid,g._grid);
 | 
					 | 
				
			||||||
  ferm = g*ferm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * Adjoint rep gauge xform
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template<typename Gimpl>
 | 
					 | 
				
			||||||
static void GaugeTransform(typename Gimpl::GaugeField &Umu, typename Gimpl::GaugeLinkField &g){
 | 
					 | 
				
			||||||
  GridBase *grid = Umu.Grid();
 | 
					 | 
				
			||||||
  conformable(grid,g.Grid());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typename Gimpl::GaugeLinkField U(grid);
 | 
					 | 
				
			||||||
  typename Gimpl::GaugeLinkField ag(grid); ag = adj(g);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int mu=0;mu<Nd;mu++){
 | 
					 | 
				
			||||||
    U= PeekIndex<LorentzIndex>(Umu,mu);
 | 
					 | 
				
			||||||
    U = g*U*Gimpl::CshiftLink(ag, mu, 1); //BC-aware
 | 
					 | 
				
			||||||
    PokeIndex<LorentzIndex>(Umu,U,mu);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
template<typename Gimpl>
 | 
					 | 
				
			||||||
static void GaugeTransform( std::vector<typename Gimpl::GaugeLinkField> &U, typename Gimpl::GaugeLinkField &g){
 | 
					 | 
				
			||||||
  GridBase *grid = g.Grid();
 | 
					 | 
				
			||||||
  typename Gimpl::GaugeLinkField ag(grid); ag = adj(g);
 | 
					 | 
				
			||||||
  for(int mu=0;mu<Nd;mu++){
 | 
					 | 
				
			||||||
    U[mu] = g*U[mu]*Gimpl::CshiftLink(ag, mu, 1); //BC-aware
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
template<typename Gimpl>
 | 
					 | 
				
			||||||
static void RandomGaugeTransform(GridParallelRNG &pRNG, typename Gimpl::GaugeField &Umu, typename Gimpl::GaugeLinkField &g){
 | 
					 | 
				
			||||||
  LieRandomize(pRNG,g,1.0);
 | 
					 | 
				
			||||||
  GaugeTransform<Gimpl>(Umu,g);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -51,10 +51,6 @@ public:
 | 
				
			|||||||
  typedef Lattice<iVector<iScalar<iMatrix<vComplexF, Dimension> >, Nd> > LatticeAdjFieldF;
 | 
					  typedef Lattice<iVector<iScalar<iMatrix<vComplexF, Dimension> >, Nd> > LatticeAdjFieldF;
 | 
				
			||||||
  typedef Lattice<iVector<iScalar<iMatrix<vComplexD, Dimension> >, Nd> > LatticeAdjFieldD;
 | 
					  typedef Lattice<iVector<iScalar<iMatrix<vComplexD, Dimension> >, Nd> > LatticeAdjFieldD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  template <typename vtype>
 | 
					 | 
				
			||||||
  using iSUnMatrix = iScalar<iScalar<iMatrix<vtype, ncolour> > >;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Lattice<iScalar<iScalar<iVector<vComplex, Dimension> > > >  LatticeAdjVector;
 | 
					  typedef Lattice<iScalar<iScalar<iVector<vComplex, Dimension> > > >  LatticeAdjVector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  template <class cplx>
 | 
					  template <class cplx>
 | 
				
			||||||
@@ -62,8 +58,8 @@ public:
 | 
				
			|||||||
    // returns i(T_Adj)^index necessary for the projectors
 | 
					    // returns i(T_Adj)^index necessary for the projectors
 | 
				
			||||||
    // see definitions above
 | 
					    // see definitions above
 | 
				
			||||||
    iAdjTa = Zero();
 | 
					    iAdjTa = Zero();
 | 
				
			||||||
    Vector<iSUnMatrix<cplx> > ta(ncolour * ncolour - 1);
 | 
					    Vector<typename SU<ncolour>::template iSUnMatrix<cplx> > ta(ncolour * ncolour - 1);
 | 
				
			||||||
    iSUnMatrix<cplx> tmp;
 | 
					    typename SU<ncolour>::template iSUnMatrix<cplx> tmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // FIXME not very efficient to get all the generators everytime
 | 
					    // FIXME not very efficient to get all the generators everytime
 | 
				
			||||||
    for (int a = 0; a < Dimension; a++) SU<ncolour>::generator(a, ta[a]);
 | 
					    for (int a = 0; a < Dimension; a++) SU<ncolour>::generator(a, ta[a]);
 | 
				
			||||||
@@ -71,7 +67,8 @@ public:
 | 
				
			|||||||
    for (int a = 0; a < Dimension; a++) {
 | 
					    for (int a = 0; a < Dimension; a++) {
 | 
				
			||||||
      tmp = ta[a] * ta[Index] - ta[Index] * ta[a];
 | 
					      tmp = ta[a] * ta[Index] - ta[Index] * ta[a];
 | 
				
			||||||
      for (int b = 0; b < (ncolour * ncolour - 1); b++) {
 | 
					      for (int b = 0; b < (ncolour * ncolour - 1); b++) {
 | 
				
			||||||
        iSUnMatrix<cplx> tmp1 = 2.0 * tmp * ta[b];  // 2.0 from the normalization
 | 
					        typename SU<ncolour>::template iSUnMatrix<cplx> tmp1 =
 | 
				
			||||||
 | 
						  2.0 * tmp * ta[b];  // 2.0 from the normalization
 | 
				
			||||||
        Complex iTr = TensorRemove(timesI(trace(tmp1)));
 | 
					        Complex iTr = TensorRemove(timesI(trace(tmp1)));
 | 
				
			||||||
        //iAdjTa()()(b, a) = iTr;
 | 
					        //iAdjTa()()(b, a) = iTr;
 | 
				
			||||||
        iAdjTa()()(a, b) = iTr;
 | 
					        iAdjTa()()(a, b) = iTr;
 | 
				
			||||||
@@ -137,7 +134,8 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    for (int a = 0; a < Dimension; a++) {
 | 
					    for (int a = 0; a < Dimension; a++) {
 | 
				
			||||||
      generator(a, iTa);
 | 
					      generator(a, iTa);
 | 
				
			||||||
      pokeColour(h_out, real(trace(iTa * in)) * coefficient, a);
 | 
					      LatticeComplex tmp = real(trace(iTa * in)) * coefficient;
 | 
				
			||||||
 | 
					      pokeColour(h_out, tmp, a);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										273
									
								
								Grid/qcd/utils/SUnTwoIndex.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										273
									
								
								Grid/qcd/utils/SUnTwoIndex.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,273 @@
 | 
				
			|||||||
 | 
					////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// * Two index representation generators
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// * Normalisation for the fundamental generators:
 | 
				
			||||||
 | 
					//   trace ta tb = 1/2 delta_ab = T_F delta_ab
 | 
				
			||||||
 | 
					//   T_F = 1/2  for SU(N) groups
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   base for NxN two index (anti-symmetric) matrices
 | 
				
			||||||
 | 
					//   normalized to 1 (d_ij is the kroenecker delta)
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   (e^(ij)_{kl} = 1 / sqrt(2) (d_ik d_jl +/- d_jk d_il)
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   Then the generators are written as
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   (iT_a)^(ij)(lk) = i * ( tr[e^(ij)^dag e^(lk) T^trasp_a] +
 | 
				
			||||||
 | 
					//   tr[e^(lk)e^(ij)^dag T_a] )  //
 | 
				
			||||||
 | 
					//   
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Authors: David Preti, Guido Cossu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef QCD_UTIL_SUN2INDEX_H
 | 
				
			||||||
 | 
					#define QCD_UTIL_SUN2INDEX_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NAMESPACE_BEGIN(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum TwoIndexSymmetry { Symmetric = 1, AntiSymmetric = -1 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline Real delta(int a, int b) { return (a == b) ? 1.0 : 0.0; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <int ncolour, TwoIndexSymmetry S>
 | 
				
			||||||
 | 
					class SU_TwoIndex : public SU<ncolour> {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  static const int Dimension = ncolour * (ncolour + S) / 2;
 | 
				
			||||||
 | 
					  static const int NumGenerators = SU<ncolour>::AdjointDimension;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <typename vtype>
 | 
				
			||||||
 | 
					  using iSUnTwoIndexMatrix = iScalar<iScalar<iMatrix<vtype, Dimension> > >;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef iSUnTwoIndexMatrix<Complex> TIMatrix;
 | 
				
			||||||
 | 
					  typedef iSUnTwoIndexMatrix<ComplexF> TIMatrixF;
 | 
				
			||||||
 | 
					  typedef iSUnTwoIndexMatrix<ComplexD> TIMatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef iSUnTwoIndexMatrix<vComplex> vTIMatrix;
 | 
				
			||||||
 | 
					  typedef iSUnTwoIndexMatrix<vComplexF> vTIMatrixF;
 | 
				
			||||||
 | 
					  typedef iSUnTwoIndexMatrix<vComplexD> vTIMatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef Lattice<vTIMatrix> LatticeTwoIndexMatrix;
 | 
				
			||||||
 | 
					  typedef Lattice<vTIMatrixF> LatticeTwoIndexMatrixF;
 | 
				
			||||||
 | 
					  typedef Lattice<vTIMatrixD> LatticeTwoIndexMatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef Lattice<iVector<iScalar<iMatrix<vComplex, Dimension> >, Nd> >
 | 
				
			||||||
 | 
					  LatticeTwoIndexField;
 | 
				
			||||||
 | 
					  typedef Lattice<iVector<iScalar<iMatrix<vComplexF, Dimension> >, Nd> >
 | 
				
			||||||
 | 
					  LatticeTwoIndexFieldF;
 | 
				
			||||||
 | 
					  typedef Lattice<iVector<iScalar<iMatrix<vComplexD, Dimension> >, Nd> >
 | 
				
			||||||
 | 
					  LatticeTwoIndexFieldD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <typename vtype>
 | 
				
			||||||
 | 
					  using iSUnMatrix = iScalar<iScalar<iMatrix<vtype, ncolour> > >;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<Complex> Matrix;
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<ComplexF> MatrixF;
 | 
				
			||||||
 | 
					  typedef iSUnMatrix<ComplexD> MatrixD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <class cplx>
 | 
				
			||||||
 | 
					  static void base(int Index, iSUnMatrix<cplx> &eij) {
 | 
				
			||||||
 | 
					    // returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R
 | 
				
			||||||
 | 
					    assert(Index < NumGenerators);
 | 
				
			||||||
 | 
					    eij = Zero();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // for the linearisation of the 2 indexes 
 | 
				
			||||||
 | 
					    static int a[ncolour * (ncolour - 1) / 2][2]; // store the a <-> i,j
 | 
				
			||||||
 | 
					    static bool filled = false;
 | 
				
			||||||
 | 
					    if (!filled) {
 | 
				
			||||||
 | 
					      int counter = 0;
 | 
				
			||||||
 | 
					      for (int i = 1; i < ncolour; i++) {
 | 
				
			||||||
 | 
					        for (int j = 0; j < i; j++) {
 | 
				
			||||||
 | 
					          a[counter][0] = i;
 | 
				
			||||||
 | 
					          a[counter][1] = j;
 | 
				
			||||||
 | 
					          counter++;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      filled = true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (Index < ncolour * (ncolour - 1) / 2) {
 | 
				
			||||||
 | 
					      baseOffDiagonal(a[Index][0], a[Index][1], eij);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      baseDiagonal(Index, eij);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <class cplx>
 | 
				
			||||||
 | 
					  static void baseDiagonal(int Index, iSUnMatrix<cplx> &eij) {
 | 
				
			||||||
 | 
					    eij = Zero();
 | 
				
			||||||
 | 
					    eij()()(Index - ncolour * (ncolour - 1) / 2,
 | 
				
			||||||
 | 
					            Index - ncolour * (ncolour - 1) / 2) = 1.0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <class cplx>
 | 
				
			||||||
 | 
					  static void baseOffDiagonal(int i, int j, iSUnMatrix<cplx> &eij) {
 | 
				
			||||||
 | 
					    eij = Zero();
 | 
				
			||||||
 | 
					    for (int k = 0; k < ncolour; k++)
 | 
				
			||||||
 | 
					      for (int l = 0; l < ncolour; l++)
 | 
				
			||||||
 | 
					        eij()()(l, k) = delta(i, k) * delta(j, l) +
 | 
				
			||||||
 | 
						  S * delta(j, k) * delta(i, l);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RealD nrm = 1. / std::sqrt(2.0);
 | 
				
			||||||
 | 
					    eij = eij * nrm;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void printBase(void) {
 | 
				
			||||||
 | 
					    for (int gen = 0; gen < Dimension; gen++) {
 | 
				
			||||||
 | 
					      Matrix tmp;
 | 
				
			||||||
 | 
					      base(gen, tmp);
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
 | 
				
			||||||
 | 
					                << std::endl;
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << tmp << std::endl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  template <class cplx>
 | 
				
			||||||
 | 
					  static void generator(int Index, iSUnTwoIndexMatrix<cplx> &i2indTa) {
 | 
				
			||||||
 | 
					    Vector<typename SU<ncolour>::template iSUnMatrix<cplx> > ta(
 | 
				
			||||||
 | 
													ncolour * ncolour - 1);
 | 
				
			||||||
 | 
					    Vector<typename SU<ncolour>::template iSUnMatrix<cplx> > eij(Dimension);
 | 
				
			||||||
 | 
					    typename SU<ncolour>::template iSUnMatrix<cplx> tmp;
 | 
				
			||||||
 | 
					    i2indTa = Zero();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    for (int a = 0; a < ncolour * ncolour - 1; a++)
 | 
				
			||||||
 | 
					      SU<ncolour>::generator(a, ta[a]);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    for (int a = 0; a < Dimension; a++) base(a, eij[a]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int a = 0; a < Dimension; a++) {
 | 
				
			||||||
 | 
					      tmp = transpose(ta[Index]) * adj(eij[a]) + adj(eij[a]) * ta[Index];
 | 
				
			||||||
 | 
					      for (int b = 0; b < Dimension; b++) {
 | 
				
			||||||
 | 
					        typename SU<ncolour>::template iSUnMatrix<cplx> tmp1 =
 | 
				
			||||||
 | 
						  tmp * eij[b]; 
 | 
				
			||||||
 | 
					        Complex iTr = TensorRemove(timesI(trace(tmp1)));
 | 
				
			||||||
 | 
					        i2indTa()()(a, b) = iTr;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void printGenerators(void) {
 | 
				
			||||||
 | 
					    for (int gen = 0; gen < ncolour * ncolour - 1; gen++) {
 | 
				
			||||||
 | 
					      TIMatrix i2indTa;
 | 
				
			||||||
 | 
					      generator(gen, i2indTa);
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << "Nc = " << ncolour << " t_" << gen
 | 
				
			||||||
 | 
					                << std::endl;
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << i2indTa << std::endl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void testGenerators(void) {
 | 
				
			||||||
 | 
					    TIMatrix i2indTa, i2indTb;
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << "2IndexRep - Checking if traceless"
 | 
				
			||||||
 | 
					              << std::endl;
 | 
				
			||||||
 | 
					    for (int a = 0; a < ncolour * ncolour - 1; a++) {
 | 
				
			||||||
 | 
					      generator(a, i2indTa);
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << a << std::endl;
 | 
				
			||||||
 | 
					      assert(norm2(trace(i2indTa)) < 1.0e-6);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << "2IndexRep - Checking if antihermitean"
 | 
				
			||||||
 | 
					              << std::endl;
 | 
				
			||||||
 | 
					    for (int a = 0; a < ncolour * ncolour - 1; a++) {
 | 
				
			||||||
 | 
					      generator(a, i2indTa);
 | 
				
			||||||
 | 
					      std::cout << GridLogMessage << a << std::endl;
 | 
				
			||||||
 | 
					      assert(norm2(adj(i2indTa) + i2indTa) < 1.0e-6);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << std::endl;
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage
 | 
				
			||||||
 | 
					              << "2IndexRep - Checking Tr[Ta*Tb]=delta(a,b)*(N +- 2)/2"
 | 
				
			||||||
 | 
					              << std::endl;
 | 
				
			||||||
 | 
					    for (int a = 0; a < ncolour * ncolour - 1; a++) {
 | 
				
			||||||
 | 
					      for (int b = 0; b < ncolour * ncolour - 1; b++) {
 | 
				
			||||||
 | 
					        generator(a, i2indTa);
 | 
				
			||||||
 | 
					        generator(b, i2indTb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // generator returns iTa, so we need a minus sign here
 | 
				
			||||||
 | 
					        Complex Tr = -TensorRemove(trace(i2indTa * i2indTb));
 | 
				
			||||||
 | 
					        std::cout << GridLogMessage << "a=" << a << "b=" << b << "Tr=" << Tr
 | 
				
			||||||
 | 
					                  << std::endl;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    std::cout << GridLogMessage << std::endl;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void TwoIndexLieAlgebraMatrix(
 | 
				
			||||||
 | 
									       const typename SU<ncolour>::LatticeAlgebraVector &h,
 | 
				
			||||||
 | 
									       LatticeTwoIndexMatrix &out, Real scale = 1.0) {
 | 
				
			||||||
 | 
					    conformable(h, out);
 | 
				
			||||||
 | 
					    GridBase *grid = out.Grid();
 | 
				
			||||||
 | 
					    LatticeTwoIndexMatrix la(grid);
 | 
				
			||||||
 | 
					    TIMatrix i2indTa;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    out = Zero();
 | 
				
			||||||
 | 
					    for (int a = 0; a < ncolour * ncolour - 1; a++) {
 | 
				
			||||||
 | 
					      generator(a, i2indTa);
 | 
				
			||||||
 | 
					      la = peekColour(h, a) * i2indTa;
 | 
				
			||||||
 | 
					      out += la;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    out *= scale;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Projects the algebra components 
 | 
				
			||||||
 | 
					  // of a lattice matrix ( of dimension ncol*ncol -1 )
 | 
				
			||||||
 | 
					  static void projectOnAlgebra(
 | 
				
			||||||
 | 
								       typename SU<ncolour>::LatticeAlgebraVector &h_out,
 | 
				
			||||||
 | 
								       const LatticeTwoIndexMatrix &in, Real scale = 1.0) {
 | 
				
			||||||
 | 
					    conformable(h_out, in);
 | 
				
			||||||
 | 
					    h_out = Zero();
 | 
				
			||||||
 | 
					    TIMatrix i2indTa;
 | 
				
			||||||
 | 
					    Real coefficient = -2.0 / (ncolour + 2 * S) * scale;
 | 
				
			||||||
 | 
					    // 2/(Nc +/- 2) for the normalization of the trace in the two index rep
 | 
				
			||||||
 | 
					    for (int a = 0; a < ncolour * ncolour - 1; a++) {
 | 
				
			||||||
 | 
					      generator(a, i2indTa);
 | 
				
			||||||
 | 
					      auto tmp = real(trace(i2indTa * in)) * coefficient;
 | 
				
			||||||
 | 
					      pokeColour(h_out, tmp, a);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // a projector that keeps the generators stored to avoid the overhead of
 | 
				
			||||||
 | 
					  // recomputing them
 | 
				
			||||||
 | 
					  static void projector(typename SU<ncolour>::LatticeAlgebraVector &h_out,
 | 
				
			||||||
 | 
					                        const LatticeTwoIndexMatrix &in, Real scale = 1.0) {
 | 
				
			||||||
 | 
					    conformable(h_out, in);
 | 
				
			||||||
 | 
					    // to store the generators
 | 
				
			||||||
 | 
					    static std::vector<TIMatrix> i2indTa(ncolour * ncolour -1); 
 | 
				
			||||||
 | 
					    h_out = Zero();
 | 
				
			||||||
 | 
					    static bool precalculated = false;
 | 
				
			||||||
 | 
					    if (!precalculated) {
 | 
				
			||||||
 | 
					      precalculated = true;
 | 
				
			||||||
 | 
					      for (int a = 0; a < ncolour * ncolour - 1; a++) generator(a, i2indTa[a]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Real coefficient =
 | 
				
			||||||
 | 
					      -2.0 / (ncolour + 2 * S) * scale;  // 2/(Nc +/- 2) for the normalization
 | 
				
			||||||
 | 
					    // of the trace in the two index rep
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int a = 0; a < ncolour * ncolour - 1; a++) {
 | 
				
			||||||
 | 
					      auto tmp = real(trace(i2indTa[a] * in)) * coefficient;
 | 
				
			||||||
 | 
					      pokeColour(h_out, tmp, a);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Some useful type names
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<Nc, Symmetric> TwoIndexSymmMatrices;
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<Nc, AntiSymmetric> TwoIndexAntiSymmMatrices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<2, Symmetric> SU2TwoIndexSymm;
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<3, Symmetric> SU3TwoIndexSymm;
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<4, Symmetric> SU4TwoIndexSymm;
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<5, Symmetric> SU5TwoIndexSymm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<2, AntiSymmetric> SU2TwoIndexAntiSymm;
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<3, AntiSymmetric> SU3TwoIndexAntiSymm;
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<4, AntiSymmetric> SU4TwoIndexAntiSymm;
 | 
				
			||||||
 | 
					typedef SU_TwoIndex<5, AntiSymmetric> SU5TwoIndexAntiSymm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
@@ -1,317 +0,0 @@
 | 
				
			|||||||
// This file is #included into the body of the class template definition of
 | 
					 | 
				
			||||||
// GaugeGroup. So, image there to be
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// template <int ncolour, class group_name>
 | 
					 | 
				
			||||||
// class GaugeGroup {
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// around it.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Please note that the unconventional file extension makes sure that it
 | 
					 | 
				
			||||||
// doesn't get found by the scripts/filelist during bootstrapping.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
template <ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static int su2subgroups(GroupName::Sp) { return (ncolour/2 * (ncolour/2 - 1)) / 2; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Sp(2N) has N(2N+1) = 2N^2+N generators
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// normalise the generators such that
 | 
					 | 
				
			||||||
// Trace ( Ta Tb) = 1/2 delta_ab
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// N generators in the cartan, 2N^2 off
 | 
					 | 
				
			||||||
// off diagonal:
 | 
					 | 
				
			||||||
//     there are 6 types named a,b,c,d and w,z
 | 
					 | 
				
			||||||
//     abcd are N(N-1)/2 each while wz are N each
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void generator(int lieIndex, iGroupMatrix<cplx> &ta, GroupName::Sp) {
 | 
					 | 
				
			||||||
  // map lie index into type of generators: diagonal, abcd type, wz type
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int nsp = ncolour/2;
 | 
					 | 
				
			||||||
  int diagIndex;
 | 
					 | 
				
			||||||
  int aIndex, bIndex, cIndex, dIndex;
 | 
					 | 
				
			||||||
  int wIndex, zIndex;  // a,b,c,d are N(N-1)/2 and w,z are N
 | 
					 | 
				
			||||||
  const int mod = nsp * (nsp - 1) * 0.5;
 | 
					 | 
				
			||||||
  const int offdiag =
 | 
					 | 
				
			||||||
      2 * nsp * nsp;  // number of generators not in the cartan subalgebra
 | 
					 | 
				
			||||||
  const int wmod = 4 * mod;
 | 
					 | 
				
			||||||
  const int zmod = wmod + nsp;
 | 
					 | 
				
			||||||
  if (lieIndex >= offdiag) {
 | 
					 | 
				
			||||||
    diagIndex = lieIndex - offdiag;  // 0, ... ,N-1
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "diag type " << std::endl;
 | 
					 | 
				
			||||||
    generatorDiagtype(diagIndex, ta);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if ((lieIndex >= wmod) && (lieIndex < zmod)) {
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "w type " << std::endl;
 | 
					 | 
				
			||||||
    wIndex = lieIndex - wmod;  // 0, ... ,N-1
 | 
					 | 
				
			||||||
    generatorWtype(wIndex, ta);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if ((lieIndex >= zmod) && (lieIndex < offdiag)) {
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "z type " << std::endl;
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "lie index " << lieIndex << std::endl;
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "z mod " << zmod << std::endl;
 | 
					 | 
				
			||||||
    zIndex = lieIndex - zmod;  // 0, ... ,N-1
 | 
					 | 
				
			||||||
    generatorZtype(zIndex, ta);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if (lieIndex < mod) {  // atype 0, ... , N(N-1)/2=mod
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "a type " << std::endl;
 | 
					 | 
				
			||||||
    aIndex = lieIndex;
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "a indx " << aIndex << std::endl;
 | 
					 | 
				
			||||||
    generatorAtype(aIndex, ta);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if ((lieIndex >= mod) && lieIndex < 2 * mod) {  // btype mod, ... , 2mod-1
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "b type " << std::endl;
 | 
					 | 
				
			||||||
    bIndex = lieIndex - mod;
 | 
					 | 
				
			||||||
    generatorBtype(bIndex, ta);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if ((lieIndex >= 2 * mod) &&
 | 
					 | 
				
			||||||
      lieIndex < 3 * mod) {  // ctype 2mod, ... , 3mod-1
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "c type " << std::endl;
 | 
					 | 
				
			||||||
    cIndex = lieIndex - 2 * mod;
 | 
					 | 
				
			||||||
    generatorCtype(cIndex, ta);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if ((lieIndex >= 3 * mod) &&
 | 
					 | 
				
			||||||
      lieIndex < wmod) {  // ctype 3mod, ... , 4mod-1 = wmod-1
 | 
					 | 
				
			||||||
    // std::cout << GridLogMessage << "d type " << std::endl;
 | 
					 | 
				
			||||||
    dIndex = lieIndex - 3 * mod;
 | 
					 | 
				
			||||||
    generatorDtype(dIndex, ta);
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}  // end of generator
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void generatorDiagtype(int diagIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  // ta(i,i) = - ta(i+N,i+N) = 1/2 for each i index of the cartan subalgebra
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  RealD nrm = 1.0 / 2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta()()(diagIndex, diagIndex) = nrm;
 | 
					 | 
				
			||||||
  ta()()(diagIndex + nsp, diagIndex + nsp) = -nrm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void generatorAtype(int aIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  // ta(i,j) = ta(j,i) = -ta(i+N,j+N) = -ta(j+N,i+N) = 1 / 2 sqrt(2)
 | 
					 | 
				
			||||||
  // with i<j and i=0,...,N-2
 | 
					 | 
				
			||||||
  // follows that j=i+1, ... , N
 | 
					 | 
				
			||||||
  int i1, i2;
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  RealD nrm = 1 / (2 * std::sqrt(2));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  su2SubGroupIndex(i1, i2, aIndex);
 | 
					 | 
				
			||||||
  ta()()(i1, i2) = 1;
 | 
					 | 
				
			||||||
  ta()()(i2, i1) = 1;
 | 
					 | 
				
			||||||
  ta()()(i1 + nsp, i2 + nsp) = -1;
 | 
					 | 
				
			||||||
  ta()()(i2 + nsp, i1 + nsp) = -1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta = ta * nrm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void generatorBtype(int bIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  // ta(i,j) = -ta(j,i) = ta(i+N,j+N) = -ta(j+N,i+N) = i / 1/ 2 sqrt(2)
 | 
					 | 
				
			||||||
  // with i<j and i=0,...,N-2
 | 
					 | 
				
			||||||
  // follows that j=i+1, ... , N-1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  int i1, i2;
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  cplx i(0.0, 1.0);
 | 
					 | 
				
			||||||
  RealD nrm = 1 / (2 * std::sqrt(2));
 | 
					 | 
				
			||||||
  su2SubGroupIndex(i1, i2, bIndex);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta()()(i1, i2) = i;
 | 
					 | 
				
			||||||
  ta()()(i2, i1) = -i;
 | 
					 | 
				
			||||||
  ta()()(i1 + nsp, i2 + nsp) = i;
 | 
					 | 
				
			||||||
  ta()()(i2 + nsp, i1 + nsp) = -i;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta = ta * nrm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void generatorCtype(int cIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  // ta(i,j+N) = ta(j,i+N) = ta(i+N,j) = ta(j+N,i) = 1 / 2 sqrt(2)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  int i1, i2;
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  RealD nrm = 1 / (2 * std::sqrt(2));
 | 
					 | 
				
			||||||
  su2SubGroupIndex(i1, i2, cIndex);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta()()(i1, i2 + nsp) = 1;
 | 
					 | 
				
			||||||
  ta()()(i2, i1 + nsp) = 1;
 | 
					 | 
				
			||||||
  ta()()(i1 + nsp, i2) = 1;
 | 
					 | 
				
			||||||
  ta()()(i2 + nsp, i1) = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta = ta * nrm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void generatorDtype(int dIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  // ta(i,j+N) = ta(j,i+N) = -ta(i+N,j) = -ta(j+N,i) = i /  2 sqrt(2)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  int i1, i2;
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  cplx i(0.0, 1.0);
 | 
					 | 
				
			||||||
  RealD nrm = 1 / (2 * std::sqrt(2));
 | 
					 | 
				
			||||||
  su2SubGroupIndex(i1, i2, dIndex);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta()()(i1, i2 + nsp) = i;
 | 
					 | 
				
			||||||
  ta()()(i2, i1 + nsp) = i;
 | 
					 | 
				
			||||||
  ta()()(i1 + nsp, i2) = -i;
 | 
					 | 
				
			||||||
  ta()()(i2 + nsp, i1) = -i;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta = ta * nrm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void generatorWtype(int wIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  // ta(i,i+N) =  ta(i+N,i) = 1/2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  RealD nrm = 1.0 / 2;  // check
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta()()(wIndex, wIndex + nsp) = 1;
 | 
					 | 
				
			||||||
  ta()()(wIndex + nsp, wIndex) = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta = ta * nrm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class cplx, ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void generatorZtype(int zIndex, iGroupMatrix<cplx> &ta) {
 | 
					 | 
				
			||||||
  // ta(i,i+N) = - ta(i+N,i) = i/2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  ta = Zero();
 | 
					 | 
				
			||||||
  RealD nrm = 1.0 / 2;  // check
 | 
					 | 
				
			||||||
  cplx i(0.0, 1.0);
 | 
					 | 
				
			||||||
  ta()()(zIndex, zIndex + nsp) = i;
 | 
					 | 
				
			||||||
  ta()()(zIndex + nsp, zIndex) = -i;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ta = ta * nrm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// Map a su2 subgroup number to the pair of rows that are non zero
 | 
					 | 
				
			||||||
////////////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
template <ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void su2SubGroupIndex(int &i1, int &i2, int su2_index, GroupName::Sp) {
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  assert((su2_index >= 0) && (su2_index < (nsp * (nsp - 1)) / 2));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int spare = su2_index;
 | 
					 | 
				
			||||||
  for (i1 = 0; spare >= (nsp - 1 - i1); i1++) {
 | 
					 | 
				
			||||||
    spare = spare - (nsp - 1 - i1);  // remove the Nc-1-i1 terms
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  i2 = i1 + 1 + spare;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void testGenerators(GroupName::Sp) {
 | 
					 | 
				
			||||||
  Matrix ta;
 | 
					 | 
				
			||||||
  Matrix tb;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage
 | 
					 | 
				
			||||||
            << "Fundamental - Checking trace ta tb is 0.5 delta_ab "
 | 
					 | 
				
			||||||
            << std::endl;
 | 
					 | 
				
			||||||
  for (int a = 0; a < AlgebraDimension; a++) {
 | 
					 | 
				
			||||||
    for (int b = 0; b < AlgebraDimension; b++) {
 | 
					 | 
				
			||||||
      generator(a, ta);
 | 
					 | 
				
			||||||
      generator(b, tb);
 | 
					 | 
				
			||||||
      Complex tr = TensorRemove(trace(ta * tb));
 | 
					 | 
				
			||||||
      std::cout << GridLogMessage << "(" << a << "," << b << ") =  " << tr
 | 
					 | 
				
			||||||
                << std::endl;
 | 
					 | 
				
			||||||
      if (a == b) assert(abs(tr - Complex(0.5)) < 1.0e-6);
 | 
					 | 
				
			||||||
      if (a != b) assert(abs(tr) < 1.0e-6);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << "Fundamental - Checking if hermitian"
 | 
					 | 
				
			||||||
            << std::endl;
 | 
					 | 
				
			||||||
  for (int a = 0; a < AlgebraDimension; a++) {
 | 
					 | 
				
			||||||
    generator(a, ta);
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << a << std::endl;
 | 
					 | 
				
			||||||
    assert(norm2(ta - adj(ta)) < 1.0e-6);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << "Fundamental - Checking if traceless"
 | 
					 | 
				
			||||||
            << std::endl;
 | 
					 | 
				
			||||||
  for (int a = 0; a < AlgebraDimension; a++) {
 | 
					 | 
				
			||||||
    generator(a, ta);
 | 
					 | 
				
			||||||
    Complex tr = TensorRemove(trace(ta));
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << a << std::endl;
 | 
					 | 
				
			||||||
    assert(abs(tr) < 1.0e-6);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <int N>
 | 
					 | 
				
			||||||
static Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > >
 | 
					 | 
				
			||||||
ProjectOnGeneralGroup(const Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu, GroupName::Sp) {
 | 
					 | 
				
			||||||
  return ProjectOnSpGroup(Umu);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class vtype>
 | 
					 | 
				
			||||||
accelerator_inline static iScalar<vtype> ProjectOnGeneralGroup(const iScalar<vtype> &r, GroupName::Sp) {
 | 
					 | 
				
			||||||
  return ProjectOnSpGroup(r);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class vtype, int N>
 | 
					 | 
				
			||||||
accelerator_inline static iVector<vtype,N> ProjectOnGeneralGroup(const iVector<vtype,N> &r, GroupName::Sp) {
 | 
					 | 
				
			||||||
  return ProjectOnSpGroup(r);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
 | 
					 | 
				
			||||||
accelerator_inline static iMatrix<vtype,N> ProjectOnGeneralGroup(const iMatrix<vtype,N> &arg, GroupName::Sp) {
 | 
					 | 
				
			||||||
  return ProjectOnSpGroup(arg);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <typename LatticeMatrixType>   
 | 
					 | 
				
			||||||
static void taProj(const LatticeMatrixType &in, LatticeMatrixType &out, GroupName::Sp) {
 | 
					 | 
				
			||||||
  out = SpTa(in);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <ONLY_IF_Sp>
 | 
					 | 
				
			||||||
static void Omega(LatticeColourMatrixD &in) {
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
  LatticeColourMatrixD OmegaLatt(in.Grid());
 | 
					 | 
				
			||||||
  LatticeColourMatrixD identity(in.Grid());
 | 
					 | 
				
			||||||
  ColourMatrix Omega;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  OmegaLatt = Zero();
 | 
					 | 
				
			||||||
  Omega = Zero();
 | 
					 | 
				
			||||||
  identity = 1.;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (int i = 0; i < nsp; i++) {
 | 
					 | 
				
			||||||
    Omega()()(i, nsp + i) = 1.;
 | 
					 | 
				
			||||||
    Omega()()(nsp + i, i) = -1;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  OmegaLatt = OmegaLatt + (identity * Omega);
 | 
					 | 
				
			||||||
  in = OmegaLatt;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template <ONLY_IF_Sp, class vtype, int N>
 | 
					 | 
				
			||||||
static void Omega(iScalar<iScalar<iMatrix<vtype, N> > > &in) {
 | 
					 | 
				
			||||||
  const int nsp=ncolour/2;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  iScalar<iScalar<iMatrix<vtype, N> > > Omega;
 | 
					 | 
				
			||||||
  Omega = Zero();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (int i = 0; i < nsp; i++) {
 | 
					 | 
				
			||||||
    Omega()()(i, nsp + i) = 1.;
 | 
					 | 
				
			||||||
    Omega()()(nsp + i, i) = -1;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  in = Omega;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -8,9 +8,9 @@
 | 
				
			|||||||
#include <Grid/qcd/utils/ScalarObjs.h>
 | 
					#include <Grid/qcd/utils/ScalarObjs.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Include representations
 | 
					// Include representations
 | 
				
			||||||
#include <Grid/qcd/utils/GaugeGroup.h>
 | 
					#include <Grid/qcd/utils/SUn.h>
 | 
				
			||||||
#include <Grid/qcd/utils/SUnAdjoint.h>
 | 
					#include <Grid/qcd/utils/SUnAdjoint.h>
 | 
				
			||||||
#include <Grid/qcd/utils/GaugeGroupTwoIndex.h>
 | 
					#include <Grid/qcd/utils/SUnTwoIndex.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// All-to-all contraction kernels that touch the 
 | 
					// All-to-all contraction kernels that touch the 
 | 
				
			||||||
// internal lattice structure
 | 
					// internal lattice structure
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -290,7 +290,7 @@ public:
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
  //////////////////////////////////////////////////
 | 
					  //////////////////////////////////////////////////
 | 
				
			||||||
  // the sum over all nu-oriented staples for nu != mu on each site
 | 
					  // the sum over all staples on each site
 | 
				
			||||||
  //////////////////////////////////////////////////
 | 
					  //////////////////////////////////////////////////
 | 
				
			||||||
  static void Staple(GaugeMat &staple, const GaugeLorentz &Umu, int mu) {
 | 
					  static void Staple(GaugeMat &staple, const GaugeLorentz &Umu, int mu) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -300,10 +300,6 @@ public:
 | 
				
			|||||||
    for (int d = 0; d < Nd; d++) {
 | 
					    for (int d = 0; d < Nd; d++) {
 | 
				
			||||||
      U[d] = PeekIndex<LorentzIndex>(Umu, d);
 | 
					      U[d] = PeekIndex<LorentzIndex>(Umu, d);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    Staple(staple, U, mu);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static void Staple(GaugeMat &staple, const std::vector<GaugeMat> &U, int mu) {
 | 
					 | 
				
			||||||
    staple = Zero();
 | 
					    staple = Zero();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int nu = 0; nu < Nd; nu++) {
 | 
					    for (int nu = 0; nu < Nd; nu++) {
 | 
				
			||||||
@@ -339,203 +335,6 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /////////////
 | 
					 | 
				
			||||||
  //Staples for each direction mu, summed over nu != mu
 | 
					 | 
				
			||||||
  //staple: output staples for each mu (Nd)
 | 
					 | 
				
			||||||
  //U: link array (Nd)
 | 
					 | 
				
			||||||
  /////////////
 | 
					 | 
				
			||||||
  static void StapleAll(std::vector<GaugeMat> &staple, const std::vector<GaugeMat> &U) {
 | 
					 | 
				
			||||||
    assert(staple.size() == Nd); assert(U.size() == Nd);
 | 
					 | 
				
			||||||
    for(int mu=0;mu<Nd;mu++) Staple(staple[mu], U, mu);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //A workspace class allowing reuse of the stencil
 | 
					 | 
				
			||||||
  class WilsonLoopPaddedStencilWorkspace{
 | 
					 | 
				
			||||||
    std::unique_ptr<GeneralLocalStencil> stencil;
 | 
					 | 
				
			||||||
    size_t nshift;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void generateStencil(GridBase* padded_grid){
 | 
					 | 
				
			||||||
      double t0 = usecond();
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      //Generate shift arrays
 | 
					 | 
				
			||||||
      std::vector<Coordinate> shifts = this->getShifts();
 | 
					 | 
				
			||||||
      nshift = shifts.size();
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      double t1 = usecond();
 | 
					 | 
				
			||||||
      //Generate local stencil
 | 
					 | 
				
			||||||
      stencil.reset(new GeneralLocalStencil(padded_grid,shifts));
 | 
					 | 
				
			||||||
      double t2 = usecond();
 | 
					 | 
				
			||||||
      std::cout << GridLogPerformance << " WilsonLoopPaddedWorkspace timings: coord:" << (t1-t0)/1000 << "ms, stencil:" << (t2-t1)/1000 << "ms" << std::endl;   
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  public:
 | 
					 | 
				
			||||||
    //Get the stencil. If not already generated, or if generated using a different Grid than in PaddedCell, it will be created on-the-fly
 | 
					 | 
				
			||||||
    const GeneralLocalStencil & getStencil(const PaddedCell &pcell){
 | 
					 | 
				
			||||||
      assert(pcell.depth >= this->paddingDepth());
 | 
					 | 
				
			||||||
      if(!stencil || stencil->Grid() != (GridBase*)pcell.grids.back() ) generateStencil((GridBase*)pcell.grids.back());
 | 
					 | 
				
			||||||
      return *stencil;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    size_t Nshift() const{ return nshift; }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    virtual std::vector<Coordinate> getShifts() const = 0;
 | 
					 | 
				
			||||||
    virtual int paddingDepth() const = 0; //padding depth required
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    virtual ~WilsonLoopPaddedStencilWorkspace(){}
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //This workspace allows the sharing of a common PaddedCell object between multiple stencil workspaces
 | 
					 | 
				
			||||||
  class WilsonLoopPaddedWorkspace{
 | 
					 | 
				
			||||||
    std::vector<WilsonLoopPaddedStencilWorkspace*> stencil_wk;
 | 
					 | 
				
			||||||
    std::unique_ptr<PaddedCell> pcell;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void generatePcell(GridBase* unpadded_grid){
 | 
					 | 
				
			||||||
      assert(stencil_wk.size());
 | 
					 | 
				
			||||||
      int max_depth = 0;
 | 
					 | 
				
			||||||
      for(auto const &s : stencil_wk) max_depth=std::max(max_depth, s->paddingDepth());
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      pcell.reset(new PaddedCell(max_depth, dynamic_cast<GridCartesian*>(unpadded_grid)));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  public:
 | 
					 | 
				
			||||||
    //Add a stencil definition. This should be done before the first call to retrieve a stencil object.
 | 
					 | 
				
			||||||
    //Takes ownership of the pointer
 | 
					 | 
				
			||||||
    void addStencil(WilsonLoopPaddedStencilWorkspace *stencil){
 | 
					 | 
				
			||||||
      assert(!pcell);
 | 
					 | 
				
			||||||
      stencil_wk.push_back(stencil);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const GeneralLocalStencil & getStencil(const size_t stencil_idx, GridBase* unpadded_grid){
 | 
					 | 
				
			||||||
      if(!pcell || pcell->unpadded_grid != unpadded_grid) generatePcell(unpadded_grid);
 | 
					 | 
				
			||||||
      return stencil_wk[stencil_idx]->getStencil(*pcell);
 | 
					 | 
				
			||||||
    }      
 | 
					 | 
				
			||||||
    const PaddedCell & getPaddedCell(GridBase* unpadded_grid){
 | 
					 | 
				
			||||||
      if(!pcell || pcell->unpadded_grid != unpadded_grid) generatePcell(unpadded_grid);
 | 
					 | 
				
			||||||
      return *pcell;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    ~WilsonLoopPaddedWorkspace(){
 | 
					 | 
				
			||||||
      for(auto &s : stencil_wk) delete s;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //A workspace class allowing reuse of the stencil
 | 
					 | 
				
			||||||
  class StaplePaddedAllWorkspace: public WilsonLoopPaddedStencilWorkspace{
 | 
					 | 
				
			||||||
  public:
 | 
					 | 
				
			||||||
    std::vector<Coordinate> getShifts() const override{
 | 
					 | 
				
			||||||
      std::vector<Coordinate> shifts;
 | 
					 | 
				
			||||||
      for(int mu=0;mu<Nd;mu++){
 | 
					 | 
				
			||||||
	for(int nu=0;nu<Nd;nu++){
 | 
					 | 
				
			||||||
	  if(nu != mu){
 | 
					 | 
				
			||||||
	    Coordinate shift_0(Nd,0);
 | 
					 | 
				
			||||||
	    Coordinate shift_mu(Nd,0); shift_mu[mu]=1;
 | 
					 | 
				
			||||||
	    Coordinate shift_nu(Nd,0); shift_nu[nu]=1;
 | 
					 | 
				
			||||||
	    Coordinate shift_mnu(Nd,0); shift_mnu[nu]=-1;
 | 
					 | 
				
			||||||
	    Coordinate shift_mnu_pmu(Nd,0); shift_mnu_pmu[nu]=-1; shift_mnu_pmu[mu]=1;
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
	    //U_nu(x+mu)U^dag_mu(x+nu) U^dag_nu(x)
 | 
					 | 
				
			||||||
	    shifts.push_back(shift_0);
 | 
					 | 
				
			||||||
	    shifts.push_back(shift_nu);
 | 
					 | 
				
			||||||
	    shifts.push_back(shift_mu);
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
	    //U_nu^dag(x-nu+mu) U_mu^dag(x-nu) U_nu(x-nu)
 | 
					 | 
				
			||||||
	    shifts.push_back(shift_mnu);
 | 
					 | 
				
			||||||
	    shifts.push_back(shift_mnu);
 | 
					 | 
				
			||||||
	    shifts.push_back(shift_mnu_pmu);
 | 
					 | 
				
			||||||
	  }
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      return shifts;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int paddingDepth() const override{ return 1; }
 | 
					 | 
				
			||||||
  }; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //Padded cell implementation of the staple method for all mu, summed over nu != mu
 | 
					 | 
				
			||||||
  //staple: output staple for each mu, summed over nu != mu (Nd)
 | 
					 | 
				
			||||||
  //U_padded: the gauge link fields padded out using the PaddedCell class
 | 
					 | 
				
			||||||
  //Cell: the padded cell class
 | 
					 | 
				
			||||||
  static void StaplePaddedAll(std::vector<GaugeMat> &staple, const std::vector<GaugeMat> &U_padded, const PaddedCell &Cell) {
 | 
					 | 
				
			||||||
    StaplePaddedAllWorkspace wk;
 | 
					 | 
				
			||||||
    StaplePaddedAll(staple,U_padded,Cell,wk.getStencil(Cell));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  //Padded cell implementation of the staple method for all mu, summed over nu != mu
 | 
					 | 
				
			||||||
  //staple: output staple for each mu, summed over nu != mu (Nd)
 | 
					 | 
				
			||||||
  //U_padded: the gauge link fields padded out using the PaddedCell class
 | 
					 | 
				
			||||||
  //Cell: the padded cell class
 | 
					 | 
				
			||||||
  //gStencil: the precomputed generalized local stencil for the staple
 | 
					 | 
				
			||||||
  static void StaplePaddedAll(std::vector<GaugeMat> &staple, const std::vector<GaugeMat> &U_padded, const PaddedCell &Cell, const GeneralLocalStencil &gStencil)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    double t0 = usecond();
 | 
					 | 
				
			||||||
    assert(U_padded.size() == Nd); assert(staple.size() == Nd);
 | 
					 | 
				
			||||||
    assert(U_padded[0].Grid() == (GridBase*)Cell.grids.back());
 | 
					 | 
				
			||||||
    assert(Cell.depth >= 1);
 | 
					 | 
				
			||||||
    GridBase *ggrid = U_padded[0].Grid(); //padded cell grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int shift_mu_off = gStencil._npoints/Nd;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    //Open views to padded gauge links and keep open over mu loop
 | 
					 | 
				
			||||||
    typedef LatticeView<typename GaugeMat::vector_object> GaugeViewType;
 | 
					 | 
				
			||||||
    size_t vsize = Nd*sizeof(GaugeViewType);
 | 
					 | 
				
			||||||
    GaugeViewType* Ug_dirs_v_host = (GaugeViewType*)malloc(vsize);
 | 
					 | 
				
			||||||
    for(int i=0;i<Nd;i++) Ug_dirs_v_host[i] = U_padded[i].View(AcceleratorRead);
 | 
					 | 
				
			||||||
    GaugeViewType* Ug_dirs_v = (GaugeViewType*)acceleratorAllocDevice(vsize);
 | 
					 | 
				
			||||||
    acceleratorCopyToDevice(Ug_dirs_v_host,Ug_dirs_v,vsize);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    GaugeMat gStaple(ggrid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int outer_off = 0;
 | 
					 | 
				
			||||||
    for(int mu=0;mu<Nd;mu++){
 | 
					 | 
				
			||||||
      { //view scope
 | 
					 | 
				
			||||||
	autoView( gStaple_v , gStaple, AcceleratorWrite);
 | 
					 | 
				
			||||||
	auto gStencil_v = gStencil.View();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	accelerator_for(ss, ggrid->oSites(), (size_t)ggrid->Nsimd(), {
 | 
					 | 
				
			||||||
	    decltype(coalescedRead(Ug_dirs_v[0][0])) stencil_ss;
 | 
					 | 
				
			||||||
	    stencil_ss = Zero();
 | 
					 | 
				
			||||||
	    int off = outer_off;
 | 
					 | 
				
			||||||
	    
 | 
					 | 
				
			||||||
	    for(int nu=0;nu<Nd;nu++){
 | 
					 | 
				
			||||||
	      if(nu != mu){	  
 | 
					 | 
				
			||||||
		GeneralStencilEntry const* e = gStencil_v.GetEntry(off++,ss);
 | 
					 | 
				
			||||||
		auto U0 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(off++,ss);
 | 
					 | 
				
			||||||
		auto U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(off++,ss);
 | 
					 | 
				
			||||||
		auto U2 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
		stencil_ss = stencil_ss + U2 * U1 * U0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(off++,ss);
 | 
					 | 
				
			||||||
		U0 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(off++,ss);
 | 
					 | 
				
			||||||
		U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(off++,ss);
 | 
					 | 
				
			||||||
		U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		stencil_ss = stencil_ss + U2 * U1 * U0;
 | 
					 | 
				
			||||||
	      }
 | 
					 | 
				
			||||||
	    }
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	    coalescedWrite(gStaple_v[ss],stencil_ss);
 | 
					 | 
				
			||||||
	  }
 | 
					 | 
				
			||||||
	  );
 | 
					 | 
				
			||||||
      } //ensure views are all closed!
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      staple[mu] = Cell.Extract(gStaple);
 | 
					 | 
				
			||||||
      outer_off += shift_mu_off;
 | 
					 | 
				
			||||||
    }//mu loop
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for(int i=0;i<Nd;i++) Ug_dirs_v_host[i].ViewClose();
 | 
					 | 
				
			||||||
    free(Ug_dirs_v_host);
 | 
					 | 
				
			||||||
    acceleratorFreeDevice(Ug_dirs_v);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    double t1=usecond();
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    std::cout << GridLogPerformance << "StaplePaddedAll timing:" << (t1-t0)/1000 << "ms" << std::endl;   
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////
 | 
					  //////////////////////////////////////////////////
 | 
				
			||||||
  // the sum over all staples on each site in direction mu,nu, upper part
 | 
					  // the sum over all staples on each site in direction mu,nu, upper part
 | 
				
			||||||
  //////////////////////////////////////////////////
 | 
					  //////////////////////////////////////////////////
 | 
				
			||||||
@@ -908,14 +707,18 @@ public:
 | 
				
			|||||||
  // the sum over all staples on each site
 | 
					  // the sum over all staples on each site
 | 
				
			||||||
  //////////////////////////////////////////////////
 | 
					  //////////////////////////////////////////////////
 | 
				
			||||||
  static void RectStapleDouble(GaugeMat &U2, const GaugeMat &U, int mu) {
 | 
					  static void RectStapleDouble(GaugeMat &U2, const GaugeMat &U, int mu) {
 | 
				
			||||||
    U2 = U * Gimpl::CshiftLink(U, mu, 1);
 | 
					    U2 = U * Cshift(U, mu, 1);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ////////////////////////////////////////////////////////////////////////////
 | 
					  ////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
  // Hop by two optimisation strategy. Use RectStapleDouble to obtain 'U2'
 | 
					  // Hop by two optimisation strategy does not work nicely with Gparity. (could
 | 
				
			||||||
 | 
					  // do,
 | 
				
			||||||
 | 
					  // but need to track two deep where cross boundary and apply a conjugation).
 | 
				
			||||||
 | 
					  // Must differentiate this in Gimpl, and use Gimpl::isPeriodicGaugeField to do
 | 
				
			||||||
 | 
					  // so .
 | 
				
			||||||
  ////////////////////////////////////////////////////////////////////////////
 | 
					  ////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
  static void RectStapleOptimised(GaugeMat &Stap, const std::vector<GaugeMat> &U2,
 | 
					  static void RectStapleOptimised(GaugeMat &Stap, std::vector<GaugeMat> &U2,
 | 
				
			||||||
                                  const std::vector<GaugeMat> &U, int mu) {
 | 
					                                  std::vector<GaugeMat> &U, int mu) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Stap = Zero();
 | 
					    Stap = Zero();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -929,9 +732,9 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Up staple    ___ ___
 | 
					        // Up staple    ___ ___
 | 
				
			||||||
        //             |       |
 | 
					        //             |       |
 | 
				
			||||||
        tmp = Gimpl::CshiftLink(adj(U[nu]), nu, -1);
 | 
					        tmp = Cshift(adj(U[nu]), nu, -1);
 | 
				
			||||||
        tmp = adj(U2[mu]) * tmp;
 | 
					        tmp = adj(U2[mu]) * tmp;
 | 
				
			||||||
        tmp = Gimpl::CshiftLink(tmp, mu, -2);
 | 
					        tmp = Cshift(tmp, mu, -2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Staple2x1 = Gimpl::CovShiftForward(U[nu], nu, tmp);
 | 
					        Staple2x1 = Gimpl::CovShiftForward(U[nu], nu, tmp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -939,14 +742,14 @@ public:
 | 
				
			|||||||
        //             |___ ___|
 | 
					        //             |___ ___|
 | 
				
			||||||
        //
 | 
					        //
 | 
				
			||||||
        tmp = adj(U2[mu]) * U[nu];
 | 
					        tmp = adj(U2[mu]) * U[nu];
 | 
				
			||||||
        Staple2x1 += Gimpl::CovShiftBackward(U[nu], nu, Gimpl::CshiftLink(tmp, mu, -2));
 | 
					        Staple2x1 += Gimpl::CovShiftBackward(U[nu], nu, Cshift(tmp, mu, -2));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //              ___ ___
 | 
					        //              ___ ___
 | 
				
			||||||
        //             |    ___|
 | 
					        //             |    ___|
 | 
				
			||||||
        //             |___ ___|
 | 
					        //             |___ ___|
 | 
				
			||||||
        //
 | 
					        //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Stap += Gimpl::CshiftLink(Gimpl::CovShiftForward(U[mu], mu, Staple2x1), mu, 1);
 | 
					        Stap += Cshift(Gimpl::CovShiftForward(U[mu], mu, Staple2x1), mu, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //              ___ ___
 | 
					        //              ___ ___
 | 
				
			||||||
        //             |___    |
 | 
					        //             |___    |
 | 
				
			||||||
@@ -955,7 +758,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        //  tmp= Staple2x1* Cshift(U[mu],mu,-2);
 | 
					        //  tmp= Staple2x1* Cshift(U[mu],mu,-2);
 | 
				
			||||||
        //  Stap+= Cshift(tmp,mu,1) ;
 | 
					        //  Stap+= Cshift(tmp,mu,1) ;
 | 
				
			||||||
        Stap += Gimpl::CshiftLink(Staple2x1, mu, 1) * Gimpl::CshiftLink(U[mu], mu, -1);
 | 
					        Stap += Cshift(Staple2x1, mu, 1) * Cshift(U[mu], mu, -1);
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //       --
 | 
					        //       --
 | 
				
			||||||
@@ -963,10 +766,10 @@ public:
 | 
				
			|||||||
        //
 | 
					        //
 | 
				
			||||||
        //      |  |
 | 
					        //      |  |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tmp = Gimpl::CshiftLink(adj(U2[nu]), nu, -2);
 | 
					        tmp = Cshift(adj(U2[nu]), nu, -2);
 | 
				
			||||||
        tmp = Gimpl::CovShiftBackward(U[mu], mu, tmp);
 | 
					        tmp = Gimpl::CovShiftBackward(U[mu], mu, tmp);
 | 
				
			||||||
        tmp = U2[nu] * Gimpl::CshiftLink(tmp, nu, 2);
 | 
					        tmp = U2[nu] * Cshift(tmp, nu, 2);
 | 
				
			||||||
        Stap += Gimpl::CshiftLink(tmp, mu, 1);
 | 
					        Stap += Cshift(tmp, mu, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //      |  |
 | 
					        //      |  |
 | 
				
			||||||
        //
 | 
					        //
 | 
				
			||||||
@@ -975,12 +778,25 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        tmp = Gimpl::CovShiftBackward(U[mu], mu, U2[nu]);
 | 
					        tmp = Gimpl::CovShiftBackward(U[mu], mu, U2[nu]);
 | 
				
			||||||
        tmp = adj(U2[nu]) * tmp;
 | 
					        tmp = adj(U2[nu]) * tmp;
 | 
				
			||||||
        tmp = Gimpl::CshiftLink(tmp, nu, -2);
 | 
					        tmp = Cshift(tmp, nu, -2);
 | 
				
			||||||
        Stap += Gimpl::CshiftLink(tmp, mu, 1);
 | 
					        Stap += Cshift(tmp, mu, 1);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void RectStaple(GaugeMat &Stap, const GaugeLorentz &Umu, int mu) {
 | 
				
			||||||
 | 
					    RectStapleUnoptimised(Stap, Umu, mu);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  static void RectStaple(const GaugeLorentz &Umu, GaugeMat &Stap,
 | 
				
			||||||
 | 
					                         std::vector<GaugeMat> &U2, std::vector<GaugeMat> &U,
 | 
				
			||||||
 | 
					                         int mu) {
 | 
				
			||||||
 | 
					    if (Gimpl::isPeriodicGaugeField()) {
 | 
				
			||||||
 | 
					      RectStapleOptimised(Stap, U2, U, mu);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      RectStapleUnoptimised(Stap, Umu, mu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static void RectStapleUnoptimised(GaugeMat &Stap, const GaugeLorentz &Umu,
 | 
					  static void RectStapleUnoptimised(GaugeMat &Stap, const GaugeLorentz &Umu,
 | 
				
			||||||
                                    int mu) {
 | 
					                                    int mu) {
 | 
				
			||||||
    GridBase *grid = Umu.Grid();
 | 
					    GridBase *grid = Umu.Grid();
 | 
				
			||||||
@@ -1079,288 +895,6 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static void RectStaple(GaugeMat &Stap, const GaugeLorentz &Umu, int mu) {
 | 
					 | 
				
			||||||
    RectStapleUnoptimised(Stap, Umu, mu);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  static void RectStaple(const GaugeLorentz &Umu, GaugeMat &Stap,
 | 
					 | 
				
			||||||
                         std::vector<GaugeMat> &U2, std::vector<GaugeMat> &U,
 | 
					 | 
				
			||||||
                         int mu) {
 | 
					 | 
				
			||||||
    RectStapleOptimised(Stap, U2, U, mu);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  //Compute the rectangular staples for all orientations
 | 
					 | 
				
			||||||
  //Stap : Array of staples (Nd)
 | 
					 | 
				
			||||||
  //U: Gauge links in each direction (Nd)
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  static void RectStapleAll(std::vector<GaugeMat> &Stap, const std::vector<GaugeMat> &U){
 | 
					 | 
				
			||||||
    assert(Stap.size() == Nd); assert(U.size() == Nd);
 | 
					 | 
				
			||||||
    std::vector<GaugeMat> U2(Nd,U[0].Grid());
 | 
					 | 
				
			||||||
    for(int mu=0;mu<Nd;mu++) RectStapleDouble(U2[mu], U[mu], mu);
 | 
					 | 
				
			||||||
    for(int mu=0;mu<Nd;mu++) RectStapleOptimised(Stap[mu], U2, U, mu);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //A workspace class allowing reuse of the stencil
 | 
					 | 
				
			||||||
  class RectStaplePaddedAllWorkspace: public WilsonLoopPaddedStencilWorkspace{
 | 
					 | 
				
			||||||
  public:
 | 
					 | 
				
			||||||
    std::vector<Coordinate> getShifts() const override{
 | 
					 | 
				
			||||||
      std::vector<Coordinate> shifts;
 | 
					 | 
				
			||||||
      for (int mu = 0; mu < Nd; mu++){
 | 
					 | 
				
			||||||
	for (int nu = 0; nu < Nd; nu++) {
 | 
					 | 
				
			||||||
	  if (nu != mu) {
 | 
					 | 
				
			||||||
	    auto genShift = [&](int mushift,int nushift){
 | 
					 | 
				
			||||||
	      Coordinate out(Nd,0); out[mu]=mushift; out[nu]=nushift; return out;
 | 
					 | 
				
			||||||
	    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	    //tmp6 = tmp5(x+mu) = U_mu(x+mu)U_nu(x+2mu)U_mu^dag(x+nu+mu) U_mu^dag(x+nu) U_nu^dag(x)
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,0));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,+1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,+1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+2,0));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	    //tmp5 = tmp4(x+mu) = U_mu(x+mu)U^dag_nu(x-nu+2mu)U^dag_mu(x-nu+mu)U^dag_mu(x-nu)U_nu(x-nu)
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,-1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,-1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,-1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+2,-1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	    //tmp5 = tmp4(x+mu) = U^dag_nu(x-nu+mu)U^dag_mu(x-nu)U^dag_mu(x-mu-nu)U_nu(x-mu-nu)U_mu(x-mu)
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(-1,0));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(-1,-1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(-1,-1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,-1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,-1));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	    //tmp5 = tmp4(x+mu) = U_nu(x+mu)U_mu^dag(x+nu)U_mu^dag(x-mu+nu)U_nu^dag(x-mu)U_mu(x-mu)
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(-1,0));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(-1,0));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(-1,+1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,+1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	    //tmp6 = tmp5(x+mu) = U_nu(x+mu)U_nu(x+mu+nu)U_mu^dag(x+2nu)U_nu^dag(x+nu)U_nu^dag(x)
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,0));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,+1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,+2));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,+1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,0));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	    //tmp5 = tmp4(x+mu) = U_nu^dag(x+mu-nu)U_nu^dag(x+mu-2nu)U_mu^dag(x-2nu)U_nu(x-2nu)U_nu(x-nu)
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,-1));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,-2));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(0,-2));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,-2));
 | 
					 | 
				
			||||||
	    shifts.push_back(genShift(+1,-1));
 | 
					 | 
				
			||||||
	  }
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      return shifts;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int paddingDepth() const override{ return 2; }
 | 
					 | 
				
			||||||
  }; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //Padded cell implementation of the rectangular staple method for all mu, summed over nu != mu
 | 
					 | 
				
			||||||
  //staple: output staple for each mu, summed over nu != mu (Nd)
 | 
					 | 
				
			||||||
  //U_padded: the gauge link fields padded out using the PaddedCell class
 | 
					 | 
				
			||||||
  //Cell: the padded cell class
 | 
					 | 
				
			||||||
  static void RectStaplePaddedAll(std::vector<GaugeMat> &staple, const std::vector<GaugeMat> &U_padded, const PaddedCell &Cell) {
 | 
					 | 
				
			||||||
    RectStaplePaddedAllWorkspace wk;
 | 
					 | 
				
			||||||
    RectStaplePaddedAll(staple,U_padded,Cell,wk.getStencil(Cell));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  //Padded cell implementation of the rectangular staple method for all mu, summed over nu != mu
 | 
					 | 
				
			||||||
  //staple: output staple for each mu, summed over nu != mu (Nd)
 | 
					 | 
				
			||||||
  //U_padded: the gauge link fields padded out using the PaddedCell class
 | 
					 | 
				
			||||||
  //Cell: the padded cell class
 | 
					 | 
				
			||||||
  //gStencil: the stencil
 | 
					 | 
				
			||||||
  static void RectStaplePaddedAll(std::vector<GaugeMat> &staple, const std::vector<GaugeMat> &U_padded, const PaddedCell &Cell, const GeneralLocalStencil &gStencil) {
 | 
					 | 
				
			||||||
    double t0 = usecond();
 | 
					 | 
				
			||||||
    assert(U_padded.size() == Nd); assert(staple.size() == Nd);
 | 
					 | 
				
			||||||
    assert(U_padded[0].Grid() == (GridBase*)Cell.grids.back());
 | 
					 | 
				
			||||||
    assert(Cell.depth >= 2);
 | 
					 | 
				
			||||||
    GridBase *ggrid = U_padded[0].Grid(); //padded cell grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    size_t nshift = gStencil._npoints;
 | 
					 | 
				
			||||||
    int mu_off_delta = nshift / Nd;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    //Open views to padded gauge links and keep open over mu loop
 | 
					 | 
				
			||||||
    typedef LatticeView<typename GaugeMat::vector_object> GaugeViewType;
 | 
					 | 
				
			||||||
    size_t vsize = Nd*sizeof(GaugeViewType);
 | 
					 | 
				
			||||||
    GaugeViewType* Ug_dirs_v_host = (GaugeViewType*)malloc(vsize);
 | 
					 | 
				
			||||||
    for(int i=0;i<Nd;i++) Ug_dirs_v_host[i] = U_padded[i].View(AcceleratorRead);
 | 
					 | 
				
			||||||
    GaugeViewType* Ug_dirs_v = (GaugeViewType*)acceleratorAllocDevice(vsize);
 | 
					 | 
				
			||||||
    acceleratorCopyToDevice(Ug_dirs_v_host,Ug_dirs_v,vsize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    GaugeMat gStaple(ggrid); //temp staple object on padded grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    int offset = 0;
 | 
					 | 
				
			||||||
    for(int mu=0; mu<Nd; mu++){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      { //view scope
 | 
					 | 
				
			||||||
	autoView( gStaple_v , gStaple, AcceleratorWrite);
 | 
					 | 
				
			||||||
	auto gStencil_v = gStencil.View();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	accelerator_for(ss, ggrid->oSites(), (size_t)ggrid->Nsimd(), {
 | 
					 | 
				
			||||||
	    decltype(coalescedRead(Ug_dirs_v[0][0])) stencil_ss;
 | 
					 | 
				
			||||||
	    stencil_ss = Zero();
 | 
					 | 
				
			||||||
	    int s=offset;
 | 
					 | 
				
			||||||
	    for(int nu=0;nu<Nd;nu++){
 | 
					 | 
				
			||||||
	      if(nu != mu){
 | 
					 | 
				
			||||||
		//tmp6 = tmp5(x+mu) = U_mu(x+mu)U_nu(x+2mu)U_mu^dag(x+nu+mu) U_mu^dag(x+nu) U_nu^dag(x)
 | 
					 | 
				
			||||||
		GeneralStencilEntry const* e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		auto U0 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		auto U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		auto U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		auto U3 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		auto U4 = coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
	    
 | 
					 | 
				
			||||||
		stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//tmp5 = tmp4(x+mu) = U_mu(x+mu)U^dag_nu(x-nu+2mu)U^dag_mu(x-nu+mu)U^dag_mu(x-nu)U_nu(x-nu)
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U0 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U3 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U4 = coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//tmp5 = tmp4(x+mu) = U^dag_nu(x-nu+mu)U^dag_mu(x-nu)U^dag_mu(x-mu-nu)U_nu(x-mu-nu)U_mu(x-mu)
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U0 = coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U1 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U3 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U4 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//tmp5 = tmp4(x+mu) = U_nu(x+mu)U_mu^dag(x+nu)U_mu^dag(x-mu+nu)U_nu^dag(x-mu)U_mu(x-mu)
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U0 = coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U3 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U4 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		stencil_ss = stencil_ss + U4*U3*U2*U1*U0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//tmp6 = tmp5(x+mu) = U_nu(x+mu)U_nu(x+mu+nu)U_mu^dag(x+2nu)U_nu^dag(x+nu)U_nu^dag(x)
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U0 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U1 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U3 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U4 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		stencil_ss = stencil_ss + U4*U3*U2*U1*U0;   
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//tmp5 = tmp4(x+mu) = U_nu^dag(x+mu-nu)U_nu^dag(x+mu-2nu)U_mu^dag(x-2nu)U_nu(x-2nu)U_nu(x-nu)
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U0 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U1 = coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd);
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U2 = adj(coalescedReadGeneralPermute(Ug_dirs_v[mu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U3 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
		e = gStencil_v.GetEntry(s++,ss);
 | 
					 | 
				
			||||||
		U4 = adj(coalescedReadGeneralPermute(Ug_dirs_v[nu][e->_offset], e->_permute, Nd));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		stencil_ss = stencil_ss + U4*U3*U2*U1*U0;   
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	      }
 | 
					 | 
				
			||||||
	    }
 | 
					 | 
				
			||||||
	    coalescedWrite(gStaple_v[ss],stencil_ss);
 | 
					 | 
				
			||||||
	  }
 | 
					 | 
				
			||||||
	  );
 | 
					 | 
				
			||||||
	offset += mu_off_delta;
 | 
					 | 
				
			||||||
      }//kernel/view scope
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      staple[mu] = Cell.Extract(gStaple);    
 | 
					 | 
				
			||||||
    }//mu loop
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
    for(int i=0;i<Nd;i++) Ug_dirs_v_host[i].ViewClose();
 | 
					 | 
				
			||||||
    free(Ug_dirs_v_host);
 | 
					 | 
				
			||||||
    acceleratorFreeDevice(Ug_dirs_v);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    double t1 = usecond();
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    std::cout << GridLogPerformance << "RectStaplePaddedAll timings:" << (t1-t0)/1000 << "ms" << std::endl;   
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //A workspace for reusing the PaddedCell and GeneralLocalStencil objects
 | 
					 | 
				
			||||||
  class StapleAndRectStapleAllWorkspace: public WilsonLoopPaddedWorkspace{
 | 
					 | 
				
			||||||
  public:
 | 
					 | 
				
			||||||
    StapleAndRectStapleAllWorkspace(){
 | 
					 | 
				
			||||||
      this->addStencil(new StaplePaddedAllWorkspace);
 | 
					 | 
				
			||||||
      this->addStencil(new RectStaplePaddedAllWorkspace);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  };     
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  //Compute the 1x1 and 1x2 staples for all orientations
 | 
					 | 
				
			||||||
  //Stap : Array of staples (Nd)
 | 
					 | 
				
			||||||
  //RectStap: Array of rectangular staples (Nd)
 | 
					 | 
				
			||||||
  //U: Gauge links in each direction (Nd)
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  static void StapleAndRectStapleAll(std::vector<GaugeMat> &Stap, std::vector<GaugeMat> &RectStap, const std::vector<GaugeMat> &U){
 | 
					 | 
				
			||||||
    StapleAndRectStapleAllWorkspace wk;
 | 
					 | 
				
			||||||
    StapleAndRectStapleAll(Stap,RectStap,U,wk);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  //Compute the 1x1 and 1x2 staples for all orientations
 | 
					 | 
				
			||||||
  //Stap : Array of staples (Nd)
 | 
					 | 
				
			||||||
  //RectStap: Array of rectangular staples (Nd)
 | 
					 | 
				
			||||||
  //U: Gauge links in each direction (Nd)
 | 
					 | 
				
			||||||
  //wk: a workspace containing stored PaddedCell and GeneralLocalStencil objects to maximize reuse
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  static void StapleAndRectStapleAll(std::vector<GaugeMat> &Stap, std::vector<GaugeMat> &RectStap, const std::vector<GaugeMat> &U, StapleAndRectStapleAllWorkspace &wk){
 | 
					 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
    StapleAll(Stap, U);
 | 
					 | 
				
			||||||
    RectStapleAll(RectStap, U);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    double t0 = usecond();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    GridCartesian* unpadded_grid = dynamic_cast<GridCartesian*>(U[0].Grid());
 | 
					 | 
				
			||||||
    const PaddedCell &Ghost = wk.getPaddedCell(unpadded_grid);
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    CshiftImplGauge<Gimpl> cshift_impl;
 | 
					 | 
				
			||||||
    std::vector<GaugeMat> U_pad(Nd, Ghost.grids.back());
 | 
					 | 
				
			||||||
    for(int mu=0;mu<Nd;mu++) U_pad[mu] = Ghost.Exchange(U[mu], cshift_impl);
 | 
					 | 
				
			||||||
    double t1 = usecond();
 | 
					 | 
				
			||||||
    StaplePaddedAll(Stap, U_pad, Ghost, wk.getStencil(0,unpadded_grid) );
 | 
					 | 
				
			||||||
    double t2 = usecond();
 | 
					 | 
				
			||||||
    RectStaplePaddedAll(RectStap, U_pad, Ghost, wk.getStencil(1,unpadded_grid));
 | 
					 | 
				
			||||||
    double t3 = usecond();
 | 
					 | 
				
			||||||
    std::cout << GridLogPerformance << "StapleAndRectStapleAll timings: pad:" << (t1-t0)/1000 << "ms, staple:" << (t2-t1)/1000 << "ms, rect-staple:" << (t3-t2)/1000 << "ms" << std::endl;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////////
 | 
					  //////////////////////////////////////////////////
 | 
				
			||||||
  // Wilson loop of size (R1, R2), oriented in mu,nu plane
 | 
					  // Wilson loop of size (R1, R2), oriented in mu,nu plane
 | 
				
			||||||
  //////////////////////////////////////////////////
 | 
					  //////////////////////////////////////////////////
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -218,10 +218,6 @@ public:
 | 
				
			|||||||
    // -------------------------------------------------
 | 
					    // -------------------------------------------------
 | 
				
			||||||
    // misc
 | 
					    // misc
 | 
				
			||||||
    // -------------------------------------------------
 | 
					    // -------------------------------------------------
 | 
				
			||||||
    void discardhi(uint64_t z) {
 | 
					 | 
				
			||||||
      _s[3] += z;
 | 
					 | 
				
			||||||
      encrypt_counter();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 9
 | 
					    // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 9
 | 
				
			||||||
    // Advances e’s state ei to ei+z by any means equivalent to z
 | 
					    // Advances e’s state ei to ei+z by any means equivalent to z
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,7 +43,7 @@ class GeneralLocalStencilView {
 | 
				
			|||||||
  int                               _npoints; // Move to template param?
 | 
					  int                               _npoints; // Move to template param?
 | 
				
			||||||
  GeneralStencilEntry*  _entries_p;
 | 
					  GeneralStencilEntry*  _entries_p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  accelerator_inline GeneralStencilEntry * GetEntry(int point,int osite) const { 
 | 
					  accelerator_inline GeneralStencilEntry * GetEntry(int point,int osite) { 
 | 
				
			||||||
    return & this->_entries_p[point+this->_npoints*osite]; 
 | 
					    return & this->_entries_p[point+this->_npoints*osite]; 
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -79,10 +79,10 @@ public:
 | 
				
			|||||||
    this->_entries.resize(npoints* osites);
 | 
					    this->_entries.resize(npoints* osites);
 | 
				
			||||||
    this->_entries_p = &_entries[0];
 | 
					    this->_entries_p = &_entries[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    thread_for(site, osites, {
 | 
					
 | 
				
			||||||
    Coordinate Coor;
 | 
					    Coordinate Coor;
 | 
				
			||||||
    Coordinate NbrCoor;
 | 
					    Coordinate NbrCoor;
 | 
				
			||||||
 | 
					    for(Integer site=0;site<osites;site++){
 | 
				
			||||||
      for(Integer ii=0;ii<npoints;ii++){
 | 
					      for(Integer ii=0;ii<npoints;ii++){
 | 
				
			||||||
	Integer lex = site*npoints+ii;
 | 
						Integer lex = site*npoints+ii;
 | 
				
			||||||
	GeneralStencilEntry SE;
 | 
						GeneralStencilEntry SE;
 | 
				
			||||||
@@ -132,7 +132,7 @@ public:
 | 
				
			|||||||
	////////////////////////////////////////////////
 | 
						////////////////////////////////////////////////
 | 
				
			||||||
	this->_entries[lex] = SE;
 | 
						this->_entries[lex] = SE;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      });
 | 
					    }      
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <Grid/stencil/SimpleCompressor.h>   // subdir aggregate
 | 
					#include <Grid/stencil/SimpleCompressor.h>   // subdir aggregate
 | 
				
			||||||
#include <Grid/stencil/Lebesgue.h>   // subdir aggregate
 | 
					#include <Grid/stencil/Lebesgue.h>   // subdir aggregate
 | 
				
			||||||
#include <Grid/stencil/GeneralLocalStencil.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
//////////////////////////////////////////////////////////////////////////////////////////
 | 
					//////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
// Must not lose sight that goal is to be able to construct really efficient
 | 
					// Must not lose sight that goal is to be able to construct really efficient
 | 
				
			||||||
@@ -706,7 +705,7 @@ public:
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    //std::cout << "BuildSurfaceList size is "<<surface_list.size()<<std::endl;
 | 
					    std::cout << "BuildSurfaceList size is "<<surface_list.size()<<std::endl;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  /// Introduce a block structure and switch off comms on boundaries
 | 
					  /// Introduce a block structure and switch off comms on boundaries
 | 
				
			||||||
  void DirichletBlock(const Coordinate &dirichlet_block)
 | 
					  void DirichletBlock(const Coordinate &dirichlet_block)
 | 
				
			||||||
@@ -761,8 +760,7 @@ public:
 | 
				
			|||||||
		   int checkerboard,
 | 
							   int checkerboard,
 | 
				
			||||||
		   const std::vector<int> &directions,
 | 
							   const std::vector<int> &directions,
 | 
				
			||||||
		   const std::vector<int> &distances,
 | 
							   const std::vector<int> &distances,
 | 
				
			||||||
		   Parameters p=Parameters(),
 | 
							   Parameters p=Parameters())
 | 
				
			||||||
		   bool preserve_shm=false)
 | 
					 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    face_table_computed=0;
 | 
					    face_table_computed=0;
 | 
				
			||||||
    _grid    = grid;
 | 
					    _grid    = grid;
 | 
				
			||||||
@@ -856,8 +854,6 @@ public:
 | 
				
			|||||||
    /////////////////////////////////////////////////////////////////////////////////
 | 
					    /////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
    const int Nsimd = grid->Nsimd();
 | 
					    const int Nsimd = grid->Nsimd();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Allow for multiple stencils to exist simultaneously
 | 
					 | 
				
			||||||
    if (!preserve_shm)
 | 
					 | 
				
			||||||
    _grid->ShmBufferFreeAll();
 | 
					    _grid->ShmBufferFreeAll();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int maxl=2;
 | 
					    int maxl=2;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -73,16 +73,6 @@ vobj coalescedReadPermute(const vobj & __restrict__ vec,int ptype,int doperm,int
 | 
				
			|||||||
    return vec;
 | 
					    return vec;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
//'perm_mask' acts as a bitmask
 | 
					 | 
				
			||||||
template<class vobj> accelerator_inline
 | 
					 | 
				
			||||||
vobj coalescedReadGeneralPermute(const vobj & __restrict__ vec,int perm_mask,int nd,int lane=0)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  auto obj = vec, tmp = vec;
 | 
					 | 
				
			||||||
  for (int d=0;d<nd;d++)
 | 
					 | 
				
			||||||
    if (perm_mask & (0x1 << d)) { permute(obj,tmp,d); tmp=obj;}
 | 
					 | 
				
			||||||
  return obj;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template<class vobj> accelerator_inline
 | 
					template<class vobj> accelerator_inline
 | 
				
			||||||
void coalescedWrite(vobj & __restrict__ vec,const vobj & __restrict__ extracted,int lane=0)
 | 
					void coalescedWrite(vobj & __restrict__ vec,const vobj & __restrict__ extracted,int lane=0)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -93,7 +83,7 @@ void coalescedWriteNonTemporal(vobj & __restrict__ vec,const vobj & __restrict__
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  vstream(vec, extracted);
 | 
					  vstream(vec, extracted);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#else //==GRID_SIMT
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//#ifndef GRID_SYCL
 | 
					//#ifndef GRID_SYCL
 | 
				
			||||||
@@ -176,14 +166,6 @@ typename vobj::scalar_object coalescedReadPermute(const vobj & __restrict__ vec,
 | 
				
			|||||||
  return extractLane(plane,vec);
 | 
					  return extractLane(plane,vec);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
template<class vobj> accelerator_inline
 | 
					template<class vobj> accelerator_inline
 | 
				
			||||||
typename vobj::scalar_object coalescedReadGeneralPermute(const vobj & __restrict__ vec,int perm_mask,int nd,int lane=acceleratorSIMTlane(vobj::Nsimd()))
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  int plane = lane;
 | 
					 | 
				
			||||||
  for (int d=0;d<nd;d++)
 | 
					 | 
				
			||||||
    plane = (perm_mask & (0x1 << d)) ? plane ^ (vobj::Nsimd() >> (d + 1)) : plane;
 | 
					 | 
				
			||||||
  return extractLane(plane,vec);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
template<class vobj> accelerator_inline
 | 
					 | 
				
			||||||
void coalescedWrite(vobj & __restrict__ vec,const typename vobj::scalar_object & __restrict__ extracted,int lane=acceleratorSIMTlane(vobj::Nsimd()))
 | 
					void coalescedWrite(vobj & __restrict__ vec,const typename vobj::scalar_object & __restrict__ extracted,int lane=acceleratorSIMTlane(vobj::Nsimd()))
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  insertLane(lane,vec,extracted);
 | 
					  insertLane(lane,vec,extracted);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,61 +66,13 @@ template<class vtype,int N> accelerator_inline iMatrix<vtype,N> Ta(const iMatrix
 | 
				
			|||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<class vtype> accelerator_inline iScalar<vtype> SpTa(const iScalar<vtype>&r)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  iScalar<vtype> ret;
 | 
					 | 
				
			||||||
  ret._internal = SpTa(r._internal);
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
template<class vtype,int N> accelerator_inline iVector<vtype,N> SpTa(const iVector<vtype,N>&r)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  iVector<vtype,N> ret;
 | 
					 | 
				
			||||||
  for(int i=0;i<N;i++){
 | 
					 | 
				
			||||||
    ret._internal[i] = SpTa(r._internal[i]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
template<class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
 | 
					 | 
				
			||||||
accelerator_inline iMatrix<vtype,N> SpTa(const iMatrix<vtype,N> &arg)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  // Generalises Ta to Sp2n
 | 
					 | 
				
			||||||
  // Applies the following projections
 | 
					 | 
				
			||||||
  // P_{antihermitian} P_{antihermitian-Sp-algebra} P_{traceless}
 | 
					 | 
				
			||||||
  // where the ordering matters
 | 
					 | 
				
			||||||
  // P_{traceless} subtracts the trace
 | 
					 | 
				
			||||||
  // P_{antihermitian-Sp-algebra} provides the block structure of the algebra based on U = exp(T) i.e. anti-hermitian generators
 | 
					 | 
				
			||||||
  // P_{antihermitian} does in-adj(in) / 2
 | 
					 | 
				
			||||||
  iMatrix<vtype,N> ret(arg);
 | 
					 | 
				
			||||||
  double factor = (1.0/(double)N);
 | 
					 | 
				
			||||||
  vtype nrm;
 | 
					 | 
				
			||||||
  nrm = 0.5;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  ret = arg - (trace(arg)*factor);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  for(int c1=0;c1<N/2;c1++)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
      for(int c2=0;c2<N/2;c2++)
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
          ret._internal[c1][c2] = nrm*(conjugate(ret._internal[c1+N/2][c2+N/2]) + ret._internal[c1][c2]); // new[up-left] = old[up-left]+old*[down-right]
 | 
					 | 
				
			||||||
          ret._internal[c1][c2+N/2] = nrm*(ret._internal[c1][c2+N/2] - conjugate(ret._internal[c1+N/2][c2])); // new[up-right] = old[up-right]-old*[down-left]
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      for(int c2=N/2;c2<N;c2++)
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
          ret._internal[c1+N/2][c2-N/2] = -conjugate(ret._internal[c1][c2]);  //  reconstructs lower blocks
 | 
					 | 
				
			||||||
          ret._internal[c1+N/2][c2] = conjugate(ret._internal[c1][c2-N/2]);   //  from upper blocks
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  ret = (ret - adj(ret))*0.5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/////////////////////////////////////////////// 
 | 
					/////////////////////////////////////////////// 
 | 
				
			||||||
// ProjectOnGroup function for scalar, vector, matrix 
 | 
					// ProjectOnGroup function for scalar, vector, matrix 
 | 
				
			||||||
// Projects on orthogonal, unitary group
 | 
					// Projects on orthogonal, unitary group
 | 
				
			||||||
/////////////////////////////////////////////// 
 | 
					/////////////////////////////////////////////// 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template<class vtype> accelerator_inline iScalar<vtype> ProjectOnGroup(const iScalar<vtype>&r)
 | 
					template<class vtype> accelerator_inline iScalar<vtype> ProjectOnGroup(const iScalar<vtype>&r)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  iScalar<vtype> ret;
 | 
					  iScalar<vtype> ret;
 | 
				
			||||||
@@ -138,12 +90,10 @@ template<class vtype,int N> accelerator_inline iVector<vtype,N> ProjectOnGroup(c
 | 
				
			|||||||
template<class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr> 
 | 
					template<class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr> 
 | 
				
			||||||
accelerator_inline iMatrix<vtype,N> ProjectOnGroup(const iMatrix<vtype,N> &arg)
 | 
					accelerator_inline iMatrix<vtype,N> ProjectOnGroup(const iMatrix<vtype,N> &arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  typedef typename iMatrix<vtype,N>::scalar_type scalar;
 | 
					 | 
				
			||||||
  // need a check for the group type?
 | 
					  // need a check for the group type?
 | 
				
			||||||
  iMatrix<vtype,N> ret(arg);
 | 
					  iMatrix<vtype,N> ret(arg);
 | 
				
			||||||
  vtype nrm;
 | 
					  vtype nrm;
 | 
				
			||||||
  vtype inner;
 | 
					  vtype inner;
 | 
				
			||||||
  scalar one(1.0);
 | 
					 | 
				
			||||||
  for(int c1=0;c1<N;c1++){
 | 
					  for(int c1=0;c1<N;c1++){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Normalises row c1
 | 
					    // Normalises row c1
 | 
				
			||||||
@@ -152,7 +102,7 @@ accelerator_inline iMatrix<vtype,N> ProjectOnGroup(const iMatrix<vtype,N> &arg)
 | 
				
			|||||||
      inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
 | 
					      inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    nrm = sqrt(inner);
 | 
					    nrm = sqrt(inner);
 | 
				
			||||||
    nrm = one/nrm;
 | 
					    nrm = 1.0/nrm;
 | 
				
			||||||
    for(int c2=0;c2<N;c2++)
 | 
					    for(int c2=0;c2<N;c2++)
 | 
				
			||||||
      ret._internal[c1][c2]*= nrm;
 | 
					      ret._internal[c1][c2]*= nrm;
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
@@ -177,7 +127,7 @@ accelerator_inline iMatrix<vtype,N> ProjectOnGroup(const iMatrix<vtype,N> &arg)
 | 
				
			|||||||
      inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
 | 
					      inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    nrm = sqrt(inner);
 | 
					    nrm = sqrt(inner);
 | 
				
			||||||
    nrm = one/nrm;
 | 
					    nrm = 1.0/nrm;
 | 
				
			||||||
    for(int c2=0;c2<N;c2++)
 | 
					    for(int c2=0;c2<N;c2++)
 | 
				
			||||||
      ret._internal[c1][c2]*= nrm;
 | 
					      ret._internal[c1][c2]*= nrm;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -185,85 +135,6 @@ accelerator_inline iMatrix<vtype,N> ProjectOnGroup(const iMatrix<vtype,N> &arg)
 | 
				
			|||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// re-do for sp2n
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Ta cannot be defined here for Sp2n because I need the generators from the Sp class
 | 
					 | 
				
			||||||
// It is defined in gauge impl types
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template<class vtype> accelerator_inline iScalar<vtype> ProjectOnSpGroup(const iScalar<vtype>&r)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  iScalar<vtype> ret;
 | 
					 | 
				
			||||||
  ret._internal = ProjectOnSpGroup(r._internal);
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
template<class vtype,int N> accelerator_inline iVector<vtype,N> ProjectOnSpGroup(const iVector<vtype,N>&r)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  iVector<vtype,N> ret;
 | 
					 | 
				
			||||||
  for(int i=0;i<N;i++){
 | 
					 | 
				
			||||||
    ret._internal[i] = ProjectOnSpGroup(r._internal[i]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// int N is 2n in Sp(2n)
 | 
					 | 
				
			||||||
template<class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
 | 
					 | 
				
			||||||
accelerator_inline iMatrix<vtype,N> ProjectOnSpGroup(const iMatrix<vtype,N> &arg)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  // need a check for the group type?
 | 
					 | 
				
			||||||
  iMatrix<vtype,N> ret(arg);
 | 
					 | 
				
			||||||
  vtype nrm;
 | 
					 | 
				
			||||||
  vtype inner;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  for(int c1=0;c1<N/2;c1++)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
    for (int b=0; b<c1; b++)                  // remove the b-rows from U_c1
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      decltype(ret._internal[b][b]*ret._internal[b][b]) pr;
 | 
					 | 
				
			||||||
      decltype(ret._internal[b][b]*ret._internal[b][b]) prn;
 | 
					 | 
				
			||||||
      zeroit(pr);
 | 
					 | 
				
			||||||
      zeroit(prn);
 | 
					 | 
				
			||||||
          
 | 
					 | 
				
			||||||
      for(int c=0; c<N; c++)
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        pr += conjugate(ret._internal[c1][c])*ret._internal[b][c];        // <U_c1 | U_b >
 | 
					 | 
				
			||||||
        prn += conjugate(ret._internal[c1][c])*ret._internal[b+N/2][c];   // <U_c1 | U_{b+N} >
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
       
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      for(int c=0; c<N; c++)
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        ret._internal[c1][c] -= (conjugate(pr) * ret._internal[b][c] + conjugate(prn) * ret._internal[b+N/2][c] );    //  U_c1 -= (  <U_c1 | U_b > U_b + <U_c1 | U_{b+N} > U_{b+N}  )
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    zeroit(inner);
 | 
					 | 
				
			||||||
    for(int c2=0;c2<N;c2++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
    nrm = sqrt(inner);
 | 
					 | 
				
			||||||
    nrm = 1.0/nrm;
 | 
					 | 
				
			||||||
    for(int c2=0;c2<N;c2++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      ret._internal[c1][c2]*= nrm;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
    for(int c2=0;c2<N/2;c2++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      ret._internal[c1+N/2][c2+N/2] = conjugate(ret._internal[c1][c2]);          // down right in the new matrix = (up-left)* of the old matrix
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
    for(int c2=N/2;c2<N;c2++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      ret._internal[c1+N/2][c2-N/2] = -conjugate(ret._internal[c1][c2]);;     // down left in the new matrix = -(up-right)* of the old
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,8 +53,9 @@ template<class vtype, int N> accelerator_inline iVector<vtype, N> Exponentiate(c
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Specialisation: Cayley-Hamilton exponential for SU(3)
 | 
					// Specialisation: Cayley-Hamilton exponential for SU(3)
 | 
				
			||||||
#if 0
 | 
					#ifndef GRID_ACCELERATED
 | 
				
			||||||
template<class vtype, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0>::type * =nullptr> 
 | 
					template<class vtype, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0>::type * =nullptr> 
 | 
				
			||||||
accelerator_inline iMatrix<vtype,3> Exponentiate(const iMatrix<vtype,3> &arg, RealD alpha  , Integer Nexp = DEFAULT_MAT_EXP )
 | 
					accelerator_inline iMatrix<vtype,3> Exponentiate(const iMatrix<vtype,3> &arg, RealD alpha  , Integer Nexp = DEFAULT_MAT_EXP )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,35 +69,6 @@ accelerator_inline auto trace(const iVector<vtype,N> &arg) -> iVector<decltype(t
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
////////////////////////////
 | 
					 | 
				
			||||||
// Fast path traceProduct
 | 
					 | 
				
			||||||
////////////////////////////
 | 
					 | 
				
			||||||
template<class S1 , class S2, IfNotGridTensor<S1> = 0, IfNotGridTensor<S2> = 0>
 | 
					 | 
				
			||||||
accelerator_inline auto traceProduct( const S1 &arg1,const S2 &arg2)
 | 
					 | 
				
			||||||
  -> decltype(arg1*arg2)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  return arg1*arg2;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template<class vtype,class rtype,int N >
 | 
					 | 
				
			||||||
accelerator_inline auto traceProduct(const iMatrix<vtype,N> &arg1,const iMatrix<rtype,N> &arg2) -> iScalar<decltype(trace(arg1._internal[0][0]*arg2._internal[0][0]))>
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  iScalar<decltype( trace(arg1._internal[0][0]*arg2._internal[0][0] )) > ret;
 | 
					 | 
				
			||||||
  zeroit(ret._internal);
 | 
					 | 
				
			||||||
  for(int i=0;i<N;i++){
 | 
					 | 
				
			||||||
  for(int j=0;j<N;j++){
 | 
					 | 
				
			||||||
    ret._internal=ret._internal+traceProduct(arg1._internal[i][j],arg2._internal[j][i]);
 | 
					 | 
				
			||||||
  }}
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
template<class vtype,class rtype >
 | 
					 | 
				
			||||||
accelerator_inline auto traceProduct(const iScalar<vtype> &arg1,const iScalar<rtype> &arg2) -> iScalar<decltype(trace(arg1._internal*arg2._internal))>
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  iScalar<decltype(trace(arg1._internal*arg2._internal))> ret;
 | 
					 | 
				
			||||||
  ret._internal=traceProduct(arg1._internal,arg2._internal);
 | 
					 | 
				
			||||||
  return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,9 +38,6 @@ NAMESPACE_BEGIN(Grid);
 | 
				
			|||||||
  template<class T, int N> struct isGridTensor<iVector<T, N>> : public std::true_type  { static constexpr bool notvalue = false; };
 | 
					  template<class T, int N> struct isGridTensor<iVector<T, N>> : public std::true_type  { static constexpr bool notvalue = false; };
 | 
				
			||||||
  template<class T, int N> struct isGridTensor<iMatrix<T, N>> : public std::true_type  { static constexpr bool notvalue = false; };
 | 
					  template<class T, int N> struct isGridTensor<iMatrix<T, N>> : public std::true_type  { static constexpr bool notvalue = false; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  template <typename T>  using IfGridTensor    = Invoke<std::enable_if<isGridTensor<T>::value, int> >;
 | 
					 | 
				
			||||||
  template <typename T>  using IfNotGridTensor = Invoke<std::enable_if<!isGridTensor<T>::value, int> >;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Traits to identify scalars
 | 
					  // Traits to identify scalars
 | 
				
			||||||
  template<typename T>     struct isGridScalar                : public std::false_type { static constexpr bool notvalue = true; };
 | 
					  template<typename T>     struct isGridScalar                : public std::false_type { static constexpr bool notvalue = true; };
 | 
				
			||||||
  template<class T>        struct isGridScalar<iScalar<T>>    : public std::true_type  { static constexpr bool notvalue = false; };
 | 
					  template<class T>        struct isGridScalar<iScalar<T>>    : public std::true_type  { static constexpr bool notvalue = false; };
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,8 +7,6 @@ uint32_t accelerator_threads=2;
 | 
				
			|||||||
uint32_t acceleratorThreads(void)       {return accelerator_threads;};
 | 
					uint32_t acceleratorThreads(void)       {return accelerator_threads;};
 | 
				
			||||||
void     acceleratorThreads(uint32_t t) {accelerator_threads = t;};
 | 
					void     acceleratorThreads(uint32_t t) {accelerator_threads = t;};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define ENV_LOCAL_RANK_PALS    "PALS_LOCAL_RANKID"
 | 
					 | 
				
			||||||
#define ENV_RANK_PALS          "PALS_RANKID"
 | 
					 | 
				
			||||||
#define ENV_LOCAL_RANK_OMPI    "OMPI_COMM_WORLD_LOCAL_RANK"
 | 
					#define ENV_LOCAL_RANK_OMPI    "OMPI_COMM_WORLD_LOCAL_RANK"
 | 
				
			||||||
#define ENV_RANK_OMPI          "OMPI_COMM_WORLD_RANK"
 | 
					#define ENV_RANK_OMPI          "OMPI_COMM_WORLD_RANK"
 | 
				
			||||||
#define ENV_LOCAL_RANK_SLURM   "SLURM_LOCALID"
 | 
					#define ENV_LOCAL_RANK_SLURM   "SLURM_LOCALID"
 | 
				
			||||||
@@ -16,10 +14,7 @@ void     acceleratorThreads(uint32_t t) {accelerator_threads = t;};
 | 
				
			|||||||
#define ENV_LOCAL_RANK_MVAPICH "MV2_COMM_WORLD_LOCAL_RANK"
 | 
					#define ENV_LOCAL_RANK_MVAPICH "MV2_COMM_WORLD_LOCAL_RANK"
 | 
				
			||||||
#define ENV_RANK_MVAPICH       "MV2_COMM_WORLD_RANK"
 | 
					#define ENV_RANK_MVAPICH       "MV2_COMM_WORLD_RANK"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef GRID_CUDA
 | 
				
			||||||
// fold omptarget into device specific acceleratorInit()
 | 
					 | 
				
			||||||
#if defined(GRID_CUDA) || (defined(GRID_OMPTARGET) && defined(__CUDA_ARCH__))
 | 
					 | 
				
			||||||
#include <cuda_runtime_api.h>
 | 
					 | 
				
			||||||
cudaDeviceProp *gpu_props;
 | 
					cudaDeviceProp *gpu_props;
 | 
				
			||||||
cudaStream_t copyStream;
 | 
					cudaStream_t copyStream;
 | 
				
			||||||
cudaStream_t computeStream;
 | 
					cudaStream_t computeStream;
 | 
				
			||||||
@@ -118,7 +113,7 @@ void acceleratorInit(void)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(GRID_HIP) || (defined(GRID_OMPTARGET) && defined(__HIP_DEVICE_COMPILE__))
 | 
					#ifdef GRID_HIP
 | 
				
			||||||
hipDeviceProp_t *gpu_props;
 | 
					hipDeviceProp_t *gpu_props;
 | 
				
			||||||
hipStream_t copyStream;
 | 
					hipStream_t copyStream;
 | 
				
			||||||
hipStream_t computeStream;
 | 
					hipStream_t computeStream;
 | 
				
			||||||
@@ -152,7 +147,7 @@ void acceleratorInit(void)
 | 
				
			|||||||
#define GPU_PROP_FMT(canMapHostMemory,FMT)     printf("AcceleratorHipInit:   " #canMapHostMemory ": " FMT" \n",prop.canMapHostMemory);
 | 
					#define GPU_PROP_FMT(canMapHostMemory,FMT)     printf("AcceleratorHipInit:   " #canMapHostMemory ": " FMT" \n",prop.canMapHostMemory);
 | 
				
			||||||
#define GPU_PROP(canMapHostMemory)             GPU_PROP_FMT(canMapHostMemory,"%d");
 | 
					#define GPU_PROP(canMapHostMemory)             GPU_PROP_FMT(canMapHostMemory,"%d");
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    auto r=hipGetDeviceProperties(&gpu_props[i], i);
 | 
					    hipGetDeviceProperties(&gpu_props[i], i);
 | 
				
			||||||
    hipDeviceProp_t prop; 
 | 
					    hipDeviceProp_t prop; 
 | 
				
			||||||
    prop = gpu_props[i];
 | 
					    prop = gpu_props[i];
 | 
				
			||||||
    totalDeviceMem = prop.totalGlobalMem;
 | 
					    totalDeviceMem = prop.totalGlobalMem;
 | 
				
			||||||
@@ -203,7 +198,7 @@ void acceleratorInit(void)
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(GRID_SYCL) //|| (defined(GRID_OMPTARGET) && defined(__SYCL_DEVICE_ONLY__))
 | 
					#ifdef GRID_SYCL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cl::sycl::queue *theGridAccelerator;
 | 
					cl::sycl::queue *theGridAccelerator;
 | 
				
			||||||
cl::sycl::queue *theCopyAccelerator;
 | 
					cl::sycl::queue *theCopyAccelerator;
 | 
				
			||||||
@@ -233,17 +228,8 @@ void acceleratorInit(void)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    rank = atoi(localRankStr);		
 | 
					    rank = atoi(localRankStr);		
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if ((localRankStr = getenv(ENV_LOCAL_RANK_PALS)) != NULL)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    rank = atoi(localRankStr);		
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if ((localRankStr = getenv(ENV_RANK_OMPI   )) != NULL) { world_rank = atoi(localRankStr);}
 | 
					  if ((localRankStr = getenv(ENV_RANK_OMPI   )) != NULL) { world_rank = atoi(localRankStr);}
 | 
				
			||||||
  if ((localRankStr = getenv(ENV_RANK_MVAPICH)) != NULL) { world_rank = atoi(localRankStr);}
 | 
					  if ((localRankStr = getenv(ENV_RANK_MVAPICH)) != NULL) { world_rank = atoi(localRankStr);}
 | 
				
			||||||
  if ((localRankStr = getenv(ENV_RANK_PALS   )) != NULL) { world_rank = atoi(localRankStr);}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  char hostname[HOST_NAME_MAX+1];
 | 
					 | 
				
			||||||
  gethostname(hostname, HOST_NAME_MAX+1);
 | 
					 | 
				
			||||||
  if ( rank==0 ) printf(" acceleratorInit world_rank %d is host %s \n",world_rank,hostname);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  auto devices = cl::sycl::device::get_devices();
 | 
					  auto devices = cl::sycl::device::get_devices();
 | 
				
			||||||
  for(int d = 0;d<devices.size();d++){
 | 
					  for(int d = 0;d<devices.size();d++){
 | 
				
			||||||
@@ -255,7 +241,6 @@ void acceleratorInit(void)
 | 
				
			|||||||
    printf("AcceleratorSyclInit:   " #prop ": " FMT" \n",devices[d].get_info<cl::sycl::info::device::prop>());
 | 
					    printf("AcceleratorSyclInit:   " #prop ": " FMT" \n",devices[d].get_info<cl::sycl::info::device::prop>());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GPU_PROP(prop)             GPU_PROP_FMT(prop,"%ld");
 | 
					#define GPU_PROP(prop)             GPU_PROP_FMT(prop,"%ld");
 | 
				
			||||||
    if ( world_rank == 0) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GPU_PROP_STR(vendor);
 | 
					    GPU_PROP_STR(vendor);
 | 
				
			||||||
    GPU_PROP_STR(version);
 | 
					    GPU_PROP_STR(version);
 | 
				
			||||||
@@ -275,7 +260,6 @@ void acceleratorInit(void)
 | 
				
			|||||||
    */
 | 
					    */
 | 
				
			||||||
    //    GPU_PROP(double_fp_config);
 | 
					    //    GPU_PROP(double_fp_config);
 | 
				
			||||||
    GPU_PROP(global_mem_size);
 | 
					    GPU_PROP(global_mem_size);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if ( world_rank == 0 ) {
 | 
					  if ( world_rank == 0 ) {
 | 
				
			||||||
@@ -286,7 +270,7 @@ void acceleratorInit(void)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if (!defined(GRID_CUDA)) && (!defined(GRID_SYCL))&& (!defined(GRID_HIP))// && (!defined(GRID_OMPTARGET))
 | 
					#if (!defined(GRID_CUDA)) && (!defined(GRID_SYCL))&& (!defined(GRID_HIP))
 | 
				
			||||||
void acceleratorInit(void){}
 | 
					void acceleratorInit(void){}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,11 +26,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
				
			|||||||
    See the full license in the file "LICENSE" in the top level distribution directory
 | 
					    See the full license in the file "LICENSE" in the top level distribution directory
 | 
				
			||||||
*************************************************************************************/
 | 
					*************************************************************************************/
 | 
				
			||||||
/*  END LEGAL */
 | 
					/*  END LEGAL */
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef ACCELERATOR_H
 | 
					 | 
				
			||||||
#define ACCELERATOR_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_MALLOC_MALLOC_H
 | 
					#ifdef HAVE_MALLOC_MALLOC_H
 | 
				
			||||||
@@ -291,12 +288,11 @@ accelerator_inline int acceleratorSIMTlane(int Nsimd) {
 | 
				
			|||||||
#define accelerator_for2dNB( iter1, num1, iter2, num2, nsimd, ... )	\
 | 
					#define accelerator_for2dNB( iter1, num1, iter2, num2, nsimd, ... )	\
 | 
				
			||||||
  theGridAccelerator->submit([&](cl::sycl::handler &cgh) {		\
 | 
					  theGridAccelerator->submit([&](cl::sycl::handler &cgh) {		\
 | 
				
			||||||
      unsigned long nt=acceleratorThreads();				\
 | 
					      unsigned long nt=acceleratorThreads();				\
 | 
				
			||||||
    if(nt < 8)nt=8;							\
 | 
					 | 
				
			||||||
      unsigned long unum1 = num1;					\
 | 
					      unsigned long unum1 = num1;					\
 | 
				
			||||||
      unsigned long unum2 = num2;					\
 | 
					      unsigned long unum2 = num2;					\
 | 
				
			||||||
    unsigned long unum1_divisible_by_nt = ((unum1 + nt - 1) / nt) * nt;	\
 | 
					      if(nt < 8)nt=8;							\
 | 
				
			||||||
      cl::sycl::range<3> local {nt,1,nsimd};				\
 | 
					      cl::sycl::range<3> local {nt,1,nsimd};				\
 | 
				
			||||||
    cl::sycl::range<3> global{unum1_divisible_by_nt,unum2,nsimd};	\
 | 
					      cl::sycl::range<3> global{unum1,unum2,nsimd};			\
 | 
				
			||||||
      cgh.parallel_for(					\
 | 
					      cgh.parallel_for(					\
 | 
				
			||||||
      cl::sycl::nd_range<3>(global,local), \
 | 
					      cl::sycl::nd_range<3>(global,local), \
 | 
				
			||||||
      [=] (cl::sycl::nd_item<3> item) /*mutable*/     \
 | 
					      [=] (cl::sycl::nd_item<3> item) /*mutable*/     \
 | 
				
			||||||
@@ -305,7 +301,7 @@ accelerator_inline int acceleratorSIMTlane(int Nsimd) {
 | 
				
			|||||||
      auto iter1    = item.get_global_id(0);	      \
 | 
					      auto iter1    = item.get_global_id(0);	      \
 | 
				
			||||||
      auto iter2    = item.get_global_id(1);	      \
 | 
					      auto iter2    = item.get_global_id(1);	      \
 | 
				
			||||||
      auto lane     = item.get_global_id(2);	      \
 | 
					      auto lane     = item.get_global_id(2);	      \
 | 
				
			||||||
		       { if (iter1 < unum1){ __VA_ARGS__ } };		\
 | 
					      { __VA_ARGS__ };				      \
 | 
				
			||||||
     });	   			              \
 | 
					     });	   			              \
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -409,7 +405,7 @@ void LambdaApply(uint64_t numx, uint64_t numy, uint64_t numz, lambda Lambda)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define accelerator_barrier(dummy)				\
 | 
					#define accelerator_barrier(dummy)				\
 | 
				
			||||||
  {								\
 | 
					  {								\
 | 
				
			||||||
    auto r=hipStreamSynchronize(computeStream);			\
 | 
					    hipStreamSynchronize(computeStream);			\
 | 
				
			||||||
    auto err = hipGetLastError();				\
 | 
					    auto err = hipGetLastError();				\
 | 
				
			||||||
    if ( err != hipSuccess ) {					\
 | 
					    if ( err != hipSuccess ) {					\
 | 
				
			||||||
      printf("After hipDeviceSynchronize() : HIP error %s \n", hipGetErrorString( err )); \
 | 
					      printf("After hipDeviceSynchronize() : HIP error %s \n", hipGetErrorString( err )); \
 | 
				
			||||||
@@ -442,19 +438,19 @@ inline void *acceleratorAllocDevice(size_t bytes)
 | 
				
			|||||||
  return ptr;
 | 
					  return ptr;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline void acceleratorFreeShared(void *ptr){ auto r=hipFree(ptr);};
 | 
					inline void acceleratorFreeShared(void *ptr){ hipFree(ptr);};
 | 
				
			||||||
inline void acceleratorFreeDevice(void *ptr){ auto r=hipFree(ptr);};
 | 
					inline void acceleratorFreeDevice(void *ptr){ hipFree(ptr);};
 | 
				
			||||||
inline void acceleratorCopyToDevice(void *from,void *to,size_t bytes)  { auto r=hipMemcpy(to,from,bytes, hipMemcpyHostToDevice);}
 | 
					inline void acceleratorCopyToDevice(void *from,void *to,size_t bytes)  { hipMemcpy(to,from,bytes, hipMemcpyHostToDevice);}
 | 
				
			||||||
inline void acceleratorCopyFromDevice(void *from,void *to,size_t bytes){ auto r=hipMemcpy(to,from,bytes, hipMemcpyDeviceToHost);}
 | 
					inline void acceleratorCopyFromDevice(void *from,void *to,size_t bytes){ hipMemcpy(to,from,bytes, hipMemcpyDeviceToHost);}
 | 
				
			||||||
//inline void acceleratorCopyDeviceToDeviceAsynch(void *from,void *to,size_t bytes)  { hipMemcpy(to,from,bytes, hipMemcpyDeviceToDevice);}
 | 
					//inline void acceleratorCopyDeviceToDeviceAsynch(void *from,void *to,size_t bytes)  { hipMemcpy(to,from,bytes, hipMemcpyDeviceToDevice);}
 | 
				
			||||||
//inline void acceleratorCopySynchronise(void) {  }
 | 
					//inline void acceleratorCopySynchronise(void) {  }
 | 
				
			||||||
inline void acceleratorMemSet(void *base,int value,size_t bytes) { auto r=hipMemset(base,value,bytes);}
 | 
					inline void acceleratorMemSet(void *base,int value,size_t bytes) { hipMemset(base,value,bytes);}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline void acceleratorCopyDeviceToDeviceAsynch(void *from,void *to,size_t bytes) // Asynch
 | 
					inline void acceleratorCopyDeviceToDeviceAsynch(void *from,void *to,size_t bytes) // Asynch
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  auto r=hipMemcpyDtoDAsync(to,from,bytes, copyStream);
 | 
					  hipMemcpyDtoDAsync(to,from,bytes, copyStream);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
inline void acceleratorCopySynchronise(void) { auto r=hipStreamSynchronize(copyStream); };
 | 
					inline void acceleratorCopySynchronise(void) { hipStreamSynchronize(copyStream); };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -478,155 +474,14 @@ inline void acceleratorCopySynchronise(void) { auto r=hipStreamSynchronize(copyS
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//////////////////////////////////////////////
 | 
					//////////////////////////////////////////////
 | 
				
			||||||
// OpenMP Target acceleration
 | 
					// CPU Target - No accelerator just thread instead
 | 
				
			||||||
//////////////////////////////////////////////
 | 
					//////////////////////////////////////////////
 | 
				
			||||||
#ifdef GRID_OMPTARGET
 | 
					 | 
				
			||||||
//TODO GRID_SIMT for OMPTARGET
 | 
					 | 
				
			||||||
#define GRID_ACCELERATED
 | 
					 | 
				
			||||||
#include<omp.h>
 | 
					 | 
				
			||||||
#ifdef __CUDA_ARCH__
 | 
					 | 
				
			||||||
#include <cuda_runtime_api.h>
 | 
					 | 
				
			||||||
#elif defined __HIP_DEVICE_COMPILE__
 | 
					 | 
				
			||||||
#include <hip/hip_runtime.h>
 | 
					 | 
				
			||||||
#elif defined __SYCL_DEVICE_ONLY__
 | 
					 | 
				
			||||||
#include <CL/sycl.hpp>
 | 
					 | 
				
			||||||
#include <CL/sycl/usm.hpp>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
extern "C" void *llvm_omp_target_alloc_host  (size_t Size, int DeviceNum);
 | 
					 | 
				
			||||||
extern "C" void *llvm_omp_target_alloc_device(size_t Size, int DeviceNum);
 | 
					 | 
				
			||||||
extern "C" void *llvm_omp_target_alloc_shared(size_t Size, int DeviceNum);
 | 
					 | 
				
			||||||
//TODO: Dynamic Shared Memory
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define THREAD_LIMIT acceleratorThreads()
 | 
					#if ( (!defined(GRID_SYCL)) && (!defined(GRID_CUDA)) && (!defined(GRID_HIP)) )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define accelerator
 | 
					#undef GRID_SIMT
 | 
				
			||||||
#define accelerator_inline strong_inline
 | 
					 | 
				
			||||||
#ifdef THREAD_LIMIT
 | 
					 | 
				
			||||||
#define accelerator_for(i,num,nsimd, ... ) \
 | 
					 | 
				
			||||||
	_Pragma("omp target teams distribute parallel for thread_limit(THREAD_LIMIT)") \
 | 
					 | 
				
			||||||
	for ( uint64_t i=0;i<num;i++) { __VA_ARGS__ } ; 
 | 
					 | 
				
			||||||
#define accelerator_forNB(i,num,nsimd, ... ) \
 | 
					 | 
				
			||||||
	_Pragma("omp target teams distribute parallel for thread_limit(THREAD_LIMIT) nowait") \
 | 
					 | 
				
			||||||
        for ( uint64_t i=0;i<num;i++) { __VA_ARGS__ } ;
 | 
					 | 
				
			||||||
#define accelerator_barrier(dummy) _Pragma("omp barrier") 
 | 
					 | 
				
			||||||
#define accelerator_for2d(iter1, num1, iter2, num2, nsimd, ... ) \
 | 
					 | 
				
			||||||
	_Pragma("omp target teams distribute parallel for thread_limit(THREAD_LIMIT) collapse(2)") \
 | 
					 | 
				
			||||||
        for ( uint64_t iter1=0;iter1<num1;iter1++) \
 | 
					 | 
				
			||||||
	for ( uint64_t iter2=0;iter2<num2;iter2++) { __VA_ARGS__ } ;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#define accelerator_for(i,num,nsimd, ... ) \
 | 
					 | 
				
			||||||
        _Pragma("omp target teams distribute parallel for") \
 | 
					 | 
				
			||||||
        for ( uint64_t i=0;i<num;i++) { __VA_ARGS__ } ;
 | 
					 | 
				
			||||||
#define accelerator_forNB(i,num,nsimd, ... ) \
 | 
					 | 
				
			||||||
        _Pragma("omp target teams distribute parallel for nowait") \
 | 
					 | 
				
			||||||
        for ( uint64_t i=0;i<num;i++) { __VA_ARGS__ } ;
 | 
					 | 
				
			||||||
#define accelerator_barrier(dummy) _Pragma("omp barrier")
 | 
					 | 
				
			||||||
#define accelerator_for2d(iter1, num1, iter2, num2, nsimd, ... ) \
 | 
					 | 
				
			||||||
        _Pragma("omp target teams distribute parallel for collapse(2)") \
 | 
					 | 
				
			||||||
        for ( uint64_t iter1=0;iter1<num1;iter1++) \
 | 
					 | 
				
			||||||
        for ( uint64_t iter2=0;iter2<num2;iter2++) { __VA_ARGS__ } ;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
accelerator_inline int acceleratorSIMTlane(int Nsimd) { return 0; } // CUDA specific
 | 
					 | 
				
			||||||
inline void acceleratorCopyToDevice(void *from,void *to,size_t bytes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  int devc = omp_get_default_device();
 | 
					 | 
				
			||||||
  int host = omp_get_initial_device();
 | 
					 | 
				
			||||||
  if( omp_target_memcpy( to, from, bytes, 0, 0, devc, host ) ) {
 | 
					 | 
				
			||||||
    printf(" omp_target_memcpy host to device failed for %ld in device %d \n",bytes,devc);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
inline void acceleratorCopyFromDevice(void *from,void *to,size_t bytes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  int devc = omp_get_default_device();
 | 
					 | 
				
			||||||
  int host = omp_get_initial_device();
 | 
					 | 
				
			||||||
  if( omp_target_memcpy( to, from, bytes, 0, 0, host, devc ) ) {
 | 
					 | 
				
			||||||
    printf(" omp_target_memcpy device to host failed for %ld in device %d \n",bytes,devc);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
inline void acceleratorCopyDeviceToDeviceAsynch(void *from,void *to,size_t bytes) 
 | 
					 | 
				
			||||||
{ 
 | 
					 | 
				
			||||||
#ifdef __CUDA_ARCH__
 | 
					 | 
				
			||||||
  extern cudaStream_t copyStream;
 | 
					 | 
				
			||||||
  cudaMemcpyAsync(to,from,bytes, cudaMemcpyDeviceToDevice,copyStream);
 | 
					 | 
				
			||||||
#elif defined __HIP_DEVICE_COMPILE__
 | 
					 | 
				
			||||||
  extern hipStream_t copyStream;
 | 
					 | 
				
			||||||
  hipMemcpyDtoDAsync(to,from,bytes, copyStream);
 | 
					 | 
				
			||||||
#elif defined __SYCL_DEVICE_ONLY__
 | 
					 | 
				
			||||||
  theCopyAccelerator->memcpy(to,from,bytes);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
inline void acceleratorCopySynchronise(void) 
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  //#pragma omp barrier
 | 
					 | 
				
			||||||
#ifdef __CUDA_ARCH__
 | 
					 | 
				
			||||||
  extern cudaStream_t copyStream;
 | 
					 | 
				
			||||||
  cudaStreamSynchronize(copyStream);
 | 
					 | 
				
			||||||
#elif defined __HIP_DEVICE_COMPILE__
 | 
					 | 
				
			||||||
  extern hipStream_t copyStream;
 | 
					 | 
				
			||||||
  hipStreamSynchronize(copyStream);
 | 
					 | 
				
			||||||
#elif defined __SYCL_DEVICE_ONLY__
 | 
					 | 
				
			||||||
  theCopyAccelerator->wait();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
inline int  acceleratorIsCommunicable(void *ptr){ return 1; }
 | 
					 | 
				
			||||||
inline void acceleratorMemSet(void *base,int value,size_t bytes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  void *base_host = memalign(GRID_ALLOC_ALIGN,bytes);
 | 
					 | 
				
			||||||
  memset(base_host,value,bytes);
 | 
					 | 
				
			||||||
  int devc = omp_get_default_device();
 | 
					 | 
				
			||||||
  int host = omp_get_initial_device();
 | 
					 | 
				
			||||||
  if( omp_target_memcpy( base, base_host, bytes, 0, 0, devc, host ) ) {
 | 
					 | 
				
			||||||
    printf(" omp_target_memcpy device to host failed in MemSet for %ld in device %d \n",bytes,devc);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
inline void *acceleratorAllocShared(size_t bytes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
#ifdef __CUDA_ARCH__
 | 
					 | 
				
			||||||
  void *ptr=NULL;
 | 
					 | 
				
			||||||
  auto err = cudaMallocManaged((void **)&ptr,bytes);
 | 
					 | 
				
			||||||
  if( err != cudaSuccess ) {
 | 
					 | 
				
			||||||
    ptr = (void *) NULL;
 | 
					 | 
				
			||||||
    printf(" cudaMallocManaged failed for %d %s \n",bytes,cudaGetErrorString(err));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return ptr;
 | 
					 | 
				
			||||||
#elif defined __HIP_DEVICE_COMPILE__
 | 
					 | 
				
			||||||
  void *ptr=NULL;
 | 
					 | 
				
			||||||
  auto err = hipMallocManaged((void **)&ptr,bytes);
 | 
					 | 
				
			||||||
  if( err != hipSuccess ) {
 | 
					 | 
				
			||||||
    ptr = (void *) NULL;
 | 
					 | 
				
			||||||
    printf(" hipMallocManaged failed for %d %s \n",bytes,cudaGetErrorString(err));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return ptr;
 | 
					 | 
				
			||||||
#elif defined __SYCL_DEVICE_ONLY__
 | 
					 | 
				
			||||||
  queue q;
 | 
					 | 
				
			||||||
  //void *ptr = malloc_shared<void *>(bytes, q);
 | 
					 | 
				
			||||||
  return ptr;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
  int devc = omp_get_default_device();
 | 
					 | 
				
			||||||
  void *ptr=NULL;
 | 
					 | 
				
			||||||
  ptr = (void *) llvm_omp_target_alloc_shared(bytes, devc);
 | 
					 | 
				
			||||||
  if( ptr == NULL ) {
 | 
					 | 
				
			||||||
    printf(" llvm_omp_target_alloc_shared failed for %ld in device %d \n",bytes,devc);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return ptr;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
inline void *acceleratorAllocDevice(size_t bytes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  int devc = omp_get_default_device();
 | 
					 | 
				
			||||||
  void *ptr=NULL;
 | 
					 | 
				
			||||||
  ptr = (void *) omp_target_alloc(bytes, devc);
 | 
					 | 
				
			||||||
  if( ptr == NULL ) {
 | 
					 | 
				
			||||||
    printf(" omp_target_alloc failed for %ld in device %d \n",bytes,devc);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return ptr;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
inline void acceleratorFreeShared(void *ptr){omp_target_free(ptr, omp_get_default_device());};
 | 
					 | 
				
			||||||
inline void acceleratorFreeDevice(void *ptr){omp_target_free(ptr, omp_get_default_device());};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
//OpenMP CPU threads
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define accelerator 
 | 
					#define accelerator 
 | 
				
			||||||
#define accelerator_inline strong_inline
 | 
					#define accelerator_inline strong_inline
 | 
				
			||||||
@@ -655,14 +510,7 @@ inline void *acceleratorAllocDevice(size_t bytes){return memalign(GRID_ALLOC_ALI
 | 
				
			|||||||
inline void acceleratorFreeShared(void *ptr){free(ptr);};
 | 
					inline void acceleratorFreeShared(void *ptr){free(ptr);};
 | 
				
			||||||
inline void acceleratorFreeDevice(void *ptr){free(ptr);};
 | 
					inline void acceleratorFreeDevice(void *ptr){free(ptr);};
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
//////////////////////////////////////////////
 | 
					 | 
				
			||||||
// CPU Target - No accelerator just thread instead
 | 
					 | 
				
			||||||
//////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if ( (!defined(GRID_SYCL)) && (!defined(GRID_CUDA)) && (!defined(GRID_HIP)) ) && (!defined(GRID_OMPTARGET))
 | 
					 | 
				
			||||||
#undef GRID_SIMT
 | 
					 | 
				
			||||||
#endif // CPU target
 | 
					#endif // CPU target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_MM_MALLOC_H
 | 
					#ifdef HAVE_MM_MALLOC_H
 | 
				
			||||||
@@ -727,13 +575,4 @@ accelerator_inline void acceleratorFence(void)
 | 
				
			|||||||
  return;
 | 
					  return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline void acceleratorCopyDeviceToDevice(void *from,void *to,size_t bytes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  acceleratorCopyDeviceToDeviceAsynch(from,to,bytes);
 | 
					 | 
				
			||||||
  acceleratorCopySynchronise();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NAMESPACE_END(Grid);
 | 
					NAMESPACE_END(Grid);
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef GRID_OMP
 | 
					#ifdef GRID_OMP
 | 
				
			||||||
#define DO_PRAGMA_(x) _Pragma ("x")
 | 
					#define DO_PRAGMA_(x) _Pragma (#x)
 | 
				
			||||||
#define DO_PRAGMA(x) DO_PRAGMA_(x)
 | 
					#define DO_PRAGMA(x) DO_PRAGMA_(x)
 | 
				
			||||||
#define thread_num(a) omp_get_thread_num()
 | 
					#define thread_num(a) omp_get_thread_num()
 | 
				
			||||||
#define thread_max(a) omp_get_max_threads()
 | 
					#define thread_max(a) omp_get_max_threads()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										226
									
								
								HMC/FTHMC2p1f.cc
									
									
									
									
									
								
							
							
						
						
									
										226
									
								
								HMC/FTHMC2p1f.cc
									
									
									
									
									
								
							@@ -1,226 +0,0 @@
 | 
				
			|||||||
/*************************************************************************************
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Grid physics library, www.github.com/paboyle/Grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Copyright (C) 2023
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is free software; you can redistribute it and/or modify
 | 
					 | 
				
			||||||
it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
the Free Software Foundation; either version 2 of the License, or
 | 
					 | 
				
			||||||
(at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You should have received a copy of the GNU General Public License along
 | 
					 | 
				
			||||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
					 | 
				
			||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
See the full license in the file "LICENSE" in the top level distribution
 | 
					 | 
				
			||||||
directory
 | 
					 | 
				
			||||||
*************************************************************************************/
 | 
					 | 
				
			||||||
/*  END LEGAL */
 | 
					 | 
				
			||||||
#include <Grid/Grid.h>
 | 
					 | 
				
			||||||
#include <Grid/qcd/smearing/GaugeConfigurationMasked.h>
 | 
					 | 
				
			||||||
#include <Grid/qcd/smearing/JacobianAction.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace Grid;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main(int argc, char **argv)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  std::cout << std::setprecision(12);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Grid_init(&argc, &argv);
 | 
					 | 
				
			||||||
  int threads = GridThread::GetThreads();
 | 
					 | 
				
			||||||
  // here make a routine to print all the relevant information on the run
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   // Typedefs to simplify notation
 | 
					 | 
				
			||||||
  typedef WilsonImplR FermionImplPolicy;
 | 
					 | 
				
			||||||
  typedef MobiusFermionD FermionAction;
 | 
					 | 
				
			||||||
  typedef typename FermionAction::FermionField FermionField;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Grid::XmlReader       Serialiser;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 | 
					 | 
				
			||||||
  IntegratorParameters MD;
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<LeapFrog> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("Leap Frog");
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<ForceGradient> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("Force Gradient");
 | 
					 | 
				
			||||||
  typedef GenericHMCRunner<MinimumNorm2> HMCWrapper;
 | 
					 | 
				
			||||||
  MD.name    = std::string("MinimumNorm2");
 | 
					 | 
				
			||||||
  MD.MDsteps = 24;
 | 
					 | 
				
			||||||
  MD.trajL   = 1.0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  HMCparameters HMCparams;
 | 
					 | 
				
			||||||
  HMCparams.StartTrajectory  = 104;
 | 
					 | 
				
			||||||
  HMCparams.Trajectories     = 200;
 | 
					 | 
				
			||||||
  HMCparams.NoMetropolisUntil=  20;
 | 
					 | 
				
			||||||
  // "[HotStart, ColdStart, TepidStart, CheckpointStart]\n";
 | 
					 | 
				
			||||||
  //  HMCparams.StartingType     =std::string("HotStart");
 | 
					 | 
				
			||||||
  HMCparams.StartingType     =std::string("CheckpointStart");
 | 
					 | 
				
			||||||
  HMCparams.MD = MD;
 | 
					 | 
				
			||||||
  HMCWrapper TheHMC(HMCparams);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Grid from the command line arguments --grid and --mpi
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddFourDimGrid("gauge"); // use default simd lanes decomposition
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  CheckpointerParameters CPparams;
 | 
					 | 
				
			||||||
  CPparams.config_prefix = "ckpoint_EODWF_lat";
 | 
					 | 
				
			||||||
  CPparams.smeared_prefix = "ckpoint_EODWF_lat_smr";
 | 
					 | 
				
			||||||
  CPparams.rng_prefix    = "ckpoint_EODWF_rng";
 | 
					 | 
				
			||||||
  CPparams.saveInterval  = 1;
 | 
					 | 
				
			||||||
  CPparams.saveSmeared   = true;
 | 
					 | 
				
			||||||
  CPparams.format        = "IEEE64BIG";
 | 
					 | 
				
			||||||
  TheHMC.Resources.LoadNerscCheckpointer(CPparams);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  RNGModuleParameters RNGpar;
 | 
					 | 
				
			||||||
  RNGpar.serial_seeds = "1 2 3 4 5";
 | 
					 | 
				
			||||||
  RNGpar.parallel_seeds = "6 7 8 9 10";
 | 
					 | 
				
			||||||
  TheHMC.Resources.SetRNGSeeds(RNGpar);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Construct observables
 | 
					 | 
				
			||||||
  // here there is too much indirection
 | 
					 | 
				
			||||||
  typedef PlaquetteMod<HMCWrapper::ImplPolicy> PlaqObs;
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddObservable<PlaqObs>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int Ls      = 16;
 | 
					 | 
				
			||||||
  Real beta         = 2.13;
 | 
					 | 
				
			||||||
  Real light_mass   = 0.01;
 | 
					 | 
				
			||||||
  Real strange_mass = 0.04;
 | 
					 | 
				
			||||||
  Real pv_mass      = 1.0;
 | 
					 | 
				
			||||||
  RealD M5  = 1.8;
 | 
					 | 
				
			||||||
  RealD b   = 1.0; // Scale factor two
 | 
					 | 
				
			||||||
  RealD c   = 0.0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  OneFlavourRationalParams OFRp;
 | 
					 | 
				
			||||||
  OFRp.lo       = 1.0e-2;
 | 
					 | 
				
			||||||
  OFRp.hi       = 64;
 | 
					 | 
				
			||||||
  OFRp.MaxIter  = 10000;
 | 
					 | 
				
			||||||
  OFRp.tolerance= 1.0e-10;
 | 
					 | 
				
			||||||
  OFRp.degree   = 14;
 | 
					 | 
				
			||||||
  OFRp.precision= 40;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<Real> hasenbusch({ 0.1 });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  auto GridPtr   = TheHMC.Resources.GetCartesian();
 | 
					 | 
				
			||||||
  auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
 | 
					 | 
				
			||||||
  auto FGrid     = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
  auto FrbGrid   = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  IwasakiGaugeActionR GaugeAction(beta);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // temporarily need a gauge field
 | 
					 | 
				
			||||||
  LatticeGaugeField U(GridPtr);
 | 
					 | 
				
			||||||
  LatticeGaugeField Uhot(GridPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // These lines are unecessary if BC are all periodic
 | 
					 | 
				
			||||||
  std::vector<Complex> boundary = {1,1,1,-1};
 | 
					 | 
				
			||||||
  FermionAction::ImplParams Params(boundary);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  double StoppingCondition = 1e-10;
 | 
					 | 
				
			||||||
  double MaxCGIterations = 30000;
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  CG(StoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  bool ApplySmearing = true;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Collect actions
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level1(1);
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level2(2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Strange action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_L (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , strange_mass, strange_mass, pv_mass, 0.0, -1, M5, b, c);
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_R (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , pv_mass, strange_mass,      pv_mass, -1.0, 1, M5, b, c);
 | 
					 | 
				
			||||||
  ExactOneFlavourRatioPseudoFermionAction<FermionImplPolicy> 
 | 
					 | 
				
			||||||
    EOFA(Strange_Op_L, Strange_Op_R, 
 | 
					 | 
				
			||||||
	 CG,
 | 
					 | 
				
			||||||
	 CG, CG,
 | 
					 | 
				
			||||||
	 CG, CG, 
 | 
					 | 
				
			||||||
	 OFRp, false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  EOFA.is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
  Level1.push_back(&EOFA);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // up down action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  std::vector<Real> light_den;
 | 
					 | 
				
			||||||
  std::vector<Real> light_num;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int n_hasenbusch = hasenbusch.size();
 | 
					 | 
				
			||||||
  light_den.push_back(light_mass);
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch;h++){
 | 
					 | 
				
			||||||
    light_den.push_back(hasenbusch[h]);
 | 
					 | 
				
			||||||
    light_num.push_back(hasenbusch[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  light_num.push_back(pv_mass);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Numerators;
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Denominators;
 | 
					 | 
				
			||||||
  std::vector<TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> *> Quotients;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch+1;h++){
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << " 2f quotient Action  "<< light_num[h] << " / " << light_den[h]<< std::endl;
 | 
					 | 
				
			||||||
    Numerators.push_back  (new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_num[h],M5,b,c, Params));
 | 
					 | 
				
			||||||
    Denominators.push_back(new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_den[h],M5,b,c, Params));
 | 
					 | 
				
			||||||
    Quotients.push_back   (new TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy>(*Numerators[h],*Denominators[h],CG,CG));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch+1;h++){
 | 
					 | 
				
			||||||
    Quotients[h]->is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
    Level1.push_back(Quotients[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // lnDetJacobianAction
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  double rho = 0.1;  // smearing parameter
 | 
					 | 
				
			||||||
  int Nsmear = 1;    // number of smearing levels - must be multiple of 2Nd
 | 
					 | 
				
			||||||
  int Nstep  = 8*Nsmear;    // number of smearing levels - must be multiple of 2Nd
 | 
					 | 
				
			||||||
  Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
 | 
					 | 
				
			||||||
  SmearedConfigurationMasked<HMCWrapper::ImplPolicy> SmearingPolicy(GridPtr, Nstep, Stout);
 | 
					 | 
				
			||||||
  JacobianAction<HMCWrapper::ImplPolicy> Jacobian(&SmearingPolicy);
 | 
					 | 
				
			||||||
  if( ApplySmearing ) Level1.push_back(&Jacobian);
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Built the Jacobian "<< std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Gauge action
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  //  GaugeAction.is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
  GaugeAction.is_smeared = true;
 | 
					 | 
				
			||||||
  Level2.push_back(&GaugeAction);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " ************************************************"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Action complete -- NO FERMIONS FOR NOW -- FIXME"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " ************************************************"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage <<  std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage <<  std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Running the FT HMC "<< std::endl;
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level1);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TheHMC.ReadCommandLine(argc,argv);  // params on CML or from param file
 | 
					 | 
				
			||||||
  TheHMC.initializeGaugeFieldAndRNGs(U);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TheHMC.Run(SmearingPolicy); // for smearing
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Grid_finalize();
 | 
					 | 
				
			||||||
} // main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -1,226 +0,0 @@
 | 
				
			|||||||
/*************************************************************************************
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Grid physics library, www.github.com/paboyle/Grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Copyright (C) 2023
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is free software; you can redistribute it and/or modify
 | 
					 | 
				
			||||||
it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
the Free Software Foundation; either version 2 of the License, or
 | 
					 | 
				
			||||||
(at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You should have received a copy of the GNU General Public License along
 | 
					 | 
				
			||||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
					 | 
				
			||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
See the full license in the file "LICENSE" in the top level distribution
 | 
					 | 
				
			||||||
directory
 | 
					 | 
				
			||||||
*************************************************************************************/
 | 
					 | 
				
			||||||
/*  END LEGAL */
 | 
					 | 
				
			||||||
#include <Grid/Grid.h>
 | 
					 | 
				
			||||||
#include <Grid/qcd/smearing/GaugeConfigurationMasked.h>
 | 
					 | 
				
			||||||
#include <Grid/qcd/smearing/JacobianAction.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace Grid;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main(int argc, char **argv)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  std::cout << std::setprecision(12);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Grid_init(&argc, &argv);
 | 
					 | 
				
			||||||
  int threads = GridThread::GetThreads();
 | 
					 | 
				
			||||||
  // here make a routine to print all the relevant information on the run
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   // Typedefs to simplify notation
 | 
					 | 
				
			||||||
  typedef WilsonImplR FermionImplPolicy;
 | 
					 | 
				
			||||||
  typedef MobiusFermionD FermionAction;
 | 
					 | 
				
			||||||
  typedef typename FermionAction::FermionField FermionField;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Grid::XmlReader       Serialiser;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 | 
					 | 
				
			||||||
  IntegratorParameters MD;
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<LeapFrog> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("Leap Frog");
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<ForceGradient> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("Force Gradient");
 | 
					 | 
				
			||||||
  typedef GenericHMCRunner<MinimumNorm2> HMCWrapper;
 | 
					 | 
				
			||||||
  MD.name    = std::string("MinimumNorm2");
 | 
					 | 
				
			||||||
  MD.MDsteps = 24;
 | 
					 | 
				
			||||||
  MD.trajL   = 1.0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  HMCparameters HMCparams;
 | 
					 | 
				
			||||||
  HMCparams.StartTrajectory  = 0;
 | 
					 | 
				
			||||||
  HMCparams.Trajectories     = 200;
 | 
					 | 
				
			||||||
  HMCparams.NoMetropolisUntil=  20;
 | 
					 | 
				
			||||||
  // "[HotStart, ColdStart, TepidStart, CheckpointStart]\n";
 | 
					 | 
				
			||||||
  //  HMCparams.StartingType     =std::string("HotStart");
 | 
					 | 
				
			||||||
  HMCparams.StartingType     =std::string("ColdStart");
 | 
					 | 
				
			||||||
  //  HMCparams.StartingType     =std::string("CheckpointStart");
 | 
					 | 
				
			||||||
  HMCparams.MD = MD;
 | 
					 | 
				
			||||||
  HMCWrapper TheHMC(HMCparams);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Grid from the command line arguments --grid and --mpi
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddFourDimGrid("gauge"); // use default simd lanes decomposition
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  CheckpointerParameters CPparams;
 | 
					 | 
				
			||||||
  CPparams.config_prefix = "ckpoint_EODWF_lat";
 | 
					 | 
				
			||||||
  CPparams.smeared_prefix = "ckpoint_EODWF_lat_smr";
 | 
					 | 
				
			||||||
  CPparams.rng_prefix    = "ckpoint_EODWF_rng";
 | 
					 | 
				
			||||||
  CPparams.saveInterval  = 1;
 | 
					 | 
				
			||||||
  CPparams.saveSmeared   = true;
 | 
					 | 
				
			||||||
  CPparams.format        = "IEEE64BIG";
 | 
					 | 
				
			||||||
  TheHMC.Resources.LoadNerscCheckpointer(CPparams);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  RNGModuleParameters RNGpar;
 | 
					 | 
				
			||||||
  RNGpar.serial_seeds = "1 2 3 4 5";
 | 
					 | 
				
			||||||
  RNGpar.parallel_seeds = "6 7 8 9 10";
 | 
					 | 
				
			||||||
  TheHMC.Resources.SetRNGSeeds(RNGpar);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Construct observables
 | 
					 | 
				
			||||||
  // here there is too much indirection
 | 
					 | 
				
			||||||
  typedef PlaquetteMod<HMCWrapper::ImplPolicy> PlaqObs;
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddObservable<PlaqObs>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int Ls      = 12;
 | 
					 | 
				
			||||||
  Real beta         = 2.37;
 | 
					 | 
				
			||||||
  Real light_mass   = 0.0047;
 | 
					 | 
				
			||||||
  Real strange_mass = 0.0186;
 | 
					 | 
				
			||||||
  Real pv_mass      = 1.0;
 | 
					 | 
				
			||||||
  RealD M5  = 1.8;
 | 
					 | 
				
			||||||
  RealD b   = 1.0; // Scale factor one, Shamir
 | 
					 | 
				
			||||||
  RealD c   = 0.0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  OneFlavourRationalParams OFRp;
 | 
					 | 
				
			||||||
  OFRp.lo       = 1.0e-2;
 | 
					 | 
				
			||||||
  OFRp.hi       = 64;
 | 
					 | 
				
			||||||
  OFRp.MaxIter  = 10000;
 | 
					 | 
				
			||||||
  OFRp.tolerance= 1.0e-10;
 | 
					 | 
				
			||||||
  OFRp.degree   = 14;
 | 
					 | 
				
			||||||
  OFRp.precision= 40;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<Real> hasenbusch({ 0.05, 0.1, 0.25, 0.5 });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  auto GridPtr   = TheHMC.Resources.GetCartesian();
 | 
					 | 
				
			||||||
  auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
 | 
					 | 
				
			||||||
  auto FGrid     = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
  auto FrbGrid   = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  IwasakiGaugeActionR GaugeAction(beta);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // temporarily need a gauge field
 | 
					 | 
				
			||||||
  LatticeGaugeField U(GridPtr);
 | 
					 | 
				
			||||||
  LatticeGaugeField Uhot(GridPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // These lines are unecessary if BC are all periodic
 | 
					 | 
				
			||||||
  std::vector<Complex> boundary = {1,1,1,-1};
 | 
					 | 
				
			||||||
  FermionAction::ImplParams Params(boundary);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  double StoppingCondition = 1e-10;
 | 
					 | 
				
			||||||
  double MaxCGIterations = 30000;
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  CG(StoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  bool ApplySmearing = true;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Collect actions
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level1(1);
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level2(2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Strange action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_L (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , strange_mass, strange_mass, pv_mass, 0.0, -1, M5, b, c);
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_R (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , pv_mass, strange_mass,      pv_mass, -1.0, 1, M5, b, c);
 | 
					 | 
				
			||||||
  ExactOneFlavourRatioPseudoFermionAction<FermionImplPolicy> 
 | 
					 | 
				
			||||||
    EOFA(Strange_Op_L, Strange_Op_R, 
 | 
					 | 
				
			||||||
	 CG,
 | 
					 | 
				
			||||||
	 CG, CG,
 | 
					 | 
				
			||||||
	 CG, CG, 
 | 
					 | 
				
			||||||
	 OFRp, false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  EOFA.is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
  Level1.push_back(&EOFA);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // up down action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  std::vector<Real> light_den;
 | 
					 | 
				
			||||||
  std::vector<Real> light_num;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int n_hasenbusch = hasenbusch.size();
 | 
					 | 
				
			||||||
  light_den.push_back(light_mass);
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch;h++){
 | 
					 | 
				
			||||||
    light_den.push_back(hasenbusch[h]);
 | 
					 | 
				
			||||||
    light_num.push_back(hasenbusch[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  light_num.push_back(pv_mass);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Numerators;
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Denominators;
 | 
					 | 
				
			||||||
  std::vector<TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> *> Quotients;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch+1;h++){
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << " 2f quotient Action  "<< light_num[h] << " / " << light_den[h]<< std::endl;
 | 
					 | 
				
			||||||
    Numerators.push_back  (new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_num[h],M5,b,c, Params));
 | 
					 | 
				
			||||||
    Denominators.push_back(new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_den[h],M5,b,c, Params));
 | 
					 | 
				
			||||||
    Quotients.push_back   (new TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy>(*Numerators[h],*Denominators[h],CG,CG));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch+1;h++){
 | 
					 | 
				
			||||||
    Quotients[h]->is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
    Level1.push_back(Quotients[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // lnDetJacobianAction
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  double rho = 0.1;  // smearing parameter
 | 
					 | 
				
			||||||
  int Nsmear = 1;    // number of smearing levels - must be multiple of 2Nd
 | 
					 | 
				
			||||||
  int Nstep  = 8*Nsmear;    // number of smearing levels - must be multiple of 2Nd
 | 
					 | 
				
			||||||
  Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
 | 
					 | 
				
			||||||
  SmearedConfigurationMasked<HMCWrapper::ImplPolicy> SmearingPolicy(GridPtr, Nstep, Stout);
 | 
					 | 
				
			||||||
  JacobianAction<HMCWrapper::ImplPolicy> Jacobian(&SmearingPolicy);
 | 
					 | 
				
			||||||
  if( ApplySmearing ) Level1.push_back(&Jacobian);
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Built the Jacobian "<< std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Gauge action
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  GaugeAction.is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
  Level2.push_back(&GaugeAction);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " ************************************************"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Action complete -- NO FERMIONS FOR NOW -- FIXME"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " ************************************************"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage <<  std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage <<  std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Running the FT HMC "<< std::endl;
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level1);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TheHMC.ReadCommandLine(argc,argv);  // params on CML or from param file
 | 
					 | 
				
			||||||
  TheHMC.initializeGaugeFieldAndRNGs(U);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TheHMC.Run(SmearingPolicy); // for smearing
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Grid_finalize();
 | 
					 | 
				
			||||||
} // main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -1,226 +0,0 @@
 | 
				
			|||||||
/*************************************************************************************
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Grid physics library, www.github.com/paboyle/Grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Copyright (C) 2023
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is free software; you can redistribute it and/or modify
 | 
					 | 
				
			||||||
it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
the Free Software Foundation; either version 2 of the License, or
 | 
					 | 
				
			||||||
(at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You should have received a copy of the GNU General Public License along
 | 
					 | 
				
			||||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
					 | 
				
			||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
See the full license in the file "LICENSE" in the top level distribution
 | 
					 | 
				
			||||||
directory
 | 
					 | 
				
			||||||
*************************************************************************************/
 | 
					 | 
				
			||||||
/*  END LEGAL */
 | 
					 | 
				
			||||||
#include <Grid/Grid.h>
 | 
					 | 
				
			||||||
#include <Grid/qcd/smearing/GaugeConfigurationMasked.h>
 | 
					 | 
				
			||||||
#include <Grid/qcd/smearing/JacobianAction.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace Grid;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main(int argc, char **argv)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  std::cout << std::setprecision(12);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Grid_init(&argc, &argv);
 | 
					 | 
				
			||||||
  int threads = GridThread::GetThreads();
 | 
					 | 
				
			||||||
  // here make a routine to print all the relevant information on the run
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   // Typedefs to simplify notation
 | 
					 | 
				
			||||||
  typedef WilsonImplR FermionImplPolicy;
 | 
					 | 
				
			||||||
  typedef MobiusFermionD FermionAction;
 | 
					 | 
				
			||||||
  typedef typename FermionAction::FermionField FermionField;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Grid::XmlReader       Serialiser;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 | 
					 | 
				
			||||||
  IntegratorParameters MD;
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<LeapFrog> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("Leap Frog");
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<ForceGradient> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("Force Gradient");
 | 
					 | 
				
			||||||
  typedef GenericHMCRunner<MinimumNorm2> HMCWrapper;
 | 
					 | 
				
			||||||
  MD.name    = std::string("MinimumNorm2");
 | 
					 | 
				
			||||||
  MD.MDsteps = 24;
 | 
					 | 
				
			||||||
  MD.trajL   = 1.0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  HMCparameters HMCparams;
 | 
					 | 
				
			||||||
  HMCparams.StartTrajectory  = 0;
 | 
					 | 
				
			||||||
  HMCparams.Trajectories     = 200;
 | 
					 | 
				
			||||||
  HMCparams.NoMetropolisUntil=  20;
 | 
					 | 
				
			||||||
  // "[HotStart, ColdStart, TepidStart, CheckpointStart]\n";
 | 
					 | 
				
			||||||
  //  HMCparams.StartingType     =std::string("HotStart");
 | 
					 | 
				
			||||||
  HMCparams.StartingType     =std::string("ColdStart");
 | 
					 | 
				
			||||||
  //  HMCparams.StartingType     =std::string("CheckpointStart");
 | 
					 | 
				
			||||||
  HMCparams.MD = MD;
 | 
					 | 
				
			||||||
  HMCWrapper TheHMC(HMCparams);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Grid from the command line arguments --grid and --mpi
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddFourDimGrid("gauge"); // use default simd lanes decomposition
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  CheckpointerParameters CPparams;
 | 
					 | 
				
			||||||
  CPparams.config_prefix = "ckpoint_EODWF_lat";
 | 
					 | 
				
			||||||
  CPparams.smeared_prefix = "ckpoint_EODWF_lat_smr";
 | 
					 | 
				
			||||||
  CPparams.rng_prefix    = "ckpoint_EODWF_rng";
 | 
					 | 
				
			||||||
  CPparams.saveInterval  = 1;
 | 
					 | 
				
			||||||
  CPparams.saveSmeared   = true;
 | 
					 | 
				
			||||||
  CPparams.format        = "IEEE64BIG";
 | 
					 | 
				
			||||||
  TheHMC.Resources.LoadNerscCheckpointer(CPparams);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  RNGModuleParameters RNGpar;
 | 
					 | 
				
			||||||
  RNGpar.serial_seeds = "1 2 3 4 5";
 | 
					 | 
				
			||||||
  RNGpar.parallel_seeds = "6 7 8 9 10";
 | 
					 | 
				
			||||||
  TheHMC.Resources.SetRNGSeeds(RNGpar);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Construct observables
 | 
					 | 
				
			||||||
  // here there is too much indirection
 | 
					 | 
				
			||||||
  typedef PlaquetteMod<HMCWrapper::ImplPolicy> PlaqObs;
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddObservable<PlaqObs>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int Ls      = 12;
 | 
					 | 
				
			||||||
  Real beta         = 2.37;
 | 
					 | 
				
			||||||
  Real light_mass   = 0.0047;
 | 
					 | 
				
			||||||
  Real strange_mass = 0.0186;
 | 
					 | 
				
			||||||
  Real pv_mass      = 1.0;
 | 
					 | 
				
			||||||
  RealD M5  = 1.8;
 | 
					 | 
				
			||||||
  RealD b   = 1.0; // Scale factor one, Shamir
 | 
					 | 
				
			||||||
  RealD c   = 0.0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  OneFlavourRationalParams OFRp;
 | 
					 | 
				
			||||||
  OFRp.lo       = 1.0e-2;
 | 
					 | 
				
			||||||
  OFRp.hi       = 64;
 | 
					 | 
				
			||||||
  OFRp.MaxIter  = 10000;
 | 
					 | 
				
			||||||
  OFRp.tolerance= 1.0e-10;
 | 
					 | 
				
			||||||
  OFRp.degree   = 14;
 | 
					 | 
				
			||||||
  OFRp.precision= 40;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<Real> hasenbusch({ 0.05, 0.1, 0.25, 0.5 });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  auto GridPtr   = TheHMC.Resources.GetCartesian();
 | 
					 | 
				
			||||||
  auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
 | 
					 | 
				
			||||||
  auto FGrid     = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
  auto FrbGrid   = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  IwasakiGaugeActionR GaugeAction(beta);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // temporarily need a gauge field
 | 
					 | 
				
			||||||
  LatticeGaugeField U(GridPtr);
 | 
					 | 
				
			||||||
  LatticeGaugeField Uhot(GridPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // These lines are unecessary if BC are all periodic
 | 
					 | 
				
			||||||
  std::vector<Complex> boundary = {1,1,1,-1};
 | 
					 | 
				
			||||||
  FermionAction::ImplParams Params(boundary);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  double StoppingCondition = 1e-10;
 | 
					 | 
				
			||||||
  double MaxCGIterations = 30000;
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  CG(StoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  bool ApplySmearing = false;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Collect actions
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level1(1);
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level2(2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Strange action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_L (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , strange_mass, strange_mass, pv_mass, 0.0, -1, M5, b, c);
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_R (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , pv_mass, strange_mass,      pv_mass, -1.0, 1, M5, b, c);
 | 
					 | 
				
			||||||
  ExactOneFlavourRatioPseudoFermionAction<FermionImplPolicy> 
 | 
					 | 
				
			||||||
    EOFA(Strange_Op_L, Strange_Op_R, 
 | 
					 | 
				
			||||||
	 CG,
 | 
					 | 
				
			||||||
	 CG, CG,
 | 
					 | 
				
			||||||
	 CG, CG, 
 | 
					 | 
				
			||||||
	 OFRp, false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  EOFA.is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
  Level1.push_back(&EOFA);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // up down action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  std::vector<Real> light_den;
 | 
					 | 
				
			||||||
  std::vector<Real> light_num;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int n_hasenbusch = hasenbusch.size();
 | 
					 | 
				
			||||||
  light_den.push_back(light_mass);
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch;h++){
 | 
					 | 
				
			||||||
    light_den.push_back(hasenbusch[h]);
 | 
					 | 
				
			||||||
    light_num.push_back(hasenbusch[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  light_num.push_back(pv_mass);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Numerators;
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Denominators;
 | 
					 | 
				
			||||||
  std::vector<TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> *> Quotients;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch+1;h++){
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage << " 2f quotient Action  "<< light_num[h] << " / " << light_den[h]<< std::endl;
 | 
					 | 
				
			||||||
    Numerators.push_back  (new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_num[h],M5,b,c, Params));
 | 
					 | 
				
			||||||
    Denominators.push_back(new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_den[h],M5,b,c, Params));
 | 
					 | 
				
			||||||
    Quotients.push_back   (new TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy>(*Numerators[h],*Denominators[h],CG,CG));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch+1;h++){
 | 
					 | 
				
			||||||
    Quotients[h]->is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
    Level1.push_back(Quotients[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // lnDetJacobianAction
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  double rho = 0.1;  // smearing parameter
 | 
					 | 
				
			||||||
  int Nsmear = 1;    // number of smearing levels - must be multiple of 2Nd
 | 
					 | 
				
			||||||
  int Nstep  = 8*Nsmear;    // number of smearing levels - must be multiple of 2Nd
 | 
					 | 
				
			||||||
  Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
 | 
					 | 
				
			||||||
  SmearedConfigurationMasked<HMCWrapper::ImplPolicy> SmearingPolicy(GridPtr, Nstep, Stout);
 | 
					 | 
				
			||||||
  JacobianAction<HMCWrapper::ImplPolicy> Jacobian(&SmearingPolicy);
 | 
					 | 
				
			||||||
  if( ApplySmearing ) Level1.push_back(&Jacobian);
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Built the Jacobian "<< std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Gauge action
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  GaugeAction.is_smeared = ApplySmearing;
 | 
					 | 
				
			||||||
  Level2.push_back(&GaugeAction);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " ************************************************"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Action complete -- NO FERMIONS FOR NOW -- FIXME"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " ************************************************"<< std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage <<  std::endl;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage <<  std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Running the FT HMC "<< std::endl;
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level1);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TheHMC.ReadCommandLine(argc,argv);  // params on CML or from param file
 | 
					 | 
				
			||||||
  TheHMC.initializeGaugeFieldAndRNGs(U);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TheHMC.Run(SmearingPolicy); // for smearing
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Grid_finalize();
 | 
					 | 
				
			||||||
} // main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -1,350 +0,0 @@
 | 
				
			|||||||
/*************************************************************************************
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Grid physics library, www.github.com/paboyle/Grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Source file: ./tests/Test_hmc_EODWFRatio.cc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Copyright (C) 2015-2016
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
 | 
					 | 
				
			||||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is free software; you can redistribute it and/or modify
 | 
					 | 
				
			||||||
it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
the Free Software Foundation; either version 2 of the License, or
 | 
					 | 
				
			||||||
(at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You should have received a copy of the GNU General Public License along
 | 
					 | 
				
			||||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
					 | 
				
			||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
See the full license in the file "LICENSE" in the top level distribution
 | 
					 | 
				
			||||||
directory
 | 
					 | 
				
			||||||
*************************************************************************************/
 | 
					 | 
				
			||||||
/*  END LEGAL */
 | 
					 | 
				
			||||||
#include <Grid/Grid.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main(int argc, char **argv) {
 | 
					 | 
				
			||||||
  using namespace Grid;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Grid_init(&argc, &argv);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  CartesianCommunicator::BarrierWorld();
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Clock skew check" <<std::endl;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  int threads = GridThread::GetThreads();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   // Typedefs to simplify notation
 | 
					 | 
				
			||||||
  typedef WilsonImplD FermionImplPolicy;
 | 
					 | 
				
			||||||
  typedef MobiusFermionD FermionAction;
 | 
					 | 
				
			||||||
  typedef MobiusEOFAFermionD FermionEOFAAction;
 | 
					 | 
				
			||||||
  typedef typename FermionAction::FermionField FermionField;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Grid::XmlReader       Serialiser;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 | 
					 | 
				
			||||||
  IntegratorParameters MD;
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<LeapFrog> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("Leap Frog");
 | 
					 | 
				
			||||||
  typedef GenericHMCRunner<ForceGradient> HMCWrapper;
 | 
					 | 
				
			||||||
  MD.name    = std::string("Force Gradient");
 | 
					 | 
				
			||||||
  //typedef GenericHMCRunner<MinimumNorm2> HMCWrapper;
 | 
					 | 
				
			||||||
  // MD.name    = std::string("MinimumNorm2");
 | 
					 | 
				
			||||||
  // TrajL = 2
 | 
					 | 
				
			||||||
  // 4/2 => 0.6 dH
 | 
					 | 
				
			||||||
  // 3/3 => 0.8 dH .. depth 3, slower
 | 
					 | 
				
			||||||
  //MD.MDsteps =  4;
 | 
					 | 
				
			||||||
  MD.MDsteps =  3;
 | 
					 | 
				
			||||||
  MD.trajL   = 0.5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  HMCparameters HMCparams;
 | 
					 | 
				
			||||||
  HMCparams.StartTrajectory  = 1077;
 | 
					 | 
				
			||||||
  HMCparams.Trajectories     = 1;
 | 
					 | 
				
			||||||
  HMCparams.NoMetropolisUntil=  0;
 | 
					 | 
				
			||||||
  // "[HotStart, ColdStart, TepidStart, CheckpointStart]\n";
 | 
					 | 
				
			||||||
  //  HMCparams.StartingType     =std::string("ColdStart");
 | 
					 | 
				
			||||||
  HMCparams.StartingType     =std::string("CheckpointStart");
 | 
					 | 
				
			||||||
  HMCparams.MD = MD;
 | 
					 | 
				
			||||||
  HMCWrapper TheHMC(HMCparams);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Grid from the command line arguments --grid and --mpi
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddFourDimGrid("gauge"); // use default simd lanes decomposition
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  CheckpointerParameters CPparams;
 | 
					 | 
				
			||||||
  CPparams.config_prefix = "ckpoint_DDHMC_lat";
 | 
					 | 
				
			||||||
  CPparams.rng_prefix    = "ckpoint_DDHMC_rng";
 | 
					 | 
				
			||||||
  CPparams.saveInterval  = 1;
 | 
					 | 
				
			||||||
  CPparams.format        = "IEEE64BIG";
 | 
					 | 
				
			||||||
  TheHMC.Resources.LoadNerscCheckpointer(CPparams);
 | 
					 | 
				
			||||||
  std::cout << "loaded NERSC checpointer"<<std::endl;
 | 
					 | 
				
			||||||
  RNGModuleParameters RNGpar;
 | 
					 | 
				
			||||||
  RNGpar.serial_seeds = "1 2 3 4 5";
 | 
					 | 
				
			||||||
  RNGpar.parallel_seeds = "6 7 8 9 10";
 | 
					 | 
				
			||||||
  TheHMC.Resources.SetRNGSeeds(RNGpar);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Construct observables
 | 
					 | 
				
			||||||
  // here there is too much indirection
 | 
					 | 
				
			||||||
  typedef PlaquetteMod<HMCWrapper::ImplPolicy> PlaqObs;
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddObservable<PlaqObs>();
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int Ls      = 12;
 | 
					 | 
				
			||||||
  RealD M5  = 1.8;
 | 
					 | 
				
			||||||
  RealD b   = 1.5;
 | 
					 | 
				
			||||||
  RealD c   = 0.5;
 | 
					 | 
				
			||||||
  Real beta         = 2.13;
 | 
					 | 
				
			||||||
  //  Real light_mass   = 5.4e-4;
 | 
					 | 
				
			||||||
  Real light_mass     = 7.8e-4;
 | 
					 | 
				
			||||||
  Real light_mass_dir = 0.01;
 | 
					 | 
				
			||||||
  Real strange_mass = 0.0362;
 | 
					 | 
				
			||||||
  Real pv_mass      = 1.0;
 | 
					 | 
				
			||||||
  std::vector<Real> hasenbusch({ 0.01, 0.045, 0.108, 0.25, 0.51 , pv_mass });
 | 
					 | 
				
			||||||
  //  std::vector<Real> hasenbusch({ light_mass, 0.01, 0.045, 0.108, 0.25, 0.51 , pv_mass });
 | 
					 | 
				
			||||||
  //  std::vector<Real> hasenbusch({ light_mass, 0.005, 0.0145, 0.045, 0.108, 0.25, 0.51 , pv_mass }); // Updated
 | 
					 | 
				
			||||||
  //  std::vector<Real> hasenbusch({ light_mass, 0.0145, 0.045, 0.108, 0.25, 0.51 , 0.75 , pv_mass });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int SP_iters=9000;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  RationalActionParams OFRp; // Up/down
 | 
					 | 
				
			||||||
  OFRp.lo       = 6.0e-5;
 | 
					 | 
				
			||||||
  OFRp.hi       = 90.0;
 | 
					 | 
				
			||||||
  OFRp.inv_pow  = 2;
 | 
					 | 
				
			||||||
  OFRp.MaxIter  = SP_iters; // get most shifts by 2000, stop sharing space
 | 
					 | 
				
			||||||
  OFRp.action_tolerance= 1.0e-8;
 | 
					 | 
				
			||||||
  OFRp.action_degree   = 18;
 | 
					 | 
				
			||||||
  OFRp.md_tolerance= 1.0e-7;
 | 
					 | 
				
			||||||
  OFRp.md_degree   = 14;
 | 
					 | 
				
			||||||
  //  OFRp.degree   = 20; converges
 | 
					 | 
				
			||||||
  //  OFRp.degree   = 16;
 | 
					 | 
				
			||||||
  OFRp.precision= 80;
 | 
					 | 
				
			||||||
  OFRp.BoundsCheckFreq=0;
 | 
					 | 
				
			||||||
  std::vector<RealD> ActionTolByPole({
 | 
					 | 
				
			||||||
      //      1.0e-8,1.0e-8,1.0e-8,1.0e-8,
 | 
					 | 
				
			||||||
      3.0e-7,1.0e-7,1.0e-8,1.0e-8,
 | 
					 | 
				
			||||||
      1.0e-8,1.0e-8,1.0e-8,1.0e-8,
 | 
					 | 
				
			||||||
      1.0e-8,1.0e-8,1.0e-8,1.0e-8,
 | 
					 | 
				
			||||||
      1.0e-8,1.0e-8,1.0e-8,1.0e-8,
 | 
					 | 
				
			||||||
      1.0e-8,1.0e-8
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  std::vector<RealD> MDTolByPole({
 | 
					 | 
				
			||||||
      //      1.6e-5,5.0e-6,1.0e-6,3.0e-7, // soften convergence more more
 | 
					 | 
				
			||||||
      //      1.0e-6,3.0e-7,1.0e-7,1.0e-7,
 | 
					 | 
				
			||||||
      1.0e-5,1.0e-6,1.0e-7,1.0e-7, // soften convergence
 | 
					 | 
				
			||||||
      1.0e-8,1.0e-8,1.0e-8,1.0e-8,
 | 
					 | 
				
			||||||
      1.0e-8,1.0e-8,1.0e-8,1.0e-8,
 | 
					 | 
				
			||||||
      1.0e-8,1.0e-8
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  auto GridPtr   = TheHMC.Resources.GetCartesian();
 | 
					 | 
				
			||||||
  auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef SchurDiagMooeeOperator<FermionAction ,FermionField > LinearOperatorD;
 | 
					 | 
				
			||||||
  typedef SchurDiagMooeeOperator<FermionEOFAAction ,FermionField > LinearOperatorEOFAD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Domain decomposed
 | 
					 | 
				
			||||||
  ////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  Coordinate latt4  = GridPtr->GlobalDimensions();
 | 
					 | 
				
			||||||
  Coordinate mpi    = GridPtr->ProcessorGrid();
 | 
					 | 
				
			||||||
  Coordinate shm;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  GlobalSharedMemory::GetShmDims(mpi,shm);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Coordinate CommDim(Nd);
 | 
					 | 
				
			||||||
  for(int d=0;d<Nd;d++) CommDim[d]= (mpi[d]/shm[d])>1 ? 1 : 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Coordinate NonDirichlet(Nd+1,0);
 | 
					 | 
				
			||||||
  Coordinate Dirichlet(Nd+1,0);
 | 
					 | 
				
			||||||
  Dirichlet[1] = CommDim[0]*latt4[0]/mpi[0] * shm[0];
 | 
					 | 
				
			||||||
  Dirichlet[2] = CommDim[1]*latt4[1]/mpi[1] * shm[1];
 | 
					 | 
				
			||||||
  Dirichlet[3] = CommDim[2]*latt4[2]/mpi[2] * shm[2];
 | 
					 | 
				
			||||||
  Dirichlet[4] = CommDim[3]*latt4[3]/mpi[3] * shm[3];
 | 
					 | 
				
			||||||
  //Dirichlet[1] = 0;
 | 
					 | 
				
			||||||
  //Dirichlet[2] = 0;
 | 
					 | 
				
			||||||
  //Dirichlet[3] = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // 
 | 
					 | 
				
			||||||
  Coordinate Block4(Nd);
 | 
					 | 
				
			||||||
  Block4[0] = Dirichlet[1];
 | 
					 | 
				
			||||||
  Block4[1] = Dirichlet[2];
 | 
					 | 
				
			||||||
  Block4[2] = Dirichlet[3];
 | 
					 | 
				
			||||||
  Block4[3] = Dirichlet[4];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int Width=4;
 | 
					 | 
				
			||||||
  TheHMC.Resources.SetMomentumFilter(new DDHMCFilter<WilsonImplD::Field>(Block4,Width));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////
 | 
					 | 
				
			||||||
  // Fermion Grids
 | 
					 | 
				
			||||||
  //////////////////////////
 | 
					 | 
				
			||||||
  auto FGrid     = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
  auto FrbGrid   = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  IwasakiGaugeActionR GaugeAction(beta);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // temporarily need a gauge field
 | 
					 | 
				
			||||||
  LatticeGaugeFieldD  U(GridPtr); U=Zero();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Running the HMC "<< std::endl;
 | 
					 | 
				
			||||||
  TheHMC.ReadCommandLine(argc,argv);  // params on CML or from param file
 | 
					 | 
				
			||||||
  TheHMC.initializeGaugeFieldAndRNGs(U);
 | 
					 | 
				
			||||||
  std::cout << "loaded NERSC gauge field"<<std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // These lines are unecessary if BC are all periodic
 | 
					 | 
				
			||||||
  std::vector<Complex> boundary = {1,1,1,-1};
 | 
					 | 
				
			||||||
  FermionAction::ImplParams Params(boundary);
 | 
					 | 
				
			||||||
  FermionAction::ImplParams ParamsDir(boundary);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Params.dirichlet=NonDirichlet;
 | 
					 | 
				
			||||||
  ParamsDir.dirichlet=Dirichlet;
 | 
					 | 
				
			||||||
  ParamsDir.partialDirichlet=0;
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage<< "Partial Dirichlet depth is "<<dwf_compressor_depth<<std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //  double StoppingCondition = 1e-14;
 | 
					 | 
				
			||||||
  //  double MDStoppingCondition = 1e-9;
 | 
					 | 
				
			||||||
  double StoppingCondition = 1e-8;
 | 
					 | 
				
			||||||
  double MDStoppingCondition = 1e-8;
 | 
					 | 
				
			||||||
  double MDStoppingConditionLoose = 1e-8;
 | 
					 | 
				
			||||||
  double MDStoppingConditionStrange = 1e-8;
 | 
					 | 
				
			||||||
  double MaxCGIterations = 300000;
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  CG(StoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  MDCG(MDStoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Collect actions
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level1(1);
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level2(3);
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level3(15);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Strange action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  FermionAction StrangeOp (U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,strange_mass,M5,b,c, Params);
 | 
					 | 
				
			||||||
  FermionAction StrangePauliVillarsOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,pv_mass,  M5,b,c, Params);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Probably dominates the force - back to EOFA.
 | 
					 | 
				
			||||||
  OneFlavourRationalParams SFRp;
 | 
					 | 
				
			||||||
  SFRp.lo       = 0.1;
 | 
					 | 
				
			||||||
  SFRp.hi       = 25.0;
 | 
					 | 
				
			||||||
  SFRp.MaxIter  = 10000;
 | 
					 | 
				
			||||||
  SFRp.tolerance= 1.0e-8;
 | 
					 | 
				
			||||||
  SFRp.mdtolerance= 2.0e-6;
 | 
					 | 
				
			||||||
  SFRp.degree   = 12;
 | 
					 | 
				
			||||||
  SFRp.precision= 50;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_L (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , strange_mass, strange_mass, pv_mass, 0.0, -1, M5, b, c);
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_R (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , pv_mass, strange_mass,      pv_mass, -1.0, 1, M5, b, c);
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>      ActionCG(StoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  DerivativeCG(MDStoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
  LinearOperatorEOFAD Strange_LinOp_L (Strange_Op_L);
 | 
					 | 
				
			||||||
  LinearOperatorEOFAD Strange_LinOp_R (Strange_Op_R);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ExactOneFlavourRatioPseudoFermionAction<FermionImplPolicy> 
 | 
					 | 
				
			||||||
    EOFA(Strange_Op_L, Strange_Op_R, 
 | 
					 | 
				
			||||||
	 ActionCG, 
 | 
					 | 
				
			||||||
	 ActionCG, ActionCG,
 | 
					 | 
				
			||||||
	 DerivativeCG, DerivativeCG,
 | 
					 | 
				
			||||||
	 SFRp, true);
 | 
					 | 
				
			||||||
  Level2.push_back(&EOFA);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // up down action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  std::vector<Real> light_den;
 | 
					 | 
				
			||||||
  std::vector<Real> light_num;
 | 
					 | 
				
			||||||
  std::vector<int> dirichlet_den;
 | 
					 | 
				
			||||||
  std::vector<int> dirichlet_num;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int n_hasenbusch = hasenbusch.size();
 | 
					 | 
				
			||||||
  light_den.push_back(light_mass);  dirichlet_den.push_back(0);
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch;h++){
 | 
					 | 
				
			||||||
    light_den.push_back(hasenbusch[h]); dirichlet_den.push_back(1);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch;h++){
 | 
					 | 
				
			||||||
    light_num.push_back(hasenbusch[h]); dirichlet_num.push_back(1);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  light_num.push_back(pv_mass);  dirichlet_num.push_back(0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Numerators;
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Denominators;
 | 
					 | 
				
			||||||
  std::vector<TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> *> Quotients;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  std::vector<GeneralEvenOddRatioRationalPseudoFermionAction<FermionImplPolicy> *> Bdys;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef SchurDiagMooeeOperator<FermionAction ,FermionField > LinearOperatorD;
 | 
					 | 
				
			||||||
  std::vector<LinearOperatorD *> LinOpD;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch+1;h++){
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage
 | 
					 | 
				
			||||||
	      << " 2f quotient Action ";
 | 
					 | 
				
			||||||
    std::cout << "det D("<<light_den[h]<<")";
 | 
					 | 
				
			||||||
    if ( dirichlet_den[h] ) std::cout << "^dirichlet    ";
 | 
					 | 
				
			||||||
    std::cout << "/ det D("<<light_num[h]<<")";
 | 
					 | 
				
			||||||
    if ( dirichlet_num[h] ) std::cout << "^dirichlet    ";
 | 
					 | 
				
			||||||
    std::cout << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    FermionAction::ImplParams ParamsNum(boundary);
 | 
					 | 
				
			||||||
    FermionAction::ImplParams ParamsDen(boundary);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if ( dirichlet_num[h]==1) ParamsNum.dirichlet = Dirichlet;
 | 
					 | 
				
			||||||
    else                      ParamsNum.dirichlet = NonDirichlet;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if ( dirichlet_den[h]==1) ParamsDen.dirichlet = Dirichlet;
 | 
					 | 
				
			||||||
    else                      ParamsDen.dirichlet = NonDirichlet;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if ( dirichlet_num[h]==1) ParamsNum.partialDirichlet = 1;
 | 
					 | 
				
			||||||
    else                      ParamsNum.partialDirichlet = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if ( dirichlet_den[h]==1) ParamsDen.partialDirichlet = 1;
 | 
					 | 
				
			||||||
    else                      ParamsDen.partialDirichlet = 0;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    Numerators.push_back  (new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_num[h],M5,b,c, ParamsNum));
 | 
					 | 
				
			||||||
    Denominators.push_back(new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_den[h],M5,b,c, ParamsDen));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LinOpD.push_back(new LinearOperatorD(*Denominators[h]));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    double conv  = MDStoppingCondition;
 | 
					 | 
				
			||||||
    if (h<3) conv= MDStoppingConditionLoose; // Relax on first two hasenbusch factors
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if(h!=0) {
 | 
					 | 
				
			||||||
      Quotients.push_back (new TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy>(*Numerators[h],*Denominators[h],MDCG,CG));
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      Bdys.push_back( new GeneralEvenOddRatioRationalPseudoFermionAction<FermionImplPolicy>(*Numerators[h],*Denominators[h],OFRp));
 | 
					 | 
				
			||||||
      Bdys.push_back( new GeneralEvenOddRatioRationalPseudoFermionAction<FermionImplPolicy>(*Numerators[h],*Denominators[h],OFRp));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  for(int h=0;h<Bdys.size();h++){
 | 
					 | 
				
			||||||
    Bdys[h]->SetTolerances(ActionTolByPole,MDTolByPole);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  int nquo=Quotients.size();
 | 
					 | 
				
			||||||
  Level1.push_back(Bdys[0]);
 | 
					 | 
				
			||||||
  Level1.push_back(Bdys[1]);
 | 
					 | 
				
			||||||
  Level2.push_back(Quotients[0]);
 | 
					 | 
				
			||||||
  for(int h=1;h<nquo-1;h++){
 | 
					 | 
				
			||||||
    Level2.push_back(Quotients[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  Level2.push_back(Quotients[nquo-1]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Gauge action
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  Level3.push_back(&GaugeAction);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level1);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level2);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level3);
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Action complete "<< std::endl;
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TheHMC.Run();  // no smearing
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Grid_finalize();
 | 
					 | 
				
			||||||
} // main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -343,7 +343,7 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
  // Probably dominates the force - back to EOFA.
 | 
					  // Probably dominates the force - back to EOFA.
 | 
				
			||||||
  OneFlavourRationalParams SFRp;
 | 
					  OneFlavourRationalParams SFRp;
 | 
				
			||||||
  SFRp.lo       = 0.1;
 | 
					  SFRp.lo       = 0.1;
 | 
				
			||||||
  SFRp.hi       = 30.0;
 | 
					  SFRp.hi       = 25.0;
 | 
				
			||||||
  SFRp.MaxIter  = 10000;
 | 
					  SFRp.MaxIter  = 10000;
 | 
				
			||||||
  SFRp.tolerance= 1.0e-5;
 | 
					  SFRp.tolerance= 1.0e-5;
 | 
				
			||||||
  SFRp.mdtolerance= 2.0e-4;
 | 
					  SFRp.mdtolerance= 2.0e-4;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -128,7 +128,7 @@ template<class FermionOperatorD, class FermionOperatorF, class SchurOperatorD, c
 | 
				
			|||||||
      ////////////////////////////////////////////////////////////////////////////////////
 | 
					      ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
      // Make a mixed precision conjugate gradient
 | 
					      // Make a mixed precision conjugate gradient
 | 
				
			||||||
      ////////////////////////////////////////////////////////////////////////////////////
 | 
					      ////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
#if 0
 | 
					#if 1
 | 
				
			||||||
      RealD delta=1.e-4;
 | 
					      RealD delta=1.e-4;
 | 
				
			||||||
      std::cout << GridLogMessage << "Calling reliable update Conjugate Gradient" <<std::endl;
 | 
					      std::cout << GridLogMessage << "Calling reliable update Conjugate Gradient" <<std::endl;
 | 
				
			||||||
      ConjugateGradientReliableUpdate<FieldD,FieldF> MPCG(Tolerance,MaxInnerIterations*MaxOuterIterations,delta,SinglePrecGrid5,LinOpF,LinOpD);
 | 
					      ConjugateGradientReliableUpdate<FieldD,FieldF> MPCG(Tolerance,MaxInnerIterations*MaxOuterIterations,delta,SinglePrecGrid5,LinOpF,LinOpD);
 | 
				
			||||||
@@ -146,8 +146,6 @@ NAMESPACE_END(Grid);
 | 
				
			|||||||
int main(int argc, char **argv) {
 | 
					int main(int argc, char **argv) {
 | 
				
			||||||
  using namespace Grid;
 | 
					  using namespace Grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  std::cout << " Grid Initialise "<<std::endl;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Grid_init(&argc, &argv);
 | 
					  Grid_init(&argc, &argv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  CartesianCommunicator::BarrierWorld();
 | 
					  CartesianCommunicator::BarrierWorld();
 | 
				
			||||||
@@ -172,10 +170,10 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
  IntegratorParameters MD;
 | 
					  IntegratorParameters MD;
 | 
				
			||||||
  //  typedef GenericHMCRunner<LeapFrog> HMCWrapper;
 | 
					  //  typedef GenericHMCRunner<LeapFrog> HMCWrapper;
 | 
				
			||||||
  //  MD.name    = std::string("Leap Frog");
 | 
					  //  MD.name    = std::string("Leap Frog");
 | 
				
			||||||
  //  typedef GenericHMCRunner<ForceGradient> HMCWrapper;
 | 
					  typedef GenericHMCRunner<ForceGradient> HMCWrapper;
 | 
				
			||||||
  //  MD.name    = std::string("Force Gradient");
 | 
					  MD.name    = std::string("Force Gradient");
 | 
				
			||||||
  typedef GenericHMCRunner<MinimumNorm2> HMCWrapper;
 | 
					  //typedef GenericHMCRunner<MinimumNorm2> HMCWrapper;
 | 
				
			||||||
  MD.name    = std::string("MinimumNorm2");
 | 
					  // MD.name    = std::string("MinimumNorm2");
 | 
				
			||||||
  // TrajL = 2
 | 
					  // TrajL = 2
 | 
				
			||||||
  // 4/2 => 0.6 dH
 | 
					  // 4/2 => 0.6 dH
 | 
				
			||||||
  // 3/3 => 0.8 dH .. depth 3, slower
 | 
					  // 3/3 => 0.8 dH .. depth 3, slower
 | 
				
			||||||
@@ -185,11 +183,11 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  HMCparameters HMCparams;
 | 
					  HMCparameters HMCparams;
 | 
				
			||||||
  HMCparams.StartTrajectory  = 1077;
 | 
					  HMCparams.StartTrajectory  = 1077;
 | 
				
			||||||
  HMCparams.Trajectories     = 20;
 | 
					  HMCparams.Trajectories     = 1;
 | 
				
			||||||
  HMCparams.NoMetropolisUntil=  0;
 | 
					  HMCparams.NoMetropolisUntil=  0;
 | 
				
			||||||
  // "[HotStart, ColdStart, TepidStart, CheckpointStart]\n";
 | 
					  // "[HotStart, ColdStart, TepidStart, CheckpointStart]\n";
 | 
				
			||||||
  HMCparams.StartingType     =std::string("ColdStart");
 | 
					  //  HMCparams.StartingType     =std::string("ColdStart");
 | 
				
			||||||
  //  HMCparams.StartingType     =std::string("CheckpointStart");
 | 
					  HMCparams.StartingType     =std::string("CheckpointStart");
 | 
				
			||||||
  HMCparams.MD = MD;
 | 
					  HMCparams.MD = MD;
 | 
				
			||||||
  HMCWrapper TheHMC(HMCparams);
 | 
					  HMCWrapper TheHMC(HMCparams);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -204,7 +202,7 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
  TheHMC.Resources.LoadNerscCheckpointer(CPparams);
 | 
					  TheHMC.Resources.LoadNerscCheckpointer(CPparams);
 | 
				
			||||||
  std::cout << "loaded NERSC checpointer"<<std::endl;
 | 
					  std::cout << "loaded NERSC checpointer"<<std::endl;
 | 
				
			||||||
  RNGModuleParameters RNGpar;
 | 
					  RNGModuleParameters RNGpar;
 | 
				
			||||||
  RNGpar.serial_seeds = "1 2 3 4 5 6 7 8 9 10";
 | 
					  RNGpar.serial_seeds = "1 2 3 4 5";
 | 
				
			||||||
  RNGpar.parallel_seeds = "6 7 8 9 10";
 | 
					  RNGpar.parallel_seeds = "6 7 8 9 10";
 | 
				
			||||||
  TheHMC.Resources.SetRNGSeeds(RNGpar);
 | 
					  TheHMC.Resources.SetRNGSeeds(RNGpar);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -218,14 +216,15 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
  RealD M5  = 1.8;
 | 
					  RealD M5  = 1.8;
 | 
				
			||||||
  RealD b   = 1.5;
 | 
					  RealD b   = 1.5;
 | 
				
			||||||
  RealD c   = 0.5;
 | 
					  RealD c   = 0.5;
 | 
				
			||||||
  RealD beta         = 2.13;
 | 
					  Real beta         = 2.13;
 | 
				
			||||||
  //  Real light_mass   = 5.4e-4;
 | 
					  //  Real light_mass   = 5.4e-4;
 | 
				
			||||||
  Real light_mass     = 7.8e-4;
 | 
					  Real light_mass     = 7.8e-4;
 | 
				
			||||||
  //  Real light_mass     = 7.8e-3;
 | 
					 | 
				
			||||||
  Real strange_mass = 0.0362;
 | 
					  Real strange_mass = 0.0362;
 | 
				
			||||||
  Real pv_mass      = 1.0;
 | 
					  Real pv_mass      = 1.0;
 | 
				
			||||||
  std::vector<Real> hasenbusch({ 0.005, 0.0145, 0.045, 0.108, 0.25, 0.35 , 0.51, 0.6, 0.8 }); // Updated
 | 
					  //  std::vector<Real> hasenbusch({ 0.01, 0.045, 0.108, 0.25, 0.51 , pv_mass });
 | 
				
			||||||
  //std::vector<Real> hasenbusch({ 0.0145, 0.045, 0.108, 0.25, 0.35 , 0.51, 0.6, 0.8 }); // Updated
 | 
					  //  std::vector<Real> hasenbusch({ light_mass, 0.01, 0.045, 0.108, 0.25, 0.51 , pv_mass });
 | 
				
			||||||
 | 
					  std::vector<Real> hasenbusch({ 0.005, 0.0145, 0.045, 0.108, 0.25, 0.51 , pv_mass }); // Updated
 | 
				
			||||||
 | 
					  //  std::vector<Real> hasenbusch({ light_mass, 0.0145, 0.045, 0.108, 0.25, 0.51 , 0.75 , pv_mass });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  auto GridPtr   = TheHMC.Resources.GetCartesian();
 | 
					  auto GridPtr   = TheHMC.Resources.GetCartesian();
 | 
				
			||||||
  auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
 | 
					  auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
 | 
				
			||||||
@@ -276,20 +275,20 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  //  double StoppingCondition = 1e-14;
 | 
					  //  double StoppingCondition = 1e-14;
 | 
				
			||||||
  //  double MDStoppingCondition = 1e-9;
 | 
					  //  double MDStoppingCondition = 1e-9;
 | 
				
			||||||
  double StoppingCondition = 1e-14;
 | 
					  double StoppingCondition = 1e-8;
 | 
				
			||||||
  double MDStoppingCondition = 1e-9;
 | 
					  double MDStoppingCondition = 1e-7;
 | 
				
			||||||
  double MDStoppingConditionLoose = 1e-9;
 | 
					  double MDStoppingConditionLoose = 1e-7;
 | 
				
			||||||
  double MDStoppingConditionStrange = 1e-9;
 | 
					  double MDStoppingConditionStrange = 1e-7;
 | 
				
			||||||
  double MaxCGIterations = 50000;
 | 
					  double MaxCGIterations = 300000;
 | 
				
			||||||
  ConjugateGradient<FermionField>  CG(StoppingCondition,MaxCGIterations);
 | 
					  ConjugateGradient<FermionField>  CG(StoppingCondition,MaxCGIterations);
 | 
				
			||||||
  ConjugateGradient<FermionField>  MDCG(MDStoppingCondition,MaxCGIterations);
 | 
					  ConjugateGradient<FermionField>  MDCG(MDStoppingCondition,MaxCGIterations);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ////////////////////////////////////
 | 
					  ////////////////////////////////////
 | 
				
			||||||
  // Collect actions
 | 
					  // Collect actions
 | 
				
			||||||
  ////////////////////////////////////
 | 
					  ////////////////////////////////////
 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level1(1);
 | 
					  //  ActionLevel<HMCWrapper::Field> Level1(1);
 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level2(2);
 | 
					  ActionLevel<HMCWrapper::Field> Level2(1);
 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level3(4);
 | 
					  ActionLevel<HMCWrapper::Field> Level3(15);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ////////////////////////////////////
 | 
					  ////////////////////////////////////
 | 
				
			||||||
  // Strange action
 | 
					  // Strange action
 | 
				
			||||||
@@ -299,11 +298,11 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Probably dominates the force - back to EOFA.
 | 
					  // Probably dominates the force - back to EOFA.
 | 
				
			||||||
  OneFlavourRationalParams SFRp;
 | 
					  OneFlavourRationalParams SFRp;
 | 
				
			||||||
  SFRp.lo       = 0.8;
 | 
					  SFRp.lo       = 0.1;
 | 
				
			||||||
  SFRp.hi       = 30.0;
 | 
					  SFRp.hi       = 30.0;
 | 
				
			||||||
  SFRp.MaxIter  = 10000;
 | 
					  SFRp.MaxIter  = 10000;
 | 
				
			||||||
  SFRp.tolerance= 1.0e-12;
 | 
					  SFRp.tolerance= 1.0e-8;
 | 
				
			||||||
  SFRp.mdtolerance= 1.0e-9;
 | 
					  SFRp.mdtolerance= 2.0e-6;
 | 
				
			||||||
  SFRp.degree   = 10;
 | 
					  SFRp.degree   = 10;
 | 
				
			||||||
  SFRp.precision= 50;
 | 
					  SFRp.precision= 50;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -354,10 +353,8 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
  ExactOneFlavourRatioPseudoFermionAction<FermionImplPolicy> 
 | 
					  ExactOneFlavourRatioPseudoFermionAction<FermionImplPolicy> 
 | 
				
			||||||
    EOFA(Strange_Op_L, Strange_Op_R, 
 | 
					    EOFA(Strange_Op_L, Strange_Op_R, 
 | 
				
			||||||
	 ActionCG, 
 | 
						 ActionCG, 
 | 
				
			||||||
	 //	 ActionCGL, ActionCGR,
 | 
						 ActionCGL, ActionCGR,
 | 
				
			||||||
	 //	 DerivativeCGL, DerivativeCGR,
 | 
						 DerivativeCGL, DerivativeCGR,
 | 
				
			||||||
	 ActionCG, ActionCG,
 | 
					 | 
				
			||||||
	 DerivativeCG, DerivativeCG,
 | 
					 | 
				
			||||||
	 SFRp, true);
 | 
						 SFRp, true);
 | 
				
			||||||
  Level2.push_back(&EOFA);
 | 
					  Level2.push_back(&EOFA);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -444,14 +441,13 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  int nquo=Quotients.size();
 | 
					  int nquo=Quotients.size();
 | 
				
			||||||
  for(int h=0;h<nquo;h++){
 | 
					  for(int h=0;h<nquo;h++){
 | 
				
			||||||
    Level1.push_back(Quotients[h]);
 | 
					    Level2.push_back(Quotients[h]);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					  /////////////////////////////////////////////////////////////
 | 
				
			||||||
  // Gauge action
 | 
					  // Gauge action
 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					  /////////////////////////////////////////////////////////////
 | 
				
			||||||
  Level3.push_back(&GaugeAction);
 | 
					  Level3.push_back(&GaugeAction);
 | 
				
			||||||
  TheHMC.TheAction.push_back(Level1);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level2);
 | 
					  TheHMC.TheAction.push_back(Level2);
 | 
				
			||||||
  TheHMC.TheAction.push_back(Level3);
 | 
					  TheHMC.TheAction.push_back(Level3);
 | 
				
			||||||
  std::cout << GridLogMessage << " Action complete "<< std::endl;
 | 
					  std::cout << GridLogMessage << " Action complete "<< std::endl;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,268 +0,0 @@
 | 
				
			|||||||
/*************************************************************************************
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Grid physics library, www.github.com/paboyle/Grid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Source file: ./tests/Test_hmc_EODWFRatio.cc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Copyright (C) 2015-2016
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
 | 
					 | 
				
			||||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is free software; you can redistribute it and/or modify
 | 
					 | 
				
			||||||
it under the terms of the GNU General Public License as published by
 | 
					 | 
				
			||||||
the Free Software Foundation; either version 2 of the License, or
 | 
					 | 
				
			||||||
(at your option) any later version.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This program is distributed in the hope that it will be useful,
 | 
					 | 
				
			||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 | 
				
			||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 | 
				
			||||||
GNU General Public License for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You should have received a copy of the GNU General Public License along
 | 
					 | 
				
			||||||
with this program; if not, write to the Free Software Foundation, Inc.,
 | 
					 | 
				
			||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
See the full license in the file "LICENSE" in the top level distribution
 | 
					 | 
				
			||||||
directory
 | 
					 | 
				
			||||||
*************************************************************************************/
 | 
					 | 
				
			||||||
/*  END LEGAL */
 | 
					 | 
				
			||||||
#include <Grid/Grid.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main(int argc, char **argv) {
 | 
					 | 
				
			||||||
  using namespace Grid;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << " Grid Initialise "<<std::endl;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Grid_init(&argc, &argv);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  CartesianCommunicator::BarrierWorld();
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Clock skew check" <<std::endl;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  int threads = GridThread::GetThreads();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   // Typedefs to simplify notation
 | 
					 | 
				
			||||||
  typedef WilsonImplD FermionImplPolicy;
 | 
					 | 
				
			||||||
  typedef MobiusFermionD FermionAction;
 | 
					 | 
				
			||||||
  typedef MobiusEOFAFermionD FermionEOFAAction;
 | 
					 | 
				
			||||||
  typedef typename FermionAction::FermionField FermionField;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef WilsonImplF FermionImplPolicyF;
 | 
					 | 
				
			||||||
  typedef MobiusFermionF FermionActionF;
 | 
					 | 
				
			||||||
  typedef MobiusEOFAFermionF FermionEOFAActionF;
 | 
					 | 
				
			||||||
  typedef typename FermionActionF::FermionField FermionFieldF;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef Grid::XmlReader       Serialiser;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 | 
					 | 
				
			||||||
  IntegratorParameters MD;
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<LeapFrog> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("Leap Frog");
 | 
					 | 
				
			||||||
  typedef GenericHMCRunner<ForceGradient> HMCWrapper;
 | 
					 | 
				
			||||||
  MD.name    = std::string("Force Gradient");
 | 
					 | 
				
			||||||
  //  typedef GenericHMCRunner<MinimumNorm2> HMCWrapper;
 | 
					 | 
				
			||||||
  //  MD.name    = std::string("MinimumNorm2");
 | 
					 | 
				
			||||||
  // TrajL = 2
 | 
					 | 
				
			||||||
  // 4/2 => 0.6 dH
 | 
					 | 
				
			||||||
  // 3/3 => 0.8 dH .. depth 3, slower
 | 
					 | 
				
			||||||
  //MD.MDsteps =  4;
 | 
					 | 
				
			||||||
  MD.MDsteps =  8;
 | 
					 | 
				
			||||||
  MD.trajL   = 0.5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  HMCparameters HMCparams;
 | 
					 | 
				
			||||||
  HMCparams.StartTrajectory  = 1077;
 | 
					 | 
				
			||||||
  HMCparams.Trajectories     = 20;
 | 
					 | 
				
			||||||
  HMCparams.NoMetropolisUntil=  0;
 | 
					 | 
				
			||||||
  // "[HotStart, ColdStart, TepidStart, CheckpointStart]\n";
 | 
					 | 
				
			||||||
  HMCparams.StartingType     =std::string("ColdStart");
 | 
					 | 
				
			||||||
  //  HMCparams.StartingType     =std::string("CheckpointStart");
 | 
					 | 
				
			||||||
  HMCparams.MD = MD;
 | 
					 | 
				
			||||||
  HMCWrapper TheHMC(HMCparams);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Grid from the command line arguments --grid and --mpi
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddFourDimGrid("gauge"); // use default simd lanes decomposition
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  CheckpointerParameters CPparams;
 | 
					 | 
				
			||||||
  CPparams.config_prefix = "ckpoint_HMC_lat";
 | 
					 | 
				
			||||||
  CPparams.rng_prefix    = "ckpoint_HMC_rng";
 | 
					 | 
				
			||||||
  CPparams.saveInterval  = 1;
 | 
					 | 
				
			||||||
  CPparams.format        = "IEEE64BIG";
 | 
					 | 
				
			||||||
  TheHMC.Resources.LoadNerscCheckpointer(CPparams);
 | 
					 | 
				
			||||||
  std::cout << "loaded NERSC checpointer"<<std::endl;
 | 
					 | 
				
			||||||
  RNGModuleParameters RNGpar;
 | 
					 | 
				
			||||||
  RNGpar.serial_seeds = "1 2 3 4 5 6 7 8 9 10";
 | 
					 | 
				
			||||||
  RNGpar.parallel_seeds = "6 7 8 9 10";
 | 
					 | 
				
			||||||
  TheHMC.Resources.SetRNGSeeds(RNGpar);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Construct observables
 | 
					 | 
				
			||||||
  // here there is too much indirection
 | 
					 | 
				
			||||||
  typedef PlaquetteMod<HMCWrapper::ImplPolicy> PlaqObs;
 | 
					 | 
				
			||||||
  TheHMC.Resources.AddObservable<PlaqObs>();
 | 
					 | 
				
			||||||
  //////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int Ls      = 12;
 | 
					 | 
				
			||||||
  RealD M5  = 1.8;
 | 
					 | 
				
			||||||
  RealD b   = 1.5;
 | 
					 | 
				
			||||||
  RealD c   = 0.5;
 | 
					 | 
				
			||||||
  RealD beta         = 2.13;
 | 
					 | 
				
			||||||
  //  Real light_mass   = 5.4e-4;
 | 
					 | 
				
			||||||
  Real light_mass     = 7.8e-4;
 | 
					 | 
				
			||||||
  //  Real light_mass     = 7.8e-3;
 | 
					 | 
				
			||||||
  Real strange_mass = 0.0362;
 | 
					 | 
				
			||||||
  Real pv_mass      = 1.0;
 | 
					 | 
				
			||||||
  std::vector<Real> hasenbusch({ 0.005, 0.0145, 0.045, 0.108, 0.25, 0.35 , 0.51, 0.6, 0.8 }); // Updated
 | 
					 | 
				
			||||||
  //std::vector<Real> hasenbusch({ 0.0145, 0.045, 0.108, 0.25, 0.35 , 0.51, 0.6, 0.8 }); // Updated
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  auto GridPtr   = TheHMC.Resources.GetCartesian();
 | 
					 | 
				
			||||||
  auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef SchurDiagMooeeOperator<FermionAction ,FermionField > LinearOperatorD;
 | 
					 | 
				
			||||||
  typedef SchurDiagMooeeOperator<FermionEOFAAction ,FermionField > LinearOperatorEOFAD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Domain decomposed
 | 
					 | 
				
			||||||
  ////////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  Coordinate latt4  = GridPtr->GlobalDimensions();
 | 
					 | 
				
			||||||
  Coordinate mpi    = GridPtr->ProcessorGrid();
 | 
					 | 
				
			||||||
  Coordinate shm;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  GlobalSharedMemory::GetShmDims(mpi,shm);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //////////////////////////
 | 
					 | 
				
			||||||
  // Fermion Grids
 | 
					 | 
				
			||||||
  //////////////////////////
 | 
					 | 
				
			||||||
  auto FGrid     = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
  auto FrbGrid   = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,GridPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  IwasakiGaugeActionR GaugeAction(beta);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // temporarily need a gauge field
 | 
					 | 
				
			||||||
  LatticeGaugeFieldD  U(GridPtr); U=Zero();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Running the HMC "<< std::endl;
 | 
					 | 
				
			||||||
  TheHMC.ReadCommandLine(argc,argv);  // params on CML or from param file
 | 
					 | 
				
			||||||
  TheHMC.initializeGaugeFieldAndRNGs(U);
 | 
					 | 
				
			||||||
  std::cout << "loaded NERSC gauge field"<<std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // These lines are unecessary if BC are all periodic
 | 
					 | 
				
			||||||
  std::vector<Complex> boundary = {1,1,1,-1};
 | 
					 | 
				
			||||||
  FermionAction::ImplParams Params(boundary);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //  double StoppingCondition = 1e-14;
 | 
					 | 
				
			||||||
  //  double MDStoppingCondition = 1e-9;
 | 
					 | 
				
			||||||
  double StoppingCondition = 1e-14;
 | 
					 | 
				
			||||||
  double MDStoppingCondition = 1e-9;
 | 
					 | 
				
			||||||
  double MDStoppingConditionLoose = 1e-9;
 | 
					 | 
				
			||||||
  double MDStoppingConditionStrange = 1e-9;
 | 
					 | 
				
			||||||
  double MaxCGIterations = 50000;
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  CG(StoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  MDCG(MDStoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Collect actions
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level1(1);
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level2(2);
 | 
					 | 
				
			||||||
  ActionLevel<HMCWrapper::Field> Level3(4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // Strange action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  FermionAction StrangeOp (U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,strange_mass,M5,b,c, Params);
 | 
					 | 
				
			||||||
  FermionAction StrangePauliVillarsOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,pv_mass,  M5,b,c, Params);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Probably dominates the force - back to EOFA.
 | 
					 | 
				
			||||||
  OneFlavourRationalParams SFRp;
 | 
					 | 
				
			||||||
  SFRp.lo       = 0.8;
 | 
					 | 
				
			||||||
  SFRp.hi       = 30.0;
 | 
					 | 
				
			||||||
  SFRp.MaxIter  = 10000;
 | 
					 | 
				
			||||||
  SFRp.tolerance= 1.0e-12;
 | 
					 | 
				
			||||||
  SFRp.mdtolerance= 1.0e-9;
 | 
					 | 
				
			||||||
  SFRp.degree   = 10;
 | 
					 | 
				
			||||||
  SFRp.precision= 50;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_L (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , strange_mass, strange_mass, pv_mass, 0.0, -1, M5, b, c);
 | 
					 | 
				
			||||||
  MobiusEOFAFermionD Strange_Op_R (U , *FGrid , *FrbGrid , *GridPtr , *GridRBPtr , pv_mass, strange_mass,      pv_mass, -1.0, 1, M5, b, c);
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>      ActionCG(StoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
  ConjugateGradient<FermionField>  DerivativeCG(MDStoppingCondition,MaxCGIterations);
 | 
					 | 
				
			||||||
  LinearOperatorEOFAD Strange_LinOp_L (Strange_Op_L);
 | 
					 | 
				
			||||||
  LinearOperatorEOFAD Strange_LinOp_R (Strange_Op_R);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ExactOneFlavourRatioPseudoFermionAction<FermionImplPolicy> 
 | 
					 | 
				
			||||||
    EOFA(Strange_Op_L, Strange_Op_R, 
 | 
					 | 
				
			||||||
	 ActionCG, 
 | 
					 | 
				
			||||||
	 ActionCG, ActionCG,
 | 
					 | 
				
			||||||
	 DerivativeCG, DerivativeCG,
 | 
					 | 
				
			||||||
	 SFRp, true);
 | 
					 | 
				
			||||||
  Level2.push_back(&EOFA);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  // up down action
 | 
					 | 
				
			||||||
  ////////////////////////////////////
 | 
					 | 
				
			||||||
  std::vector<Real> light_den;
 | 
					 | 
				
			||||||
  std::vector<Real> light_num;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  int n_hasenbusch = hasenbusch.size();
 | 
					 | 
				
			||||||
  light_den.push_back(light_mass); 
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch;h++){
 | 
					 | 
				
			||||||
    light_den.push_back(hasenbusch[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch;h++){
 | 
					 | 
				
			||||||
    light_num.push_back(hasenbusch[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  light_num.push_back(pv_mass);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Numerators;
 | 
					 | 
				
			||||||
  std::vector<FermionAction *> Denominators;
 | 
					 | 
				
			||||||
  std::vector<TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> *> Quotients;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  std::vector<OneFlavourEvenOddRatioRationalPseudoFermionAction<FermionImplPolicy> *> Bdys;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  typedef SchurDiagMooeeOperator<FermionAction ,FermionField > LinearOperatorD;
 | 
					 | 
				
			||||||
  std::vector<LinearOperatorD *> LinOpD;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  for(int h=0;h<n_hasenbusch+1;h++){
 | 
					 | 
				
			||||||
    std::cout << GridLogMessage
 | 
					 | 
				
			||||||
	      << " 2f quotient Action ";
 | 
					 | 
				
			||||||
    std::cout << "det D("<<light_den[h]<<")";
 | 
					 | 
				
			||||||
    std::cout << "/ det D("<<light_num[h]<<")";
 | 
					 | 
				
			||||||
    std::cout << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    FermionAction::ImplParams ParamsNum(boundary);
 | 
					 | 
				
			||||||
    FermionAction::ImplParams ParamsDen(boundary);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    Numerators.push_back  (new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_num[h],M5,b,c, ParamsNum));
 | 
					 | 
				
			||||||
    Denominators.push_back(new FermionAction(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,light_den[h],M5,b,c, ParamsDen));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    LinOpD.push_back(new LinearOperatorD(*Denominators[h]));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    double conv  = MDStoppingCondition;
 | 
					 | 
				
			||||||
    if (h<3) conv= MDStoppingConditionLoose; // Relax on first two hasenbusch factors
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    Quotients.push_back (new TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy>(*Numerators[h],*Denominators[h],MDCG,CG,CG));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  int nquo=Quotients.size();
 | 
					 | 
				
			||||||
  for(int h=0;h<nquo;h++){
 | 
					 | 
				
			||||||
    Level1.push_back(Quotients[h]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  // Gauge action
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
  Level3.push_back(&GaugeAction);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level1);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level2);
 | 
					 | 
				
			||||||
  TheHMC.TheAction.push_back(Level3);
 | 
					 | 
				
			||||||
  std::cout << GridLogMessage << " Action complete "<< std::endl;
 | 
					 | 
				
			||||||
  /////////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  TheHMC.Run();  // no smearing
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Grid_finalize();
 | 
					 | 
				
			||||||
} // main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							
								
								
									
										25
									
								
								HOWTO
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								HOWTO
									
									
									
									
									
								
							@@ -1,25 +0,0 @@
 | 
				
			|||||||
1. on Cori GPU, load necessary modules
 | 
					 | 
				
			||||||
source ./load_cgpu_modules.sh 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
2. run bootstrap scrip
 | 
					 | 
				
			||||||
./bootstrap.sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
3. Create a build directory, for example, 
 | 
					 | 
				
			||||||
mkdir build-cgpu
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
3. run configure script in the build directory 
 | 
					 | 
				
			||||||
cd build-cgpu
 | 
					 | 
				
			||||||
sh config-command
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Example config-command for single-GPU omp offload: 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
../configure \
 | 
					 | 
				
			||||||
    --enable-comms=none \
 | 
					 | 
				
			||||||
    --enable-simd=GEN \
 | 
					 | 
				
			||||||
    --enable-gen-simd-width=16 \
 | 
					 | 
				
			||||||
    CXX=clang++ \
 | 
					 | 
				
			||||||
    LDFLAGS="-L${CUDA_ROOT}/lib64 -lcudart" \
 | 
					 | 
				
			||||||
    CXXFLAGS="-Wno-unknown-cuda-version -I${CUDA_ROOT}/include -fopenmp -std=c++14 -fopenmp-cuda-mode  -O3 -g -fopenmp-targets=nvptx64-nvidia-cuda -Wformat -DOMPTARGET -DOMPTARGET_MANAGED"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
4. compile 
 | 
					 | 
				
			||||||
make -j8
 | 
					 | 
				
			||||||
@@ -1,22 +0,0 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					 | 
				
			||||||
#PBS -q EarlyAppAccess
 | 
					 | 
				
			||||||
#PBS -l select=2
 | 
					 | 
				
			||||||
#PBS -l walltime=01:00:00
 | 
					 | 
				
			||||||
#PBS -A LatticeQCD_aesp_CNDA
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export TZ='/usr/share/zoneinfo/US/Central'
 | 
					 | 
				
			||||||
export OMP_PROC_BIND=spread
 | 
					 | 
				
			||||||
export OMP_NUM_THREADS=3
 | 
					 | 
				
			||||||
unset OMP_PLACES
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cd $PBS_O_WORKDIR
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NNODES=`wc -l < $PBS_NODEFILE`
 | 
					 | 
				
			||||||
NRANKS=12         # Number of MPI ranks per node
 | 
					 | 
				
			||||||
NDEPTH=4          # Number of hardware threads per rank, spacing between MPI ranks on a node
 | 
					 | 
				
			||||||
NTHREADS=$OMP_NUM_THREADS # Number of OMP threads per rank, given to OMP_NUM_THREADS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
NTOTRANKS=$(( NNODES * NRANKS ))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
CMD="mpiexec -np 2 -ppn 1  -envall ./gpu_tile_compact.sh ./halo_mpi --mpi 2.1.1.1"
 | 
					 | 
				
			||||||
$CMD
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
mpicxx  -fsycl halo_mpi.cc -o halo_mpi
 | 
					 | 
				
			||||||
@@ -1,30 +0,0 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export NUMA_PMAP=(2 2 2 3 3 3 2 2 2 3 3 3 )
 | 
					 | 
				
			||||||
export NUMA_MAP=(0 0 0 1 1 1 0 0 0 1 1 1 )
 | 
					 | 
				
			||||||
export  GPU_MAP=(0 1 2 3 4 5 0 1 2 3 4 5 )
 | 
					 | 
				
			||||||
export TILE_MAP=(0 0 0 0 0 0 1 1 1 1 1 1 )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export PNUMA=${NUMA_PMAP[$PALS_LOCAL_RANKID]}
 | 
					 | 
				
			||||||
export NUMA=${NUMA_MAP[$PALS_LOCAL_RANKID]}
 | 
					 | 
				
			||||||
export gpu_id=${GPU_MAP[$PALS_LOCAL_RANKID]}
 | 
					 | 
				
			||||||
export tile_id=${TILE_MAP[$PALS_LOCAL_RANKID]}
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export ZE_AFFINITY_MASK=$gpu_id.$tile_id
 | 
					 | 
				
			||||||
export ONEAPI_DEVICE_FILTER=gpu,level_zero
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#unset EnableWalkerPartition
 | 
					 | 
				
			||||||
#export EnableImplicitScaling=0
 | 
					 | 
				
			||||||
#export GRID_MPICH_NIC_BIND=$NIC
 | 
					 | 
				
			||||||
#export ONEAPI_DEVICE_SELECTOR=level_zero:$gpu_id.$tile_id
 | 
					 | 
				
			||||||
#export ZE_ENABLE_PCI_ID_DEVICE_ORDER=1
 | 
					 | 
				
			||||||
#export SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS=0
 | 
					 | 
				
			||||||
#export SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1
 | 
					 | 
				
			||||||
#export SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE=0:2
 | 
					 | 
				
			||||||
#export SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_D2D_COPY=1
 | 
					 | 
				
			||||||
#export SYCL_PI_LEVEL_ZERO_USM_RESIDENT=1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "rank $PALS_RANKID ; local rank $PALS_LOCAL_RANKID ; ZE_AFFINITY_MASK=$ZE_AFFINITY_MASK ; NUMA $NUMA "
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
numactl -m $PNUMA -N $NUMA  "$@"
 | 
					 | 
				
			||||||
@@ -1,333 +0,0 @@
 | 
				
			|||||||
#include <cassert>
 | 
					 | 
				
			||||||
#include <complex>
 | 
					 | 
				
			||||||
#include <memory>
 | 
					 | 
				
			||||||
#include <vector>
 | 
					 | 
				
			||||||
#include <algorithm>
 | 
					 | 
				
			||||||
#include <array>
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <strings.h>
 | 
					 | 
				
			||||||
#include <ctime>
 | 
					 | 
				
			||||||
#include <sys/time.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <mpi.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**************************************************************
 | 
					 | 
				
			||||||
 * GPU - GPU memory cartesian halo exchange benchmark
 | 
					 | 
				
			||||||
 * Config: what is the target
 | 
					 | 
				
			||||||
 **************************************************************
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#undef ACC_CUDA
 | 
					 | 
				
			||||||
#undef  ACC_HIP
 | 
					 | 
				
			||||||
#define  ACC_SYCL
 | 
					 | 
				
			||||||
#undef  ACC_NONE
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**************************************************************
 | 
					 | 
				
			||||||
 * Some MPI globals
 | 
					 | 
				
			||||||
 **************************************************************
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
MPI_Comm WorldComm;
 | 
					 | 
				
			||||||
MPI_Comm WorldShmComm;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int WorldSize;
 | 
					 | 
				
			||||||
int WorldRank;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int WorldShmSize;
 | 
					 | 
				
			||||||
int WorldShmRank;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**************************************************************
 | 
					 | 
				
			||||||
 * Allocate buffers on the GPU, SYCL needs an init call and context
 | 
					 | 
				
			||||||
 **************************************************************
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#ifdef ACC_CUDA
 | 
					 | 
				
			||||||
#include <cuda.h>
 | 
					 | 
				
			||||||
void acceleratorInit(void){}
 | 
					 | 
				
			||||||
void *acceleratorAllocDevice(size_t bytes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  void *ptr=NULL;
 | 
					 | 
				
			||||||
  auto err = cudaMalloc((void **)&ptr,bytes);
 | 
					 | 
				
			||||||
  assert(err==cudaSuccess);
 | 
					 | 
				
			||||||
  return ptr;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
void acceleratorFreeDevice(void *ptr){  cudaFree(ptr);}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef ACC_HIP
 | 
					 | 
				
			||||||
#include <hip/hip_runtime.h>
 | 
					 | 
				
			||||||
void acceleratorInit(void){}
 | 
					 | 
				
			||||||
inline void *acceleratorAllocDevice(size_t bytes)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  void *ptr=NULL;
 | 
					 | 
				
			||||||
  auto err = hipMalloc((void **)&ptr,bytes);
 | 
					 | 
				
			||||||
  if( err != hipSuccess ) {
 | 
					 | 
				
			||||||
    ptr = (void *) NULL;
 | 
					 | 
				
			||||||
    printf(" hipMalloc failed for %ld %s \n",bytes,hipGetErrorString(err));
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return ptr;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
inline void acceleratorFreeDevice(void *ptr){ auto r=hipFree(ptr);};
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef ACC_SYCL
 | 
					 | 
				
			||||||
#include <sycl/CL/sycl.hpp>
 | 
					 | 
				
			||||||
#include <sycl/usm.hpp>
 | 
					 | 
				
			||||||
cl::sycl::queue *theAccelerator;
 | 
					 | 
				
			||||||
void acceleratorInit(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  int nDevices = 1;
 | 
					 | 
				
			||||||
#if 1
 | 
					 | 
				
			||||||
  cl::sycl::gpu_selector selector;
 | 
					 | 
				
			||||||
  cl::sycl::device selectedDevice { selector };
 | 
					 | 
				
			||||||
  theAccelerator = new sycl::queue (selectedDevice);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
  cl::sycl::device selectedDevice {cl::sycl::gpu_selector_v  };
 | 
					 | 
				
			||||||
  theAccelerator = new sycl::queue (selectedDevice);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
  auto name = theAccelerator->get_device().get_info<sycl::info::device::name>();
 | 
					 | 
				
			||||||
  printf("AcceleratorSyclInit: Selected device is %s\n",name.c_str()); fflush(stdout);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
inline void *acceleratorAllocDevice(size_t bytes){ return malloc_device(bytes,*theAccelerator);};
 | 
					 | 
				
			||||||
inline void acceleratorFreeDevice(void *ptr){free(ptr,*theAccelerator);};
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef ACC_NONE
 | 
					 | 
				
			||||||
void acceleratorInit(void){}
 | 
					 | 
				
			||||||
inline void *acceleratorAllocDevice(size_t bytes){ return malloc(bytes);};
 | 
					 | 
				
			||||||
inline void acceleratorFreeDevice(void *ptr){free(ptr);};
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**************************************************************
 | 
					 | 
				
			||||||
 * Microsecond timer
 | 
					 | 
				
			||||||
 **************************************************************
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
inline double usecond(void) {
 | 
					 | 
				
			||||||
  struct timeval tv;
 | 
					 | 
				
			||||||
  gettimeofday(&tv,NULL);
 | 
					 | 
				
			||||||
  return 1.0e6*tv.tv_sec + 1.0*tv.tv_usec;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/**************************************************************
 | 
					 | 
				
			||||||
 * Main benchmark routine
 | 
					 | 
				
			||||||
 **************************************************************
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
void Benchmark(int64_t L,std::vector<int> cart_geom,bool use_device,int ncall)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  int64_t words = 3*4*2;
 | 
					 | 
				
			||||||
  int64_t face,vol;
 | 
					 | 
				
			||||||
  int Nd=cart_geom.size();
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  /**************************************************************
 | 
					 | 
				
			||||||
   * L^Nd volume, L^(Nd-1) faces, 12 complex per site
 | 
					 | 
				
			||||||
   * Allocate memory for these
 | 
					 | 
				
			||||||
   **************************************************************
 | 
					 | 
				
			||||||
   */
 | 
					 | 
				
			||||||
  face=1; for( int d=0;d<Nd-1;d++) face = face*L;
 | 
					 | 
				
			||||||
  vol=1;  for( int d=0;d<Nd;d++) vol = vol*L;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  std::vector<void *> send_bufs;
 | 
					 | 
				
			||||||
  std::vector<void *> recv_bufs;
 | 
					 | 
				
			||||||
  size_t vw = face*words;
 | 
					 | 
				
			||||||
  size_t bytes = face*words*sizeof(double);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if ( use_device ) {
 | 
					 | 
				
			||||||
    for(int d=0;d<2*Nd;d++){
 | 
					 | 
				
			||||||
      send_bufs.push_back(acceleratorAllocDevice(bytes));
 | 
					 | 
				
			||||||
      recv_bufs.push_back(acceleratorAllocDevice(bytes));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    for(int d=0;d<2*Nd;d++){
 | 
					 | 
				
			||||||
      send_bufs.push_back(malloc(bytes));
 | 
					 | 
				
			||||||
      recv_bufs.push_back(malloc(bytes));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  /*********************************************************
 | 
					 | 
				
			||||||
   * Build cartesian communicator
 | 
					 | 
				
			||||||
   *********************************************************
 | 
					 | 
				
			||||||
   */
 | 
					 | 
				
			||||||
  int ierr;
 | 
					 | 
				
			||||||
  int rank;
 | 
					 | 
				
			||||||
  std::vector<int> coor(Nd);
 | 
					 | 
				
			||||||
  MPI_Comm communicator;
 | 
					 | 
				
			||||||
  std::vector<int> periodic(Nd,1);
 | 
					 | 
				
			||||||
  MPI_Cart_create(WorldComm,Nd,&cart_geom[0],&periodic[0],0,&communicator);
 | 
					 | 
				
			||||||
  MPI_Comm_rank(communicator,&rank);
 | 
					 | 
				
			||||||
  MPI_Cart_coords(communicator,rank,Nd,&coor[0]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static int reported;
 | 
					 | 
				
			||||||
  if ( ! reported ) { 
 | 
					 | 
				
			||||||
    printf("World Rank %d Shm Rank %d CartCoor %d %d %d %d\n",WorldRank,WorldShmRank,
 | 
					 | 
				
			||||||
	 coor[0],coor[1],coor[2],coor[3]); fflush(stdout);
 | 
					 | 
				
			||||||
    reported =1 ;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  /*********************************************************
 | 
					 | 
				
			||||||
   * Perform halo exchanges
 | 
					 | 
				
			||||||
   *********************************************************
 | 
					 | 
				
			||||||
   */
 | 
					 | 
				
			||||||
  for(int d=0;d<Nd;d++){
 | 
					 | 
				
			||||||
    if ( cart_geom[d]>1 ) {
 | 
					 | 
				
			||||||
      double t0=usecond();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      int from,to;
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      MPI_Barrier(communicator);
 | 
					 | 
				
			||||||
      for(int n=0;n<ncall;n++){
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	void *xmit = (void *)send_bufs[d];
 | 
					 | 
				
			||||||
	void *recv = (void *)recv_bufs[d];
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	ierr=MPI_Cart_shift(communicator,d,1,&from,&to);
 | 
					 | 
				
			||||||
	assert(ierr==0);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	ierr=MPI_Sendrecv(xmit,bytes,MPI_CHAR,to,rank,
 | 
					 | 
				
			||||||
			  recv,bytes,MPI_CHAR,from, from,
 | 
					 | 
				
			||||||
			  communicator,MPI_STATUS_IGNORE);
 | 
					 | 
				
			||||||
	assert(ierr==0);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	xmit = (void *)send_bufs[Nd+d];
 | 
					 | 
				
			||||||
	recv = (void *)recv_bufs[Nd+d];
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	ierr=MPI_Cart_shift(communicator,d,-1,&from,&to);
 | 
					 | 
				
			||||||
	assert(ierr==0);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	ierr=MPI_Sendrecv(xmit,bytes,MPI_CHAR,to,rank,
 | 
					 | 
				
			||||||
			  recv,bytes,MPI_CHAR,from, from,
 | 
					 | 
				
			||||||
			  communicator,MPI_STATUS_IGNORE);
 | 
					 | 
				
			||||||
	assert(ierr==0);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      MPI_Barrier(communicator);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      double t1=usecond();
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      double dbytes    = bytes*WorldShmSize;
 | 
					 | 
				
			||||||
      double xbytes    = dbytes*2.0*ncall;
 | 
					 | 
				
			||||||
      double rbytes    = xbytes;
 | 
					 | 
				
			||||||
      double bidibytes = xbytes+rbytes;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if ( ! WorldRank ) {
 | 
					 | 
				
			||||||
	printf("\t%12ld\t %12ld %16.0lf\n",L,bytes,bidibytes/(t1-t0)); fflush(stdout);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  /*********************************************************
 | 
					 | 
				
			||||||
   * Free memory
 | 
					 | 
				
			||||||
   *********************************************************
 | 
					 | 
				
			||||||
   */
 | 
					 | 
				
			||||||
  if ( use_device ) {
 | 
					 | 
				
			||||||
    for(int d=0;d<2*Nd;d++){
 | 
					 | 
				
			||||||
      acceleratorFreeDevice(send_bufs[d]);
 | 
					 | 
				
			||||||
      acceleratorFreeDevice(recv_bufs[d]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    for(int d=0;d<2*Nd;d++){
 | 
					 | 
				
			||||||
      free(send_bufs[d]);
 | 
					 | 
				
			||||||
      free(recv_bufs[d]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**************************************
 | 
					 | 
				
			||||||
 * Command line junk
 | 
					 | 
				
			||||||
 **************************************/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
std::string CmdOptionPayload(char ** begin, char ** end, const std::string & option)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  char ** itr = std::find(begin, end, option);
 | 
					 | 
				
			||||||
  if (itr != end && ++itr != end) {
 | 
					 | 
				
			||||||
    std::string payload(*itr);
 | 
					 | 
				
			||||||
    return payload;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return std::string("");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
bool CmdOptionExists(char** begin, char** end, const std::string& option)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  return std::find(begin, end, option) != end;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
void CmdOptionIntVector(const std::string &str,std::vector<int> & vec)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  vec.resize(0);
 | 
					 | 
				
			||||||
  std::stringstream ss(str);
 | 
					 | 
				
			||||||
  int i;
 | 
					 | 
				
			||||||
  while (ss >> i){
 | 
					 | 
				
			||||||
    vec.push_back(i);
 | 
					 | 
				
			||||||
    if(std::ispunct(ss.peek()))
 | 
					 | 
				
			||||||
      ss.ignore();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/**************************************
 | 
					 | 
				
			||||||
 * Command line junk
 | 
					 | 
				
			||||||
 **************************************/
 | 
					 | 
				
			||||||
int main(int argc, char **argv)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  std::string arg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  acceleratorInit();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  MPI_Init(&argc,&argv);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  WorldComm = MPI_COMM_WORLD;
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  MPI_Comm_split_type(WorldComm, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL,&WorldShmComm);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  MPI_Comm_rank(WorldComm     ,&WorldRank);
 | 
					 | 
				
			||||||
  MPI_Comm_size(WorldComm     ,&WorldSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  MPI_Comm_rank(WorldShmComm     ,&WorldShmRank);
 | 
					 | 
				
			||||||
  MPI_Comm_size(WorldShmComm     ,&WorldShmSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if ( WorldSize/WorldShmSize > 2) {
 | 
					 | 
				
			||||||
    printf("This benchmark is meant to run on at most two nodes only\n");
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  auto mpi =std::vector<int>({1,1,1,1});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if( CmdOptionExists(argv,argv+argc,"--mpi") ){
 | 
					 | 
				
			||||||
    arg = CmdOptionPayload(argv,argv+argc,"--mpi");
 | 
					 | 
				
			||||||
    CmdOptionIntVector(arg,mpi);
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    printf("Must specify --mpi <n1.n2.n3.n4> command line argument\n");
 | 
					 | 
				
			||||||
    exit(0);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if( !WorldRank ) {
 | 
					 | 
				
			||||||
    printf("***********************************\n");
 | 
					 | 
				
			||||||
    printf("%d ranks\n",WorldSize); 
 | 
					 | 
				
			||||||
    printf("%d ranks-per-node\n",WorldShmSize);
 | 
					 | 
				
			||||||
    printf("%d nodes\n",WorldSize/WorldShmSize);fflush(stdout);
 | 
					 | 
				
			||||||
    printf("Cartesian layout: ");
 | 
					 | 
				
			||||||
    for(int d=0;d<mpi.size();d++){
 | 
					 | 
				
			||||||
      printf("%d ",mpi[d]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    printf("\n");fflush(stdout);
 | 
					 | 
				
			||||||
    printf("***********************************\n");
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  if( !WorldRank ) {
 | 
					 | 
				
			||||||
    printf("=========================================================\n");
 | 
					 | 
				
			||||||
    printf("= Benchmarking HOST memory MPI performance               \n");
 | 
					 | 
				
			||||||
    printf("=========================================================\n");fflush(stdout);
 | 
					 | 
				
			||||||
    printf("= L\t pkt bytes\t MB/s           \n");
 | 
					 | 
				
			||||||
    printf("=========================================================\n");fflush(stdout);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for(int L=16;L<=64;L+=4){
 | 
					 | 
				
			||||||
    Benchmark(L,mpi,false,100);
 | 
					 | 
				
			||||||
  }  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if( !WorldRank ) {
 | 
					 | 
				
			||||||
    printf("=========================================================\n");
 | 
					 | 
				
			||||||
    printf("= Benchmarking DEVICE memory MPI performance             \n");
 | 
					 | 
				
			||||||
    printf("=========================================================\n");fflush(stdout);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  for(int L=16;L<=64;L+=4){
 | 
					 | 
				
			||||||
    Benchmark(L,mpi,true,100);
 | 
					 | 
				
			||||||
  }  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if( !WorldRank ) {
 | 
					 | 
				
			||||||
    printf("=========================================================\n");
 | 
					 | 
				
			||||||
    printf("= DONE   \n");
 | 
					 | 
				
			||||||
    printf("=========================================================\n");
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  MPI_Finalize();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,27 +0,0 @@
 | 
				
			|||||||
module load rocm/5.5.1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
mkdir build-amd-err && cd build-amd-err
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cp ../amd-omp-stack-err/Test.cc ../amd-omp-stack-err/WilsonFermionInstantiationWilsonImplD.cc .
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
../configure CXX=amdclang++ --enable-comms=none --enable-simd=GEN --enable-accelerator-cshift=no --enable-shm=no --disable-unified --enable-unified=no --enable-fermion-reps=no --enable-gen-simd-width=16 CXXFLAGS="-Wno-unknown-cuda-version -fopenmp --offload-arch=gfx90a -std=c++14 -fopenmp-cuda-mode -O3 -g -Wformat -DEIGEN_NO_CUDA -DEIGEN_DONT_VECTORIZE -DOMPTARGET"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
amdclang++ -c Test.cc -o Test.o -I/autofs/nccs-svm1_home1/atif/Grid -I/autofs/nccs-svm1_home1/atif/Grid/build-amd-err/Grid/ -O3 -Wno-unknown-cuda-version -fopenmp --offload-arch=gfx90a -std=c++14 -fopenmp-cuda-mode -O3 -Wformat -DEIGEN_NO_CUDA -DOMPTARGET -fno-strict-aliasing
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
amdclang++ -c WilsonFermionInstantiationWilsonImplD.cc -o WilsonFails.o -I/autofs/nccs-svm1_home1/atif/Grid -I/autofs/nccs-svm1_home1/atif/Grid/build-amd-err/Grid/ -O3 -Wno-unknown-cuda-version -fopenmp --offload-arch=gfx90a -std=c++14 -fopenmp-cuda-mode -O3 -Wformat -DEIGEN_NO_CUDA -DOMPTARGET -fno-strict-aliasing
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ar cru libWilsonFails.a WilsonFails.o
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ranlib libWilsonFails.a
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
amdclang++ -o Test -I/autofs/nccs-svm1_home1/atif/Grid -I/autofs/nccs-svm1_home1/atif/Grid/build-amd-err/Grid/   -O3 -Wno-unknown-cuda-version -fopenmp --offload-arch=gfx90a -std=c++14 -fopenmp-cuda-mode -O3 -Wformat -DEIGEN_NO_CUDA -DOMPTARGET  -fno-strict-aliasing Test.o -L./  -lWilsonFails
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
error: stack frame size (149840) exceeds limit (131056) in function '__omp_offloading_72_1e118ab9__ZN4Grid7LatticeINS_7iScalarINS_7iMatrixINS2_INS_9Grid_simdISt7complexIdENS_12Optimization3vecIdEEEELi3EEELi4EEEEEEaSINS_12TrinaryWhereENS0_INS1_INS3_IjNS7_IjEEEEEEEESD_SD_EERSD_RKNS_24LatticeTrinaryExpressionIT_T0_T1_T2_EE_l190'
 | 
					 | 
				
			||||||
error: stack frame size (149840) exceeds limit (131056) in function '__omp_offloading_72_1e118ab9__ZN4Grid7LatticeINS_7iScalarINS_7iMatrixINS2_INS_9Grid_simdISt7complexIdENS_12Optimization3vecIdEEEELi3EEELi4EEEEEEaSINS_12TrinaryWhereENS_23LatticeBinaryExpressionINS_10BinaryOrOrENS0_INS1_INS3_IjNS7_IjEEEEEEEESL_EESD_SD_EERSD_RKNS_24LatticeTrinaryExpressionIT_T0_T1_T2_EE_l190'
 | 
					 | 
				
			||||||
error: stack frame size (149840) exceeds limit (131056) in function '__omp_offloading_72_1e118ab9__ZN4Grid7LatticeINS_7iScalarINS_7iMatrixINS2_INS_9Grid_simdISt7complexIdENS_12Optimization3vecIdEEEELi3EEELi4EEEEEEaSINS_9BinaryAddESD_NS_24LatticeTrinaryExpressionINS_12TrinaryWhereENS0_INS1_INS3_IjNS7_IjEEEEEEEESD_SD_EEEERSD_RKNS_23LatticeBinaryExpressionIT_T0_T1_EE_l166'
 | 
					 | 
				
			||||||
clang-16: error: amdgcn-link command failed with exit code 1 (use -v to see invocation)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
llvm-objdump -t libWilsonFermionWorks2.a > objdump_works2.txt
 | 
					 | 
				
			||||||
llvm-cxxfilt < objdump_works2.txt > cxxfilt_works2.txt
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user