Skip to content

Commit

Permalink
Added a timer to the main loop output to track how long each time ste…
Browse files Browse the repository at this point in the history
…p takes
  • Loading branch information
stevenhofmeyr committed Sep 13, 2024
1 parent fee7b62 commit 6719fb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/CensusData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ void CensusData::initAgents (AgentContainer& pc, /*!< Agents */
demo.CopyToHostAsync(demo.Unit_on_proc_d, demo.Unit_on_proc);
amrex::Gpu::streamSynchronize();

/*
// Note: this hack depends on managed memory
std::ofstream outf("agents." + std::to_string(ParallelDescriptor::MyProc()) + ".csv");
for (MFIter mfi = pc.MakeMFIter(0, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
auto& ptile = pc.ParticlesAt(0, mfi);
Expand All @@ -518,7 +520,7 @@ void CensusData::initAgents (AgentContainer& pc, /*!< Agents */
}
}
outf.close();

*/
}

/*! \brief Read worker flow data from file and set work location for agents
Expand Down
16 changes: 13 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
\brief **Main**: Contains main() and runAgent()
*/

#include <chrono>

#include <AMReX.H>
#include <AMReX_iMultiFab.H>
#include <AMReX_ParmParse.H>
Expand Down Expand Up @@ -216,7 +218,7 @@ void runAgent ()
BL_PROFILE_REGION("Evolution");
for (int i = 0; i < params.nsteps; ++i)
{
amrex::Print() << "Simulating day " << i << " " << std::flush;
auto start_time = std::chrono::high_resolution_clock::now();

if ((params.plot_int > 0) && (i % params.plot_int == 0)) {
ExaEpi::IO::writePlotFile(pc, censusData, params.num_diseases, params.disease_names, cur_time, i);
Expand Down Expand Up @@ -282,8 +284,6 @@ void runAgent ()

if (ParallelDescriptor::IOProcessor())
{
amrex::Print() << " " << counts[1] << " infected, " << counts[4] << " deaths\n";

// total number of deaths computed on agents and on mesh should be the same...
if (mmc[3] != counts[4]) {
amrex::Print() << mmc[3] << " " << counts[4] << "\n";
Expand Down Expand Up @@ -354,6 +354,16 @@ void runAgent ()
pc.infectAgents();

cur_time += 1.0_rt; // time step is one day

std::chrono::duration<double> elapsed_time = std::chrono::high_resolution_clock::now() - start_time;

Print() << "[Day " << cur_time << " " << std::fixed << std::setprecision(1) << elapsed_time.count() << "s] ";
for (int d = 0; d < params.num_diseases; d++) {
auto counts = pc.getTotals(d);
if (d > 0) Print() << "; ";
Print() << params.disease_names[d] << ": " << counts[1] << " infected, " << counts[4] << " deaths";
}
Print() << "\n";
}
}

Expand Down

0 comments on commit 6719fb6

Please sign in to comment.