mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
C++ emacs happy
This commit is contained in:
parent
dda151250f
commit
ab1068044e
@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
See the full license in the file "LICENSE" in the top level distribution
|
See the full license in the file "LICENSE" in the top level distribution
|
||||||
directory
|
directory
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
/* END LEGAL */
|
/* END LEGAL */
|
||||||
#ifndef GRID_ILDG_IO_H
|
#ifndef GRID_ILDG_IO_H
|
||||||
#define GRID_ILDG_IO_H
|
#define GRID_ILDG_IO_H
|
||||||
|
|
||||||
@ -38,159 +38,158 @@ directory
|
|||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
//C-Lime is a must have for this functionality
|
//C-Lime is a must have for this functionality
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "lime.h"
|
#include "lime.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Grid {
|
NAMESPACE_BEGIN(Grid);
|
||||||
namespace QCD {
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Encode word types as strings
|
// Encode word types as strings
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
template<class word> inline std::string ScidacWordMnemonic(void){ return std::string("unknown"); }
|
template<class word> inline std::string ScidacWordMnemonic(void){ return std::string("unknown"); }
|
||||||
template<> inline std::string ScidacWordMnemonic<double> (void){ return std::string("D"); }
|
template<> inline std::string ScidacWordMnemonic<double> (void){ return std::string("D"); }
|
||||||
template<> inline std::string ScidacWordMnemonic<float> (void){ return std::string("F"); }
|
template<> inline std::string ScidacWordMnemonic<float> (void){ return std::string("F"); }
|
||||||
template<> inline std::string ScidacWordMnemonic< int32_t>(void){ return std::string("I32_t"); }
|
template<> inline std::string ScidacWordMnemonic< int32_t>(void){ return std::string("I32_t"); }
|
||||||
template<> inline std::string ScidacWordMnemonic<uint32_t>(void){ return std::string("U32_t"); }
|
template<> inline std::string ScidacWordMnemonic<uint32_t>(void){ return std::string("U32_t"); }
|
||||||
template<> inline std::string ScidacWordMnemonic< int64_t>(void){ return std::string("I64_t"); }
|
template<> inline std::string ScidacWordMnemonic< int64_t>(void){ return std::string("I64_t"); }
|
||||||
template<> inline std::string ScidacWordMnemonic<uint64_t>(void){ return std::string("U64_t"); }
|
template<> inline std::string ScidacWordMnemonic<uint64_t>(void){ return std::string("U64_t"); }
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
// Encode a generic tensor as a string
|
// Encode a generic tensor as a string
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
template<class vobj> std::string ScidacRecordTypeString(int &colors, int &spins, int & typesize,int &datacount) {
|
template<class vobj> std::string ScidacRecordTypeString(int &colors, int &spins, int & typesize,int &datacount) {
|
||||||
|
|
||||||
typedef typename getPrecision<vobj>::real_scalar_type stype;
|
typedef typename getPrecision<vobj>::real_scalar_type stype;
|
||||||
|
|
||||||
int _ColourN = indexRank<ColourIndex,vobj>();
|
int _ColourN = indexRank<ColourIndex,vobj>();
|
||||||
int _ColourScalar = isScalar<ColourIndex,vobj>();
|
int _ColourScalar = isScalar<ColourIndex,vobj>();
|
||||||
int _ColourVector = isVector<ColourIndex,vobj>();
|
int _ColourVector = isVector<ColourIndex,vobj>();
|
||||||
int _ColourMatrix = isMatrix<ColourIndex,vobj>();
|
int _ColourMatrix = isMatrix<ColourIndex,vobj>();
|
||||||
|
|
||||||
int _SpinN = indexRank<SpinIndex,vobj>();
|
int _SpinN = indexRank<SpinIndex,vobj>();
|
||||||
int _SpinScalar = isScalar<SpinIndex,vobj>();
|
int _SpinScalar = isScalar<SpinIndex,vobj>();
|
||||||
int _SpinVector = isVector<SpinIndex,vobj>();
|
int _SpinVector = isVector<SpinIndex,vobj>();
|
||||||
int _SpinMatrix = isMatrix<SpinIndex,vobj>();
|
int _SpinMatrix = isMatrix<SpinIndex,vobj>();
|
||||||
|
|
||||||
int _LorentzN = indexRank<LorentzIndex,vobj>();
|
int _LorentzN = indexRank<LorentzIndex,vobj>();
|
||||||
int _LorentzScalar = isScalar<LorentzIndex,vobj>();
|
int _LorentzScalar = isScalar<LorentzIndex,vobj>();
|
||||||
int _LorentzVector = isVector<LorentzIndex,vobj>();
|
int _LorentzVector = isVector<LorentzIndex,vobj>();
|
||||||
int _LorentzMatrix = isMatrix<LorentzIndex,vobj>();
|
int _LorentzMatrix = isMatrix<LorentzIndex,vobj>();
|
||||||
|
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
|
|
||||||
stream << "GRID_";
|
stream << "GRID_";
|
||||||
stream << ScidacWordMnemonic<stype>();
|
stream << ScidacWordMnemonic<stype>();
|
||||||
|
|
||||||
if ( _LorentzVector ) stream << "_LorentzVector"<<_LorentzN;
|
if ( _LorentzVector ) stream << "_LorentzVector"<<_LorentzN;
|
||||||
if ( _LorentzMatrix ) stream << "_LorentzMatrix"<<_LorentzN;
|
if ( _LorentzMatrix ) stream << "_LorentzMatrix"<<_LorentzN;
|
||||||
|
|
||||||
if ( _SpinVector ) stream << "_SpinVector"<<_SpinN;
|
if ( _SpinVector ) stream << "_SpinVector"<<_SpinN;
|
||||||
if ( _SpinMatrix ) stream << "_SpinMatrix"<<_SpinN;
|
if ( _SpinMatrix ) stream << "_SpinMatrix"<<_SpinN;
|
||||||
|
|
||||||
if ( _ColourVector ) stream << "_ColourVector"<<_ColourN;
|
if ( _ColourVector ) stream << "_ColourVector"<<_ColourN;
|
||||||
if ( _ColourMatrix ) stream << "_ColourMatrix"<<_ColourN;
|
if ( _ColourMatrix ) stream << "_ColourMatrix"<<_ColourN;
|
||||||
|
|
||||||
if ( _ColourScalar && _LorentzScalar && _SpinScalar ) stream << "_Complex";
|
if ( _ColourScalar && _LorentzScalar && _SpinScalar ) stream << "_Complex";
|
||||||
|
|
||||||
|
|
||||||
typesize = sizeof(typename vobj::scalar_type);
|
typesize = sizeof(typename vobj::scalar_type);
|
||||||
|
|
||||||
if ( _ColourMatrix ) typesize*= _ColourN*_ColourN;
|
if ( _ColourMatrix ) typesize*= _ColourN*_ColourN;
|
||||||
else typesize*= _ColourN;
|
else typesize*= _ColourN;
|
||||||
|
|
||||||
if ( _SpinMatrix ) typesize*= _SpinN*_SpinN;
|
if ( _SpinMatrix ) typesize*= _SpinN*_SpinN;
|
||||||
else typesize*= _SpinN;
|
else typesize*= _SpinN;
|
||||||
|
|
||||||
colors = _ColourN;
|
colors = _ColourN;
|
||||||
spins = _SpinN;
|
spins = _SpinN;
|
||||||
datacount = _LorentzN;
|
datacount = _LorentzN;
|
||||||
|
|
||||||
return stream.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class vobj> std::string ScidacRecordTypeString(Lattice<vobj> & lat,int &colors, int &spins, int & typesize,int &datacount) {
|
template<class vobj> std::string ScidacRecordTypeString(Lattice<vobj> & lat,int &colors, int &spins, int & typesize,int &datacount) {
|
||||||
return ScidacRecordTypeString<vobj>(colors,spins,typesize,datacount);
|
return ScidacRecordTypeString<vobj>(colors,spins,typesize,datacount);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Helper to fill out metadata
|
// Helper to fill out metadata
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template<class vobj> void ScidacMetaData(Lattice<vobj> & field,
|
template<class vobj> void ScidacMetaData(Lattice<vobj> & field,
|
||||||
FieldMetaData &header,
|
FieldMetaData &header,
|
||||||
scidacRecord & _scidacRecord,
|
scidacRecord & _scidacRecord,
|
||||||
scidacFile & _scidacFile)
|
scidacFile & _scidacFile)
|
||||||
{
|
{
|
||||||
typedef typename getPrecision<vobj>::real_scalar_type stype;
|
typedef typename getPrecision<vobj>::real_scalar_type stype;
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Pull Grid's metadata
|
// Pull Grid's metadata
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
PrepareMetaData(field,header);
|
PrepareMetaData(field,header);
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Scidac Private File structure
|
// Scidac Private File structure
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
_scidacFile = scidacFile(field._grid);
|
_scidacFile = scidacFile(field._grid);
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Scidac Private Record structure
|
// Scidac Private Record structure
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
scidacRecord sr;
|
scidacRecord sr;
|
||||||
sr.datatype = ScidacRecordTypeString(field,sr.colors,sr.spins,sr.typesize,sr.datacount);
|
sr.datatype = ScidacRecordTypeString(field,sr.colors,sr.spins,sr.typesize,sr.datacount);
|
||||||
sr.date = header.creation_date;
|
sr.date = header.creation_date;
|
||||||
sr.precision = ScidacWordMnemonic<stype>();
|
sr.precision = ScidacWordMnemonic<stype>();
|
||||||
sr.recordtype = GRID_IO_FIELD;
|
sr.recordtype = GRID_IO_FIELD;
|
||||||
|
|
||||||
_scidacRecord = sr;
|
_scidacRecord = sr;
|
||||||
|
|
||||||
// std::cout << GridLogMessage << "Build SciDAC datatype " <<sr.datatype<<std::endl;
|
// std::cout << GridLogMessage << "Build SciDAC datatype " <<sr.datatype<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
// Scidac checksum
|
// Scidac checksum
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
static int scidacChecksumVerify(scidacChecksum &scidacChecksum_,uint32_t scidac_csuma,uint32_t scidac_csumb)
|
static int scidacChecksumVerify(scidacChecksum &scidacChecksum_,uint32_t scidac_csuma,uint32_t scidac_csumb)
|
||||||
{
|
{
|
||||||
uint32_t scidac_checksuma = stoull(scidacChecksum_.suma,0,16);
|
uint32_t scidac_checksuma = stoull(scidacChecksum_.suma,0,16);
|
||||||
uint32_t scidac_checksumb = stoull(scidacChecksum_.sumb,0,16);
|
uint32_t scidac_checksumb = stoull(scidacChecksum_.sumb,0,16);
|
||||||
if ( scidac_csuma !=scidac_checksuma) return 0;
|
if ( scidac_csuma !=scidac_checksuma) return 0;
|
||||||
if ( scidac_csumb !=scidac_checksumb) return 0;
|
if ( scidac_csumb !=scidac_checksumb) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Lime, ILDG and Scidac I/O classes
|
// Lime, ILDG and Scidac I/O classes
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
class GridLimeReader : public BinaryIO {
|
class GridLimeReader : public BinaryIO {
|
||||||
public:
|
public:
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
// FIXME: format for RNG? Now just binary out instead
|
// FIXME: format for RNG? Now just binary out instead
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
|
||||||
FILE *File;
|
FILE *File;
|
||||||
LimeReader *LimeR;
|
LimeReader *LimeR;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
// Open the file
|
// Open the file
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
void open(const std::string &_filename)
|
void open(const std::string &_filename)
|
||||||
{
|
{
|
||||||
filename= _filename;
|
filename= _filename;
|
||||||
File = fopen(filename.c_str(), "r");
|
File = fopen(filename.c_str(), "r");
|
||||||
LimeR = limeCreateReader(File);
|
LimeR = limeCreateReader(File);
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
// Close the file
|
// Close the file
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
void close(void){
|
void close(void){
|
||||||
fclose(File);
|
fclose(File);
|
||||||
// limeDestroyReader(LimeR);
|
// limeDestroyReader(LimeR);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
// Read a generic lattice field and verify checksum
|
// Read a generic lattice field and verify checksum
|
||||||
@ -273,28 +272,28 @@ class GridLimeReader : public BinaryIO {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class GridLimeWriter : public BinaryIO {
|
class GridLimeWriter : public BinaryIO {
|
||||||
public:
|
public:
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
// FIXME: format for RNG? Now just binary out instead
|
// FIXME: format for RNG? Now just binary out instead
|
||||||
// FIXME: collective calls or not ?
|
// FIXME: collective calls or not ?
|
||||||
// : must know if I am the I/O boss
|
// : must know if I am the I/O boss
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
FILE *File;
|
FILE *File;
|
||||||
LimeWriter *LimeW;
|
LimeWriter *LimeW;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
void open(const std::string &_filename) {
|
void open(const std::string &_filename) {
|
||||||
filename= _filename;
|
filename= _filename;
|
||||||
File = fopen(filename.c_str(), "w");
|
File = fopen(filename.c_str(), "w");
|
||||||
LimeW = limeCreateWriter(File); assert(LimeW != NULL );
|
LimeW = limeCreateWriter(File); assert(LimeW != NULL );
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
// Close the file
|
// Close the file
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
void close(void) {
|
void close(void) {
|
||||||
fclose(File);
|
fclose(File);
|
||||||
// limeDestroyWriter(LimeW);
|
// limeDestroyWriter(LimeW);
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
// Lime utility functions
|
// Lime utility functions
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
@ -386,15 +385,15 @@ class GridLimeWriter : public BinaryIO {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ScidacWriter : public GridLimeWriter {
|
class ScidacWriter : public GridLimeWriter {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template<class SerialisableUserFile>
|
template<class SerialisableUserFile>
|
||||||
void writeScidacFileRecord(GridBase *grid,SerialisableUserFile &_userFile)
|
void writeScidacFileRecord(GridBase *grid,SerialisableUserFile &_userFile)
|
||||||
{
|
{
|
||||||
scidacFile _scidacFile(grid);
|
scidacFile _scidacFile(grid);
|
||||||
writeLimeObject(1,0,_scidacFile,_scidacFile.SerialisableClassName(),std::string(SCIDAC_PRIVATE_FILE_XML));
|
writeLimeObject(1,0,_scidacFile,_scidacFile.SerialisableClassName(),std::string(SCIDAC_PRIVATE_FILE_XML));
|
||||||
writeLimeObject(0,1,_userFile,_userFile.SerialisableClassName(),std::string(SCIDAC_FILE_XML));
|
writeLimeObject(0,1,_userFile,_userFile.SerialisableClassName(),std::string(SCIDAC_FILE_XML));
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// Write generic lattice field in scidac format
|
// Write generic lattice field in scidac format
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
@ -424,15 +423,15 @@ class ScidacWriter : public GridLimeWriter {
|
|||||||
|
|
||||||
|
|
||||||
class ScidacReader : public GridLimeReader {
|
class ScidacReader : public GridLimeReader {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template<class SerialisableUserFile>
|
template<class SerialisableUserFile>
|
||||||
void readScidacFileRecord(GridBase *grid,SerialisableUserFile &_userFile)
|
void readScidacFileRecord(GridBase *grid,SerialisableUserFile &_userFile)
|
||||||
{
|
{
|
||||||
scidacFile _scidacFile(grid);
|
scidacFile _scidacFile(grid);
|
||||||
readLimeObject(_scidacFile,_scidacFile.SerialisableClassName(),std::string(SCIDAC_PRIVATE_FILE_XML));
|
readLimeObject(_scidacFile,_scidacFile.SerialisableClassName(),std::string(SCIDAC_PRIVATE_FILE_XML));
|
||||||
readLimeObject(_userFile,_userFile.SerialisableClassName(),std::string(SCIDAC_FILE_XML));
|
readLimeObject(_userFile,_userFile.SerialisableClassName(),std::string(SCIDAC_FILE_XML));
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// Write generic lattice field in scidac format
|
// Write generic lattice field in scidac format
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
@ -483,7 +482,7 @@ class ScidacReader : public GridLimeReader {
|
|||||||
|
|
||||||
|
|
||||||
class IldgWriter : public ScidacWriter {
|
class IldgWriter : public ScidacWriter {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
// A little helper
|
// A little helper
|
||||||
@ -526,7 +525,7 @@ class IldgWriter : public ScidacWriter {
|
|||||||
header.ildg_lfn = LFN;
|
header.ildg_lfn = LFN;
|
||||||
|
|
||||||
assert ( (format == std::string("IEEE32BIG"))
|
assert ( (format == std::string("IEEE32BIG"))
|
||||||
||(format == std::string("IEEE64BIG")) );
|
||(format == std::string("IEEE64BIG")) );
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// Fill ILDG header data struct
|
// Fill ILDG header data struct
|
||||||
@ -573,7 +572,7 @@ class IldgWriter : public ScidacWriter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class IldgReader : public GridLimeReader {
|
class IldgReader : public GridLimeReader {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// Read either Grid/SciDAC/ILDG configuration
|
// Read either Grid/SciDAC/ILDG configuration
|
||||||
@ -788,9 +787,9 @@ class IldgReader : public GridLimeReader {
|
|||||||
std::cout << GridLogMessage<<"Plaquette and link trace match " << std::endl;
|
std::cout << GridLogMessage<<"Plaquette and link trace match " << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
NAMESPACE_END(Grid);
|
||||||
|
|
||||||
//HAVE_LIME
|
//HAVE_LIME
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user