1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-04 11:15:55 +01:00

Hadrons: integer types cleanup

This commit is contained in:
Antonin Portelli 2016-12-05 08:53:48 +09:00
parent 8190523e4c
commit 1540616b22
2 changed files with 31 additions and 22 deletions

View File

@ -143,6 +143,7 @@ void Environment::pushModule(Environment::ModPt &pt)
if (!hasModule(name))
{
std::vector<unsigned int> inputAddress;
unsigned int address;
ModuleInfo m;
m.data = std::move(pt);
@ -159,18 +160,19 @@ void Environment::pushModule(Environment::ModPt &pt)
}
auto output = m.data->getOutput();
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)
{
if (!hasObject(out))
{
addObject(out , module_.size() - 1);
addObject(out, address);
}
else
{
if (object_[objectAddress_[out]].module < 0)
{
object_[objectAddress_[out]].module = module_.size() - 1;
object_[objectAddress_[out]].module = address;
}
else
{
@ -287,9 +289,10 @@ Graph<unsigned int> Environment::makeModuleGraph(void) const
#define MEM_MSG(size)\
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;
bool continueCollect, nothingFreed;
@ -385,7 +388,7 @@ unsigned int Environment::executeProgram(const std::vector<unsigned int> &p)
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;
@ -405,7 +408,7 @@ void Environment::addObject(const std::string name, const int moduleAddress)
info.name = name;
info.module = moduleAddress;
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,
@ -483,7 +486,7 @@ std::string Environment::getObjectType(const std::string name) const
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))
{
@ -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));
}
@ -573,9 +576,9 @@ bool Environment::isObject5d(const std::string name) const
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_)
{

View File

@ -31,6 +31,10 @@ directory.
#include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Graph.hpp>
#ifndef SITE_SIZE_TYPE
#define SITE_SIZE_TYPE unsigned int
#endif
BEGIN_HADRONS_NAMESPACE
/******************************************************************************
@ -64,11 +68,12 @@ class Environment
{
SINGLETON(Environment);
public:
typedef std::unique_ptr<ModuleBase> ModPt;
typedef std::unique_ptr<GridCartesian> GridPt;
typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
typedef std::unique_ptr<GridParallelRNG> RngPt;
typedef std::unique_ptr<LatticeBase> LatticePt;
typedef SITE_SIZE_TYPE Size;
typedef std::unique_ptr<ModuleBase> ModPt;
typedef std::unique_ptr<GridCartesian> GridPt;
typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
typedef std::unique_ptr<GridParallelRNG> RngPt;
typedef std::unique_ptr<LatticeBase> LatticePt;
private:
struct ModuleInfo
{
@ -79,7 +84,8 @@ private:
};
struct ObjInfo
{
unsigned int size{0}, Ls{0};
Size size{0};
unsigned int Ls{0};
bool isRegistered{false};
const std::type_info *type{nullptr};
std::string name;
@ -124,8 +130,8 @@ public:
bool hasModule(const unsigned int address) const;
bool hasModule(const std::string name) const;
Graph<unsigned int> makeModuleGraph(void) const;
unsigned int executeProgram(const std::vector<unsigned int> &p);
unsigned int executeProgram(const std::vector<std::string> &p);
Size executeProgram(const std::vector<unsigned int> &p);
Size executeProgram(const std::vector<std::string> &p);
// general memory management
void addObject(const std::string name,
const int moduleAddress);
@ -159,8 +165,8 @@ public:
std::string getObjectName(const unsigned int address) const;
std::string getObjectType(const unsigned int address) const;
std::string getObjectType(const std::string name) const;
unsigned int getObjectSize(const unsigned int address) const;
unsigned int getObjectSize(const std::string name) const;
Size getObjectSize(const unsigned int address) const;
Size getObjectSize(const std::string name) const;
unsigned int getObjectLs(const unsigned int address) const;
unsigned int getObjectLs(const std::string name) const;
bool hasObject(const unsigned int address) const;
@ -169,7 +175,7 @@ public:
bool hasRegisteredObject(const std::string name) const;
bool isObject5d(const unsigned int address) 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,
const unsigned int property);
void addOwnership(const std::string owner,