mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-13 01:05:36 +00:00
Post Michael / Felix review. Ready for Peter / Antonin review
This commit is contained in:
parent
cfe5fa7a35
commit
8dc0587621
@ -362,13 +362,13 @@ template<typename Scalar_, int NumIndices_, uint16_t Endian_Scalar_Size_> struct
|
|||||||
template<typename T> struct is_named_tensor<T, typename std::enable_if<std::is_base_of<NamedTensor<typename T::Scalar, T::NumIndices, T::Endian_Scalar_Size_>, T>::value>::type> : public std::true_type {};
|
template<typename T> struct is_named_tensor<T, typename std::enable_if<std::is_base_of<NamedTensor<typename T::Scalar, T::NumIndices, T::Endian_Scalar_Size_>, T>::value>::type> : public std::true_type {};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
Perambulator object
|
PerambTensor object
|
||||||
Endian_Scalar_Size can be removed once (deprecated) NamedTensor::ReadBinary & WriteBinary methods deleted
|
Endian_Scalar_Size can be removed once (deprecated) NamedTensor::ReadBinary & WriteBinary methods deleted
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
//template<typename Scalar_, int NumIndices_, uint16_t Endian_Scalar_Size = sizeof(Scalar_)>
|
//template<typename Scalar_, int NumIndices_, uint16_t Endian_Scalar_Size = sizeof(Scalar_)>
|
||||||
using Perambulator = NamedTensor<SpinVector, 6, sizeof(Real)>;
|
using PerambTensor = NamedTensor<SpinVector, 6, sizeof(Real)>;
|
||||||
static const std::array<std::string, 6> PerambIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
static const std::array<std::string, 6> PerambIndexNames{"nT", "nVec", "LI", "nNoise", "nT_inv", "SI"};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
Save NamedTensor binary format (NB: On-disk format is Big Endian)
|
Save NamedTensor binary format (NB: On-disk format is Big Endian)
|
||||||
@ -552,7 +552,7 @@ void NamedTensor<Scalar_, NumIndices_, Endian_Scalar_Size>::ReadBinary(const std
|
|||||||
#else
|
#else
|
||||||
u32 -= GridChecksum::crc32(tensor.data(), TotalDataSize);
|
u32 -= GridChecksum::crc32(tensor.data(), TotalDataSize);
|
||||||
#endif
|
#endif
|
||||||
assert( u32 == 0 && "NamedTensor error: Perambulator checksum invalid");
|
assert( u32 == 0 && "NamedTensor error: PerambTensor checksum invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -593,7 +593,20 @@ void NamedTensor<Scalar_, NumIndices_, Endian_Scalar_Size>::read(Reader &r, cons
|
|||||||
const typename ET::Dimensions & NewDimensions{tensor.dimensions()};
|
const typename ET::Dimensions & NewDimensions{tensor.dimensions()};
|
||||||
for( int i=0; i < NumIndices_; i++ ) {
|
for( int i=0; i < NumIndices_; i++ ) {
|
||||||
assert(OldDimensions[i] == 0 || OldDimensions[i] == NewDimensions[i] && "NamedTensor::load dimension size");
|
assert(OldDimensions[i] == 0 || OldDimensions[i] == NewDimensions[i] && "NamedTensor::load dimension size");
|
||||||
assert(OldIndexNames[i].size() == 0 || OldIndexNames[i] == IndexNames[i] && "NamedTensor::load dimension name");
|
// Case insensitive name compare - TODO std:: c++ way of doing this
|
||||||
|
const int iOldLen{ static_cast<int>( OldIndexNames[i].size() ) };
|
||||||
|
const int iNewLen{ static_cast<int>( IndexNames[i].size() ) };
|
||||||
|
bool bSame{ iOldLen == 0 || iOldLen == iNewLen };
|
||||||
|
for( int j = 0; j < iOldLen && bSame; j++ ) {
|
||||||
|
wchar_t c1 = OldIndexNames[i][j];
|
||||||
|
if( c1 >= 'a' && c1 <= 'z' )
|
||||||
|
c1 -= 'a' - 'A';
|
||||||
|
wchar_t c2 = IndexNames[i][j];
|
||||||
|
if( c2 >= 'a' && c1 <= 'z' )
|
||||||
|
c2 -= 'a' - 'A';
|
||||||
|
bSame = ( c1 == c2 );
|
||||||
|
}
|
||||||
|
assert(bSame && "NamedTensor::load dimension name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,14 +163,14 @@ void TDistilVectors<FImpl>::setup(void)
|
|||||||
{
|
{
|
||||||
Cleanup();
|
Cleanup();
|
||||||
auto &noise = envGet(NoiseTensor, NoiseVectorName);
|
auto &noise = envGet(NoiseTensor, NoiseVectorName);
|
||||||
auto &perambulator = envGet(Perambulator, PerambulatorName);
|
auto &perambulator = envGet(PerambTensor, PerambulatorName);
|
||||||
|
|
||||||
// We expect the perambulator to have been created with these indices
|
// We expect the perambulator to have been created with these indices
|
||||||
for(int i = 0; i < Perambulator::NumIndices; i++ )
|
for(int i = 0; i < PerambTensor::NumIndices; i++ )
|
||||||
assert( PerambIndexNames[i] == perambulator.IndexNames[i] && "Perambulator indices bad" );
|
assert( PerambIndexNames[i] == perambulator.IndexNames[i] && "PerambTensor indices bad" );
|
||||||
|
|
||||||
const int Nt{ env().getDim(Tdir) };
|
const int Nt{ env().getDim(Tdir) };
|
||||||
assert( Nt == static_cast<int>( perambulator.tensor.dimension(0) ) && "Perambulator time dimensionality bad" );
|
assert( Nt == static_cast<int>( perambulator.tensor.dimension(0) ) && "PerambTensor time dimensionality bad" );
|
||||||
const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, true) };
|
const int TI{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().TI, Nt, true) };
|
||||||
const int LI{ static_cast<int>( perambulator.tensor.dimension(2) ) };
|
const int LI{ static_cast<int>( perambulator.tensor.dimension(2) ) };
|
||||||
const int SI{ static_cast<int>( perambulator.tensor.dimension(5) ) };
|
const int SI{ static_cast<int>( perambulator.tensor.dimension(5) ) };
|
||||||
@ -222,7 +222,7 @@ template <typename FImpl>
|
|||||||
void TDistilVectors<FImpl>::execute(void)
|
void TDistilVectors<FImpl>::execute(void)
|
||||||
{
|
{
|
||||||
auto &noise = envGet(NoiseTensor, NoiseVectorName);
|
auto &noise = envGet(NoiseTensor, NoiseVectorName);
|
||||||
auto &perambulator = envGet(Perambulator, PerambulatorName);
|
auto &perambulator = envGet(PerambTensor, PerambulatorName);
|
||||||
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, LapEvecName);
|
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, LapEvecName);
|
||||||
|
|
||||||
envGetTmp(LatticeSpinColourVector, tmp2);
|
envGetTmp(LatticeSpinColourVector, tmp2);
|
||||||
|
@ -205,11 +205,12 @@ void TLapEvec<GImpl>::execute(void)
|
|||||||
|
|
||||||
// Stout smearing
|
// Stout smearing
|
||||||
envGetTmp(GaugeField, Umu_smear);
|
envGetTmp(GaugeField, Umu_smear);
|
||||||
|
const StoutParameters &Stout{par().Stout};
|
||||||
|
if( Stout.steps )
|
||||||
{
|
{
|
||||||
auto &Umu = envGet(GaugeField, sGaugeName);
|
auto &Umu = envGet(GaugeField, sGaugeName);
|
||||||
LOG(Message) << "Initial plaquette: " << WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
|
LOG(Message) << "Initial plaquette: " << WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
|
||||||
Umu_smear = Umu;
|
Umu_smear = Umu;
|
||||||
const StoutParameters &Stout{par().Stout};
|
|
||||||
envGetTmp(GaugeField, Umu_stout);
|
envGetTmp(GaugeField, Umu_stout);
|
||||||
Smear_Stout<PeriodicGimplR> LS(Stout.rho, Tdir); // spatial smearing only
|
Smear_Stout<PeriodicGimplR> LS(Stout.rho, Tdir); // spatial smearing only
|
||||||
for (int i = 0; i < Stout.steps; i++) {
|
for (int i = 0; i < Stout.steps; i++) {
|
||||||
|
@ -56,8 +56,8 @@ public:
|
|||||||
std::string, PerambFileName,
|
std::string, PerambFileName,
|
||||||
std::string, solve,
|
std::string, solve,
|
||||||
int, nvec,
|
int, nvec,
|
||||||
int, nvec_reduced,
|
std::string, nvec_reduced,
|
||||||
int, LI_reduced,
|
std::string, LI_reduced,
|
||||||
DistilParameters, Distil);
|
DistilParameters, Distil);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,12 +122,12 @@ void TPerambFromSolve<FImpl>::setup(void)
|
|||||||
{
|
{
|
||||||
Cleanup();
|
Cleanup();
|
||||||
DISTIL_PARAMETERS_DEFINE( true );
|
DISTIL_PARAMETERS_DEFINE( true );
|
||||||
|
const int nvec_reduced{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().nvec_reduced, nvec, true) };
|
||||||
|
const int LI_reduced{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().LI_reduced, LI, true) };
|
||||||
grid4d = env().getGrid();
|
grid4d = env().getGrid();
|
||||||
grid3d = MakeLowerDimGrid(grid4d);
|
grid3d = MakeLowerDimGrid(grid4d);
|
||||||
const int nvec_reduced{par().nvec_reduced};
|
|
||||||
const int LI_reduced{par().LI_reduced};
|
|
||||||
//std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
//std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||||
envCreate(Perambulator, getName(), 1, PerambIndexNames,Nt,nvec_reduced,LI_reduced,nnoise,Nt_inv,SI);
|
envCreate(PerambTensor, getName(), 1, PerambIndexNames,Nt,nvec_reduced,LI_reduced,nnoise,Nt_inv,SI);
|
||||||
envCreate(NoiseTensor, getName() + "_noise", 1, nnoise, Nt, nvec, Ns );
|
envCreate(NoiseTensor, getName() + "_noise", 1, nnoise, Nt, nvec, Ns );
|
||||||
envTmp(LatticeColourVector, "result_3d",1,LatticeColourVector(grid3d));
|
envTmp(LatticeColourVector, "result_3d",1,LatticeColourVector(grid3d));
|
||||||
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
|
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d));
|
||||||
@ -151,10 +151,10 @@ void TPerambFromSolve<FImpl>::execute(void)
|
|||||||
GridCartesian * grid4d = env().getGrid();
|
GridCartesian * grid4d = env().getGrid();
|
||||||
const int Ntlocal{grid4d->LocalDimensions()[3]};
|
const int Ntlocal{grid4d->LocalDimensions()[3]};
|
||||||
const int Ntfirst{grid4d->LocalStarts()[3]};
|
const int Ntfirst{grid4d->LocalStarts()[3]};
|
||||||
const int nvec_reduced{par().nvec_reduced};
|
|
||||||
const int LI_reduced{par().LI_reduced};
|
|
||||||
DISTIL_PARAMETERS_DEFINE( false );
|
DISTIL_PARAMETERS_DEFINE( false );
|
||||||
auto &perambulator = envGet(Perambulator, getName());
|
const int nvec_reduced{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().nvec_reduced, nvec, false) };
|
||||||
|
const int LI_reduced{ Hadrons::MDistil::DistilParameters::ParameterDefault( par().LI_reduced, LI, false) };
|
||||||
|
auto &perambulator = envGet(PerambTensor, getName());
|
||||||
auto &solve = envGet(std::vector<FermionField>, par().solve);
|
auto &solve = envGet(std::vector<FermionField>, par().solve);
|
||||||
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
|
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
|
||||||
|
|
||||||
|
@ -82,8 +82,7 @@ protected:
|
|||||||
std::string sNoiseName;
|
std::string sNoiseName;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Can't name the module Perambulator, because that's what we've called the object
|
MODULE_REGISTER_TMP(Perambulator, TPerambulator<FIMPL>, MDistil);
|
||||||
MODULE_REGISTER_TMP(Peramb, TPerambulator<FIMPL>, MDistil);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TPerambulator implementation *
|
* TPerambulator implementation *
|
||||||
@ -127,7 +126,7 @@ void TPerambulator<FImpl>::setup(void)
|
|||||||
grid3d = MakeLowerDimGrid(grid4d);
|
grid3d = MakeLowerDimGrid(grid4d);
|
||||||
DISTIL_PARAMETERS_DEFINE( true );
|
DISTIL_PARAMETERS_DEFINE( true );
|
||||||
|
|
||||||
envCreate(Perambulator, getName(), 1, PerambIndexNames,Nt,nvec,LI,nnoise,Nt_inv,SI);
|
envCreate(PerambTensor, getName(), 1, PerambIndexNames,Nt,nvec,LI,nnoise,Nt_inv,SI);
|
||||||
envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1,
|
envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1,
|
||||||
nnoise*LI*Ns*Nt_inv, envGetGrid(FermionField));
|
nnoise*LI*Ns*Nt_inv, envGetGrid(FermionField));
|
||||||
|
|
||||||
@ -170,7 +169,7 @@ void TPerambulator<FImpl>::execute(void)
|
|||||||
envGetTmp(FermionField, v5dtmp_sol);
|
envGetTmp(FermionField, v5dtmp_sol);
|
||||||
|
|
||||||
auto &noise = envGet(NoiseTensor, sNoiseName);
|
auto &noise = envGet(NoiseTensor, sNoiseName);
|
||||||
auto &perambulator = envGet(Perambulator, getName());
|
auto &perambulator = envGet(PerambTensor, getName());
|
||||||
auto &epack = envGet(LapEvecs, sLapEvecName);
|
auto &epack = envGet(LapEvecs, sLapEvecName);
|
||||||
auto &unsmeared_sink = envGet(std::vector<FermionField>, getName() + "_unsmeared_sink");
|
auto &unsmeared_sink = envGet(std::vector<FermionField>, getName() + "_unsmeared_sink");
|
||||||
|
|
||||||
|
@ -103,14 +103,14 @@ void TLoadPerambulator<FImpl>::setup(void)
|
|||||||
{
|
{
|
||||||
DISTIL_PARAMETERS_DEFINE( true );
|
DISTIL_PARAMETERS_DEFINE( true );
|
||||||
//std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
//std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||||
envCreate(MDistil::Perambulator, getName(), 1, MDistil::PerambIndexNames,Nt,nvec,LI,nnoise,Nt_inv,SI);
|
envCreate(MDistil::PerambTensor, getName(), 1, MDistil::PerambIndexNames,Nt,nvec,LI,nnoise,Nt_inv,SI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// execution ///////////////////////////////////////////////////////////////////
|
// execution ///////////////////////////////////////////////////////////////////
|
||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
void TLoadPerambulator<FImpl>::execute(void)
|
void TLoadPerambulator<FImpl>::execute(void)
|
||||||
{
|
{
|
||||||
auto &perambulator = envGet(MDistil::Perambulator, getName());
|
auto &perambulator = envGet(MDistil::PerambTensor, getName());
|
||||||
const std::string sPerambName{par().PerambFileName + "." + std::to_string(vm().getTrajectory())};
|
const std::string sPerambName{par().PerambFileName + "." + std::to_string(vm().getTrajectory())};
|
||||||
perambulator.read(sPerambName.c_str());
|
perambulator.read(sPerambName.c_str());
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ void test_Perambulators( Application &application, const char * pszSuffix = null
|
|||||||
{
|
{
|
||||||
std::string sModuleName{ PerambulatorName( pszSuffix ) };
|
std::string sModuleName{ PerambulatorName( pszSuffix ) };
|
||||||
// Perambulator parameters
|
// Perambulator parameters
|
||||||
MDistil::Peramb::Par PerambPar;
|
MDistil::Perambulator::Par PerambPar;
|
||||||
PerambPar.lapevec = "LapEvec";
|
PerambPar.lapevec = "LapEvec";
|
||||||
PerambPar.PerambFileName = sModuleName;
|
PerambPar.PerambFileName = sModuleName;
|
||||||
PerambPar.solver = test_Solver( application, pszSuffix );
|
PerambPar.solver = test_Solver( application, pszSuffix );
|
||||||
@ -183,7 +183,7 @@ void test_Perambulators( Application &application, const char * pszSuffix = null
|
|||||||
PerambPar.Distil.nnoise = 1;
|
PerambPar.Distil.nnoise = 1;
|
||||||
PerambPar.nvec = 5;
|
PerambPar.nvec = 5;
|
||||||
test_Noises(application, sModuleName); // I want these written after solver stuff
|
test_Noises(application, sModuleName); // I want these written after solver stuff
|
||||||
application.createModule<MDistil::Peramb>( sModuleName, PerambPar );
|
application.createModule<MDistil::Perambulator>( sModuleName, PerambPar );
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
@ -892,7 +892,7 @@ bool DebugGridTensorTest( void )
|
|||||||
|
|
||||||
bool ConvertPeramb(const char * pszSource, const char * pszDest) {
|
bool ConvertPeramb(const char * pszSource, const char * pszDest) {
|
||||||
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||||
Grid::Hadrons::MDistil::Perambulator p(sIndexNames);
|
Grid::Hadrons::MDistil::PerambTensor p(sIndexNames);
|
||||||
p.ReadBinary( pszSource );
|
p.ReadBinary( pszSource );
|
||||||
p.write(pszDest);
|
p.write(pszDest);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user