1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-07 04:35:56 +01:00

Hadrons: macro refactoring for library portability

This commit is contained in:
Antonin Portelli 2018-04-25 16:49:14 +01:00
parent b234784c8e
commit cc6eb51e3e
22 changed files with 55 additions and 55 deletions

@ -114,12 +114,12 @@ void Application::parseParameterFile(const std::string parameterFileName)
setPar(par);
if (!push(reader, "modules"))
{
HADRON_ERROR(Parsing, "Cannot open node 'modules' in parameter file '"
HADRONS_ERROR(Parsing, "Cannot open node 'modules' in parameter file '"
+ parameterFileName + "'");
}
if (!push(reader, "module"))
{
HADRON_ERROR(Parsing, "Cannot open node 'modules/module' in parameter file '"
HADRONS_ERROR(Parsing, "Cannot open node 'modules/module' in parameter file '"
+ parameterFileName + "'");
}
do
@ -177,7 +177,7 @@ void Application::saveSchedule(const std::string filename)
if (!scheduled_)
{
HADRON_ERROR(Definition, "Computation not scheduled");
HADRONS_ERROR(Definition, "Computation not scheduled");
}
for (auto address: program_)
@ -208,7 +208,7 @@ void Application::printSchedule(void)
{
if (!scheduled_)
{
HADRON_ERROR(Definition, "Computation not scheduled");
HADRONS_ERROR(Definition, "Computation not scheduled");
}
auto peak = vm().memoryNeeded(program_);
LOG(Message) << "Schedule (memory needed: " << sizeString(peak) << "):"

@ -123,7 +123,7 @@ protected:
binReader.readScidacFieldRecord(evec[k], vecRecord);
if (vecRecord.index != k)
{
HADRON_ERROR(Io, "Eigenvector " + std::to_string(k) + " has a"
HADRONS_ERROR(Io, "Eigenvector " + std::to_string(k) + " has a"
+ " wrong index (expected " + std::to_string(vecRecord.index)
+ ") in file '" + filename + "'");
}

@ -35,7 +35,7 @@ using namespace QCD;
using namespace Hadrons;
#define ERROR_NO_ADDRESS(address)\
HADRON_ERROR(Definition, "no object with address " + std::to_string(address));
HADRONS_ERROR(Definition, "no object with address " + std::to_string(address));
/******************************************************************************
* Environment implementation *
@ -85,7 +85,7 @@ void Environment::createCoarseGrid(const std::vector<int> &blockSize,
coarseDim[d] = fineDim[d]/blockSize[d];
if (coarseDim[d]*blockSize[d] != fineDim[d])
{
HADRON_ERROR(Size, "Fine dimension " + std::to_string(d)
HADRONS_ERROR(Size, "Fine dimension " + std::to_string(d)
+ " (" + std::to_string(fineDim[d])
+ ") not divisible by coarse dimension ("
+ std::to_string(coarseDim[d]) + ")");
@ -96,7 +96,7 @@ void Environment::createCoarseGrid(const std::vector<int> &blockSize,
cLs = Ls/blockSize[nd];
if (cLs*blockSize[nd] != Ls)
{
HADRON_ERROR(Size, "Fine Ls (" + std::to_string(Ls)
HADRONS_ERROR(Size, "Fine Ls (" + std::to_string(Ls)
+ ") not divisible by coarse Ls ("
+ std::to_string(cLs) + ")");
}
@ -128,7 +128,7 @@ GridCartesian * Environment::getGrid(const unsigned int Ls) const
}
catch(std::out_of_range &)
{
HADRON_ERROR(Definition, "no grid with Ls= " + std::to_string(Ls));
HADRONS_ERROR(Definition, "no grid with Ls= " + std::to_string(Ls));
}
}
@ -147,7 +147,7 @@ GridRedBlackCartesian * Environment::getRbGrid(const unsigned int Ls) const
}
catch(std::out_of_range &)
{
HADRON_ERROR(Definition, "no red-black grid with Ls= " + std::to_string(Ls));
HADRONS_ERROR(Definition, "no red-black grid with Ls= " + std::to_string(Ls));
}
}
@ -171,7 +171,7 @@ GridCartesian * Environment::getCoarseGrid(
}
catch(std::out_of_range &)
{
HADRON_ERROR(Definition, "no coarse grid with Ls= " + std::to_string(Ls));
HADRONS_ERROR(Definition, "no coarse grid with Ls= " + std::to_string(Ls));
}
}
@ -221,7 +221,7 @@ void Environment::addObject(const std::string name, const int moduleAddress)
}
else
{
HADRON_ERROR(Definition, "object '" + name + "' already exists");
HADRONS_ERROR(Definition, "object '" + name + "' already exists");
}
}
@ -244,7 +244,7 @@ unsigned int Environment::getObjectAddress(const std::string name) const
}
else
{
HADRON_ERROR(Definition, "no object with name '" + name + "'");
HADRONS_ERROR(Definition, "no object with name '" + name + "'");
}
}

@ -245,7 +245,7 @@ void Environment::createDerivedObject(const std::string name,
(object_[address].type != &typeid(B)) or
(object_[address].derivedType != &typeid(T)))
{
HADRON_ERROR(Definition, "object '" + name + "' already allocated");
HADRONS_ERROR(Definition, "object '" + name + "' already allocated");
}
}
@ -279,7 +279,7 @@ T * Environment::getDerivedObject(const unsigned int address) const
}
else
{
HADRON_ERROR(Definition, "object with address " + std::to_string(address) +
HADRONS_ERROR(Definition, "object with address " + std::to_string(address) +
" cannot be casted to '" + typeName(&typeid(T)) +
"' (has type '" + typeName(&typeid(h->get())) + "')");
}
@ -287,20 +287,20 @@ T * Environment::getDerivedObject(const unsigned int address) const
}
else
{
HADRON_ERROR(Definition, "object with address " + std::to_string(address) +
HADRONS_ERROR(Definition, "object with address " + std::to_string(address) +
" does not have type '" + typeName(&typeid(B)) +
"' (has type '" + getObjectType(address) + "')");
}
}
else
{
HADRON_ERROR(Definition, "object with address " + std::to_string(address) +
HADRONS_ERROR(Definition, "object with address " + std::to_string(address) +
" is empty");
}
}
else
{
HADRON_ERROR(Definition, "no object with address " + std::to_string(address));
HADRONS_ERROR(Definition, "no object with address " + std::to_string(address));
}
}
@ -338,7 +338,7 @@ bool Environment::isObjectOfType(const unsigned int address) const
}
else
{
HADRON_ERROR(Definition, "no object with address " + std::to_string(address));
HADRONS_ERROR(Definition, "no object with address " + std::to_string(address));
}
}

@ -34,10 +34,10 @@ See the full license in the file "LICENSE" in the top level distribution directo
#include <Grid/Hadrons/Global.hpp>
#endif
#define SRC_LOC std::string(__FUNCTION__) + " at " + std::string(__FILE__) + ":"\
+ std::to_string(__LINE__)
#define HADRON_ERROR(exc, msg)\
throw(Exceptions::exc(msg, SRC_LOC));
#define HADRONS_SRC_LOC std::string(__FUNCTION__) + " at " \
+ std::string(__FILE__) + ":" + std::to_string(__LINE__)
#define HADRONS_ERROR(exc, msg)\
throw(Exceptions::exc(msg, HADRONS_SRC_LOC));
#define DECL_EXC(name, base) \
class name: public base\

@ -94,7 +94,7 @@ std::unique_ptr<T> Factory<T>::create(const std::string type,
}
catch (std::out_of_range &)
{
HADRON_ERROR(Argument, "object of type '" + type + "' unknown");
HADRONS_ERROR(Argument, "object of type '" + type + "' unknown");
}
return func(name);

@ -110,7 +110,7 @@ public:
};
#define LOG(channel) std::cout << HadronsLog##channel
#define DEBUG_VAR(var) LOG(Debug) << #var << "= " << (var) << std::endl;
#define HADRONS_DEBUG_VAR(var) LOG(Debug) << #var << "= " << (var) << std::endl;
extern HadronsLogger HadronsLogError;
extern HadronsLogger HadronsLogWarning;

@ -184,7 +184,7 @@ void Graph<T>::removeVertex(const T &value)
}
else
{
HADRON_ERROR(Range, "vertex does not exists");
HADRONS_ERROR(Range, "vertex does not exists");
}
// remove all edges containing the vertex
@ -213,7 +213,7 @@ void Graph<T>::removeEdge(const Edge &e)
}
else
{
HADRON_ERROR(Range, "edge does not exists");
HADRONS_ERROR(Range, "edge does not exists");
}
}
@ -259,7 +259,7 @@ void Graph<T>::mark(const T &value, const bool doMark)
}
else
{
HADRON_ERROR(Range, "vertex does not exists");
HADRONS_ERROR(Range, "vertex does not exists");
}
}
@ -297,7 +297,7 @@ bool Graph<T>::isMarked(const T &value) const
}
else
{
HADRON_ERROR(Range, "vertex does not exists");
HADRONS_ERROR(Range, "vertex does not exists");
return false;
}
@ -543,7 +543,7 @@ std::vector<T> Graph<T>::topoSort(void)
{
if (tmpMarked.at(v))
{
HADRON_ERROR(Range, "cannot topologically sort a cyclic graph");
HADRONS_ERROR(Range, "cannot topologically sort a cyclic graph");
}
if (!isMarked(v))
{
@ -602,7 +602,7 @@ std::vector<T> Graph<T>::topoSort(Gen &gen)
{
if (tmpMarked.at(v))
{
HADRON_ERROR(Range, "cannot topologically sort a cyclic graph");
HADRONS_ERROR(Range, "cannot topologically sort a cyclic graph");
}
if (!isMarked(v))
{

@ -49,7 +49,7 @@ std::string ModuleBase::getName(void) const
// get factory registration name if available
std::string ModuleBase::getRegisteredName(void)
{
HADRON_ERROR(Definition, "module '" + getName() + "' has no registered type"
HADRONS_ERROR(Definition, "module '" + getName() + "' has no registered type"
+ " in the factory");
}

@ -126,7 +126,7 @@ if (env().getGrid()->IsBoss())\
\
if (mkdir(_dirname))\
{\
HADRON_ERROR(Io, "cannot create directory '" + _dirname + "'");\
HADRONS_ERROR(Io, "cannot create directory '" + _dirname + "'");\
}\
{\
ResultWriter _writer(RESULT_FILE_NAME(ioStem));\

@ -119,7 +119,7 @@ void TWardIdentity<FImpl>::setup(void)
Ls_ = env().getObjectLs(par().q);
if (Ls_ != env().getObjectLs(par().action))
{
HADRON_ERROR(Size, "Ls mismatch between quark action and propagator");
HADRONS_ERROR(Size, "Ls mismatch between quark action and propagator");
}
envTmpLat(PropagatorField, "tmp");
envTmpLat(PropagatorField, "vector_WI");

@ -177,7 +177,7 @@ void TGaugeProp<FImpl>::execute(void)
{
if (Ls_ != env().getObjectLs(par().source))
{
HADRON_ERROR(Size, "Ls mismatch between quark action and source");
HADRONS_ERROR(Size, "Ls mismatch between quark action and source");
}
else
{

@ -112,7 +112,7 @@ void TDiv<SImpl>::setup(void)
{
if (par().op.size() != env().getNd())
{
HADRON_ERROR(Size, "the number of components differs from number of dimensions");
HADRONS_ERROR(Size, "the number of components differs from number of dimensions");
}
envCreateLat(ComplexField, getName());
}

@ -134,14 +134,14 @@ void TShiftProbe<SImpl>::execute(void)
shift = strToVec<ShiftPair>(par().shifts);
if (shift.size() % 2 != 0)
{
HADRON_ERROR(Size, "the number of shifts is odd");
HADRONS_ERROR(Size, "the number of shifts is odd");
}
sign = (shift.size() % 4 == 0) ? 1 : -1;
for (auto &s: shift)
{
if (s.first >= env().getNd())
{
HADRON_ERROR(Size, "dimension to large for shift <"
HADRONS_ERROR(Size, "dimension to large for shift <"
+ std::to_string(s.first) + " "
+ std::to_string(s.second) + ">" );
}

@ -119,7 +119,7 @@ void TTrPhi<SImpl>::setup(void)
{
if (par().maxPow < 2)
{
HADRON_ERROR(Size, "'maxPow' should be at least equal to 2");
HADRONS_ERROR(Size, "'maxPow' should be at least equal to 2");
}
envTmpLat(Field, "phi2");
envTmpLat(Field, "buf");

@ -143,7 +143,7 @@ void TTwoPoint<SImpl>::setup(void)
mom_[i] = strToVec<int>(par().mom[i]);
if (mom_[i].size() != nd - 1)
{
HADRON_ERROR(Size, "momentum number of components different from "
HADRONS_ERROR(Size, "momentum number of components different from "
+ std::to_string(nd-1));
}
}

@ -44,7 +44,7 @@ inline void dmu(Field &out, const Field &in, const unsigned int mu, const DiffTy
if (mu >= env.getNd())
{
HADRON_ERROR(Range, "Derivative direction out of range");
HADRONS_ERROR(Range, "Derivative direction out of range");
}
switch(type)
{
@ -58,7 +58,7 @@ inline void dmu(Field &out, const Field &in, const unsigned int mu, const DiffTy
out = 0.5*(Cshift(in, mu, 1) - Cshift(in, mu, -1));
break;
default:
HADRON_ERROR(Argument, "Derivative type invalid");
HADRONS_ERROR(Argument, "Derivative type invalid");
break;
}
}
@ -70,7 +70,7 @@ inline void dmuAcc(Field &out, const Field &in, const unsigned int mu, const Dif
if (mu >= env.getNd())
{
HADRON_ERROR(Range, "Derivative direction out of range");
HADRONS_ERROR(Range, "Derivative direction out of range");
}
switch(type)
{
@ -84,7 +84,7 @@ inline void dmuAcc(Field &out, const Field &in, const unsigned int mu, const Dif
out += 0.5*(Cshift(in, mu, 1) - Cshift(in, mu, -1));
break;
default:
HADRON_ERROR(Argument, "Derivative type invalid");
HADRONS_ERROR(Argument, "Derivative type invalid");
break;
}
}

@ -127,7 +127,7 @@ void TRBPrecCG<FImpl, nBasis>::setup(void)
{
if (par().maxIteration == 0)
{
HADRON_ERROR(Argument, "zero maximum iteration");
HADRONS_ERROR(Argument, "zero maximum iteration");
}
LOG(Message) << "setting up Schur red-black preconditioned CG for"

@ -123,7 +123,7 @@ void TTestSeqConserved<FImpl>::setup(void)
auto Ls = env().getObjectLs(par().q);
if (Ls != env().getObjectLs(par().action))
{
HADRON_ERROR(Size, "Ls mismatch between quark action and propagator");
HADRONS_ERROR(Size, "Ls mismatch between quark action and propagator");
}
envTmpLat(PropagatorField, "tmp");
envTmpLat(LatticeComplex, "c");

@ -123,7 +123,7 @@ void VirtualMachine::pushModule(VirtualMachine::ModPt &pt)
else
{
// output already fully registered, error
HADRON_ERROR(Definition, "object '" + out
HADRONS_ERROR(Definition, "object '" + out
+ "' is already produced by module '"
+ module_[env().getObjectModule(out)].name
+ "' (while pushing module '" + name + "')");
@ -158,7 +158,7 @@ void VirtualMachine::pushModule(VirtualMachine::ModPt &pt)
}
else
{
HADRON_ERROR(Definition, "module '" + name + "' already exists");
HADRONS_ERROR(Definition, "module '" + name + "' already exists");
}
}
@ -185,7 +185,7 @@ ModuleBase * VirtualMachine::getModule(const unsigned int address) const
}
else
{
HADRON_ERROR(Definition, "no module with address " + std::to_string(address));
HADRONS_ERROR(Definition, "no module with address " + std::to_string(address));
}
}
@ -202,7 +202,7 @@ unsigned int VirtualMachine::getModuleAddress(const std::string name) const
}
else
{
HADRON_ERROR(Definition, "no module with name '" + name + "'");
HADRONS_ERROR(Definition, "no module with name '" + name + "'");
}
}
@ -214,7 +214,7 @@ std::string VirtualMachine::getModuleName(const unsigned int address) const
}
else
{
HADRON_ERROR(Definition, "no module with address " + std::to_string(address));
HADRONS_ERROR(Definition, "no module with address " + std::to_string(address));
}
}
@ -226,7 +226,7 @@ std::string VirtualMachine::getModuleType(const unsigned int address) const
}
else
{
HADRON_ERROR(Definition, "no module with address " + std::to_string(address));
HADRONS_ERROR(Definition, "no module with address " + std::to_string(address));
}
}
@ -306,7 +306,7 @@ void VirtualMachine::makeModuleGraph(void)
if (min < 0)
{
HADRON_ERROR(Definition, "dependency '"
HADRONS_ERROR(Definition, "dependency '"
+ env().getObjectName(in) + "' (address "
+ std::to_string(in)
+ ") is not produced by any module");

@ -195,7 +195,7 @@ M * VirtualMachine::getModule(const unsigned int address) const
}
else
{
HADRON_ERROR(Definition, "module '" + module_[address].name
HADRONS_ERROR(Definition, "module '" + module_[address].name
+ "' does not have type " + typeid(M).name()
+ "(has type: " + getModuleType(address) + ")");
}

@ -95,7 +95,7 @@ std::unique_ptr<T> Factory<T, CreatorInput>::create(const std::string type,
}
catch (std::out_of_range &)
{
//HADRON_ERROR("object of type '" + type + "' unknown");
//HADRONS_ERROR("object of type '" + type + "' unknown");
std::cout << GridLogError << "Error" << std::endl;
std::cout << GridLogError << obj_type() << " object of name [" << type << "] unknown" << std::endl;
exit(1);