fixed indexing error, though things are still going haywire with MPI. Going to test if this is due to sort or unique_ptr.

This commit is contained in:
John Tramm 2020-01-17 15:03:34 +00:00
parent 714d0b266e
commit 732a780366
3 changed files with 12 additions and 9 deletions

View file

@ -2,6 +2,7 @@
#include "openmc/capi.h"
#include "openmc/error.h"
#include "openmc/simulation.h"
#include "openmc/message_passing.h"
#include <cstdint>
@ -74,7 +75,7 @@ void sort_fission_bank()
tmp = simulation::progeny_per_particle[i];
simulation::progeny_per_particle[i] = value;
}
// TODO: C++17 introduces the exclusive_scan() function which could be
// used to replace everything above this point in this function.
@ -83,8 +84,9 @@ void sort_fission_bank()
// Use parent and progeny indices to sort fission bank
for (int64_t i = 0; i < simulation::fission_bank_length; i++) {
Particle::Bank& site = simulation::fission_bank[i];
int64_t idx = simulation::progeny_per_particle[site.parent_id-1] + site.progeny_id;
const auto& site = simulation::fission_bank[i];
int64_t offset = site.parent_id - 1 - simulation::work_index[mpi::rank];
int64_t idx = simulation::progeny_per_particle[offset] + site.progeny_id;
sorted_bank[idx] = site;
}

View file

@ -168,7 +168,7 @@ Particle::event_calculate_xs()
if (write_track_) write_particle_track(*this);
if (settings::check_overlaps) check_cell_overlap(this);
// Calculate microscopic and macroscopic cross sections
if (material_ != MATERIAL_VOID) {
if (settings::run_CE) {
@ -394,7 +394,10 @@ Particle::event_death()
// Record the number of progeny created by this particle.
// This data will be used to efficiently sort the fission bank.
simulation::progeny_per_particle[id_-1] = n_progeny_;
int64_t offset = id_ - 1 - simulation::work_index[mpi::rank];
assert(offset >= 0);
assert(offset < simulation::work_per_rank);
simulation::progeny_per_particle[offset] = n_progeny_;
}

View file

@ -397,11 +397,9 @@ void finalize_generation()
// 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.
#ifdef _OPENMP
//std::stable_sort(simulation::fission_bank,
// simulation::fission_bank + simulation::fission_bank_length);
//#ifdef _OPENMP
sort_fission_bank();
#endif
//#endif
// Distribute fission bank across processors evenly
synchronize_bank();