From f93bb05fb4d8758d1bf9aa79ffda29224232f84b Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Mon, 23 Dec 2024 15:02:45 +0100 Subject: [PATCH 1/4] Fix incorrect xmlfile bool parsing in MPICheckpointWriter::readXML Signed-off-by: Christoph Niethammer --- examples/Generators/mkesfera/config.xml | 2 +- examples/all-options.xml | 2 +- src/io/MPICheckpointWriter.cpp | 21 ++++++--------------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/examples/Generators/mkesfera/config.xml b/examples/Generators/mkesfera/config.xml index 41fa4812e4..b284706b77 100644 --- a/examples/Generators/mkesfera/config.xml +++ b/examples/Generators/mkesfera/config.xml @@ -109,7 +109,7 @@ mkesfera true native - 1 + true striping_factor 4 striping_unit 65536 diff --git a/examples/all-options.xml b/examples/all-options.xml index 94723411a4..4e23416f49 100644 --- a/examples/all-options.xml +++ b/examples/all-options.xml @@ -417,7 +417,7 @@ default true native - 1 + true diff --git a/src/io/MPICheckpointWriter.cpp b/src/io/MPICheckpointWriter.cpp index 8081b0b5b0..cfb3778945 100644 --- a/src/io/MPICheckpointWriter.cpp +++ b/src/io/MPICheckpointWriter.cpp @@ -55,20 +55,14 @@ void MPICheckpointWriter::readXML(XMLfileUnits& xmlconfig) Log::global_log->info() << "[MPICheckpointWriter]\toutput prefix: " << _outputPrefix << std::endl; _incremental = false; - int incremental = 1; - xmlconfig.getNodeValue("incremental", incremental); - //_incremental = (incremental != 0); - if(incremental > 0) { - _incremental = true; + xmlconfig.getNodeValue("incremental", _incremental); + if(_incremental) { Log::global_log->info() << "[MPICheckpointWriter]\tusing incremental numbers in file names" << std::endl; } _appendTimestamp = false; - int appendTimestamp = 0; - xmlconfig.getNodeValue("appendTimestamp", appendTimestamp); - //_appendTimestamp = (appendTimestamp != 0); - if(appendTimestamp > 0) { - _appendTimestamp = true; + xmlconfig.getNodeValue("appendTimestamp", _appendTimestamp); + if(_appendTimestamp) { Log::global_log->info() << "[MPICheckpointWriter]\tappend timestamp to file names" << std::endl; } @@ -79,11 +73,8 @@ void MPICheckpointWriter::readXML(XMLfileUnits& xmlconfig) Log::global_log->info() << "[MPICheckpointWriter]\tdata representation: " << _datarep << std::endl; _measureTime = false; - int measureTime = 0; - xmlconfig.getNodeValue("measureTime", measureTime); - //_measureTime = (measureTime != 0); - if(measureTime > 0) { - _measureTime = true; + xmlconfig.getNodeValue("measureTime", _measureTime); + if(_measureTime) { Log::global_log->info() << "[MPICheckpointWriter]\texecution wall time will be measured" << std::endl; } From aef0537a433dba82160b08bee15a48d262e588d2 Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Mon, 23 Dec 2024 15:59:17 +0100 Subject: [PATCH 2/4] Replace tabs in log output with whitespaces for better readability Signed-off-by: Christoph Niethammer --- src/io/MPICheckpointWriter.cpp | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/io/MPICheckpointWriter.cpp b/src/io/MPICheckpointWriter.cpp index cfb3778945..280bd18294 100644 --- a/src/io/MPICheckpointWriter.cpp +++ b/src/io/MPICheckpointWriter.cpp @@ -48,34 +48,34 @@ void MPICheckpointWriter::readXML(XMLfileUnits& xmlconfig) { _writeFrequency = 1; xmlconfig.getNodeValue("writefrequency", _writeFrequency); - Log::global_log->info() << "[MPICheckpointWriter]\twrite frequency: " << _writeFrequency << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] write frequency: " << _writeFrequency << std::endl; _outputPrefix = "mardyn"; xmlconfig.getNodeValue("outputprefix", _outputPrefix); - Log::global_log->info() << "[MPICheckpointWriter]\toutput prefix: " << _outputPrefix << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] output prefix: " << _outputPrefix << std::endl; _incremental = false; xmlconfig.getNodeValue("incremental", _incremental); if(_incremental) { - Log::global_log->info() << "[MPICheckpointWriter]\tusing incremental numbers in file names" << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] using incremental numbers in file names" << std::endl; } _appendTimestamp = false; xmlconfig.getNodeValue("appendTimestamp", _appendTimestamp); if(_appendTimestamp) { - Log::global_log->info() << "[MPICheckpointWriter]\tappend timestamp to file names" << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] appending timestamps to file names" << std::endl; } _datarep = ""; // -> NULL //_datarep = "external32"; // "native", "internal", "external32" xmlconfig.getNodeValue("datarep", _datarep); if(!_datarep.empty()) - Log::global_log->info() << "[MPICheckpointWriter]\tdata representation: " << _datarep << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] data representation: " << _datarep << std::endl; _measureTime = false; xmlconfig.getNodeValue("measureTime", _measureTime); if(_measureTime) { - Log::global_log->info() << "[MPICheckpointWriter]\texecution wall time will be measured" << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] execution wall time will be measured" << std::endl; } if(xmlconfig.changecurrentnode("mpi_info")) { @@ -93,9 +93,9 @@ void MPICheckpointWriter::readXML(XMLfileUnits& xmlconfig) if(_particlesbuffersize) { #ifdef ENABLE_MPI - Log::global_log->info() << "[MPICheckpointWriter]\tparticles buffer size: " << _particlesbuffersize << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] particles buffer size: " << _particlesbuffersize << std::endl; #else - Log::global_log->info() << "[MPICheckpointWriter]\tparticles buffer size (" << _particlesbuffersize << ") only used in parallel/MPI version" << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] particles buffer size (" << _particlesbuffersize << ") only used in parallel/MPI version" << std::endl; #endif } } @@ -155,14 +155,14 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe filenamestream << ".MPIrestart.dat"; std::string filename = filenamestream.str(); - Log::global_log->info() << "[MPICheckpointWriter]\tfilename: " << filename << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] filename: " << filename << std::endl; unsigned long numParticles_global = domain->getglobalNumMolecules(true, particleContainer, domainDecomp); unsigned long numParticles = particleContainer->getNumberOfParticles(); // local unsigned long numbb{1ul}; #ifdef ENABLE_MPI - Log::global_log->info() << "[MPICheckpointWriter]\tnumber of particles: " << numParticles_global - << "\t(*" << sizeof(ParticleData) << "=" << numParticles_global*sizeof(ParticleData) << " Bytes in memory)" + Log::global_log->info() << "[MPICheckpointWriter] number of particles: " << numParticles_global + << " (*" << sizeof(ParticleData) << "=" << numParticles_global*sizeof(ParticleData) << " Bytes in memory)" << std::endl; //global_log->set_mpi_output_all() int num_procs; @@ -251,10 +251,10 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe mpioffset+=sizeof(unsigned long); MPI_CHECK( MPI_File_write_at(mpifh,mpioffset,&numParticles,1,MPI_UNSIGNED_LONG,&mpistat) ); mpioffset+=sizeof(unsigned long); - Log::global_log->debug() << "[MPICheckpointWriter](" << ownrank << ")\tBB " << ":\t" + Log::global_log->debug() << "[MPICheckpointWriter](" << ownrank << ") BB " << ": " << bbmin[0] << ", " << bbmin[1] << ", " << bbmin[2] << " - " << bbmax[0] << ", " << bbmax[1] << ", " << bbmax[2] - << "\tstarting index=" << startidx << " numParticles=" << numParticles << std::endl; + << " starting index=" << startidx << " numParticles=" << numParticles << std::endl; // MPI_Datatype mpidtParticleM, mpidtParticleD; ParticleData::getMPIType(mpidtParticleM); @@ -276,7 +276,7 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe Log::global_log->debug() << "[MPICheckpointWriter](" << ownrank - << ")\twriting molecule data for " + << ") writing molecule data for " << numParticles << " particles of size " << mpidtParticleDts @@ -354,20 +354,20 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe // global_simulation->timers()->stop("MPI_CHECKPOINT_WRITER_INPUT"); // double mpimeasuredtime=global_simulation->timers()->getTime("MPI_CHECKPOINT_WRITER_INPUT"); if(ownrank==0) { - Log::global_log->info() << "[MPICheckpointWriter]\tmeasured time: " << mpimeasuredtime << " sec (par., " + Log::global_log->info() << "[MPICheckpointWriter] measured time: " << mpimeasuredtime << " sec (par., " << num_procs << " proc.; " << numParticles_global << "*" << mpidtParticleDts << "=" << numParticles_global * mpidtParticleDts << " Bytes)" << std::endl; } } #else - Log::global_log->info() << "[MPICheckpointWriter]\tnumber of particles: " << numParticles_global - << "\t(*" << 2*sizeof(unsigned long)+13*sizeof(double) << "=" << numParticles_global*(2*sizeof(unsigned long)+13*sizeof(double)) << " Bytes in memory)" + Log::global_log->info() << "[MPICheckpointWriter] number of particles: " << numParticles_global + << " (*" << 2*sizeof(unsigned long)+13*sizeof(double) << "=" << numParticles_global*(2*sizeof(unsigned long)+13*sizeof(double)) << " Bytes in memory)" << std::endl; unsigned long gap=7+3+sizeof(unsigned long)+(6*sizeof(double)+2*sizeof(unsigned long)); unsigned int i; unsigned int offset=0; if (!_datarep.empty()) { - Log::global_log->warning() << "[MPICheckpointWriter]\tsetting data representation (" << _datarep + Log::global_log->warning() << "[MPICheckpointWriter] setting data representation (" << _datarep << ") is not supported (yet) in sequential version" << std::endl; } // should use Timer instead @@ -433,7 +433,7 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe double measuredtime=(double)(tod_end.tv_sec-tod_start.tv_sec)+(double)(tod_end.tv_usec-tod_start.tv_usec)/1.E6; // global_simulation->timers()->stop("MPI_CHECKPOINT_WRITER_INPUT"); // double measuredtime=global_simulation->timers()->getTime("MPI_CHECKPOINT_WRITER_INPUT"); - Log::global_log->info() << "[MPICheckpointWriter]\tmeasured time: " << measuredtime << " sec (seq.)" << std::endl; + Log::global_log->info() << "[MPICheckpointWriter] measured time: " << measuredtime << " sec (seq.)" << std::endl; } #endif } From a1d1b34df94030a09b92acc7f3acdeaff81409f7 Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Mon, 23 Dec 2024 16:20:02 +0100 Subject: [PATCH 3/4] Add documentation for readXML of MPICheckpointWriter Signed-off-by: Christoph Niethammer --- src/io/MPICheckpointWriter.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/io/MPICheckpointWriter.h b/src/io/MPICheckpointWriter.h index 6cd6ad2ee4..023b85c97e 100644 --- a/src/io/MPICheckpointWriter.h +++ b/src/io/MPICheckpointWriter.h @@ -40,6 +40,20 @@ class MPICheckpointWriter : public PluginBase { , std::string datarep=std::string("")); //~MPICheckpointWriter() {}; + /** @brief Read in XML configuration for MPICheckpointWriter and all its included objects. + * + * The following xml object structure is handled by this method: + * \code{.xml} + + INTEGER + STRING + BOOL + BOOL + STRING + + + \endcode + */ void readXML(XMLfileUnits& xmlconfig); void init(ParticleContainer *particleContainer, From deacfc7542c8145c1bd1e395277b1d1096031247 Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Mon, 23 Dec 2024 16:25:36 +0100 Subject: [PATCH 4/4] Clean up outcommented code Signed-off-by: Christoph Niethammer --- src/io/MPICheckpointWriter.cpp | 54 ++-------------------------------- src/io/MPICheckpointWriter.h | 1 - 2 files changed, 2 insertions(+), 53 deletions(-) diff --git a/src/io/MPICheckpointWriter.cpp b/src/io/MPICheckpointWriter.cpp index 280bd18294..1a36256d8d 100644 --- a/src/io/MPICheckpointWriter.cpp +++ b/src/io/MPICheckpointWriter.cpp @@ -28,7 +28,6 @@ extern Simulation* global_simulation; const char MPICheckpointWriter::_magicVersion[] = "MarDyn20150211trunk"; -// int32_t const int MPICheckpointWriter::_endiannesstest = 0x0a0b0c0d; MPICheckpointWriter::MPICheckpointWriter(unsigned long writeFrequency, std::string outputPrefix, bool incremental, std::string datarep) @@ -134,7 +133,6 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe if(_incremental) { /* align file numbers with preceding '0's in the required range from 0 to _numberOfTimesteps. */ - unsigned long numTimesteps = _simulation.getNumTimesteps(); int num_digits = (int) ceil( log( double( numTimesteps / _writeFrequency ) ) / log(10.) ); filenamestream << "-" << aligned_number( simstep / _writeFrequency, num_digits, '0' ); @@ -164,7 +162,6 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe Log::global_log->info() << "[MPICheckpointWriter] number of particles: " << numParticles_global << " (*" << sizeof(ParticleData) << "=" << numParticles_global*sizeof(ParticleData) << " Bytes in memory)" << std::endl; - //global_log->set_mpi_output_all() int num_procs; MPI_CHECK( MPI_Comm_size(MPI_COMM_WORLD, &num_procs) ); unsigned long gap=7+3+sizeof(unsigned long)+num_procs*(6*sizeof(double)+2*sizeof(unsigned long)); @@ -173,10 +170,8 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe double mpistarttime=0; // =0 to prevent Jenkins/gcc complaining about uninitialized mpistarttime [-Werror=uninitialized] if(_measureTime) { - //if(ownrank==0) Log::global_log->debug() << "MPICheckpointWriter (" << filename << ")\tstart measuring time" << std::endl; MPI_CHECK( MPI_Barrier(MPI_COMM_WORLD) ); mpistarttime=MPI_Wtime(); - // global_simulation->timers()->start("MPI_CHECKPOINT_WRITER_INPUT"); // should use Timer instead } MPI_File mpifh; // arg 2 type cast due to old MPI (<=V2) implementations (should be const char* now) @@ -226,7 +221,7 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe startidx=0; } MPI_CHECK( MPI_Exscan(&numParticles, &startidx, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD) ); - // + mpioffset=64+7+3+sizeof(unsigned long)+ownrank*(6*sizeof(double)+2*sizeof(unsigned long)); double bbmin[3],bbmax[3]; bbmin[0]=domainDecomp->getBoundingBoxMin(0,domain); @@ -281,41 +276,21 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe << " particles of size " << mpidtParticleDts << std::endl; - //unsigned long writecounter=0; if(_particlesbuffersize>0) { ParticleData* particleStructBuffer=new ParticleData[_particlesbuffersize]; unsigned long bufidx=0; for (auto pos = particleContainer->iterator(ParticleIterator::ONLY_INNER_AND_BOUNDARY); pos.isValid(); ++pos) { - // Log::global_log->debug() - // << "MPICheckpointWriter[" - // << ownrank - // << "]\t" - // << pos->getID() - // << "\t" - // << pos->componentid() - // << "\t" - // << pos->r(0) - // << "," - // << pos->r(1) - // << "," - // << pos->r(2) - // << std::endl; ParticleData::MoleculeToParticleData(particleStructBuffer[bufidx], *pos); ++bufidx; - if(bufidx==_particlesbuffersize) - { - //global_log->debug() << "MPICheckpointWriter[" << ownrank << "]\twriting" << _particlesbuffersize << " particles" << std::endl + if(bufidx==_particlesbuffersize) { MPI_CHECK( MPI_File_write(mpifh, particleStructBuffer, _particlesbuffersize, mpidtParticleD, &mpistat) ); - //++writecounter; bufidx=0; } } if(bufidx>0) { - //global_log->debug() << "MPICheckpointWriter[" << ownrank << "]\twriting" << bufidx << " particles" << std::endl MPI_CHECK( MPI_File_write(mpifh, particleStructBuffer, bufidx, mpidtParticleD, &mpistat) ); - //++writecounter; } delete[] particleStructBuffer; } @@ -323,26 +298,8 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe { ParticleData particleStruct; for (auto pos = particleContainer->iterator(ParticleIterator::ONLY_INNER_AND_BOUNDARY); pos.isValid(); ++pos) { - // Log::global_log->debug() - // << "MPICheckpointWriter[" - // << ownrank - // << "]\t" - // << pos->getID() - // << "\t" - // << pos->componentid() - // << "\t" - // << pos->r(0) - // << "," - // << pos->r(1) - // << "," - // << pos->r(2) - // << std::endl; ParticleData::MoleculeToParticleData(particleStruct, *pos); - // Log::global_log->debug() << "MPICheckpointWriter[" << ownrank << "]\twriting particle" << std::endl MPI_CHECK( MPI_File_write(mpifh, &particleStruct, 1, mpidtParticleD, &mpistat) ); - //++writecounter; - // saving a struct directly will also save padding zeros... - //mpioffset+=mpidtParticleMsize; } } @@ -351,8 +308,6 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe { MPI_CHECK( MPI_Barrier(MPI_COMM_WORLD) ); double mpimeasuredtime=MPI_Wtime()-mpistarttime; - // global_simulation->timers()->stop("MPI_CHECKPOINT_WRITER_INPUT"); - // double mpimeasuredtime=global_simulation->timers()->getTime("MPI_CHECKPOINT_WRITER_INPUT"); if(ownrank==0) { Log::global_log->info() << "[MPICheckpointWriter] measured time: " << mpimeasuredtime << " sec (par., " << num_procs << " proc.; " << numParticles_global << "*" << mpidtParticleDts @@ -373,11 +328,8 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe // should use Timer instead struct timeval tod_start; if(_measureTime) { - //global_log->debug() << "MPICheckpointWriter (" << filename << ")\tstart measuring time" << std::endl; gettimeofday( &tod_start, NULL ); - // global_simulation->timers()->start("MPI_CHECKPOINT_WRITER_INPUT"); } - // std::ofstream ostrm(filename.c_str(),std::ios::out|std::ios::binary); ostrm << _magicVersion; offset+=strlen(_magicVersion); @@ -431,8 +383,6 @@ void MPICheckpointWriter::endStep(ParticleContainer *particleContainer, DomainDe struct timeval tod_end; gettimeofday( &tod_end, NULL ); double measuredtime=(double)(tod_end.tv_sec-tod_start.tv_sec)+(double)(tod_end.tv_usec-tod_start.tv_usec)/1.E6; - // global_simulation->timers()->stop("MPI_CHECKPOINT_WRITER_INPUT"); - // double measuredtime=global_simulation->timers()->getTime("MPI_CHECKPOINT_WRITER_INPUT"); Log::global_log->info() << "[MPICheckpointWriter] measured time: " << measuredtime << " sec (seq.)" << std::endl; } #endif diff --git a/src/io/MPICheckpointWriter.h b/src/io/MPICheckpointWriter.h index 023b85c97e..2025e3446e 100644 --- a/src/io/MPICheckpointWriter.h +++ b/src/io/MPICheckpointWriter.h @@ -38,7 +38,6 @@ class MPICheckpointWriter : public PluginBase { MPICheckpointWriter(unsigned long writeFrequency , std::string outputPrefix, bool incremental=true , std::string datarep=std::string("")); - //~MPICheckpointWriter() {}; /** @brief Read in XML configuration for MPICheckpointWriter and all its included objects. *