From 944afb1d206be4967ae98c5fe411e7ff71796eb5 Mon Sep 17 00:00:00 2001 From: rockfool Date: Wed, 1 Apr 2020 17:06:44 -0400 Subject: [PATCH 1/6] fix a bug in timer reset --- include/openmc/capi.h | 1 + openmc/lib/core.py | 3 +++ src/finalize.cpp | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 0c0f18bae..11c90ff3a 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -86,6 +86,7 @@ extern "C" { int openmc_id_map(const void* slice, int32_t* data_out); int openmc_property_map(const void* slice, double* data_out); int openmc_reset(); + int openmc_reset_timers(); int openmc_run(); void openmc_set_seed(int64_t new_seed); int openmc_simulation_finalize(); diff --git a/openmc/lib/core.py b/openmc/lib/core.py index 6a2a7cdea..61b8a6ed6 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -63,6 +63,8 @@ _dll.openmc_run.restype = c_int _dll.openmc_run.errcheck = _error_handler _dll.openmc_reset.restype = c_int _dll.openmc_reset.errcheck = _error_handler +_dll.openmc_reset_timers.restype = c_int +_dll.openmc_reset_timers.errcheck = _error_handler _run_linsolver_argtypes = [_array_1d_dble, _array_1d_dble, _array_1d_dble, c_double] _dll.openmc_run_linsolver.argtypes = _run_linsolver_argtypes @@ -305,6 +307,7 @@ def plot_geometry(): def reset(): """Reset tallies and timers.""" _dll.openmc_reset() + _dll.openmc_reset_timers() def run(): diff --git a/src/finalize.cpp b/src/finalize.cpp index 74f02cc64..b5d5eb038 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -165,6 +165,12 @@ int openmc_reset() return 0; } +int openmc_reset_timers() +{ + reset_timers(); + return 0; +} + int openmc_hard_reset() { // Reset all tallies and timers From e645acdfa1e44e0fac47531456125d1c7be75587 Mon Sep 17 00:00:00 2001 From: rockfool Date: Wed, 1 Apr 2020 23:03:02 -0400 Subject: [PATCH 2/6] add timer restart for C API --- include/openmc/capi.h | 1 + include/openmc/timer.h | 2 ++ openmc/lib/core.py | 3 +++ src/finalize.cpp | 6 ++++++ src/timer.cpp | 22 ++++++++++++++++++++++ 5 files changed, 34 insertions(+) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 11c90ff3a..a2bab1e2c 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -87,6 +87,7 @@ extern "C" { int openmc_property_map(const void* slice, double* data_out); int openmc_reset(); int openmc_reset_timers(); + int openmc_restart_timers(); int openmc_run(); void openmc_set_seed(int64_t new_seed); int openmc_simulation_finalize(); diff --git a/include/openmc/timer.h b/include/openmc/timer.h index cc20751a8..0ebbe0e8d 100644 --- a/include/openmc/timer.h +++ b/include/openmc/timer.h @@ -69,6 +69,8 @@ private: void reset_timers(); +void restart_timers(); + } // namespace openmc #endif // OPENMC_TIMER_H diff --git a/openmc/lib/core.py b/openmc/lib/core.py index 61b8a6ed6..a30341ed5 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -65,6 +65,8 @@ _dll.openmc_reset.restype = c_int _dll.openmc_reset.errcheck = _error_handler _dll.openmc_reset_timers.restype = c_int _dll.openmc_reset_timers.errcheck = _error_handler +_dll.openmc_restart_timers.restype = c_int +_dll.openmc_restart_timers.errcheck = _error_handler _run_linsolver_argtypes = [_array_1d_dble, _array_1d_dble, _array_1d_dble, c_double] _dll.openmc_run_linsolver.argtypes = _run_linsolver_argtypes @@ -308,6 +310,7 @@ def reset(): """Reset tallies and timers.""" _dll.openmc_reset() _dll.openmc_reset_timers() + _dll.openmc_restart_timers() def run(): diff --git a/src/finalize.cpp b/src/finalize.cpp index b5d5eb038..7d80b9fdf 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -171,6 +171,12 @@ int openmc_reset_timers() return 0; } +int openmc_restart_timers() +{ + restart_timers(); + return 0; +} + int openmc_hard_reset() { // Reset all tallies and timers diff --git a/src/timer.cpp b/src/timer.cpp index fdb10f0f2..449e2dce0 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -87,4 +87,26 @@ void reset_timers() simulation::time_event_death.reset(); } +void restart_timers() +{ + simulation::time_active.restart(); + simulation::time_bank.restart(); + simulation::time_bank_sample.restart(); + simulation::time_bank_sendrecv.restart(); + simulation::time_finalize.restart(); + simulation::time_inactive.restart(); + simulation::time_initialize.restart(); + simulation::time_read_xs.restart(); + simulation::time_sample_source.restart(); + simulation::time_tallies.restart(); + simulation::time_total.restart(); + simulation::time_transport.restart(); + simulation::time_event_init.restart(); + simulation::time_event_calculate_xs.restart(); + simulation::time_event_advance_particle.restart(); + simulation::time_event_surface_crossing.restart(); + simulation::time_event_collision.restart(); + simulation::time_event_death.restart(); +} + } // namespace openmc From 65802068683f1f2b8ca4b6ca19399af815b5a962 Mon Sep 17 00:00:00 2001 From: rockfool Date: Wed, 1 Apr 2020 23:06:54 -0400 Subject: [PATCH 3/6] fix a bug in timer.cpp --- src/timer.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/timer.cpp b/src/timer.cpp index 449e2dce0..71b85e33f 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -89,24 +89,24 @@ void reset_timers() void restart_timers() { - simulation::time_active.restart(); - simulation::time_bank.restart(); - simulation::time_bank_sample.restart(); - simulation::time_bank_sendrecv.restart(); - simulation::time_finalize.restart(); - simulation::time_inactive.restart(); - simulation::time_initialize.restart(); - simulation::time_read_xs.restart(); - simulation::time_sample_source.restart(); - simulation::time_tallies.restart(); - simulation::time_total.restart(); - simulation::time_transport.restart(); - simulation::time_event_init.restart(); - simulation::time_event_calculate_xs.restart(); - simulation::time_event_advance_particle.restart(); - simulation::time_event_surface_crossing.restart(); - simulation::time_event_collision.restart(); - simulation::time_event_death.restart(); + simulation::time_active.start(); + simulation::time_bank.start(); + simulation::time_bank_sample.start(); + simulation::time_bank_sendrecv.start(); + simulation::time_finalize.start(); + simulation::time_inactive.start(); + simulation::time_initialize.start(); + simulation::time_read_xs.start(); + simulation::time_sample_source.start(); + simulation::time_tallies.start(); + simulation::time_total.start(); + simulation::time_transport.start(); + simulation::time_event_init.start(); + simulation::time_event_calculate_xs.start(); + simulation::time_event_advance_particle.start(); + simulation::time_event_surface_crossing.start(); + simulation::time_event_collision.start(); + simulation::time_event_death.start(); } } // namespace openmc From 296dc72b3b05f560424a1df52e324a406c9aeb9f Mon Sep 17 00:00:00 2001 From: rockfool Date: Fri, 3 Apr 2020 13:38:39 -0400 Subject: [PATCH 4/6] fix a bug in total timer --- openmc/deplete/operator.py | 1 + openmc/lib/core.py | 6 +++++- src/timer.cpp | 17 ----------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/openmc/deplete/operator.py b/openmc/deplete/operator.py index 8eb033783..646a869e1 100644 --- a/openmc/deplete/operator.py +++ b/openmc/deplete/operator.py @@ -274,6 +274,7 @@ class Operator(TransportOperator): # Run OpenMC openmc.lib.reset() openmc.lib.run() + openmc.lib.reset_timers() # Extract results op_result = self._unpack_tallies_and_normalize(power) diff --git a/openmc/lib/core.py b/openmc/lib/core.py index a30341ed5..e2e5e73a9 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -307,8 +307,12 @@ def plot_geometry(): def reset(): - """Reset tallies and timers.""" + """Reset tallies but keep timers.""" _dll.openmc_reset() + + +def reset_timers(): + """Reset timers and restart for next batch.""" _dll.openmc_reset_timers() _dll.openmc_restart_timers() diff --git a/src/timer.cpp b/src/timer.cpp index 71b85e33f..454f77003 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -89,24 +89,7 @@ void reset_timers() void restart_timers() { - simulation::time_active.start(); - simulation::time_bank.start(); - simulation::time_bank_sample.start(); - simulation::time_bank_sendrecv.start(); - simulation::time_finalize.start(); - simulation::time_inactive.start(); - simulation::time_initialize.start(); - simulation::time_read_xs.start(); - simulation::time_sample_source.start(); - simulation::time_tallies.start(); simulation::time_total.start(); - simulation::time_transport.start(); - simulation::time_event_init.start(); - simulation::time_event_calculate_xs.start(); - simulation::time_event_advance_particle.start(); - simulation::time_event_surface_crossing.start(); - simulation::time_event_collision.start(); - simulation::time_event_death.start(); } } // namespace openmc From 6d55a720f7309b7d317b9eec9fa4abad4a02668a Mon Sep 17 00:00:00 2001 From: rockfool Date: Mon, 6 Apr 2020 22:51:30 -0400 Subject: [PATCH 5/6] fix docstring for reset --- openmc/lib/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/lib/core.py b/openmc/lib/core.py index e2e5e73a9..8540f832b 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -307,7 +307,7 @@ def plot_geometry(): def reset(): - """Reset tallies but keep timers.""" + """Reset tally results""" _dll.openmc_reset() From dd283875a8f8a6bd28ac376cb31ab7f662a39c73 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 7 Apr 2020 13:49:10 -0500 Subject: [PATCH 6/6] Remove restart_timers and have openmc_init/run start/stop total timer --- include/openmc/capi.h | 1 - include/openmc/timer.h | 2 -- openmc/lib/core.py | 5 +---- src/finalize.cpp | 6 ------ src/initialize.cpp | 1 + src/simulation.cpp | 10 ++++++---- src/timer.cpp | 5 ----- 7 files changed, 8 insertions(+), 22 deletions(-) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index a2bab1e2c..11c90ff3a 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -87,7 +87,6 @@ extern "C" { int openmc_property_map(const void* slice, double* data_out); int openmc_reset(); int openmc_reset_timers(); - int openmc_restart_timers(); int openmc_run(); void openmc_set_seed(int64_t new_seed); int openmc_simulation_finalize(); diff --git a/include/openmc/timer.h b/include/openmc/timer.h index 0ebbe0e8d..cc20751a8 100644 --- a/include/openmc/timer.h +++ b/include/openmc/timer.h @@ -69,8 +69,6 @@ private: void reset_timers(); -void restart_timers(); - } // namespace openmc #endif // OPENMC_TIMER_H diff --git a/openmc/lib/core.py b/openmc/lib/core.py index 8540f832b..b9deed6b1 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -65,8 +65,6 @@ _dll.openmc_reset.restype = c_int _dll.openmc_reset.errcheck = _error_handler _dll.openmc_reset_timers.restype = c_int _dll.openmc_reset_timers.errcheck = _error_handler -_dll.openmc_restart_timers.restype = c_int -_dll.openmc_restart_timers.errcheck = _error_handler _run_linsolver_argtypes = [_array_1d_dble, _array_1d_dble, _array_1d_dble, c_double] _dll.openmc_run_linsolver.argtypes = _run_linsolver_argtypes @@ -312,9 +310,8 @@ def reset(): def reset_timers(): - """Reset timers and restart for next batch.""" + """Reset timers.""" _dll.openmc_reset_timers() - _dll.openmc_restart_timers() def run(): diff --git a/src/finalize.cpp b/src/finalize.cpp index 7d80b9fdf..b5d5eb038 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -171,12 +171,6 @@ int openmc_reset_timers() return 0; } -int openmc_restart_timers() -{ - restart_timers(); - return 0; -} - int openmc_hard_reset() { // Reset all tallies and timers diff --git a/src/initialize.cpp b/src/initialize.cpp index 10d86ee80..3c2cc03ac 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -78,6 +78,7 @@ int openmc_init(int argc, char* argv[], const void* intracomm) // Stop initialization timer simulation::time_initialize.stop(); + simulation::time_total.stop(); return 0; } diff --git a/src/simulation.cpp b/src/simulation.cpp index 64a7d0e80..0a234e53f 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -47,6 +47,7 @@ int openmc_run() { + openmc::simulation::time_total.start(); openmc_simulation_init(); int err = 0; @@ -56,6 +57,7 @@ int openmc_run() } openmc_simulation_finalize(); + openmc::simulation::time_total.stop(); return err; } @@ -422,8 +424,8 @@ void finalize_generation() } global_tally_leakage = 0.0; - if (settings::run_mode == RunMode::EIGENVALUE) { - // If using shared memory, stable sort the fission bank (by parent IDs) + if (settings::run_mode == RunMode::EIGENVALUE) { + // If using shared memory, stable sort the fission bank (by parent IDs) // so as to allow for reproducibility regardless of which order particles // are run in. sort_fission_bank(); @@ -525,7 +527,7 @@ void initialize_history_partial(Particle* p) p->flux_derivs_.resize(model::tally_derivs.size(), 0.0); std::fill(p->flux_derivs_.begin(), p->flux_derivs_.end(), 0.0); } - + // Allocate space for tally filter matches p->filter_matches_.resize(model::tally_filters.size()); } @@ -669,7 +671,7 @@ void transport_event_based() process_collision_events(); } } - + // Execute death event for all particles process_death_events(n_particles); diff --git a/src/timer.cpp b/src/timer.cpp index 454f77003..fdb10f0f2 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -87,9 +87,4 @@ void reset_timers() simulation::time_event_death.reset(); } -void restart_timers() -{ - simulation::time_total.start(); -} - } // namespace openmc