Skip to content

Commit

Permalink
Streamlined URR PRNG stream selection to avoid unneeded store/load ops (
Browse files Browse the repository at this point in the history
  • Loading branch information
jtramm authored Sep 11, 2023
1 parent 7505f61 commit f46d3ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/nuclide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,8 @@ void Nuclide::calculate_urr_xs(int i_temp, Particle& p) const
// This guarantees the randomness and, at the same time, makes sure we
// reuse random numbers for the same nuclide at different temperatures,
// therefore preserving correlation of temperature in probability tables.
p.stream() = STREAM_URR_PTABLE;
double r = future_prn(static_cast<int64_t>(index_), *p.current_seed());
p.stream() = STREAM_TRACKING;
double r =
future_prn(static_cast<int64_t>(index_), p.seeds(STREAM_URR_PTABLE));

// Warning: this assumes row-major order of cdf_values_
int i_low = upper_bound_index(&urr.cdf_values_(i_energy, 0),
Expand Down
4 changes: 1 addition & 3 deletions src/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ void sample_neutron_reaction(Particle& p)

// Advance URR seed stream 'N' times after energy changes
if (p.E() != p.E_last()) {
p.stream() = STREAM_URR_PTABLE;
advance_prn_seed(data::nuclides.size(), p.current_seed());
p.stream() = STREAM_TRACKING;
advance_prn_seed(data::nuclides.size(), &p.seeds(STREAM_URR_PTABLE));
}

// Play russian roulette if survival biasing is turned on
Expand Down

0 comments on commit f46d3ee

Please sign in to comment.