mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Put timers in simulation namespace
This commit is contained in:
parent
624e9875d6
commit
a63a89f9d6
5 changed files with 80 additions and 70 deletions
|
|
@ -5,6 +5,27 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
//==============================================================================
|
||||
|
||||
class Timer;
|
||||
|
||||
namespace simulation {
|
||||
|
||||
extern Timer time_active;
|
||||
extern Timer time_bank;
|
||||
extern Timer time_bank_sample;
|
||||
extern Timer time_bank_sendrecv;
|
||||
extern Timer time_finalize;
|
||||
extern Timer time_inactive;
|
||||
extern Timer time_initialize;
|
||||
extern Timer time_tallies;
|
||||
extern Timer time_total;
|
||||
extern Timer time_transport;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
//==============================================================================
|
||||
//! Class for measuring time elapsed
|
||||
//==============================================================================
|
||||
|
|
@ -34,21 +55,6 @@ private:
|
|||
double elapsed_ {0.0}; //!< elasped time in [s]
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
//==============================================================================
|
||||
|
||||
extern Timer time_active;
|
||||
extern Timer time_bank;
|
||||
extern Timer time_bank_sample;
|
||||
extern Timer time_bank_sendrecv;
|
||||
extern Timer time_finalize;
|
||||
extern Timer time_inactive;
|
||||
extern Timer time_initialize;
|
||||
extern Timer time_tallies;
|
||||
extern Timer time_total;
|
||||
extern Timer time_transport;
|
||||
|
||||
//==============================================================================
|
||||
// Non-member functions
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ void calculate_generation_keff()
|
|||
|
||||
void synchronize_bank()
|
||||
{
|
||||
time_bank.start();
|
||||
simulation::time_bank.start();
|
||||
|
||||
// Get pointers to source/fission bank
|
||||
Bank* source_bank;
|
||||
|
|
@ -131,7 +131,7 @@ void synchronize_bank()
|
|||
}
|
||||
double p_sample = static_cast<double>(sites_needed) / total;
|
||||
|
||||
time_bank_sample.start();
|
||||
simulation::time_bank_sample.start();
|
||||
|
||||
// ==========================================================================
|
||||
// SAMPLE N_PARTICLES FROM FISSION BANK AND PLACE IN TEMP_SITES
|
||||
|
|
@ -204,8 +204,8 @@ void synchronize_bank()
|
|||
finish = simulation::work_index[mpi::rank + 1];
|
||||
}
|
||||
|
||||
time_bank_sample.stop();
|
||||
time_bank_sendrecv.start();
|
||||
simulation::time_bank_sample.stop();
|
||||
simulation::time_bank_sendrecv.start();
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
// ==========================================================================
|
||||
|
|
@ -303,8 +303,8 @@ void synchronize_bank()
|
|||
std::copy(temp_sites.data(), temp_sites.data() + settings::n_particles, source_bank);
|
||||
#endif
|
||||
|
||||
time_bank_sendrecv.stop();
|
||||
time_bank.stop();
|
||||
simulation::time_bank_sendrecv.stop();
|
||||
simulation::time_bank.stop();
|
||||
}
|
||||
|
||||
void calculate_average_keff()
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ int openmc_init(int argc, char* argv[], const void* intracomm)
|
|||
if (err) return err;
|
||||
|
||||
// Start total and initialization timer
|
||||
time_total.start();
|
||||
time_initialize.start();
|
||||
simulation::time_total.start();
|
||||
simulation::time_initialize.start();
|
||||
|
||||
#ifdef _OPENMP
|
||||
// If OMP_SCHEDULE is not set, default to a static schedule
|
||||
|
|
@ -79,7 +79,7 @@ int openmc_init(int argc, char* argv[], const void* intracomm)
|
|||
if (settings::particle_restart_run) settings::run_mode = RUN_MODE_PARTICLE;
|
||||
|
||||
// Stop initialization timer
|
||||
time_initialize.stop();
|
||||
simulation::time_initialize.stop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ int openmc_simulation_finalize()
|
|||
if (!simulation::initialized) return 0;
|
||||
|
||||
// Stop active batch timer and start finalization timer
|
||||
time_active.stop();
|
||||
time_finalize.start();
|
||||
simulation::time_active.stop();
|
||||
simulation::time_finalize.start();
|
||||
|
||||
#pragma omp parallel
|
||||
{
|
||||
|
|
@ -166,8 +166,8 @@ int openmc_simulation_finalize()
|
|||
}
|
||||
|
||||
// Stop timers and show timing statistics
|
||||
time_finalize.stop();
|
||||
time_total.stop();
|
||||
simulation::time_finalize.stop();
|
||||
simulation::time_total.stop();
|
||||
if (mpi::master) {
|
||||
if (settings::verbosity >= 6) print_runtime();
|
||||
if (settings::verbosity >= 4) print_results();
|
||||
|
|
@ -200,7 +200,7 @@ int openmc_next_batch(int* status)
|
|||
initialize_generation();
|
||||
|
||||
// Start timer for transport
|
||||
time_transport.start();
|
||||
simulation::time_transport.start();
|
||||
|
||||
// ====================================================================
|
||||
// LOOP OVER PARTICLES
|
||||
|
|
@ -218,7 +218,7 @@ int openmc_next_batch(int* status)
|
|||
}
|
||||
|
||||
// Accumulate time for transport
|
||||
time_transport.stop();
|
||||
simulation::time_transport.stop();
|
||||
|
||||
finalize_generation();
|
||||
}
|
||||
|
|
@ -305,10 +305,10 @@ void initialize_batch()
|
|||
|
||||
// Manage active/inactive timers and activate tallies if necessary.
|
||||
if (first_inactive) {
|
||||
time_inactive.start();
|
||||
simulation::time_inactive.start();
|
||||
} else if (first_active) {
|
||||
time_inactive.stop();
|
||||
time_active.start();
|
||||
simulation::time_inactive.stop();
|
||||
simulation::time_active.start();
|
||||
for (int i = 1; i <= n_tallies; ++i) {
|
||||
// TODO: change one-based index
|
||||
openmc_tally_set_active(i, true);
|
||||
|
|
@ -327,9 +327,9 @@ void initialize_batch()
|
|||
void finalize_batch()
|
||||
{
|
||||
// Reduce tallies onto master process and accumulate
|
||||
time_tallies.start();
|
||||
simulation::time_tallies.start();
|
||||
accumulate_tallies();
|
||||
time_tallies.stop();
|
||||
simulation::time_tallies.stop();
|
||||
|
||||
// Reset global tally results
|
||||
if (simulation::current_batch <= settings::n_inactive) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,25 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
//==============================================================================
|
||||
|
||||
namespace simulation {
|
||||
|
||||
Timer time_active;
|
||||
Timer time_bank;
|
||||
Timer time_bank_sample;
|
||||
Timer time_bank_sendrecv;
|
||||
Timer time_finalize;
|
||||
Timer time_inactive;
|
||||
Timer time_initialize;
|
||||
Timer time_tallies;
|
||||
Timer time_total;
|
||||
Timer time_transport;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
//==============================================================================
|
||||
// Timer implementation
|
||||
//==============================================================================
|
||||
|
|
@ -34,35 +53,20 @@ double Timer::elapsed()
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
//==============================================================================
|
||||
|
||||
Timer time_active;
|
||||
Timer time_bank;
|
||||
Timer time_bank_sample;
|
||||
Timer time_bank_sendrecv;
|
||||
Timer time_finalize;
|
||||
Timer time_inactive;
|
||||
Timer time_initialize;
|
||||
Timer time_tallies;
|
||||
Timer time_total;
|
||||
Timer time_transport;
|
||||
|
||||
//==============================================================================
|
||||
// Fortran compatibility
|
||||
//==============================================================================
|
||||
|
||||
extern "C" double time_active_elapsed() { return time_active.elapsed(); }
|
||||
extern "C" double time_bank_elapsed() { return time_bank.elapsed(); }
|
||||
extern "C" double time_bank_sample_elapsed() { return time_bank_sample.elapsed(); }
|
||||
extern "C" double time_bank_sendrecv_elapsed() { return time_bank_sendrecv.elapsed(); }
|
||||
extern "C" double time_finalize_elapsed() { return time_finalize.elapsed(); }
|
||||
extern "C" double time_inactive_elapsed() { return time_inactive.elapsed(); }
|
||||
extern "C" double time_initialize_elapsed() { return time_initialize.elapsed(); }
|
||||
extern "C" double time_tallies_elapsed() { return time_tallies.elapsed(); }
|
||||
extern "C" double time_total_elapsed() { return time_total.elapsed(); }
|
||||
extern "C" double time_transport_elapsed() { return time_transport.elapsed(); }
|
||||
extern "C" double time_active_elapsed() { return simulation::time_active.elapsed(); }
|
||||
extern "C" double time_bank_elapsed() { return simulation::time_bank.elapsed(); }
|
||||
extern "C" double time_bank_sample_elapsed() { return simulation::time_bank_sample.elapsed(); }
|
||||
extern "C" double time_bank_sendrecv_elapsed() { return simulation::time_bank_sendrecv.elapsed(); }
|
||||
extern "C" double time_finalize_elapsed() { return simulation::time_finalize.elapsed(); }
|
||||
extern "C" double time_inactive_elapsed() { return simulation::time_inactive.elapsed(); }
|
||||
extern "C" double time_initialize_elapsed() { return simulation::time_initialize.elapsed(); }
|
||||
extern "C" double time_tallies_elapsed() { return simulation::time_tallies.elapsed(); }
|
||||
extern "C" double time_total_elapsed() { return simulation::time_total.elapsed(); }
|
||||
extern "C" double time_transport_elapsed() { return simulation::time_transport.elapsed(); }
|
||||
|
||||
//==============================================================================
|
||||
// Non-member functions
|
||||
|
|
@ -70,16 +74,16 @@ extern "C" double time_transport_elapsed() { return time_transport.elapsed(); }
|
|||
|
||||
void reset_timers()
|
||||
{
|
||||
time_active.reset();
|
||||
time_bank.reset();
|
||||
time_bank_sample.reset();
|
||||
time_bank_sendrecv.reset();
|
||||
time_finalize.reset();
|
||||
time_inactive.reset();
|
||||
time_initialize.reset();
|
||||
time_tallies.reset();
|
||||
time_total.reset();
|
||||
time_transport.reset();
|
||||
simulation::time_active.reset();
|
||||
simulation::time_bank.reset();
|
||||
simulation::time_bank_sample.reset();
|
||||
simulation::time_bank_sendrecv.reset();
|
||||
simulation::time_finalize.reset();
|
||||
simulation::time_inactive.reset();
|
||||
simulation::time_initialize.reset();
|
||||
simulation::time_tallies.reset();
|
||||
simulation::time_total.reset();
|
||||
simulation::time_transport.reset();
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue