diff --git a/lib/parallelIO/NerscIO.h b/lib/parallelIO/NerscIO.h index ab535dac..ba9d23de 100644 --- a/lib/parallelIO/NerscIO.h +++ b/lib/parallelIO/NerscIO.h @@ -30,12 +30,6 @@ #ifndef GRID_NERSC_IO_H #define GRID_NERSC_IO_H -#undef PARALLEL_READ -#undef SERIAL_READ -#define MPI_READ - -#define PARALLEL_WRITE - #include #include #include @@ -133,10 +127,6 @@ namespace Grid { ////////////////////////////////////////////////////////////////////// // Utilities ; these are QCD aware ////////////////////////////////////////////////////////////////////// - inline void NerscChecksum(uint32_t *buf,uint32_t buf_size_bytes,uint32_t &csum) - { - BinaryIO::Uint32Checksum(buf,buf_size_bytes,csum); - } inline void reconstruct3(LorentzColourMatrix & cm) { const int x=0; @@ -151,43 +141,38 @@ namespace Grid { template struct NerscSimpleMunger{ - void operator()(fobj &in, sobj &out, uint32_t &csum) { + void operator()(fobj &in, sobj &out) { for (int mu = 0; mu < Nd; mu++) { for (int i = 0; i < Nc; i++) { - for (int j = 0; j < Nc; j++) { - out(mu)()(i, j) = in(mu)()(i, j); - } - } + for (int j = 0; j < Nc; j++) { + out(mu)()(i, j) = in(mu)()(i, j); + }} } - NerscChecksum((uint32_t *)&in, sizeof(in), csum); }; }; template struct NerscSimpleUnmunger { - void operator()(sobj &in, fobj &out, uint32_t &csum) { + + void operator()(sobj &in, fobj &out) { for (int mu = 0; mu < Nd; mu++) { for (int i = 0; i < Nc; i++) { - for (int j = 0; j < Nc; j++) { - out(mu)()(i, j) = in(mu)()(i, j); - } - } + for (int j = 0; j < Nc; j++) { + out(mu)()(i, j) = in(mu)()(i, j); + }} } - NerscChecksum((uint32_t *)&out, sizeof(out), csum); }; }; template struct Nersc3x2munger{ - void operator() (fobj &in,sobj &out,uint32_t &csum){ - - NerscChecksum((uint32_t *)&in,sizeof(in),csum); + void operator() (fobj &in,sobj &out){ for(int mu=0;mu<4;mu++){ for(int i=0;i<2;i++){ - for(int j=0;j<3;j++){ - out(mu)()(i,j) = in(mu)(i)(j); - }} + for(int j=0;j<3;j++){ + out(mu)()(i,j) = in(mu)(i)(j); + }} } reconstruct3(out); } @@ -196,18 +181,13 @@ namespace Grid { template struct Nersc3x2unmunger{ - void operator() (sobj &in,fobj &out,uint32_t &csum){ - - + void operator() (sobj &in,fobj &out){ for(int mu=0;mu<4;mu++){ for(int i=0;i<2;i++){ - for(int j=0;j<3;j++){ - out(mu)(i)(j) = in(mu)()(i,j); - }} + for(int j=0;j<3;j++){ + out(mu)(i)(j) = in(mu)()(i,j); + }} } - - NerscChecksum((uint32_t *)&out,sizeof(out),csum); - } }; @@ -333,9 +313,9 @@ namespace Grid { // Now the meat: the object readers ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template - static inline void readConfiguration(Lattice > &Umu,NerscField& header,std::string file) - { + template + static inline void readConfiguration(Lattice > &Umu,NerscField& header,std::string file) + { typedef Lattice > GaugeField; GridBase *grid = Umu._grid; @@ -354,62 +334,22 @@ namespace Grid { // depending on datatype, set up munger; // munger is a function of if ( header.data_type == std::string("4D_SU3_GAUGE") ) { - if ( ieee32 || ieee32big ) { -#ifdef PARALLEL_READ - csum=BinaryIO::readObjectParallel, LorentzColour2x3F> - (Umu,file,Nersc3x2munger(), offset,format); -#endif -#ifdef MPI_READ - csum=BinaryIO::readObjectMPI, LorentzColour2x3F> - (Umu,file,Nersc3x2munger(), offset,format); -#endif -#ifdef SERIAL_READ - csum=BinaryIO::readObjectSerial, LorentzColour2x3F> - (Umu,file,Nersc3x2munger(), offset,format); -#endif - } - if ( ieee64 || ieee64big ) { -#ifdef PARALLEL_READ - csum=BinaryIO::readObjectParallel, LorentzColour2x3D> - (Umu,file,Nersc3x2munger(),offset,format); -#endif -#ifdef MPI_READ - csum=BinaryIO::readObjectMPI, LorentzColour2x3D> - (Umu,file,Nersc3x2munger(),offset,format); -#endif -#ifdef SERIAL_READ - csum=BinaryIO::readObjectSerial, LorentzColour2x3D> - (Umu,file,Nersc3x2munger(),offset,format); -#endif - } - } else if ( header.data_type == std::string("4D_SU3_GAUGE_3x3") ) { if ( ieee32 || ieee32big ) { -#ifdef PARALLEL_READ - csum=BinaryIO::readObjectParallel,LorentzColourMatrixF> - (Umu,file,NerscSimpleMunger(),offset,format); -#endif -#ifdef MPI_READ - csum=BinaryIO::readObjectMPI,LorentzColourMatrixF> - (Umu,file,NerscSimpleMunger(),offset,format); -#endif -#ifdef SERIAL_READ - csum=BinaryIO::readObjectSerial,LorentzColourMatrixF> - (Umu,file,NerscSimpleMunger(),offset,format); -#endif + csum=BinaryIO::readLatticeObject, LorentzColour2x3F> + (Umu,file,Nersc3x2munger(), offset,format); } if ( ieee64 || ieee64big ) { -#ifdef PARALLEL_READ - csum=BinaryIO::readObjectParallel,LorentzColourMatrixD> + csum=BinaryIO::readLatticeObject, LorentzColour2x3D> + (Umu,file,Nersc3x2munger(),offset,format); + } + } else if ( header.data_type == std::string("4D_SU3_GAUGE_3x3") ) { + if ( ieee32 || ieee32big ) { + csum=BinaryIO::readLatticeObject,LorentzColourMatrixF> + (Umu,file,NerscSimpleMunger(),offset,format); + } + if ( ieee64 || ieee64big ) { + csum=BinaryIO::readLatticeObject,LorentzColourMatrixD> (Umu,file,NerscSimpleMunger(),offset,format); -#endif -#ifdef MPI_READ - csum=BinaryIO::readObjectMPI,LorentzColourMatrixD> - (Umu,file,NerscSimpleMunger(),offset,format); -#endif -#ifdef SERIAL_READ - csum=BinaryIO::readObjectSerial,LorentzColourMatrixD> - (Umu,file,NerscSimpleMunger(),offset,format); -#endif } } else { assert(0); @@ -434,14 +374,14 @@ namespace Grid { std::cerr << " plaqs " << clone.plaquette << " " << header.plaquette << std::endl; std::cerr << " trace " << clone.link_trace<< " " << header.link_trace<< std::endl; std::cerr << " csum " < static inline void writeConfiguration(Lattice > &Umu,std::string file, int two_row,int bits32) @@ -466,41 +406,29 @@ namespace Grid { NerscStatistics(Umu,header); NerscMachineCharacteristics(header); - uint32_t csum; int offset; truncate(file); if ( two_row ) { - header.floating_point = std::string("IEEE64BIG"); header.data_type = std::string("4D_SU3_GAUGE"); Nersc3x2unmunger munge; - BinaryIO::Uint32Checksum(Umu, munge,header.checksum); offset = writeHeader(header,file); -#ifdef PARALLEL_WRITE - csum=BinaryIO::writeObjectParallel(Umu,file,munge,offset,header.floating_point); -#else - csum=BinaryIO::writeObjectSerial(Umu,file,munge,offset,header.floating_point); -#endif + header.checksum=BinaryIO::writeLatticeObject(Umu,file,munge,offset,header.floating_point); + writeHeader(header,file); } else { header.floating_point = std::string("IEEE64BIG"); header.data_type = std::string("4D_SU3_GAUGE_3x3"); NerscSimpleUnmunger munge; - BinaryIO::Uint32Checksum(Umu, munge,header.checksum); offset = writeHeader(header,file); -#ifdef PARALLEL_WRITE - csum=BinaryIO::writeObjectParallel(Umu,file,munge,offset,header.floating_point); -#else - csum=BinaryIO::writeObjectSerial(Umu,file,munge,offset,header.floating_point); -#endif + header.checksum=BinaryIO::writeLatticeObject(Umu,file,munge,offset,header.floating_point); + writeHeader(header,file); } - - std::cout< - uint32_t csum=BinaryIO::readRNGSerial(serial,parallel,file,offset); + uint32_t csum=BinaryIO::readRNG(serial,parallel,file,offset); if ( csum != header.checksum ) { std::cerr << "checksum mismatch "<