mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
added timers
This commit is contained in:
parent
b3821256cb
commit
3641a6632f
6 changed files with 59 additions and 8 deletions
|
|
@ -73,6 +73,7 @@ extern int64_t max_particles_in_flight;
|
|||
void init_event_queues(int64_t n_particles);
|
||||
void free_event_queues(void);
|
||||
void dispatch_xs_event(int64_t i);
|
||||
void process_init_events(int64_t n_particles, int64_t source_offset);
|
||||
void process_calculate_xs_events(QueueItem* queue, int64_t n);
|
||||
void process_advance_particle_events();
|
||||
void process_surface_crossing_events();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ extern Timer time_sample_source;
|
|||
extern Timer time_tallies;
|
||||
extern Timer time_total;
|
||||
extern Timer time_transport;
|
||||
extern Timer time_event_init;
|
||||
extern Timer time_event_calculate_xs;
|
||||
extern Timer time_event_advance_particle;
|
||||
extern Timer time_event_surface_crossing;
|
||||
extern Timer time_event_collision;
|
||||
extern Timer time_event_death;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "openmc/event.h"
|
||||
#include "openmc/material.h"
|
||||
#include "openmc/simulation.h"
|
||||
#include "openmc/timer.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -80,10 +82,23 @@ void dispatch_xs_event(int64_t i)
|
|||
}
|
||||
}
|
||||
|
||||
void process_init_events(int64_t n_particles, int64_t source_offset)
|
||||
{
|
||||
simulation::time_event_init.start();
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
for (int64_t i = 0; i < n_particles; i++) {
|
||||
initialize_history(&simulation::particles[i], source_offset + i + 1);
|
||||
dispatch_xs_event(i);
|
||||
}
|
||||
simulation::time_event_init.stop();
|
||||
}
|
||||
|
||||
void process_calculate_xs_events(QueueItem* queue, int64_t n)
|
||||
{
|
||||
// Sort queue by energy
|
||||
std::sort(queue, queue+n);
|
||||
simulation::time_event_calculate_xs.start();
|
||||
|
||||
// TODO: Sort queue by particle type, material type, and energy
|
||||
//std::sort(queue, queue+n);
|
||||
|
||||
// Save last_ members, find grid index
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
|
|
@ -93,10 +108,14 @@ void process_calculate_xs_events(QueueItem* queue, int64_t n)
|
|||
enqueue_particle(simulation::advance_particle_queue.get(),
|
||||
simulation::advance_particle_queue_length, p, queue[i].idx, true);
|
||||
}
|
||||
|
||||
simulation::time_event_calculate_xs.stop();
|
||||
}
|
||||
|
||||
void process_advance_particle_events()
|
||||
{
|
||||
simulation::time_event_advance_particle.start();
|
||||
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
for (int64_t i = 0; i < simulation::advance_particle_queue_length; i++) {
|
||||
int64_t buffer_idx = simulation::advance_particle_queue[i].idx;
|
||||
|
|
@ -110,10 +129,14 @@ void process_advance_particle_events()
|
|||
simulation::collision_queue_length, p, buffer_idx, true);
|
||||
}
|
||||
}
|
||||
|
||||
simulation::time_event_advance_particle.stop();
|
||||
}
|
||||
|
||||
void process_surface_crossing_events()
|
||||
{
|
||||
simulation::time_event_surface_crossing.start();
|
||||
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
for (int64_t i = 0; i < simulation::surface_crossing_queue_length; i++) {
|
||||
int64_t buffer_index = simulation::surface_crossing_queue[i].idx;
|
||||
|
|
@ -123,11 +146,14 @@ void process_surface_crossing_events()
|
|||
if (p->alive_)
|
||||
dispatch_xs_event(buffer_index);
|
||||
}
|
||||
|
||||
|
||||
simulation::time_event_surface_crossing.stop();
|
||||
}
|
||||
|
||||
void process_collision_events()
|
||||
{
|
||||
simulation::time_event_collision.start();
|
||||
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
for (int64_t i = 0; i < simulation::collision_queue_length; i++) {
|
||||
int64_t buffer_index = simulation::collision_queue[i].idx;
|
||||
|
|
@ -138,15 +164,18 @@ void process_collision_events()
|
|||
dispatch_xs_event(buffer_index);
|
||||
}
|
||||
|
||||
simulation::time_event_collision.stop();
|
||||
}
|
||||
|
||||
void process_death_events(int64_t n_particles)
|
||||
{
|
||||
simulation::time_event_death.start();
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
for (int64_t i = 0; i < n_particles; i++) {
|
||||
Particle* p = &simulation::particles[i];
|
||||
p->event_death();
|
||||
}
|
||||
simulation::time_event_death.stop();
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -466,6 +466,12 @@ void print_runtime()
|
|||
show_time("Total time in simulation", time_inactive.elapsed() +
|
||||
time_active.elapsed());
|
||||
show_time("Time in transport only", time_transport.elapsed(), 1);
|
||||
show_time("Event time: Init", time_event_init.elapsed(), 2);
|
||||
show_time("Event time: XS Lookup", time_event_calculate_xs.elapsed(), 2);
|
||||
show_time("Event time: Advance", time_event_advance_particle.elapsed(), 2);
|
||||
show_time("Event time: Surface", time_event_surface_crossing.elapsed(), 2);
|
||||
show_time("Event time: Collision", time_event_collision.elapsed(), 2);
|
||||
show_time("Event time: Death", time_event_death.elapsed(), 2);
|
||||
if (settings::run_mode == RUN_MODE_EIGENVALUE) {
|
||||
show_time("Time in inactive batches", time_inactive.elapsed(), 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -621,11 +621,7 @@ void transport_event_based()
|
|||
int64_t n_particles = std::min(remaining_work, simulation::max_particles_in_flight);
|
||||
|
||||
// Initialize all particle histories for this subiteration
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
for (auto i = 0; i < n_particles; i++) {
|
||||
initialize_history(&simulation::particles[i], source_offset + i + 1);
|
||||
dispatch_xs_event(i);
|
||||
}
|
||||
process_init_events(n_particles, source_offset);
|
||||
|
||||
int events_retired = 0;
|
||||
|
||||
|
|
@ -663,6 +659,7 @@ void transport_event_based()
|
|||
events_retired++;
|
||||
}
|
||||
|
||||
// Execute death events for all particles
|
||||
process_death_events(n_particles);
|
||||
|
||||
remaining_work -= n_particles;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@ Timer time_sample_source;
|
|||
Timer time_tallies;
|
||||
Timer time_total;
|
||||
Timer time_transport;
|
||||
Timer time_event_init;
|
||||
Timer time_event_calculate_xs;
|
||||
Timer time_event_advance_particle;
|
||||
Timer time_event_surface_crossing;
|
||||
Timer time_event_collision;
|
||||
Timer time_event_death;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
@ -73,6 +79,12 @@ void reset_timers()
|
|||
simulation::time_tallies.reset();
|
||||
simulation::time_total.reset();
|
||||
simulation::time_transport.reset();
|
||||
simulation::time_event_init.reset();
|
||||
simulation::time_event_calculate_xs.reset();
|
||||
simulation::time_event_advance_particle.reset();
|
||||
simulation::time_event_surface_crossing.reset();
|
||||
simulation::time_event_collision.reset();
|
||||
simulation::time_event_death.reset();
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue