mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-12 20:27:06 +01:00
Added index names to perambulator
This commit is contained in:
@ -34,6 +34,10 @@
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
#ifndef COMMA
|
||||
#define COMMA ,
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
This potentially belongs in CartesianCommunicator
|
||||
Turns out I don't actually need this when running inside hadrons
|
||||
@ -199,10 +203,13 @@ inline GridCartesian * MakeLowerDimGrid( GridCartesian * gridHD )
|
||||
template<typename Scalar_, int NumIndices_>
|
||||
class Perambulator : public Eigen::Tensor<Scalar_, NumIndices_, Eigen::RowMajor | Eigen::DontAlign>
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
std::array<std::string,NumIndices_> IndexNames;
|
||||
public:
|
||||
template<typename... IndexTypes>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Perambulator(Eigen::Index firstDimension, IndexTypes... otherDimensions)
|
||||
: Eigen::Tensor<Scalar_, NumIndices_, Eigen::RowMajor | Eigen::DontAlign>(firstDimension, otherDimensions...)
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Perambulator(std::array<std::string,NumIndices_> &IndexNames_, Eigen::Index firstDimension, IndexTypes... otherDimensions)
|
||||
: IndexNames{IndexNames_}, Eigen::Tensor<Scalar_, NumIndices_, Eigen::RowMajor | Eigen::DontAlign>(firstDimension, otherDimensions...)
|
||||
{
|
||||
// The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
|
||||
EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices_, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||
@ -212,7 +219,7 @@ public:
|
||||
|
||||
// Share data for timeslices we calculated with other nodes
|
||||
inline void SliceShare( GridCartesian * gridLowDim, GridCartesian * gridHighDim ) {
|
||||
//Grid::SliceShare( gridLowDim, gridHighDim, data(), (int) (size() * sizeof(Scalar_)));
|
||||
Grid::SliceShare( gridLowDim, gridHighDim, this->data(), (int) (this->size() * sizeof(Scalar_)));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -134,7 +134,7 @@ void TDistilVectors<FImpl>::execute(void)
|
||||
|
||||
//auto &noise = envGet(std::vector<std::vector<std::vector<SpinVector>>>, par().noise);
|
||||
auto &noise = envGet(std::vector<Complex>, par().noise);
|
||||
auto &perambulator = *env().template getObject<Perambulator<SpinVector,6> >(par().perambulator);
|
||||
auto &perambulator = envGet(Perambulator<SpinVector COMMA 6>, par().perambulator);
|
||||
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
|
||||
auto &rho = envGet(std::vector<FermionField>, getName() + "_rho");
|
||||
auto &phi = envGet(std::vector<FermionField>, getName() + "_phi");
|
||||
|
@ -127,10 +127,17 @@ void TPerambLight<GImpl>::setup(void)
|
||||
// auto &noise = envGet(std::vector<std::vector<std::vector<SpinVector>>>, par().noise);
|
||||
const int nvec{par().nvec};
|
||||
const DistilParameters & Distil{par().Distil};
|
||||
//const char * IndexNames[6] = {"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||
std::array<std::string,6> sIndexNames{"Nt", "nvec", "LI", "nnoise", "Nt_inv", "SI"};
|
||||
//std::complex<double> z{0.6,-3.1};
|
||||
|
||||
//envCreate(Perambulator<SpinVector, 6>, getName() + "_perambulator_light", 1,
|
||||
env().template createObject<Perambulator<SpinVector, 6> >(getName() + "_perambulator_light", Environment::Storage::object, 1,
|
||||
Distil.Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
|
||||
//envCreate(std::string, getName() + "_debug_delete_me", 1, "Bingonuts");
|
||||
//envCreate(std::complex<double>, getName() + "_debug_delete_me_2", 1, 0.6);
|
||||
//envCreate(std::complex<double>, getName() + "_debug_delete_me_3", 1, z);
|
||||
//envCreate(std::complex<double>, getName() + "_debug_delete_me_4", 1, {0.6 COMMA -3.1});
|
||||
//envCreate(std::array<std::string COMMA 3>, getName() + "_debug_delete_me_5", 1, {"One" COMMA "Two" COMMA "Three"});
|
||||
envCreate(Perambulator<SpinVector COMMA 6>, getName() + "_perambulator_light", 1,
|
||||
sIndexNames,Distil.Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI);
|
||||
envCreate(std::vector<Complex>, getName() + "_noise", 1,
|
||||
nvec*Distil.Ns*Distil.Nt*Distil.nnoise);
|
||||
|
||||
@ -183,9 +190,7 @@ void TPerambLight<GImpl>::execute(void)
|
||||
|
||||
//auto &noise = envGet(std::vector<std::vector<std::vector<SpinVector>>>, par().noise);
|
||||
auto &noise = envGet(std::vector<Complex>, getName() + "_noise");
|
||||
auto &perambulator = //envGet(Perambulator<SpinVector>,
|
||||
*env().template getObject<Perambulator<SpinVector,6> >(
|
||||
getName() + "_perambulator_light");
|
||||
auto &perambulator = envGet(Perambulator<SpinVector COMMA 6>, getName() + "_perambulator_light");
|
||||
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
|
||||
|
||||
envGetTmp(GaugeField, Umu);
|
||||
@ -252,9 +257,10 @@ void TPerambLight<GImpl>::execute(void)
|
||||
noise[inoise + nnoise*(t + Nt*(ivec+nvec*is))] = 1.;
|
||||
//noises[inoise][t][ivec]()(is)() = 1.;
|
||||
else{
|
||||
random(sRNG,rn);
|
||||
noise[inoise + nnoise*(t + Nt*(ivec+nvec*is))] = (rn-0.5 > 0) - (rn-0.5 < 0); //TODO: This could be 0 if rn==0.5!!
|
||||
//noises[inoise][t][ivec]()(is)() = (rn-0.5 > 0) - (rn-0.5 < 0); //TODO: This could be 0 if rn==0.5!!
|
||||
random(sRNG,rn);
|
||||
// We could use a greater number of complex roots of unity
|
||||
// ... but this seems to work well
|
||||
noise[inoise + nnoise*(t + Nt*(ivec+nvec*is))] = (rn > 0.5) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user