From 1c48584c4623d20003af4d8262c2cc2ed12f98b2 Mon Sep 17 00:00:00 2001 From: John Tramm Date: Fri, 17 Jan 2020 15:50:19 +0000 Subject: [PATCH] Added progeny_id field of Particle::Bank type to MPI Bank type to fix bug. Also some minor comment/assert cleanups from debugging. --- src/bank.cpp | 1 + src/initialize.cpp | 11 ++++++----- src/particle.cpp | 2 -- src/simulation.cpp | 2 -- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/bank.cpp b/src/bank.cpp index c4f1511b9..8d0ffe49d 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -43,6 +43,7 @@ void free_memory_bank() simulation::source_bank.clear(); simulation::fission_bank.reset(); simulation::fission_bank_length = 0; + simulation::progeny_per_particle.clear(); } void init_fission_bank(int64_t max) diff --git a/src/initialize.cpp b/src/initialize.cpp index 652c19f1d..df10c1d04 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -101,7 +101,7 @@ void initialize_mpi(MPI_Comm intracomm) // Create bank datatype Particle::Bank b; - MPI_Aint disp[7]; + MPI_Aint disp[8]; MPI_Get_address(&b.r, &disp[0]); MPI_Get_address(&b.u, &disp[1]); MPI_Get_address(&b.E, &disp[2]); @@ -109,11 +109,12 @@ void initialize_mpi(MPI_Comm intracomm) MPI_Get_address(&b.delayed_group, &disp[4]); MPI_Get_address(&b.particle, &disp[5]); MPI_Get_address(&b.parent_id, &disp[6]); - for (int i = 6; i >= 0; --i) disp[i] -= disp[0]; + MPI_Get_address(&b.progeny_id, &disp[7]); + for (int i = 7; i >= 0; --i) disp[i] -= disp[0]; - int blocks[] {3, 3, 1, 1, 1, 1, 1}; - MPI_Datatype types[] {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_INT, MPI_INT, MPI_LONG}; - MPI_Type_create_struct(7, blocks, disp, types, &mpi::bank); + int blocks[] {3, 3, 1, 1, 1, 1, 1, 1}; + MPI_Datatype types[] {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_INT, MPI_INT, MPI_LONG, MPI_LONG}; + MPI_Type_create_struct(8, blocks, disp, types, &mpi::bank); MPI_Type_commit(&mpi::bank); } #endif // OPENMC_MPI diff --git a/src/particle.cpp b/src/particle.cpp index 89eeb4372..d30c9b452 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -395,8 +395,6 @@ Particle::event_death() // Record the number of progeny created by this particle. // This data will be used to efficiently sort the fission bank. 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_; } diff --git a/src/simulation.cpp b/src/simulation.cpp index 40819d1b0..d613fdda7 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -397,9 +397,7 @@ 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 sort_fission_bank(); - //#endif // Distribute fission bank across processors evenly synchronize_bank();