mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 05:54:32 +00:00 
			
		
		
		
	Hadrons: integer types cleanup
This commit is contained in:
		@@ -143,6 +143,7 @@ void Environment::pushModule(Environment::ModPt &pt)
 | 
				
			|||||||
    if (!hasModule(name))
 | 
					    if (!hasModule(name))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::vector<unsigned int> inputAddress;
 | 
					        std::vector<unsigned int> inputAddress;
 | 
				
			||||||
 | 
					        unsigned int              address;
 | 
				
			||||||
        ModuleInfo                m;
 | 
					        ModuleInfo                m;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        m.data = std::move(pt);
 | 
					        m.data = std::move(pt);
 | 
				
			||||||
@@ -159,18 +160,19 @@ void Environment::pushModule(Environment::ModPt &pt)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        auto output = m.data->getOutput();
 | 
					        auto output = m.data->getOutput();
 | 
				
			||||||
        module_.push_back(std::move(m));
 | 
					        module_.push_back(std::move(m));
 | 
				
			||||||
        moduleAddress_[name] = module_.size() - 1;
 | 
					        address              = static_cast<unsigned int>(module_.size() - 1);
 | 
				
			||||||
 | 
					        moduleAddress_[name] = address;
 | 
				
			||||||
        for (auto &out: output)
 | 
					        for (auto &out: output)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!hasObject(out))
 | 
					            if (!hasObject(out))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                addObject(out , module_.size() - 1);
 | 
					                addObject(out, address);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (object_[objectAddress_[out]].module < 0)
 | 
					                if (object_[objectAddress_[out]].module < 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    object_[objectAddress_[out]].module = module_.size() - 1;
 | 
					                    object_[objectAddress_[out]].module = address;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@@ -287,9 +289,10 @@ Graph<unsigned int> Environment::makeModuleGraph(void) const
 | 
				
			|||||||
#define MEM_MSG(size)\
 | 
					#define MEM_MSG(size)\
 | 
				
			||||||
sizeString((size)*locVol_) << " (" << sizeString(size)  << "/site)"
 | 
					sizeString((size)*locVol_) << " (" << sizeString(size)  << "/site)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned int Environment::executeProgram(const std::vector<unsigned int> &p)
 | 
					Environment::Size
 | 
				
			||||||
 | 
					Environment::executeProgram(const std::vector<unsigned int> &p)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    unsigned int                        memPeak = 0, sizeBefore, sizeAfter;
 | 
					    Size                                memPeak = 0, sizeBefore, sizeAfter;
 | 
				
			||||||
    std::vector<std::set<unsigned int>> freeProg;
 | 
					    std::vector<std::set<unsigned int>> freeProg;
 | 
				
			||||||
    bool                                continueCollect, nothingFreed;
 | 
					    bool                                continueCollect, nothingFreed;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@@ -385,7 +388,7 @@ unsigned int Environment::executeProgram(const std::vector<unsigned int> &p)
 | 
				
			|||||||
    return memPeak;
 | 
					    return memPeak;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned int Environment::executeProgram(const std::vector<std::string> &p)
 | 
					Environment::Size Environment::executeProgram(const std::vector<std::string> &p)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    std::vector<unsigned int> pAddress;
 | 
					    std::vector<unsigned int> pAddress;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@@ -405,7 +408,7 @@ void Environment::addObject(const std::string name, const int moduleAddress)
 | 
				
			|||||||
    info.name   = name;
 | 
					    info.name   = name;
 | 
				
			||||||
    info.module = moduleAddress;
 | 
					    info.module = moduleAddress;
 | 
				
			||||||
    object_.push_back(std::move(info));
 | 
					    object_.push_back(std::move(info));
 | 
				
			||||||
    objectAddress_[name] = object_.size() - 1;
 | 
					    objectAddress_[name] = static_cast<unsigned int>(object_.size() - 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Environment::registerObject(const unsigned int address,
 | 
					void Environment::registerObject(const unsigned int address,
 | 
				
			||||||
@@ -483,7 +486,7 @@ std::string Environment::getObjectType(const std::string name) const
 | 
				
			|||||||
    return getObjectType(getObjectAddress(name));
 | 
					    return getObjectType(getObjectAddress(name));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned int Environment::getObjectSize(const unsigned int address) const
 | 
					Environment::Size Environment::getObjectSize(const unsigned int address) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (hasRegisteredObject(address))
 | 
					    if (hasRegisteredObject(address))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -500,7 +503,7 @@ unsigned int Environment::getObjectSize(const unsigned int address) const
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned int Environment::getObjectSize(const std::string name) const
 | 
					Environment::Size Environment::getObjectSize(const std::string name) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return getObjectSize(getObjectAddress(name));
 | 
					    return getObjectSize(getObjectAddress(name));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -573,9 +576,9 @@ bool Environment::isObject5d(const std::string name) const
 | 
				
			|||||||
    return (getObjectLs(name) > 1);
 | 
					    return (getObjectLs(name) > 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
long unsigned int Environment::getTotalSize(void) const
 | 
					Environment::Size Environment::getTotalSize(void) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    long unsigned int size = 0;
 | 
					    Environment::Size size = 0;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    for (auto &o: object_)
 | 
					    for (auto &o: object_)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,6 +31,10 @@ directory.
 | 
				
			|||||||
#include <Grid/Hadrons/Global.hpp>
 | 
					#include <Grid/Hadrons/Global.hpp>
 | 
				
			||||||
#include <Grid/Hadrons/Graph.hpp>
 | 
					#include <Grid/Hadrons/Graph.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef SITE_SIZE_TYPE
 | 
				
			||||||
 | 
					#define SITE_SIZE_TYPE unsigned int
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BEGIN_HADRONS_NAMESPACE
 | 
					BEGIN_HADRONS_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/******************************************************************************
 | 
					/******************************************************************************
 | 
				
			||||||
@@ -64,11 +68,12 @@ class Environment
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    SINGLETON(Environment);
 | 
					    SINGLETON(Environment);
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    typedef std::unique_ptr<ModuleBase>                 ModPt;
 | 
					    typedef SITE_SIZE_TYPE                         Size;
 | 
				
			||||||
    typedef std::unique_ptr<GridCartesian>              GridPt;
 | 
					    typedef std::unique_ptr<ModuleBase>            ModPt;
 | 
				
			||||||
    typedef std::unique_ptr<GridRedBlackCartesian>      GridRbPt;
 | 
					    typedef std::unique_ptr<GridCartesian>         GridPt;
 | 
				
			||||||
    typedef std::unique_ptr<GridParallelRNG>            RngPt;
 | 
					    typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
 | 
				
			||||||
    typedef std::unique_ptr<LatticeBase>                LatticePt;
 | 
					    typedef std::unique_ptr<GridParallelRNG>       RngPt;
 | 
				
			||||||
 | 
					    typedef std::unique_ptr<LatticeBase>           LatticePt;
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    struct ModuleInfo
 | 
					    struct ModuleInfo
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -79,7 +84,8 @@ private:
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
    struct ObjInfo
 | 
					    struct ObjInfo
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        unsigned int            size{0}, Ls{0};
 | 
					        Size                    size{0};
 | 
				
			||||||
 | 
					        unsigned int            Ls{0};
 | 
				
			||||||
        bool                    isRegistered{false};
 | 
					        bool                    isRegistered{false};
 | 
				
			||||||
        const std::type_info    *type{nullptr};
 | 
					        const std::type_info    *type{nullptr};
 | 
				
			||||||
        std::string             name;
 | 
					        std::string             name;
 | 
				
			||||||
@@ -124,8 +130,8 @@ public:
 | 
				
			|||||||
    bool                    hasModule(const unsigned int address) const;
 | 
					    bool                    hasModule(const unsigned int address) const;
 | 
				
			||||||
    bool                    hasModule(const std::string name) const;
 | 
					    bool                    hasModule(const std::string name) const;
 | 
				
			||||||
    Graph<unsigned int>     makeModuleGraph(void) const;
 | 
					    Graph<unsigned int>     makeModuleGraph(void) const;
 | 
				
			||||||
    unsigned int            executeProgram(const std::vector<unsigned int> &p);
 | 
					    Size                    executeProgram(const std::vector<unsigned int> &p);
 | 
				
			||||||
    unsigned int            executeProgram(const std::vector<std::string> &p);
 | 
					    Size                    executeProgram(const std::vector<std::string> &p);
 | 
				
			||||||
    // general memory management
 | 
					    // general memory management
 | 
				
			||||||
    void                    addObject(const std::string name,
 | 
					    void                    addObject(const std::string name,
 | 
				
			||||||
                                      const int moduleAddress);
 | 
					                                      const int moduleAddress);
 | 
				
			||||||
@@ -159,8 +165,8 @@ public:
 | 
				
			|||||||
    std::string             getObjectName(const unsigned int address) const;
 | 
					    std::string             getObjectName(const unsigned int address) const;
 | 
				
			||||||
    std::string             getObjectType(const unsigned int address) const;
 | 
					    std::string             getObjectType(const unsigned int address) const;
 | 
				
			||||||
    std::string             getObjectType(const std::string name) const;
 | 
					    std::string             getObjectType(const std::string name) const;
 | 
				
			||||||
    unsigned int            getObjectSize(const unsigned int address) const;
 | 
					    Size                    getObjectSize(const unsigned int address) const;
 | 
				
			||||||
    unsigned int            getObjectSize(const std::string name) const;
 | 
					    Size                    getObjectSize(const std::string name) const;
 | 
				
			||||||
    unsigned int            getObjectLs(const unsigned int address) const;
 | 
					    unsigned int            getObjectLs(const unsigned int address) const;
 | 
				
			||||||
    unsigned int            getObjectLs(const std::string name) const;
 | 
					    unsigned int            getObjectLs(const std::string name) const;
 | 
				
			||||||
    bool                    hasObject(const unsigned int address) const;
 | 
					    bool                    hasObject(const unsigned int address) const;
 | 
				
			||||||
@@ -169,7 +175,7 @@ public:
 | 
				
			|||||||
    bool                    hasRegisteredObject(const std::string name) const;
 | 
					    bool                    hasRegisteredObject(const std::string name) const;
 | 
				
			||||||
    bool                    isObject5d(const unsigned int address) const;
 | 
					    bool                    isObject5d(const unsigned int address) const;
 | 
				
			||||||
    bool                    isObject5d(const std::string name) const;
 | 
					    bool                    isObject5d(const std::string name) const;
 | 
				
			||||||
    long unsigned int       getTotalSize(void) const;
 | 
					    Environment::Size       getTotalSize(void) const;
 | 
				
			||||||
    void                    addOwnership(const unsigned int owner,
 | 
					    void                    addOwnership(const unsigned int owner,
 | 
				
			||||||
                                         const unsigned int property);
 | 
					                                         const unsigned int property);
 | 
				
			||||||
    void                    addOwnership(const std::string owner,
 | 
					    void                    addOwnership(const std::string owner,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user