Skip to content

Commit

Permalink
Clean up outcommented code
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Niethammer <[email protected]>
  • Loading branch information
cniethammer committed Dec 23, 2024
1 parent a1d1b34 commit deacfc7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 53 deletions.
54 changes: 2 additions & 52 deletions src/io/MPICheckpointWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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' );
Expand Down Expand Up @@ -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));
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -281,68 +276,30 @@ 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;
}
else
{
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;
}
}

Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/io/MPICheckpointWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit deacfc7

Please sign in to comment.