mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	Removed SliceShare as a reusable routine
This commit is contained in:
		@@ -186,6 +186,67 @@ void TLapEvec<GImpl>::Cleanup(void)
 | 
			
		||||
  gridHD = nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************
 | 
			
		||||
 | 
			
		||||
 -Grad^2 (Peardon, 2009, pg 2, equation 3, https://arxiv.org/abs/0905.2160)
 | 
			
		||||
 Field      Type of field the operator will be applied to
 | 
			
		||||
 GaugeField Gauge field the operator will smear using
 | 
			
		||||
 
 | 
			
		||||
 *************************************************************************************/
 | 
			
		||||
 | 
			
		||||
template<typename Field, typename GaugeField=LatticeGaugeField>
 | 
			
		||||
class Laplacian3D : public LinearOperatorBase<Field>, public LinearFunction<Field> {
 | 
			
		||||
  typedef typename GaugeField::vector_type vCoeff_t;
 | 
			
		||||
protected: // I don't really mind if _gf is messed with ... so make this public?
 | 
			
		||||
  //GaugeField & _gf;
 | 
			
		||||
  int          nd; // number of spatial dimensions
 | 
			
		||||
  std::vector<Lattice<iColourMatrix<vCoeff_t> > > U;
 | 
			
		||||
public:
 | 
			
		||||
  // Construct this operator given a gauge field and the number of dimensions it should act on
 | 
			
		||||
  Laplacian3D( GaugeField& gf, int dimSpatial = Tdir ) : /*_gf(gf),*/ nd{dimSpatial} {
 | 
			
		||||
    assert(dimSpatial>=1);
 | 
			
		||||
    for( int mu = 0 ; mu < nd ; mu++ )
 | 
			
		||||
      U.push_back(PeekIndex<LorentzIndex>(gf,mu));
 | 
			
		||||
      }
 | 
			
		||||
  
 | 
			
		||||
  // Apply this operator to "in", return result in "out"
 | 
			
		||||
  void operator()(const Field& in, Field& out) {
 | 
			
		||||
    assert( nd <= in.Grid()->Nd() );
 | 
			
		||||
    conformable( in, out );
 | 
			
		||||
    out = ( ( Real ) ( 2 * nd ) ) * in;
 | 
			
		||||
    Field _tmp(in.Grid());
 | 
			
		||||
    typedef typename GaugeField::vector_type vCoeff_t;
 | 
			
		||||
    //Lattice<iColourMatrix<vCoeff_t> > U(in.Grid());
 | 
			
		||||
    for( int mu = 0 ; mu < nd ; mu++ ) {
 | 
			
		||||
      //U = PeekIndex<LorentzIndex>(_gf,mu);
 | 
			
		||||
      out -= U[mu] * Cshift( in, mu, 1);
 | 
			
		||||
      _tmp = adj( U[mu] ) * in;
 | 
			
		||||
      out -= Cshift(_tmp,mu,-1);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  void OpDiag (const Field &in, Field &out) { assert(0); };
 | 
			
		||||
  void OpDir  (const Field &in, Field &out,int dir,int disp) { assert(0); };
 | 
			
		||||
  void Op     (const Field &in, Field &out) { assert(0); };
 | 
			
		||||
  void AdjOp  (const Field &in, Field &out) { assert(0); };
 | 
			
		||||
  void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2) { assert(0); };
 | 
			
		||||
  void HermOp(const Field &in, Field &out) { operator()(in,out); };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<typename Field>
 | 
			
		||||
class Laplacian3DHerm : public LinearFunction<Field> {
 | 
			
		||||
public:
 | 
			
		||||
  OperatorFunction<Field>   & _poly;
 | 
			
		||||
  LinearOperatorBase<Field> &_Linop;
 | 
			
		||||
  
 | 
			
		||||
  Laplacian3DHerm(OperatorFunction<Field> & poly,LinearOperatorBase<Field>& linop)
 | 
			
		||||
  : _poly{poly}, _Linop{linop} {}
 | 
			
		||||
  
 | 
			
		||||
  void operator()(const Field& in, Field& out) {
 | 
			
		||||
    _poly(_Linop,in,out);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/******************************************************************************
 | 
			
		||||
 Calculate low-mode eigenvalues of the Laplacian
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
 
 | 
			
		||||
@@ -33,12 +33,11 @@
 | 
			
		||||
#include <Hadrons/Distil.hpp>
 | 
			
		||||
 | 
			
		||||
BEGIN_HADRONS_NAMESPACE
 | 
			
		||||
 | 
			
		||||
BEGIN_MODULE_NAMESPACE(MDistil)
 | 
			
		||||
 | 
			
		||||
/******************************************************************************
 | 
			
		||||
 *                             Perambulator                                    *
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
BEGIN_MODULE_NAMESPACE(MDistil)
 | 
			
		||||
 | 
			
		||||
class PerambulatorPar: Serializable
 | 
			
		||||
{
 | 
			
		||||
@@ -254,20 +253,43 @@ void TPerambulator<FImpl>::execute(void)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    LOG(Message) <<  "perambulator done" << std::endl;
 | 
			
		||||
    perambulator.SliceShare( grid3d, grid4d );
 | 
			
		||||
    
 | 
			
		||||
    if(grid4d->IsBoss())
 | 
			
		||||
    // Now share my timeslice data with other members of the grid
 | 
			
		||||
    const int NumSlices{grid4d->_processors[Tdir] / grid3d->_processors[Tdir]};
 | 
			
		||||
    if (NumSlices > 1)
 | 
			
		||||
    {
 | 
			
		||||
        std::string sPerambName{par().PerambFileName};
 | 
			
		||||
        if( sPerambName.length() == 0 )
 | 
			
		||||
        LOG(Debug) <<  "Sharing perambulator data with other nodes" << std::endl;
 | 
			
		||||
        const int MySlice {grid4d->_processor_coor[Tdir]};
 | 
			
		||||
        const int SliceCount {static_cast<int>(perambulator.tensor.size()/NumSlices)};
 | 
			
		||||
        PerambTensor::Scalar * const MyData {perambulator.tensor.data()+MySlice*SliceCount};
 | 
			
		||||
        Coordinate coor(Nd);
 | 
			
		||||
        for (int i = 0 ; i < Tdir ; i++) coor[i] = grid4d->_processor_coor[i];
 | 
			
		||||
        std::vector<CommsRequest_t> reqs(0);
 | 
			
		||||
        for (int i = 1; i < NumSlices ; i++)
 | 
			
		||||
        {
 | 
			
		||||
            coor[Tdir] = (MySlice+i)%NumSlices;
 | 
			
		||||
            const int SendRank { grid4d->RankFromProcessorCoor(coor) };
 | 
			
		||||
            const int RecvSlice { ( MySlice - i + NumSlices ) % NumSlices };
 | 
			
		||||
            coor[Tdir] = RecvSlice;
 | 
			
		||||
            const auto RecvRank = grid4d->RankFromProcessorCoor(coor);
 | 
			
		||||
            grid4d->SendToRecvFromBegin(reqs,MyData,SendRank, perambulator.tensor.data()
 | 
			
		||||
                                        + RecvSlice*SliceCount,RecvRank,SliceCount*sizeof(PerambTensor::Scalar));
 | 
			
		||||
        }
 | 
			
		||||
        grid4d->SendToRecvFromComplete(reqs);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // Save the perambulator to disk from the boss node
 | 
			
		||||
    if (grid4d->IsBoss())
 | 
			
		||||
    {
 | 
			
		||||
        std::string sPerambName {par().PerambFileName};
 | 
			
		||||
        if (sPerambName.empty())
 | 
			
		||||
            sPerambName = getName();
 | 
			
		||||
        sPerambName.append( "." );
 | 
			
		||||
        sPerambName.append( std::to_string(vm().getTrajectory()));
 | 
			
		||||
        sPerambName.append(".");
 | 
			
		||||
        sPerambName.append(std::to_string(vm().getTrajectory()));
 | 
			
		||||
        perambulator.write(sPerambName.c_str());
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if( !UnsmearedSinkFileName.empty() )
 | 
			
		||||
    //Save the unsmeared sinks if filename specified
 | 
			
		||||
    if (!UnsmearedSinkFileName.empty())
 | 
			
		||||
    {
 | 
			
		||||
        bool bMulti = ( Hadrons::MDistil::DistilParameters::ParameterDefault( par().UnsmearedSinkMultiFile, 1, false ) != 0 );
 | 
			
		||||
        LOG(Message) << "Writing unsmeared sink to " << UnsmearedSinkFileName << std::endl;
 | 
			
		||||
@@ -276,7 +298,6 @@ void TPerambulator<FImpl>::execute(void)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
END_MODULE_NAMESPACE
 | 
			
		||||
 | 
			
		||||
END_HADRONS_NAMESPACE
 | 
			
		||||
 | 
			
		||||
#endif // Hadrons_MDistil_Perambulator_hpp_
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user