1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Hadrons: eigenpack converter generalised for RB/5d grids

This commit is contained in:
Antonin Portelli 2018-10-02 13:34:17 +01:00
parent 430b98b354
commit 9aafa8ee60

View File

@ -7,7 +7,8 @@ using namespace Hadrons;
template <typename FOut, typename FIn> template <typename FOut, typename FIn>
void convert(const std::string outFilename, const std::string inFilename, void convert(const std::string outFilename, const std::string inFilename,
const unsigned int size, const bool multiFile) const unsigned int Ls, const bool rb, const unsigned int size,
const bool multiFile)
{ {
assert(outFilename != inFilename); assert(outFilename != inFilename);
@ -16,28 +17,60 @@ void convert(const std::string outFilename, const std::string inFilename,
typedef typename FOut::vector_type VTypeOut; typedef typename FOut::vector_type VTypeOut;
typedef typename FIn::vector_type VTypeIn; typedef typename FIn::vector_type VTypeIn;
std::shared_ptr<GridCartesian> fgIn, fgOut; std::shared_ptr<GridCartesian> gInBase, gOutBase, gIn5, gOut5;
std::shared_ptr<GridRedBlackCartesian> gIn, gOut; std::shared_ptr<GridRedBlackCartesian> rbgIn, rbgOut;
GridBase *gIn, *gOut;
auto dim = GridDefaultLatt(); auto dim = GridDefaultLatt();
unsigned int nd = dim.size(); unsigned int nd = dim.size();
auto simdOut = GridDefaultSimd(nd, VTypeOut::Nsimd()); auto simdOut = GridDefaultSimd(nd, VTypeOut::Nsimd());
auto simdIn = GridDefaultSimd(nd, VTypeIn::Nsimd()); auto simdIn = GridDefaultSimd(nd, VTypeIn::Nsimd());
fgOut.reset(SpaceTimeGrid::makeFourDimGrid(dim, simdOut, GridDefaultMpi())); gOutBase.reset(SpaceTimeGrid::makeFourDimGrid(dim, simdOut, GridDefaultMpi()));
gOut.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(fgOut.get())); gInBase.reset(SpaceTimeGrid::makeFourDimGrid(dim, simdIn, GridDefaultMpi()));
fgIn.reset(SpaceTimeGrid::makeFourDimGrid(dim, simdIn, GridDefaultMpi())); if (rb)
gIn.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(fgIn.get())); {
if (Ls > 1)
{
rbgOut.reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, gOutBase.get()));
rbgIn.reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, gInBase.get()));
}
else
{
rbgOut.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(gOutBase.get()));
rbgIn.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(gInBase.get()));
}
gOut = rbgOut.get();
gIn = rbgIn.get();
}
else
{
if (Ls > 1)
{
gOut5.reset(SpaceTimeGrid::makeFiveDimGrid(Ls, gOutBase.get()));
gIn5.reset(SpaceTimeGrid::makeFiveDimGrid(Ls, gInBase.get()));
gOut = gOut5.get();
gIn = gIn5.get();
}
else
{
gOut = gOutBase.get();
gIn = gInBase.get();
}
}
FOut bufOut(gOut.get()); FOut bufOut(gOut);
FIn bufIn(gIn.get()), testIn(gIn.get()); FIn bufIn(gIn), testIn(gIn);
LOG(Message) << "==== EIGENPACK CONVERSION" << std::endl; LOG(Message) << "==== EIGENPACK CONVERSION" << std::endl;
LOG(Message) << "In path : " << inFilename << std::endl; LOG(Message) << "Lattice : " << gIn->GlobalDimensions() << std::endl;
LOG(Message) << "In type : " << typeName<FIn>() << std::endl; LOG(Message) << "Checkerboarded: " << (rb ? "yes" : "no") << std::endl;
LOG(Message) << "Out path : " << outFilename << std::endl; LOG(Message) << "In path : " << inFilename << std::endl;
LOG(Message) << "Out type : " << typeName<FOut>() << std::endl; LOG(Message) << "In type : " << typeName<FIn>() << std::endl;
LOG(Message) << "Multifile: " << (multiFile ? "yes" : "no") << std::endl; LOG(Message) << "Out path : " << outFilename << std::endl;
LOG(Message) << "Out type : " << typeName<FOut>() << std::endl;
LOG(Message) << "#vectors : " << size << std::endl;
LOG(Message) << "Multifile : " << (multiFile ? "yes" : "no") << std::endl;
if (multiFile) if (multiFile)
{ {
for(unsigned int k = 0; k < size; ++k) for(unsigned int k = 0; k < size; ++k)
@ -52,7 +85,7 @@ void convert(const std::string outFilename, const std::string inFilename,
LOG(Message) << "==== Converting vector " << k << std::endl; LOG(Message) << "==== Converting vector " << k << std::endl;
LOG(Message) << "In : " << inV << std::endl; LOG(Message) << "In : " << inV << std::endl;
LOG(Message) << "Out: " << outV << std::endl; LOG(Message) << "Out: " << outV << std::endl;
makeFileDir(outV, gOut.get()); makeFileDir(outV, gOut);
binWriter.open(outV); binWriter.open(outV);
binReader.open(inV); binReader.open(inV);
EPIn::readHeader(record, binReader); EPIn::readHeader(record, binReader);
@ -73,7 +106,7 @@ void convert(const std::string outFilename, const std::string inFilename,
ScidacReader binReader; ScidacReader binReader;
PackRecord record; PackRecord record;
makeFileDir(outFilename, gOut.get()); makeFileDir(outFilename, gOut);
binWriter.open(outFilename); binWriter.open(outFilename);
binReader.open(inFilename); binReader.open(inFilename);
EPIn::readHeader(record, binReader); EPIn::readHeader(record, binReader);
@ -108,19 +141,21 @@ int main(int argc, char *argv[])
{ {
// parse command line // parse command line
std::string outFilename, inFilename; std::string outFilename, inFilename;
unsigned int size; unsigned int size, Ls;
bool multiFile; bool rb, multiFile;
if (argc < 5) if (argc < 7)
{ {
std::cerr << "usage: " << argv[0] << " <out eigenpack> <in eigenpack> <size> <multifile (0|1)> [Grid options]"; std::cerr << "usage: " << argv[0] << " <out eigenpack> <in eigenpack> <Ls> <red-black (0|1)> <#vector> <multifile (0|1)> [Grid options]";
std::cerr << std::endl; std::cerr << std::endl;
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }
outFilename = argv[1]; outFilename = argv[1];
inFilename = argv[2]; inFilename = argv[2];
size = std::stoi(std::string(argv[3])); Ls = std::stoi(std::string(argv[3]));
multiFile = (std::string(argv[4]) != "0"); rb = (std::string(argv[4]) != "0");
size = std::stoi(std::string(argv[5]));
multiFile = (std::string(argv[6]) != "0");
// initialization // initialization
Grid_init(&argc, &argv); Grid_init(&argc, &argv);
@ -128,7 +163,7 @@ int main(int argc, char *argv[])
// execution // execution
try try
{ {
convert<FOUT, FIN>(outFilename, inFilename, size, multiFile); convert<FOUT, FIN>(outFilename, inFilename, Ls, rb, size, multiFile);
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {