mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 15:55:37 +00:00
Merge branch 'master' into hadrons
# Conflicts: # lib/Log.h
This commit is contained in:
commit
312637e5fb
@ -69,10 +69,10 @@ public:
|
||||
StopWatch.Stop();
|
||||
GridTime now = StopWatch.Elapsed();
|
||||
StopWatch.Start();
|
||||
stream << BLACK <<std::setw(10) << std::left << log.topName << BLACK<< " : ";
|
||||
stream << log.COLOUR <<std::setw(10) << log.name << BLACK << " : ";
|
||||
stream << YELLOW<< now <<BLACK << " : " ;
|
||||
stream << log.COLOUR;
|
||||
stream << BLACK <<std::setw(8) << std::left << log.topName << BLACK<< " : ";
|
||||
stream << log.COLOUR <<std::setw(11) << log.name << BLACK << " : ";
|
||||
stream << YELLOW <<std::setw(6) << now <<BLACK << " : " ;
|
||||
stream << log.COLOUR;
|
||||
return stream;
|
||||
} else {
|
||||
return devnull;
|
||||
|
@ -55,7 +55,13 @@ extern int GridCshiftPermuteMap[4][16];
|
||||
// Basic expressions used in Expression Template
|
||||
////////////////////////////////////////////////
|
||||
|
||||
class LatticeBase {};
|
||||
class LatticeBase
|
||||
{
|
||||
public:
|
||||
virtual ~LatticeBase(void) = default;
|
||||
GridBase *_grid;
|
||||
};
|
||||
|
||||
class LatticeExpressionBase {};
|
||||
|
||||
template<class T> using Vector = std::vector<T,alignedAllocator<T> >; // Aligned allocator??
|
||||
@ -88,8 +94,6 @@ template<class vobj>
|
||||
class Lattice : public LatticeBase
|
||||
{
|
||||
public:
|
||||
|
||||
GridBase *_grid;
|
||||
int checkerboard;
|
||||
Vector<vobj> _odata;
|
||||
|
||||
@ -177,8 +181,8 @@ PARALLEL_FOR_LOOP
|
||||
}
|
||||
//GridFromExpression is tricky to do
|
||||
template<class Op,class T1>
|
||||
Lattice(const LatticeUnaryExpression<Op,T1> & expr): _grid(nullptr){
|
||||
|
||||
Lattice(const LatticeUnaryExpression<Op,T1> & expr) {
|
||||
_grid = nullptr;
|
||||
GridFromExpression(_grid,expr);
|
||||
assert(_grid!=nullptr);
|
||||
|
||||
@ -199,7 +203,8 @@ PARALLEL_FOR_LOOP
|
||||
}
|
||||
};
|
||||
template<class Op,class T1, class T2>
|
||||
Lattice(const LatticeBinaryExpression<Op,T1,T2> & expr): _grid(nullptr){
|
||||
Lattice(const LatticeBinaryExpression<Op,T1,T2> & expr) {
|
||||
_grid = nullptr;
|
||||
GridFromExpression(_grid,expr);
|
||||
assert(_grid!=nullptr);
|
||||
|
||||
@ -220,7 +225,8 @@ PARALLEL_FOR_LOOP
|
||||
}
|
||||
};
|
||||
template<class Op,class T1, class T2, class T3>
|
||||
Lattice(const LatticeTrinaryExpression<Op,T1,T2,T3> & expr): _grid(nullptr){
|
||||
Lattice(const LatticeTrinaryExpression<Op,T1,T2,T3> & expr) {
|
||||
_grid = nullptr;
|
||||
GridFromExpression(_grid,expr);
|
||||
assert(_grid!=nullptr);
|
||||
|
||||
@ -240,7 +246,8 @@ PARALLEL_FOR_LOOP
|
||||
// Constructor requires "grid" passed.
|
||||
// what about a default grid?
|
||||
//////////////////////////////////////////////////////////////////
|
||||
Lattice(GridBase *grid) : _grid(grid), _odata(_grid->oSites()) {
|
||||
Lattice(GridBase *grid) : _odata(grid->oSites()) {
|
||||
_grid = grid;
|
||||
// _odata.reserve(_grid->oSites());
|
||||
// _odata.resize(_grid->oSites());
|
||||
// std::cout << "Constructing lattice object with Grid pointer "<<_grid<<std::endl;
|
||||
@ -248,6 +255,8 @@ PARALLEL_FOR_LOOP
|
||||
checkerboard=0;
|
||||
}
|
||||
|
||||
virtual ~Lattice(void) = default;
|
||||
|
||||
template<class sobj> strong_inline Lattice<vobj> & operator = (const sobj & r){
|
||||
PARALLEL_FOR_LOOP
|
||||
for(int ss=0;ss<_grid->oSites();ss++){
|
||||
|
@ -213,37 +213,38 @@ class NerscIO : public BinaryIO {
|
||||
static inline void truncate(std::string file){
|
||||
std::ofstream fout(file,std::ios::out);
|
||||
}
|
||||
|
||||
#define dump_nersc_header(field, s)\
|
||||
s << "BEGIN_HEADER" << std::endl;\
|
||||
s << "HDR_VERSION = " << field.hdr_version << std::endl;\
|
||||
s << "DATATYPE = " << field.data_type << std::endl;\
|
||||
s << "STORAGE_FORMAT = " << field.storage_format << std::endl;\
|
||||
for(int i=0;i<4;i++){\
|
||||
s << "DIMENSION_" << i+1 << " = " << field.dimension[i] << std::endl ;\
|
||||
}\
|
||||
s << "LINK_TRACE = " << std::setprecision(10) << field.link_trace << std::endl;\
|
||||
s << "PLAQUETTE = " << std::setprecision(10) << field.plaquette << std::endl;\
|
||||
for(int i=0;i<4;i++){\
|
||||
s << "BOUNDARY_"<<i+1<<" = " << field.boundary[i] << std::endl;\
|
||||
}\
|
||||
\
|
||||
s << "CHECKSUM = "<< std::hex << std::setw(10) << field.checksum << std::dec<<std::endl;\
|
||||
s << "ENSEMBLE_ID = " << field.ensemble_id << std::endl;\
|
||||
s << "ENSEMBLE_LABEL = " << field.ensemble_label << std::endl;\
|
||||
s << "SEQUENCE_NUMBER = " << field.sequence_number << std::endl;\
|
||||
s << "CREATOR = " << field.creator << std::endl;\
|
||||
s << "CREATOR_HARDWARE = "<< field.creator_hardware << std::endl;\
|
||||
s << "CREATION_DATE = " << field.creation_date << std::endl;\
|
||||
s << "ARCHIVE_DATE = " << field.archive_date << std::endl;\
|
||||
s << "FLOATING_POINT = " << field.floating_point << std::endl;\
|
||||
s << "END_HEADER" << std::endl;
|
||||
|
||||
static inline unsigned int writeHeader(NerscField &field,std::string file)
|
||||
{
|
||||
std::ofstream fout(file,std::ios::out|std::ios::in);
|
||||
|
||||
fout.seekp(0,std::ios::beg);
|
||||
fout << "BEGIN_HEADER" << std::endl;
|
||||
fout << "HDR_VERSION = " << field.hdr_version << std::endl;
|
||||
fout << "DATATYPE = " << field.data_type << std::endl;
|
||||
fout << "STORAGE_FORMAT = " << field.storage_format << std::endl;
|
||||
|
||||
for(int i=0;i<4;i++){
|
||||
fout << "DIMENSION_" << i+1 << " = " << field.dimension[i] << std::endl ;
|
||||
}
|
||||
// just to keep the space and write it later
|
||||
fout << "LINK_TRACE = " << std::setprecision(10) << field.link_trace << std::endl;
|
||||
fout << "PLAQUETTE = " << std::setprecision(10) << field.plaquette << std::endl;
|
||||
for(int i=0;i<4;i++){
|
||||
fout << "BOUNDARY_"<<i+1<<" = " << field.boundary[i] << std::endl;
|
||||
}
|
||||
|
||||
fout << "CHECKSUM = "<< std::hex << std::setw(10) << field.checksum << std::dec<<std::endl;
|
||||
|
||||
fout << "ENSEMBLE_ID = " << field.ensemble_id << std::endl;
|
||||
fout << "ENSEMBLE_LABEL = " << field.ensemble_label << std::endl;
|
||||
fout << "SEQUENCE_NUMBER = " << field.sequence_number << std::endl;
|
||||
fout << "CREATOR = " << field.creator << std::endl;
|
||||
fout << "CREATOR_HARDWARE = "<< field.creator_hardware << std::endl;
|
||||
fout << "CREATION_DATE = " << field.creation_date << std::endl;
|
||||
fout << "ARCHIVE_DATE = " << field.archive_date << std::endl;
|
||||
fout << "FLOATING_POINT = " << field.floating_point << std::endl;
|
||||
fout << "END_HEADER" << std::endl;
|
||||
dump_nersc_header(field, fout);
|
||||
field.data_start = fout.tellp();
|
||||
return field.data_start;
|
||||
}
|
||||
|
@ -49,6 +49,24 @@ namespace Grid {
|
||||
return v;
|
||||
}
|
||||
|
||||
// output to streams for vectors
|
||||
template < class T >
|
||||
inline std::ostream & operator<<(std::ostream &os, const std::vector<T> &v)
|
||||
{
|
||||
os << "[";
|
||||
for (auto &x: v)
|
||||
{
|
||||
os << x << " ";
|
||||
}
|
||||
if (v.size() > 0)
|
||||
{
|
||||
os << "\b";
|
||||
}
|
||||
os << "]";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
class Serializable {};
|
||||
|
||||
// static polymorphism implemented using CRTP idiom
|
||||
@ -154,23 +172,6 @@ namespace Grid {
|
||||
r.read(s, output);
|
||||
}
|
||||
|
||||
template < class T >
|
||||
inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v)
|
||||
{
|
||||
os << "[";
|
||||
for (auto &x: v)
|
||||
{
|
||||
os << x << " ";
|
||||
}
|
||||
if (v.size() > 0)
|
||||
{
|
||||
os << "\b";
|
||||
}
|
||||
os << "]";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
// Writer template implementation ////////////////////////////////////////////
|
||||
template <typename T>
|
||||
Writer<T>::Writer(void)
|
||||
|
Loading…
Reference in New Issue
Block a user