diff --git a/extras/Hadrons/Environment.cc b/extras/Hadrons/Environment.cc index e9c7c733..03f33366 100644 --- a/extras/Hadrons/Environment.cc +++ b/extras/Hadrons/Environment.cc @@ -143,6 +143,7 @@ void Environment::pushModule(Environment::ModPt &pt) if (!hasModule(name)) { std::vector 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(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 Environment::makeModuleGraph(void) const #define MEM_MSG(size)\ sizeString((size)*locVol_) << " (" << sizeString(size) << "/site)" -unsigned int Environment::executeProgram(const std::vector &p) +Environment::Size +Environment::executeProgram(const std::vector &p) { - unsigned int memPeak = 0, sizeBefore, sizeAfter; + Size memPeak = 0, sizeBefore, sizeAfter; std::vector> freeProg; bool continueCollect, nothingFreed; @@ -385,7 +388,7 @@ unsigned int Environment::executeProgram(const std::vector &p) return memPeak; } -unsigned int Environment::executeProgram(const std::vector &p) +Environment::Size Environment::executeProgram(const std::vector &p) { std::vector 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(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_) { diff --git a/extras/Hadrons/Environment.hpp b/extras/Hadrons/Environment.hpp index aa93eb79..002d5d9d 100644 --- a/extras/Hadrons/Environment.hpp +++ b/extras/Hadrons/Environment.hpp @@ -31,6 +31,10 @@ directory. #include #include +#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 ModPt; - typedef std::unique_ptr GridPt; - typedef std::unique_ptr GridRbPt; - typedef std::unique_ptr RngPt; - typedef std::unique_ptr LatticePt; + typedef SITE_SIZE_TYPE Size; + typedef std::unique_ptr ModPt; + typedef std::unique_ptr GridPt; + typedef std::unique_ptr GridRbPt; + typedef std::unique_ptr RngPt; + typedef std::unique_ptr 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 makeModuleGraph(void) const; - unsigned int executeProgram(const std::vector &p); - unsigned int executeProgram(const std::vector &p); + Size executeProgram(const std::vector &p); + Size executeProgram(const std::vector &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,