1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-09 21:50:45 +01:00

cout IO for all types

This commit is contained in:
Peter Boyle 2015-05-13 09:24:10 +01:00
parent b4a570477c
commit d388b831b4
6 changed files with 118 additions and 8 deletions

18
TODO
View File

@ -5,6 +5,7 @@
- Performance check on Guido's reimplementation strategy - Performance check on Guido's reimplementation strategy
* FIXME audit * FIXME audit
* const audit * const audit
* Replace vset with a call to merge.; * Replace vset with a call to merge.;
@ -13,6 +14,8 @@
* Strong test for norm2, conj and all primitive types. -- tests/Grid_simd.cc is almost there * Strong test for norm2, conj and all primitive types. -- tests/Grid_simd.cc is almost there
* Thread scaling tests Xeon, XeonPhi
================================================================ ================================================================
*** New Functionality *** New Functionality
================================================================ ================================================================
@ -23,9 +26,6 @@
- use protocol buffers? replace xmlReader/Writer ec.. - use protocol buffers? replace xmlReader/Writer ec..
- Binary use htonll, htonl - Binary use htonll, htonl
* Bug in SeedFixedIntegers gave same output on each site. -- Think I fixed but NOT checked for sure
Implement and use lattice IO to verify this.
* Expression template engine: -- DONE * Expression template engine: -- DONE
-- Norm2(expression) problem: introduce norm2 unary op, or Introduce conversion automatic from expression to Lattice<vobj> -- Norm2(expression) problem: introduce norm2 unary op, or Introduce conversion automatic from expression to Lattice<vobj>
@ -33,6 +33,7 @@
** Make the Tensor types and Complex etc... play more nicely. ** Make the Tensor types and Complex etc... play more nicely.
- TensorRemove is a hack, come up with a long term rationalised approach to Complex vs. Scalar<Scalar<Scalar<Complex > > > - TensorRemove is a hack, come up with a long term rationalised approach to Complex vs. Scalar<Scalar<Scalar<Complex > > >
QDP forces use of "toDouble" to get back to non tensor scalar. This role is presently taken TensorRemove, but I QDP forces use of "toDouble" to get back to non tensor scalar. This role is presently taken TensorRemove, but I
want to introduce a syntax that does not require this. want to introduce a syntax that does not require this.
- Reductions that contract indices on a site should always demote the tensor structure. - Reductions that contract indices on a site should always demote the tensor structure.
@ -71,6 +72,7 @@
// Fourier transform equivalent. // Fourier transform equivalent.
Actions -- coherent framework for implementing actions and their forces. Actions -- coherent framework for implementing actions and their forces.
* Fermion * Fermion
- Wilson - Wilson
- Clover - Clover
@ -81,22 +83,24 @@ Actions -- coherent framework for implementing actions and their forces.
* Gauge * Gauge
- Wilson, symanzik, iwasaki - Wilson, symanzik, iwasaki
Algorithms Algorithms (lots of reuse/port from BFM)
* LinearOperator * LinearOperator
* LinearSolver * LinearSolver
* Polynomial * Polynomial
* Eigen * Eigen
* CG
* Pcg * Pcg
* Adef2 * Adef2
* DeflCG * DeflCG
* fPcg * fPcg
* MCR * MCR
* HDCG * HDCG
* HMC, Heatbath * HMC,
* Heatbath
* etc.. * etc..
====================================================================================================== ======================================================================================================
FUNCTIONALITY: it pleases me to keep track of things I have done (keeps sane) FUNCTIONALITY: it pleases me to keep track of things I have done (keeps me arguably sane)
====================================================================================================== ======================================================================================================
* Command line args for geometry, simd, etc. layout. Is it necessary to have -- DONE * Command line args for geometry, simd, etc. layout. Is it necessary to have -- DONE
@ -158,4 +162,6 @@ FUNCTIONALITY: it pleases me to keep track of things I have done (keeps sane)
* Conformable test in Cshift routines. -- none needed ; there is only one * Conformable test in Cshift routines. -- none needed ; there is only one
* Conformable testing in expression templates -- DONE (recursive) * Conformable testing in expression templates -- DONE (recursive)
* Bug in SeedFixedIntegers gave same output on each site. -- DONE
Implement and use lattice IO to verify this. -- cout for lattice types DONE

View File

@ -234,5 +234,60 @@ namespace Grid {
typedef vRealF vReal; typedef vRealF vReal;
typedef vComplexF vComplex; typedef vComplexF vComplex;
#endif #endif
inline std::ostream& operator<< (std::ostream& stream, const vComplexF &o){
int nn=vComplexF::Nsimd();
std::vector<ComplexF,alignedAllocator<ComplexF> > buf(nn);
vstore(o,&buf[0]);
stream<<"<";
for(int i=0;i<nn;i++){
stream<<buf[i];
if(i<nn-1) stream<<",";
}
stream<<">";
return stream;
}
inline std::ostream& operator<< (std::ostream& stream, const vComplexD &o){
int nn=vComplexD::Nsimd();
std::vector<ComplexD,alignedAllocator<ComplexD> > buf(nn);
vstore(o,&buf[0]);
stream<<"<";
for(int i=0;i<nn;i++){
stream<<buf[i];
if(i<nn-1) stream<<",";
}
stream<<">";
return stream;
}
inline std::ostream& operator<< (std::ostream& stream, const vRealF &o){
int nn=vRealF::Nsimd();
std::vector<RealF,alignedAllocator<RealF> > buf(nn);
vstore(o,&buf[0]);
stream<<"<";
for(int i=0;i<nn;i++){
stream<<buf[i];
if(i<nn-1) stream<<",";
}
stream<<">";
return stream;
}
inline std::ostream& operator<< (std::ostream& stream, const vRealD &o){
int nn=vRealD::Nsimd();
std::vector<RealD,alignedAllocator<RealD> > buf(nn);
vstore(o,&buf[0]);
stream<<"<";
for(int i=0;i<nn;i++){
stream<<buf[i];
if(i<nn-1) stream<<",";
}
stream<<">";
return stream;
}
} }
#endif #endif

View File

@ -176,7 +176,27 @@ PARALLEL_FOR_LOOP
} }
return ret; return ret;
}; };
}; // class Lattice }; // class Lattice
template<class vobj> inline std::ostream& operator<< (std::ostream& stream, const Lattice<vobj> &o){
std::vector<int> gcoor;
typedef typename vobj::scalar_object sobj;
sobj ss;
for(int g=0;g<o._grid->_gsites;g++){
o._grid->GlobalIndexToGlobalCoor(g,gcoor);
peekSite(ss,o,gcoor);
stream<<"[";
for(int d=0;d<gcoor.size();d++){
stream<<gcoor[d];
if(d!=gcoor.size()-1) stream<<",";
}
stream<<"]\t";
stream<<ss<<std::endl;
}
return stream;
}
} }

View File

@ -110,7 +110,7 @@ PARALLEL_FOR_LOOP
// Peek a scalar object from the SIMD array // Peek a scalar object from the SIMD array
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
template<class vobj,class sobj> template<class vobj,class sobj>
void peekSite(sobj &s,Lattice<vobj> &l,std::vector<int> &site){ void peekSite(sobj &s,const Lattice<vobj> &l,std::vector<int> &site){
GridBase *grid=l._grid; GridBase *grid=l._grid;

View File

@ -95,6 +95,10 @@ public:
return *this; return *this;
} }
friend std::ostream& operator<< (std::ostream& stream, const iScalar<vtype> &o){
stream<< "S {"<<o._internal<<"}";
return stream;
};
}; };
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Allows to turn scalar<scalar<scalar<double>>>> back to double. // Allows to turn scalar<scalar<scalar<double>>>> back to double.
@ -170,6 +174,15 @@ public:
inline const vtype & operator ()(int i) const { inline const vtype & operator ()(int i) const {
return _internal[i]; return _internal[i];
} }
friend std::ostream& operator<< (std::ostream& stream, const iVector<vtype,N> &o){
stream<< "V<"<<N<<">{";
for(int i=0;i<N;i++) {
stream<<o._internal[i];
if (i<N-1) stream<<",";
}
stream<<"}";
return stream;
};
// inline vtype && operator ()(int i) { // inline vtype && operator ()(int i) {
// return _internal[i]; // return _internal[i];
// } // }
@ -262,6 +275,19 @@ public:
inline const vtype & operator ()(int i,int j) const { inline const vtype & operator ()(int i,int j) const {
return _internal[i][j]; return _internal[i][j];
} }
friend std::ostream& operator<< (std::ostream& stream, const iMatrix<vtype,N> &o){
stream<< "M<"<<N<<">{";
for(int i=0;i<N;i++) {
stream<< "{";
for(int j=0;j<N;j++) {
stream<<o._internal[i][j];
if (i<N-1) stream<<",";
}
stream<<"}\n\t\t";
}
stream<<"}";
return stream;
};
// inline vtype && operator ()(int i,int j) { // inline vtype && operator ()(int i,int j) {
// return _internal[i][j]; // return _internal[i][j];

View File

@ -5,11 +5,14 @@ AM_LDFLAGS = -L$(top_srcdir)/lib
# #
# Test code # Test code
# #
bin_PROGRAMS = Grid_main Grid_stencil Grid_nersc_io Grid_cshift Grid_gamma Grid_simd bin_PROGRAMS = Grid_main Grid_stencil Grid_nersc_io Grid_cshift Grid_gamma Grid_simd Grid_rng
Grid_main_SOURCES = Grid_main.cc Grid_main_SOURCES = Grid_main.cc
Grid_main_LDADD = -lGrid Grid_main_LDADD = -lGrid
Grid_rng_SOURCES = Grid_rng.cc
Grid_rng_LDADD = -lGrid
Grid_nersc_io_SOURCES = Grid_nersc_io.cc Grid_nersc_io_SOURCES = Grid_nersc_io.cc
Grid_nersc_io_LDADD = -lGrid Grid_nersc_io_LDADD = -lGrid