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

Namespace

This commit is contained in:
paboyle 2018-01-14 23:50:20 +00:00
parent eda4fd9912
commit 4c829b410e

View File

@ -93,16 +93,16 @@ public:
namespace QCD {
using namespace Grid;
////////////////////////////////////////////////////////////////////// using namespace Grid;
// Bit and Physical Checksumming and QA of data
//////////////////////////////////////////////////////////////////////
inline void GridMetaData(GridBase *grid,FieldMetaData &header) //////////////////////////////////////////////////////////////////////
{ // Bit and Physical Checksumming and QA of data
//////////////////////////////////////////////////////////////////////
inline void GridMetaData(GridBase *grid,FieldMetaData &header)
{
int nd = grid->_ndimension; int nd = grid->_ndimension;
header.nd = nd; header.nd = nd;
header.dimension.resize(nd); header.dimension.resize(nd);
@ -114,10 +114,10 @@ namespace QCD {
for(int d=0;d<nd;d++) { for(int d=0;d<nd;d++) {
header.boundary[d] = std::string("PERIODIC"); header.boundary[d] = std::string("PERIODIC");
} }
} }
inline void MachineCharacteristics(FieldMetaData &header) inline void MachineCharacteristics(FieldMetaData &header)
{ {
// Who // Who
struct passwd *pw = getpwuid (getuid()); struct passwd *pw = getpwuid (getuid());
if (pw) header.creator = std::string(pw->pw_name); if (pw) header.creator = std::string(pw->pw_name);
@ -136,7 +136,7 @@ namespace QCD {
header.creator_hardware+= std::string(name.machine)+"-"; header.creator_hardware+= std::string(name.machine)+"-";
header.creator_hardware+= std::string(name.sysname)+"-"; header.creator_hardware+= std::string(name.sysname)+"-";
header.creator_hardware+= std::string(name.release); header.creator_hardware+= std::string(name.release);
} }
#define dump_meta_data(field, s) \ #define dump_meta_data(field, s) \
s << "BEGIN_HEADER" << std::endl; \ s << "BEGIN_HEADER" << std::endl; \
@ -165,29 +165,29 @@ namespace QCD {
s << "FLOATING_POINT = " << field.floating_point << std::endl; \ s << "FLOATING_POINT = " << field.floating_point << std::endl; \
s << "END_HEADER" << std::endl; s << "END_HEADER" << std::endl;
template<class vobj> inline void PrepareMetaData(Lattice<vobj> & field, FieldMetaData &header) template<class vobj> inline void PrepareMetaData(Lattice<vobj> & field, FieldMetaData &header)
{ {
GridBase *grid = field._grid; GridBase *grid = field._grid;
std::string format = getFormatString<vobj>(); std::string format = getFormatString<vobj>();
header.floating_point = format; header.floating_point = format;
header.checksum = 0x0; // Nersc checksum unused in ILDG, Scidac header.checksum = 0x0; // Nersc checksum unused in ILDG, Scidac
GridMetaData(grid,header); GridMetaData(grid,header);
MachineCharacteristics(header); MachineCharacteristics(header);
} }
inline void GaugeStatistics(Lattice<vLorentzColourMatrixF> & data,FieldMetaData &header) inline void GaugeStatistics(Lattice<vLorentzColourMatrixF> & data,FieldMetaData &header)
{ {
// How to convert data precision etc... // How to convert data precision etc...
header.link_trace=Grid::QCD::WilsonLoops<PeriodicGimplF>::linkTrace(data); header.link_trace=Grid::QCD::WilsonLoops<PeriodicGimplF>::linkTrace(data);
header.plaquette =Grid::QCD::WilsonLoops<PeriodicGimplF>::avgPlaquette(data); header.plaquette =Grid::QCD::WilsonLoops<PeriodicGimplF>::avgPlaquette(data);
} }
inline void GaugeStatistics(Lattice<vLorentzColourMatrixD> & data,FieldMetaData &header) inline void GaugeStatistics(Lattice<vLorentzColourMatrixD> & data,FieldMetaData &header)
{ {
// How to convert data precision etc... // How to convert data precision etc...
header.link_trace=Grid::QCD::WilsonLoops<PeriodicGimplD>::linkTrace(data); header.link_trace=Grid::QCD::WilsonLoops<PeriodicGimplD>::linkTrace(data);
header.plaquette =Grid::QCD::WilsonLoops<PeriodicGimplD>::avgPlaquette(data); header.plaquette =Grid::QCD::WilsonLoops<PeriodicGimplD>::avgPlaquette(data);
} }
template<> inline void PrepareMetaData<vLorentzColourMatrixF>(Lattice<vLorentzColourMatrixF> & field, FieldMetaData &header) template<> inline void PrepareMetaData<vLorentzColourMatrixF>(Lattice<vLorentzColourMatrixF> & field, FieldMetaData &header)
{ {
GridBase *grid = field._grid; GridBase *grid = field._grid;
std::string format = getFormatString<vLorentzColourMatrixF>(); std::string format = getFormatString<vLorentzColourMatrixF>();
@ -196,9 +196,9 @@ namespace QCD {
GridMetaData(grid,header); GridMetaData(grid,header);
GaugeStatistics(field,header); GaugeStatistics(field,header);
MachineCharacteristics(header); MachineCharacteristics(header);
} }
template<> inline void PrepareMetaData<vLorentzColourMatrixD>(Lattice<vLorentzColourMatrixD> & field, FieldMetaData &header) template<> inline void PrepareMetaData<vLorentzColourMatrixD>(Lattice<vLorentzColourMatrixD> & field, FieldMetaData &header)
{ {
GridBase *grid = field._grid; GridBase *grid = field._grid;
std::string format = getFormatString<vLorentzColourMatrixD>(); std::string format = getFormatString<vLorentzColourMatrixD>();
header.floating_point = format; header.floating_point = format;
@ -206,13 +206,13 @@ namespace QCD {
GridMetaData(grid,header); GridMetaData(grid,header);
GaugeStatistics(field,header); GaugeStatistics(field,header);
MachineCharacteristics(header); MachineCharacteristics(header);
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Utilities ; these are QCD aware // Utilities ; these are QCD aware
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
inline void reconstruct3(LorentzColourMatrix & cm) inline void reconstruct3(LorentzColourMatrix & cm)
{ {
const int x=0; const int x=0;
const int y=1; const int y=1;
const int z=2; const int z=2;
@ -221,22 +221,22 @@ namespace QCD {
cm(mu)()(2,y) = adj(cm(mu)()(0,z)*cm(mu)()(1,x)-cm(mu)()(0,x)*cm(mu)()(1,z)); //y= zx-xz cm(mu)()(2,y) = adj(cm(mu)()(0,z)*cm(mu)()(1,x)-cm(mu)()(0,x)*cm(mu)()(1,z)); //y= zx-xz
cm(mu)()(2,z) = adj(cm(mu)()(0,x)*cm(mu)()(1,y)-cm(mu)()(0,y)*cm(mu)()(1,x)); //z= xy-yx cm(mu)()(2,z) = adj(cm(mu)()(0,x)*cm(mu)()(1,y)-cm(mu)()(0,y)*cm(mu)()(1,x)); //z= xy-yx
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Some data types for intermediate storage // Some data types for intermediate storage
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<typename vtype> using iLorentzColour2x3 = iVector<iVector<iVector<vtype, Nc>, 2>, Nd >; template<typename vtype> using iLorentzColour2x3 = iVector<iVector<iVector<vtype, Nc>, 2>, Nd >;
typedef iLorentzColour2x3<Complex> LorentzColour2x3; typedef iLorentzColour2x3<Complex> LorentzColour2x3;
typedef iLorentzColour2x3<ComplexF> LorentzColour2x3F; typedef iLorentzColour2x3<ComplexF> LorentzColour2x3F;
typedef iLorentzColour2x3<ComplexD> LorentzColour2x3D; typedef iLorentzColour2x3<ComplexD> LorentzColour2x3D;
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// Simple classes for precision conversion // Simple classes for precision conversion
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
template <class fobj, class sobj> template <class fobj, class sobj>
struct BinarySimpleUnmunger { struct BinarySimpleUnmunger {
typedef typename getPrecision<fobj>::real_scalar_type fobj_stype; typedef typename getPrecision<fobj>::real_scalar_type fobj_stype;
typedef typename getPrecision<sobj>::real_scalar_type sobj_stype; typedef typename getPrecision<sobj>::real_scalar_type sobj_stype;
@ -252,10 +252,10 @@ namespace QCD {
out_buffer[word] = in_buffer[word]; // type conversion on the fly out_buffer[word] = in_buffer[word]; // type conversion on the fly
} }
}; };
template <class fobj, class sobj> template <class fobj, class sobj>
struct BinarySimpleMunger { struct BinarySimpleMunger {
typedef typename getPrecision<fobj>::real_scalar_type fobj_stype; typedef typename getPrecision<fobj>::real_scalar_type fobj_stype;
typedef typename getPrecision<sobj>::real_scalar_type sobj_stype; typedef typename getPrecision<sobj>::real_scalar_type sobj_stype;
@ -271,11 +271,11 @@ namespace QCD {
out_buffer[word] = in_buffer[word]; // type conversion on the fly out_buffer[word] = in_buffer[word]; // type conversion on the fly
} }
}; };
template<class fobj,class sobj> template<class fobj,class sobj>
struct GaugeSimpleMunger{ struct GaugeSimpleMunger{
void operator()(fobj &in, sobj &out) { void operator()(fobj &in, sobj &out) {
for (int mu = 0; mu < Nd; mu++) { for (int mu = 0; mu < Nd; mu++) {
for (int i = 0; i < Nc; i++) { for (int i = 0; i < Nc; i++) {
@ -284,10 +284,10 @@ namespace QCD {
}} }}
} }
}; };
}; };
template <class fobj, class sobj> template <class fobj, class sobj>
struct GaugeSimpleUnmunger { struct GaugeSimpleUnmunger {
void operator()(sobj &in, fobj &out) { void operator()(sobj &in, fobj &out) {
for (int mu = 0; mu < Nd; mu++) { for (int mu = 0; mu < Nd; mu++) {
@ -297,10 +297,10 @@ namespace QCD {
}} }}
} }
}; };
}; };
template<class fobj,class sobj> template<class fobj,class sobj>
struct Gauge3x2munger{ struct Gauge3x2munger{
void operator() (fobj &in,sobj &out){ void operator() (fobj &in,sobj &out){
for(int mu=0;mu<Nd;mu++){ for(int mu=0;mu<Nd;mu++){
for(int i=0;i<2;i++){ for(int i=0;i<2;i++){
@ -310,10 +310,10 @@ namespace QCD {
} }
reconstruct3(out); reconstruct3(out);
} }
}; };
template<class fobj,class sobj> template<class fobj,class sobj>
struct Gauge3x2unmunger{ struct Gauge3x2unmunger{
void operator() (sobj &in,fobj &out){ void operator() (sobj &in,fobj &out){
for(int mu=0;mu<Nd;mu++){ for(int mu=0;mu<Nd;mu++){
for(int i=0;i<2;i++){ for(int i=0;i<2;i++){
@ -322,8 +322,7 @@ namespace QCD {
}} }}
} }
} }
}; };
}
NAMESPACE_END(Grid); NAMESPACE_END(Grid);