1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-09 23:45:36 +00:00

Making the ILDG support optional

This commit is contained in:
Guido Cossu 2016-10-26 09:48:01 +01:00
parent 47c7159177
commit d50055cd96
7 changed files with 78 additions and 44 deletions

View File

@ -131,9 +131,11 @@ CXXFLAGS=$CXXFLAGS_CPY
LDFLAGS=$LDFLAGS_CPY
AC_CHECK_LIB([lime],[limeCreateReader],
[AC_DEFINE([HAVE_LIME],[1],[Define to 1 if you have the `LIME' library (-llime).])]
[have_lime=true]
[LIBS="$LIBS -llime"],
[AC_MSG_ERROR(C-LIME library was not found in your system.
Please install or provide the correct path to your installation [default search path ~/lime/]
[AC_MSG_WARN(C-LIME library was not found in your system.
In order to use ILGG file format please install or provide the correct path to your installation [default search path ~/lime/]
Info at: http://usqcd.jlab.org/usqcd-docs/c-lime/)])
@ -355,6 +357,7 @@ Summary of configuration for $PACKAGE v$VERSION
- RNG choice : ${ac_RNG}
- GMP : `if test "x$have_gmp" = xtrue; then echo yes; else echo no; fi`
- LAPACK : ${ac_LAPACK}
- ILDG support (LIME) : `if test "x$have_lime" = xtrue; then echo yes; else echo no; fi`
- FFTW : `if test "x$have_fftw" = xtrue; then echo yes; else echo no; fi`
- build DOXYGEN documentation : `if test "x$enable_doc" = xyes; then echo yes; else echo no; fi`
- graphs and diagrams : `if test "x$enable_dot" = xyes; then echo yes; else echo no; fi`

View File

@ -568,9 +568,11 @@ class BinaryIO {
if (ILDG.is_ILDG){
// use C-LIME to populate the record
#ifdef HAVE_LIME
size_t sizeFO = sizeof(fileObj);
limeReaderSeek(ILDG.LR, g_idx*sizeFO, SEEK_SET);
int status = limeReaderReadData((void *)&fileObj, &sizeFO, ILDG.LR);
#endif
} else{
fin.seekg(offset+g_idx*sizeof(fileObj));
fin.read((char *)&fileObj,sizeof(fileObj));
@ -764,11 +766,16 @@ class BinaryIO {
if (ieee64big) htobe64_v((void *)&fileObj, sizeof(fileObj));
if (ieee64) htole64_v((void *)&fileObj, sizeof(fileObj));
if (ILDG.is_ILDG) {
#ifdef HAVE_LIME
size_t sizeFO = sizeof(fileObj);
limeWriterSeek(ILDG.LW, g_idx*sizeFO, SEEK_SET);
int status = limeWriteRecordData((void *)&fileObj, &sizeFO, ILDG.LW);
} else {
#endif
}
else {
fout.seekp(offset + g_idx * sizeof(fileObj));
fout.write((char *)&fileObj, sizeof(fileObj));
}

View File

@ -37,6 +37,8 @@ directory
#include <sys/utsname.h>
#include <unistd.h>
#ifdef HAVE_LIME
extern "C" { // for linkage
#include "lime.h"
}
@ -238,8 +240,12 @@ class ILDGIO : public BinaryIO {
return csum;
}
// format for RNG?
// format for RNG? Now just binary out
};
}
}
//HAVE_LIME
#endif
#endif

View File

@ -27,50 +27,54 @@ directory
#ifndef GRID_ILDGTYPES_IO_H
#define GRID_ILDGTYPES_IO_H
#ifdef HAVE_LIME
extern "C" { // for linkage
#include "lime.h"
}
namespace Grid {
struct ILDGtype{
bool is_ILDG;
LimeWriter* LW;
LimeReader* LR;
ILDGtype(bool is, LimeWriter* L):is_ILDG(is),LW(L),LR(NULL){}
ILDGtype(bool is, LimeReader* L):is_ILDG(is),LW(NULL),LR(L){}
ILDGtype():is_ILDG(false),LW(NULL),LR(NULL){}
};
class ILDGField {
public:
// header strings (not in order)
std::vector<int> dimension;
std::vector<std::string> boundary;
int data_start;
std::string hdr_version;
std::string storage_format;
// Checks on data
double link_trace;
double plaquette;
uint32_t checksum;
unsigned int sequence_number;
std::string data_type;
std::string ensemble_id ;
std::string ensemble_label ;
std::string creator ;
std::string creator_hardware ;
std::string creation_date ;
std::string archive_date ;
std::string floating_point;
};
struct ILDGtype {
bool is_ILDG;
LimeWriter* LW;
LimeReader* LR;
ILDGtype(bool is, LimeWriter* L) : is_ILDG(is), LW(L), LR(NULL) {}
ILDGtype(bool is, LimeReader* L) : is_ILDG(is), LW(NULL), LR(L) {}
ILDGtype() : is_ILDG(false), LW(NULL), LR(NULL) {}
};
class ILDGField {
public:
// header strings (not in order)
std::vector<int> dimension;
std::vector<std::string> boundary;
int data_start;
std::string hdr_version;
std::string storage_format;
// Checks on data
double link_trace;
double plaquette;
uint32_t checksum;
unsigned int sequence_number;
std::string data_type;
std::string ensemble_id;
std::string ensemble_label;
std::string creator;
std::string creator_hardware;
std::string creation_date;
std::string archive_date;
std::string floating_point;
};
}
#else
namespace Grid {
struct ILDGtype {
bool is_ILDG;
ILDGtype() : is_ILDG(false) {}
};
}
#endif
#endif

View File

@ -83,6 +83,7 @@ namespace QCD {
}
//////////////////////////////
template <class SmearingPolicy, class IOCheckpointer>
void Runner(int argc,
char ** argv,

View File

@ -29,6 +29,8 @@ directory
#ifndef ILDG_CHECKPOINTER
#define ILDG_CHECKPOINTER
#ifdef HAVE_LIME
#include <iostream>
#include <sstream>
#include <string>
@ -47,7 +49,7 @@ class ILDGHmcCheckpointer
std::string format;
public:
INHERIT_GIMPL_TYPES(Implementation); //
INHERIT_GIMPL_TYPES(Implementation);
ILDGHmcCheckpointer(std::string cf, std::string rn, int savemodulo,
std::string form = "IEEE64BIG") {
@ -62,8 +64,13 @@ class ILDGHmcCheckpointer
int ieee64big = (format == std::string("IEEE64BIG"));
int ieee64 = (format == std::string("IEEE64"));
if (!(ieee64big ^ ieee32 ^ ieee32big ^ ieee64)) {
std::cout << GridLogMessage << "Invalid format: " << format << std::endl;
if (!(ieee64big || ieee32 || ieee32big || ieee64)) {
std::cout << GridLogError << "Unrecognized file format " << format
<< std::endl;
std::cout << GridLogError
<< "Allowed: IEEE32BIG | IEEE32 | IEEE64BIG | IEEE64"
<< std::endl;
exit(0);
}
};
@ -118,4 +125,6 @@ class ILDGHmcCheckpointer
};
}
}
#endif
#endif

View File

@ -81,6 +81,10 @@ class HmcRunner : public BinaryHmcRunner {
TheAction.push_back(Level1);
// Add observables
// options for checkpointers
//BinaryHmcCheckpointer
//ILDGHmcCheckpointer
//NerscHmcCheckpointer
ILDGHmcCheckpointer<BinaryHmcRunner::ImplPolicy> Checkpoint(
HMCPar.conf_prefix, HMCPar.rng_prefix, HMCPar.SaveInterval, HMCPar.format);
// Can implement also a specific function in the hmcrunner