mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	Hadrons: everything is broken, repairing while implementing the new memory model
This commit is contained in:
		@@ -316,3 +316,17 @@ void Application::configLoop(void)
 | 
			
		||||
    LOG(Message) << BIG_SEP << " End of measurement " << BIG_SEP << std::endl;
 | 
			
		||||
    env().freeAll();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// memory profile //////////////////////////////////////////////////////////////
 | 
			
		||||
void Application::memoryProfile(void)
 | 
			
		||||
{
 | 
			
		||||
    auto graph   = env().makeModuleGraph();
 | 
			
		||||
    auto program = graph.topoSort();
 | 
			
		||||
    bool msg;
 | 
			
		||||
    
 | 
			
		||||
    msg = HadronsLogMessage.isActive();
 | 
			
		||||
    HadronsLogMessage.Active(false);
 | 
			
		||||
    
 | 
			
		||||
    HadronsLogMessage.Active(msg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -101,6 +101,8 @@ public:
 | 
			
		||||
private:
 | 
			
		||||
    // environment shortcut
 | 
			
		||||
    Environment & env(void) const;
 | 
			
		||||
    // memory profile
 | 
			
		||||
    void memoryProfile(void);
 | 
			
		||||
private:
 | 
			
		||||
    long unsigned int         locVol_;
 | 
			
		||||
    std::string               parameterFileName_{""};
 | 
			
		||||
 
 | 
			
		||||
@@ -67,6 +67,16 @@ bool Environment::isDryRun(void) const
 | 
			
		||||
    return dryRun_;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Environment::memoryProfile(const bool doMemoryProfile)
 | 
			
		||||
{
 | 
			
		||||
    memoryProfile_ = doMemoryProfile;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Environment::doMemoryProfile(void) const
 | 
			
		||||
{
 | 
			
		||||
    return memoryProfile_;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// trajectory number ///////////////////////////////////////////////////////////
 | 
			
		||||
void Environment::setTrajectory(const unsigned int traj)
 | 
			
		||||
{
 | 
			
		||||
@@ -349,10 +359,10 @@ Environment::executeProgram(const std::vector<unsigned int> &p)
 | 
			
		||||
        auto it = std::find_if(p.rbegin(), p.rend(), pred);
 | 
			
		||||
        if (it != p.rend())
 | 
			
		||||
        {
 | 
			
		||||
            freeProg[p.rend() - it - 1].insert(i);
 | 
			
		||||
            freeProg[std::distance(p.rend(), it) - 1].insert(i);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    // program execution
 | 
			
		||||
    for (unsigned int i = 0; i < p.size(); ++i)
 | 
			
		||||
    {
 | 
			
		||||
@@ -448,6 +458,7 @@ void Environment::addObject(const std::string name, const int moduleAddress)
 | 
			
		||||
        
 | 
			
		||||
        info.name   = name;
 | 
			
		||||
        info.module = moduleAddress;
 | 
			
		||||
        info.data   = nullptr;
 | 
			
		||||
        object_.push_back(std::move(info));
 | 
			
		||||
        objectAddress_[name] = static_cast<unsigned int>(object_.size() - 1);
 | 
			
		||||
    }
 | 
			
		||||
@@ -457,39 +468,6 @@ void Environment::addObject(const std::string name, const int moduleAddress)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Environment::registerObject(const unsigned int address,
 | 
			
		||||
                                 const unsigned int size, const unsigned int Ls)
 | 
			
		||||
{
 | 
			
		||||
    if (!hasRegisteredObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        if (hasObject(address))
 | 
			
		||||
        {
 | 
			
		||||
            object_[address].size         = size;
 | 
			
		||||
            object_[address].Ls           = Ls;
 | 
			
		||||
            object_[address].isRegistered = true;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            HADRON_ERROR("no object with address " + std::to_string(address));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("object with address " + std::to_string(address)
 | 
			
		||||
                     + " already registered");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Environment::registerObject(const std::string name,
 | 
			
		||||
                                 const unsigned int size, const unsigned int Ls)
 | 
			
		||||
{
 | 
			
		||||
    if (!hasObject(name))
 | 
			
		||||
    {
 | 
			
		||||
        addObject(name);
 | 
			
		||||
    }
 | 
			
		||||
    registerObject(getObjectAddress(name), size, Ls);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned int Environment::getObjectAddress(const std::string name) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasObject(name))
 | 
			
		||||
@@ -516,7 +494,7 @@ std::string Environment::getObjectName(const unsigned int address) const
 | 
			
		||||
 | 
			
		||||
std::string Environment::getObjectType(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasRegisteredObject(address))
 | 
			
		||||
    if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        if (object_[address].type)
 | 
			
		||||
        {
 | 
			
		||||
@@ -527,11 +505,6 @@ std::string Environment::getObjectType(const unsigned int address) const
 | 
			
		||||
            return "<no type>";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("object with address " + std::to_string(address)
 | 
			
		||||
                     + " exists but is not registered");
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("no object with address " + std::to_string(address));
 | 
			
		||||
@@ -545,15 +518,10 @@ std::string Environment::getObjectType(const std::string name) const
 | 
			
		||||
 | 
			
		||||
Environment::Size Environment::getObjectSize(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasRegisteredObject(address))
 | 
			
		||||
    if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        return object_[address].size;
 | 
			
		||||
    }
 | 
			
		||||
    else if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("object with address " + std::to_string(address)
 | 
			
		||||
                     + " exists but is not registered");
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("no object with address " + std::to_string(address));
 | 
			
		||||
@@ -584,15 +552,10 @@ unsigned int Environment::getObjectModule(const std::string name) const
 | 
			
		||||
 | 
			
		||||
unsigned int Environment::getObjectLs(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasRegisteredObject(address))
 | 
			
		||||
    if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        return object_[address].Ls;
 | 
			
		||||
    }
 | 
			
		||||
    else if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("object with address " + std::to_string(address)
 | 
			
		||||
                     + " exists but is not registered");
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("no object with address " + std::to_string(address));
 | 
			
		||||
@@ -616,30 +579,6 @@ bool Environment::hasObject(const std::string name) const
 | 
			
		||||
    return ((it != objectAddress_.end()) and hasObject(it->second));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Environment::hasRegisteredObject(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        return object_[address].isRegistered;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Environment::hasRegisteredObject(const std::string name) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasObject(name))
 | 
			
		||||
    {
 | 
			
		||||
        return hasRegisteredObject(getObjectAddress(name));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Environment::hasCreatedObject(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasObject(address))
 | 
			
		||||
@@ -680,10 +619,7 @@ Environment::Size Environment::getTotalSize(void) const
 | 
			
		||||
    
 | 
			
		||||
    for (auto &o: object_)
 | 
			
		||||
    {
 | 
			
		||||
        if (o.isRegistered)
 | 
			
		||||
        {
 | 
			
		||||
            size += o.size;
 | 
			
		||||
        }
 | 
			
		||||
        size += o.size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return size;
 | 
			
		||||
@@ -738,7 +674,7 @@ bool Environment::freeObject(const unsigned int address)
 | 
			
		||||
{
 | 
			
		||||
    if (!hasOwners(address))
 | 
			
		||||
    {
 | 
			
		||||
        if (!isDryRun() and object_[address].isRegistered)
 | 
			
		||||
        if (!isDryRun())
 | 
			
		||||
        {
 | 
			
		||||
            LOG(Message) << "Destroying object '" << object_[address].name
 | 
			
		||||
                         << "'" << std::endl;
 | 
			
		||||
@@ -747,10 +683,8 @@ bool Environment::freeObject(const unsigned int address)
 | 
			
		||||
        {
 | 
			
		||||
            object_[p].owners.erase(address);
 | 
			
		||||
        }
 | 
			
		||||
        object_[address].size         = 0;
 | 
			
		||||
        object_[address].Ls           = 0;
 | 
			
		||||
        object_[address].isRegistered = false;
 | 
			
		||||
        object_[address].type         = nullptr;
 | 
			
		||||
        object_[address].size = 0;
 | 
			
		||||
        object_[address].type = nullptr;
 | 
			
		||||
        object_[address].owners.clear();
 | 
			
		||||
        object_[address].properties.clear();
 | 
			
		||||
        object_[address].data.reset(nullptr);
 | 
			
		||||
 
 | 
			
		||||
@@ -83,12 +83,12 @@ private:
 | 
			
		||||
        std::string               name;
 | 
			
		||||
        ModPt                     data{nullptr};
 | 
			
		||||
        std::vector<unsigned int> input;
 | 
			
		||||
        size_t                    maxAllocated;
 | 
			
		||||
    };
 | 
			
		||||
    struct ObjInfo
 | 
			
		||||
    {
 | 
			
		||||
        Size                    size{0};
 | 
			
		||||
        unsigned int            Ls{0};
 | 
			
		||||
        bool                    isRegistered{false};
 | 
			
		||||
        const std::type_info    *type{nullptr};
 | 
			
		||||
        std::string             name;
 | 
			
		||||
        int                     module{-1};
 | 
			
		||||
@@ -99,6 +99,8 @@ public:
 | 
			
		||||
    // dry run
 | 
			
		||||
    void                    dryRun(const bool isDry);
 | 
			
		||||
    bool                    isDryRun(void) const;
 | 
			
		||||
    void                    memoryProfile(const bool doMemoryProfile);
 | 
			
		||||
    bool                    doMemoryProfile(void) const;
 | 
			
		||||
    // trajectory number
 | 
			
		||||
    void                    setTrajectory(const unsigned int traj);
 | 
			
		||||
    unsigned int            getTrajectory(void) const;
 | 
			
		||||
@@ -143,32 +145,17 @@ public:
 | 
			
		||||
    // general memory management
 | 
			
		||||
    void                    addObject(const std::string name,
 | 
			
		||||
                                      const int moduleAddress = -1);
 | 
			
		||||
    void                    registerObject(const unsigned int address,
 | 
			
		||||
                                           const unsigned int size,
 | 
			
		||||
                                           const unsigned int Ls = 1);
 | 
			
		||||
    void                    registerObject(const std::string name,
 | 
			
		||||
                                           const unsigned int size,
 | 
			
		||||
                                           const unsigned int Ls = 1);
 | 
			
		||||
    template <typename T, typename ... Ts>
 | 
			
		||||
    void                    createObject(const std::string name,
 | 
			
		||||
                                         const unsigned int Ls,
 | 
			
		||||
                                         Ts ... args);
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    unsigned int            lattice4dSize(void) const;
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    void                    registerLattice(const unsigned int address,
 | 
			
		||||
                                            const unsigned int Ls = 1);
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    void                    registerLattice(const std::string name,
 | 
			
		||||
                                            const unsigned int Ls = 1);
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    void                    setObject(const unsigned int address, T *object);
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    void                    setObject(const std::string name, T *object);
 | 
			
		||||
    void                    createLattice(const std::string name,
 | 
			
		||||
                                          const unsigned int Ls = 1);
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    T *                     getObject(const unsigned int address) const;
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    T *                     getObject(const std::string name) const;
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    T *                     createLattice(const unsigned int address);
 | 
			
		||||
    template <typename T>
 | 
			
		||||
    T *                     createLattice(const std::string name);
 | 
			
		||||
    unsigned int            getObjectAddress(const std::string name) const;
 | 
			
		||||
    std::string             getObjectName(const unsigned int address) const;
 | 
			
		||||
    std::string             getObjectType(const unsigned int address) const;
 | 
			
		||||
@@ -181,8 +168,6 @@ public:
 | 
			
		||||
    unsigned int            getObjectLs(const std::string name) const;
 | 
			
		||||
    bool                    hasObject(const unsigned int address) const;
 | 
			
		||||
    bool                    hasObject(const std::string name) const;
 | 
			
		||||
    bool                    hasRegisteredObject(const unsigned int address) const;
 | 
			
		||||
    bool                    hasRegisteredObject(const std::string name) const;
 | 
			
		||||
    bool                    hasCreatedObject(const unsigned int address) const;
 | 
			
		||||
    bool                    hasCreatedObject(const std::string name) const;
 | 
			
		||||
    bool                    isObject5d(const unsigned int address) const;
 | 
			
		||||
@@ -204,7 +189,7 @@ public:
 | 
			
		||||
    void                    printContent(void);
 | 
			
		||||
private:
 | 
			
		||||
    // general
 | 
			
		||||
    bool                                   dryRun_{false};
 | 
			
		||||
    bool                                   dryRun_{false}, memoryProfile_{false};
 | 
			
		||||
    unsigned int                           traj_, locVol_;
 | 
			
		||||
    // grids
 | 
			
		||||
    std::vector<int>                       dim_;
 | 
			
		||||
@@ -296,56 +281,45 @@ M * Environment::getModule(const std::string name) const
 | 
			
		||||
    return getModule<M>(getModuleAddress(name));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
unsigned int Environment::lattice4dSize(void) const
 | 
			
		||||
template <typename T, typename ... Ts>
 | 
			
		||||
void Environment::createObject(const std::string name, const unsigned int Ls,
 | 
			
		||||
                               Ts ... args)
 | 
			
		||||
{
 | 
			
		||||
    return sizeof(typename T::vector_object)/getGrid()->Nsimd();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
void Environment::registerLattice(const unsigned int address,
 | 
			
		||||
                                  const unsigned int Ls)
 | 
			
		||||
{
 | 
			
		||||
    createGrid(Ls);
 | 
			
		||||
    registerObject(address, Ls*lattice4dSize<T>(), Ls);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
void Environment::registerLattice(const std::string name, const unsigned int Ls)
 | 
			
		||||
{
 | 
			
		||||
    createGrid(Ls);
 | 
			
		||||
    registerObject(name, Ls*lattice4dSize<T>(), Ls);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
void Environment::setObject(const unsigned int address, T *object)
 | 
			
		||||
{
 | 
			
		||||
    if (hasRegisteredObject(address))
 | 
			
		||||
    if (!hasObject(name))
 | 
			
		||||
    {
 | 
			
		||||
        object_[address].data.reset(new Holder<T>(object));
 | 
			
		||||
        object_[address].type = &typeid(T);
 | 
			
		||||
        addObject(name);
 | 
			
		||||
    }
 | 
			
		||||
    else if (hasObject(address))
 | 
			
		||||
    
 | 
			
		||||
    unsigned int address = getObjectAddress(name);
 | 
			
		||||
    
 | 
			
		||||
    if (!object_[address].data)
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("object with address " + std::to_string(address) +
 | 
			
		||||
                     " exists but is not registered");
 | 
			
		||||
        MemoryStats  memStats;
 | 
			
		||||
 | 
			
		||||
        MemoryProfiler::stats = &memStats;
 | 
			
		||||
        object_[address].Ls   = Ls;
 | 
			
		||||
        object_[address].data.reset(new Holder<T>(new T(args...)));
 | 
			
		||||
        object_[address].size = memStats.totalAllocated;
 | 
			
		||||
        object_[address].type = &typeid(T);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("no object with address " + std::to_string(address));
 | 
			
		||||
        HADRON_ERROR("object '" + name + "' already allocated");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
void Environment::setObject(const std::string name, T *object)
 | 
			
		||||
void Environment::createLattice(const std::string name, const unsigned int Ls)
 | 
			
		||||
{
 | 
			
		||||
    setObject(getObjectAddress(name), object);
 | 
			
		||||
    GridCartesian *g = getGrid(Ls);
 | 
			
		||||
    
 | 
			
		||||
    createObject<T>(name, Ls, g);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
T * Environment::getObject(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasRegisteredObject(address))
 | 
			
		||||
    if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        if (auto h = dynamic_cast<Holder<T> *>(object_[address].data.get()))
 | 
			
		||||
        {
 | 
			
		||||
@@ -358,11 +332,6 @@ T * Environment::getObject(const unsigned int address) const
 | 
			
		||||
                         "' (has type '" + getObjectType(address) + "')");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("object with address " + std::to_string(address) +
 | 
			
		||||
                     " exists but is not registered");
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("no object with address " + std::to_string(address));
 | 
			
		||||
@@ -375,26 +344,10 @@ T * Environment::getObject(const std::string name) const
 | 
			
		||||
    return getObject<T>(getObjectAddress(name));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
T * Environment::createLattice(const unsigned int address)
 | 
			
		||||
{
 | 
			
		||||
    GridCartesian *g = getGrid(getObjectLs(address));
 | 
			
		||||
    
 | 
			
		||||
    setObject(address, new T(g));
 | 
			
		||||
    
 | 
			
		||||
    return getObject<T>(address);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
T * Environment::createLattice(const std::string name)
 | 
			
		||||
{
 | 
			
		||||
    return createLattice<T>(getObjectAddress(name));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
bool Environment::isObjectOfType(const unsigned int address) const
 | 
			
		||||
{
 | 
			
		||||
    if (hasRegisteredObject(address))
 | 
			
		||||
    if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        if (auto h = dynamic_cast<Holder<T> *>(object_[address].data.get()))
 | 
			
		||||
        {
 | 
			
		||||
@@ -405,11 +358,6 @@ bool Environment::isObjectOfType(const unsigned int address) const
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else if (hasObject(address))
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("object with address " + std::to_string(address) +
 | 
			
		||||
                     " exists but is not registered");
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        HADRON_ERROR("no object with address " + std::to_string(address));
 | 
			
		||||
 
 | 
			
		||||
@@ -88,6 +88,12 @@ static ns##mod##ModuleRegistrar ns##mod##ModuleRegistrarInstance;
 | 
			
		||||
 | 
			
		||||
#define ARG(...) __VA_ARGS__
 | 
			
		||||
 | 
			
		||||
#define mCreateObj(type, name, Ls, ...)\
 | 
			
		||||
env().template createObject<type>(name, Ls, __VA_ARGS__)
 | 
			
		||||
 | 
			
		||||
#define mGetObj(type, name)\
 | 
			
		||||
*env().template getObject<type>(name)
 | 
			
		||||
 | 
			
		||||
/******************************************************************************
 | 
			
		||||
 *                            Module class                                    *
 | 
			
		||||
 ******************************************************************************/
 | 
			
		||||
 
 | 
			
		||||
@@ -30,31 +30,31 @@ See the full license in the file "LICENSE" in the top level distribution directo
 | 
			
		||||
 | 
			
		||||
#include <Grid/Hadrons/Modules/MAction/DWF.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MAction/Wilson.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/Baryon.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/DiscLoop.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/Gamma3pt.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/Meson.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/WardIdentity.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/WeakHamiltonian.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MFermion/GaugeProp.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MGauge/Load.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MGauge/Random.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MGauge/StochEm.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/Baryon.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/DiscLoop.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/Gamma3pt.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/Meson.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/WardIdentity.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonian.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MFermion/GaugeProp.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MGauge/Load.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MGauge/Random.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MGauge/StochEm.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MGauge/Unit.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MLoop/NoiseLoop.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MScalar/Scalar.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MSink/Point.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MSink/Smear.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MLoop/NoiseLoop.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MScalar/Scalar.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MSink/Point.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MSink/Smear.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MSolver/RBPrecCG.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MSource/Point.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MSource/SeqConserved.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MSource/SeqGamma.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MSource/Wall.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MSource/Z2.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MUtilities/TestSeqConserved.hpp>
 | 
			
		||||
#include <Grid/Hadrons/Modules/MUtilities/TestSeqGamma.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MSource/Point.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MSource/SeqConserved.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MSource/SeqGamma.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MSource/Wall.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MSource/Z2.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MUtilities/TestSeqConserved.hpp>
 | 
			
		||||
// #include <Grid/Hadrons/Modules/MUtilities/TestSeqGamma.hpp>
 | 
			
		||||
 
 | 
			
		||||
@@ -102,37 +102,30 @@ std::vector<std::string> TDWF<FImpl>::getOutput(void)
 | 
			
		||||
// setup ///////////////////////////////////////////////////////////////////////
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
void TDWF<FImpl>::setup(void)
 | 
			
		||||
{
 | 
			
		||||
    unsigned int size;
 | 
			
		||||
    
 | 
			
		||||
    size = 2*env().template lattice4dSize<typename FImpl::DoubledGaugeField>();
 | 
			
		||||
    env().registerObject(getName(), size, par().Ls);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// execution ///////////////////////////////////////////////////////////////////
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
void TDWF<FImpl>::execute(void)
 | 
			
		||||
{
 | 
			
		||||
    LOG(Message) << "Setting up domain wall fermion matrix with m= "
 | 
			
		||||
                 << par().mass << ", M5= " << par().M5 << " and Ls= "
 | 
			
		||||
                 << par().Ls << " using gauge field '" << par().gauge << "'"
 | 
			
		||||
                 << std::endl;
 | 
			
		||||
    LOG(Message) << "Fermion boundary conditions: " << par().boundary 
 | 
			
		||||
    LOG(Message) << "Fermion boundary conditions: " << par().boundary
 | 
			
		||||
                 << std::endl;
 | 
			
		||||
    env().createGrid(par().Ls);
 | 
			
		||||
    auto &U      = *env().template getObject<LatticeGaugeField>(par().gauge);
 | 
			
		||||
    auto &U      = mGetObj(LatticeGaugeField, par().gauge);
 | 
			
		||||
    auto &g4     = *env().getGrid();
 | 
			
		||||
    auto &grb4   = *env().getRbGrid();
 | 
			
		||||
    auto &g5     = *env().getGrid(par().Ls);
 | 
			
		||||
    auto &grb5   = *env().getRbGrid(par().Ls);
 | 
			
		||||
    std::vector<Complex> boundary = strToVec<Complex>(par().boundary);
 | 
			
		||||
    typename DomainWallFermion<FImpl>::ImplParams implParams(boundary);
 | 
			
		||||
    FMat *fMatPt = new DomainWallFermion<FImpl>(U, g5, grb5, g4, grb4,
 | 
			
		||||
                                                par().mass, par().M5,
 | 
			
		||||
                                                implParams);
 | 
			
		||||
    env().setObject(getName(), fMatPt);
 | 
			
		||||
    mCreateObj(DomainWallFermion<FImpl>, getName(), par().Ls,
 | 
			
		||||
               U, g5, grb5, g4, grb4, par().mass, par().M5, implParams);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// execution ///////////////////////////////////////////////////////////////////
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
void TDWF<FImpl>::execute(void)
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
END_MODULE_NAMESPACE
 | 
			
		||||
 | 
			
		||||
END_HADRONS_NAMESPACE
 | 
			
		||||
 
 | 
			
		||||
@@ -101,29 +101,23 @@ std::vector<std::string> TWilson<FImpl>::getOutput(void)
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
void TWilson<FImpl>::setup(void)
 | 
			
		||||
{
 | 
			
		||||
    unsigned int size;
 | 
			
		||||
    
 | 
			
		||||
    size = 2*env().template lattice4dSize<typename FImpl::DoubledGaugeField>();
 | 
			
		||||
    env().registerObject(getName(), size);
 | 
			
		||||
    LOG(Message) << "Setting up TWilson fermion matrix with m= " << par().mass
 | 
			
		||||
                 << " using gauge field '" << par().gauge << "'" << std::endl;
 | 
			
		||||
    LOG(Message) << "Fermion boundary conditions: " << par().boundary
 | 
			
		||||
                 << std::endl;
 | 
			
		||||
    auto &U      = mGetObj(LatticeGaugeField, par().gauge);
 | 
			
		||||
    auto &grid   = *env().getGrid();
 | 
			
		||||
    auto &gridRb = *env().getRbGrid();
 | 
			
		||||
    std::vector<Complex> boundary = strToVec<Complex>(par().boundary);
 | 
			
		||||
    typename WilsonFermion<FImpl>::ImplParams implParams(boundary);
 | 
			
		||||
    mCreateObj(WilsonFermion<FImpl>, getName(), 1, U, grid, gridRb, par().mass,
 | 
			
		||||
               implParams);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// execution ///////////////////////////////////////////////////////////////////
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
void TWilson<FImpl>::execute()
 | 
			
		||||
{
 | 
			
		||||
    LOG(Message) << "Setting up TWilson fermion matrix with m= " << par().mass
 | 
			
		||||
                 << " using gauge field '" << par().gauge << "'" << std::endl;
 | 
			
		||||
    LOG(Message) << "Fermion boundary conditions: " << par().boundary 
 | 
			
		||||
                 << std::endl;
 | 
			
		||||
    auto &U      = *env().template getObject<LatticeGaugeField>(par().gauge);
 | 
			
		||||
    auto &grid   = *env().getGrid();
 | 
			
		||||
    auto &gridRb = *env().getRbGrid();
 | 
			
		||||
    std::vector<Complex> boundary = strToVec<Complex>(par().boundary);
 | 
			
		||||
    typename WilsonFermion<FImpl>::ImplParams implParams(boundary);
 | 
			
		||||
    FMat *fMatPt = new WilsonFermion<FImpl>(U, grid, gridRb, par().mass,
 | 
			
		||||
                                            implParams);
 | 
			
		||||
    env().setObject(getName(), fMatPt);
 | 
			
		||||
}
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
END_MODULE_NAMESPACE
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -57,13 +57,13 @@ std::vector<std::string> TUnit::getOutput(void)
 | 
			
		||||
// setup ///////////////////////////////////////////////////////////////////////
 | 
			
		||||
void TUnit::setup(void)
 | 
			
		||||
{
 | 
			
		||||
    env().registerLattice<LatticeGaugeField>(getName());
 | 
			
		||||
    mCreateObj(LatticeGaugeField, getName(), 1, env().getGrid());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// execution ///////////////////////////////////////////////////////////////////
 | 
			
		||||
void TUnit::execute(void)
 | 
			
		||||
{
 | 
			
		||||
    LOG(Message) << "Creating unit gauge configuration" << std::endl;
 | 
			
		||||
    LatticeGaugeField &U = *env().createLattice<LatticeGaugeField>(getName());
 | 
			
		||||
    auto &U = mGetObj(LatticeGaugeField, getName());
 | 
			
		||||
    SU3::ColdConfiguration(*env().get4dRng(), U);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -100,17 +100,12 @@ std::vector<std::string> TRBPrecCG<FImpl>::getOutput(void)
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
void TRBPrecCG<FImpl>::setup(void)
 | 
			
		||||
{
 | 
			
		||||
    auto Ls = env().getObjectLs(par().action);
 | 
			
		||||
    
 | 
			
		||||
    env().registerObject(getName(), 0, Ls);
 | 
			
		||||
    env().addOwnership(getName(), par().action);
 | 
			
		||||
}
 | 
			
		||||
    LOG(Message) << "setting up Schur red-black preconditioned CG for"
 | 
			
		||||
                 << " action '" << par().action << "' with residual "
 | 
			
		||||
                 << par().residual << std::endl;
 | 
			
		||||
 | 
			
		||||
// execution ///////////////////////////////////////////////////////////////////
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
void TRBPrecCG<FImpl>::execute(void)
 | 
			
		||||
{
 | 
			
		||||
    auto &mat   = *(env().template getObject<FMat>(par().action));
 | 
			
		||||
    auto Ls     = env().getObjectLs(par().action);
 | 
			
		||||
    auto &mat   = mGetObj(FMat, par().action);
 | 
			
		||||
    auto solver = [&mat, this](FermionField &sol, const FermionField &source)
 | 
			
		||||
    {
 | 
			
		||||
        ConjugateGradient<FermionField>           cg(par().residual, 10000);
 | 
			
		||||
@@ -118,13 +113,15 @@ void TRBPrecCG<FImpl>::execute(void)
 | 
			
		||||
        
 | 
			
		||||
        schurSolver(mat, source, sol);
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    LOG(Message) << "setting up Schur red-black preconditioned CG for"
 | 
			
		||||
                 << " action '" << par().action << "' with residual "
 | 
			
		||||
                 << par().residual << std::endl;
 | 
			
		||||
    env().setObject(getName(), new SolverFn(solver));
 | 
			
		||||
    mCreateObj(SolverFn, getName(), Ls, solver);
 | 
			
		||||
    env().addOwnership(getName(), par().action);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// execution ///////////////////////////////////////////////////////////////////
 | 
			
		||||
template <typename FImpl>
 | 
			
		||||
void TRBPrecCG<FImpl>::execute(void)
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
END_MODULE_NAMESPACE
 | 
			
		||||
 | 
			
		||||
END_HADRONS_NAMESPACE
 | 
			
		||||
 
 | 
			
		||||
@@ -1,42 +1,44 @@
 | 
			
		||||
modules_cc =\
 | 
			
		||||
  Modules/MContraction/WeakHamiltonianEye.cc \
 | 
			
		||||
  Modules/MContraction/WeakHamiltonianNonEye.cc \
 | 
			
		||||
  Modules/MContraction/WeakNeutral4ptDisc.cc \
 | 
			
		||||
  Modules/MGauge/Load.cc \
 | 
			
		||||
  Modules/MGauge/Random.cc \
 | 
			
		||||
  Modules/MGauge/StochEm.cc \
 | 
			
		||||
  Modules/MGauge/Unit.cc \
 | 
			
		||||
  Modules/MScalar/ChargedProp.cc \
 | 
			
		||||
  Modules/MScalar/FreeProp.cc
 | 
			
		||||
  Modules/MGauge/Unit.cc
 | 
			
		||||
  # Modules/MContraction/WeakHamiltonianEye.cc \
 | 
			
		||||
  # Modules/MContraction/WeakHamiltonianNonEye.cc \
 | 
			
		||||
  # Modules/MContraction/WeakNeutral4ptDisc.cc \
 | 
			
		||||
  # Modules/MGauge/Load.cc \
 | 
			
		||||
  # Modules/MGauge/Random.cc \
 | 
			
		||||
  # Modules/MGauge/StochEm.cc \
 | 
			
		||||
  # Modules/MScalar/ChargedProp.cc \
 | 
			
		||||
  # Modules/MScalar/FreeProp.cc
 | 
			
		||||
 | 
			
		||||
modules_hpp =\
 | 
			
		||||
  Modules/MAction/DWF.hpp \
 | 
			
		||||
  Modules/MAction/Wilson.hpp \
 | 
			
		||||
  Modules/MContraction/Baryon.hpp \
 | 
			
		||||
  Modules/MContraction/DiscLoop.hpp \
 | 
			
		||||
  Modules/MContraction/Gamma3pt.hpp \
 | 
			
		||||
  Modules/MContraction/Meson.hpp \
 | 
			
		||||
  Modules/MContraction/WardIdentity.hpp \
 | 
			
		||||
  Modules/MContraction/WeakHamiltonian.hpp \
 | 
			
		||||
  Modules/MContraction/WeakHamiltonianEye.hpp \
 | 
			
		||||
  Modules/MContraction/WeakHamiltonianNonEye.hpp \
 | 
			
		||||
  Modules/MContraction/WeakNeutral4ptDisc.hpp \
 | 
			
		||||
  Modules/MFermion/GaugeProp.hpp \
 | 
			
		||||
  Modules/MGauge/Load.hpp \
 | 
			
		||||
  Modules/MGauge/Random.hpp \
 | 
			
		||||
  Modules/MGauge/StochEm.hpp \
 | 
			
		||||
  Modules/MGauge/Unit.hpp \
 | 
			
		||||
  Modules/MLoop/NoiseLoop.hpp \
 | 
			
		||||
  Modules/MScalar/ChargedProp.hpp \
 | 
			
		||||
  Modules/MScalar/FreeProp.hpp \
 | 
			
		||||
  Modules/MScalar/Scalar.hpp \
 | 
			
		||||
  Modules/MSink/Point.hpp \
 | 
			
		||||
  Modules/MSink/Smear.hpp \
 | 
			
		||||
  Modules/MSolver/RBPrecCG.hpp \
 | 
			
		||||
  Modules/MSource/Point.hpp \
 | 
			
		||||
  Modules/MSource/SeqConserved.hpp \
 | 
			
		||||
  Modules/MSource/SeqGamma.hpp \
 | 
			
		||||
  Modules/MSource/Wall.hpp \
 | 
			
		||||
  Modules/MSource/Z2.hpp \
 | 
			
		||||
  Modules/MUtilities/TestSeqConserved.hpp \
 | 
			
		||||
  Modules/MUtilities/TestSeqGamma.hpp
 | 
			
		||||
  Modules/MSolver/RBPrecCG.hpp
 | 
			
		||||
 | 
			
		||||
  # Modules/MContraction/Baryon.hpp \
 | 
			
		||||
  # Modules/MContraction/DiscLoop.hpp \
 | 
			
		||||
  # Modules/MContraction/Gamma3pt.hpp \
 | 
			
		||||
  # Modules/MContraction/Meson.hpp \
 | 
			
		||||
  # Modules/MContraction/WardIdentity.hpp \
 | 
			
		||||
  # Modules/MContraction/WeakHamiltonian.hpp \
 | 
			
		||||
  # Modules/MContraction/WeakHamiltonianEye.hpp \
 | 
			
		||||
  # Modules/MContraction/WeakHamiltonianNonEye.hpp \
 | 
			
		||||
  # Modules/MContraction/WeakNeutral4ptDisc.hpp \
 | 
			
		||||
  # Modules/MFermion/GaugeProp.hpp \
 | 
			
		||||
  # Modules/MGauge/Load.hpp \
 | 
			
		||||
  # Modules/MGauge/Random.hpp \
 | 
			
		||||
  # Modules/MGauge/StochEm.hpp \
 | 
			
		||||
  # Modules/MLoop/NoiseLoop.hpp \
 | 
			
		||||
  # Modules/MScalar/ChargedProp.hpp \
 | 
			
		||||
  # Modules/MScalar/FreeProp.hpp \
 | 
			
		||||
  # Modules/MScalar/Scalar.hpp \
 | 
			
		||||
  # Modules/MSink/Point.hpp \
 | 
			
		||||
  # Modules/MSink/Smear.hpp \
 | 
			
		||||
  # Modules/MSolver/RBPrecCG.hpp \
 | 
			
		||||
  # Modules/MSource/Point.hpp \
 | 
			
		||||
  # Modules/MSource/SeqConserved.hpp \
 | 
			
		||||
  # Modules/MSource/SeqGamma.hpp \
 | 
			
		||||
  # Modules/MSource/Wall.hpp \
 | 
			
		||||
  # Modules/MSource/Z2.hpp \
 | 
			
		||||
  # Modules/MUtilities/TestSeqConserved.hpp \
 | 
			
		||||
  # Modules/MUtilities/TestSeqGamma.hpp
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user