Skip to content

Commit

Permalink
Merge pull request #24 from exasmr/sort_toggle
Browse files Browse the repository at this point in the history
CLI options to disable event-based queue sorting
  • Loading branch information
paulromano authored Apr 13, 2023
2 parents 0be43fa + 750a263 commit 6b9f3e9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/openmc/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ extern "C" int64_t n_particles; //!< number of particles per genera

extern int64_t max_particles_in_flight; //!< Max num. event-based particles in flight

extern bool sort_fissionable_xs_lookups; //!< Sort fissionable material XS lookups in event-based mode?
extern bool sort_non_fissionable_xs_lookups; //!< Sort non-fissionable material XS lookups in event-based mode?

#pragma omp declare target
extern ElectronTreatment electron_treatment; //!< how to treat secondary electrons
extern std::array<double, 4> energy_cutoff; //!< Energy cutoff in [eV] for each particle type
Expand Down
8 changes: 6 additions & 2 deletions src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ bool depletion_rx_check()
void process_calculate_xs_events_nonfuel()
{
// Sort non fuel lookup queue by material and energy
sort_queue(simulation::calculate_nonfuel_xs_queue);
if (settings::sort_non_fissionable_xs_lookups) {
sort_queue(simulation::calculate_nonfuel_xs_queue);
}

simulation::time_event_calculate_xs.start();
simulation::time_event_calculate_xs_nonfuel.start();
Expand Down Expand Up @@ -208,7 +210,9 @@ void process_calculate_xs_events_nonfuel()
void process_calculate_xs_events_fuel()
{
// Sort fuel lookup queue by energy
sort_queue(simulation::calculate_fuel_xs_queue);
if (settings::sort_fissionable_xs_lookups) {
sort_queue(simulation::calculate_fuel_xs_queue);
}

// The below line can be used to check if the queue has actually been sorted.
// May be useful for debugging future on-device sorting strategies.
Expand Down
6 changes: 6 additions & 0 deletions src/initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ parse_command_line(int argc, char* argv[])
} else if (arg == "-e" || arg == "--event") {
settings::event_based = true;

} else if (arg == "--no-sort-fissionable-xs") {
settings::sort_fissionable_xs_lookups = false;

} else if (arg == "--no-sort-non-fissionable-xs") {
settings::sort_non_fissionable_xs_lookups = false;

} else if (arg == "-m" || arg == "--minimum") {
i += 1;
settings::minimum_sort_items = std::stoll(argv[i]);
Expand Down
2 changes: 2 additions & 0 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ void print_usage()
" -e, --event Run using event-based parallelism\n"
" -m, --minimum Minimum energy sorting threshold\n"
" -i, --inflight Maximum number of in-flight particles\n"
" --no-sort-fissionable-xs Do not sort event-based fissionable material xs lookups\n"
" --no-sort-non-fissionable-xs Do not sort event-based non-fissionable material xs lookups\n"
" -v, --version Show version information\n"
" -h, --help Show this message\n");
}
Expand Down
3 changes: 3 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ int64_t n_particles {-1};

int64_t max_particles_in_flight {-1};

bool sort_fissionable_xs_lookups {true};
bool sort_non_fissionable_xs_lookups {true};

ElectronTreatment electron_treatment {ElectronTreatment::TTB};
std::array<double, 4> energy_cutoff {0.0, 1000.0, 0.0, 0.0};
int legendre_to_tabular_points {C_NONE};
Expand Down

0 comments on commit 6b9f3e9

Please sign in to comment.