From 492d984525a665f97baf02326a8b407d884883fc Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 20 Mar 2019 13:26:04 -0500 Subject: [PATCH] Change name of work -> work_per_rank --- include/openmc/simulation.h | 2 +- src/eigenvalue.cpp | 4 ++-- src/particle.cpp | 3 ++- src/simulation.cpp | 16 ++++++++-------- src/source.cpp | 4 ++-- src/state_point.cpp | 8 ++++---- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 8d43108f1..fef6ebbcd 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -37,7 +37,7 @@ extern "C" int restart_batch; //!< batch at which a restart job resumed extern "C" bool satisfy_triggers; //!< have tally triggers been satisfied? extern "C" int total_gen; //!< total number of generations simulated extern double total_weight; //!< Total source weight in a batch -extern "C" int64_t work; //!< number of particles per process +extern int64_t work_per_rank; //!< number of particles per MPI rank extern std::vector k_generation; extern std::vector work_index; diff --git a/src/eigenvalue.cpp b/src/eigenvalue.cpp index f5ed493fb..08a4d3f91 100644 --- a/src/eigenvalue.cpp +++ b/src/eigenvalue.cpp @@ -138,7 +138,7 @@ void synchronize_bank() // Allocate temporary source bank int64_t index_temp = 0; - std::vector temp_sites(3*simulation::work); + std::vector temp_sites(3*simulation::work_per_rank); for (const auto& site : simulation::fission_bank) { // If there are less than n_particles particles banked, automatically add @@ -597,7 +597,7 @@ void ufs_count_sites() // Since the total starting weight is not equal to n_particles, we need to // renormalize the weight of the source sites - for (int i = 0; i < simulation::work; ++i) { + for (int i = 0; i < simulation::work_per_rank; ++i) { simulation::source_bank[i].wgt *= settings::n_particles / total; } } diff --git a/src/particle.cpp b/src/particle.cpp index 8ca07ca82..d2b845bf4 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -594,7 +594,8 @@ Particle::mark_as_lost(const char* message) simulation::n_lost_particles += 1; // Count the total number of simulated particles (on this processor) - auto n = simulation::current_batch * settings::gen_per_batch * simulation::work; + auto n = simulation::current_batch * settings::gen_per_batch * + simulation::work_per_rank; // Abort the simulation if the maximum number of lost particles has been // reached diff --git a/src/simulation.cpp b/src/simulation.cpp index ea313e94c..fc7a78851 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -189,7 +189,7 @@ int openmc_next_batch(int* status) // LOOP OVER PARTICLES #pragma omp parallel for schedule(runtime) - for (int64_t i_work = 1; i_work <= simulation::work; ++i_work) { + for (int64_t i_work = 1; i_work <= simulation::work_per_rank; ++i_work) { simulation::current_work = i_work; // grab source particle from bank @@ -245,7 +245,7 @@ int restart_batch; bool satisfy_triggers {false}; int total_gen {0}; double total_weight; -int64_t work; +int64_t work_per_rank; std::vector k_generation; std::vector work_index; @@ -262,7 +262,7 @@ bool trace; //!< flag to show debug information void allocate_banks() { // Allocate source bank - simulation::source_bank.resize(simulation::work); + simulation::source_bank.resize(simulation::work_per_rank); if (settings::run_mode == RUN_MODE_EIGENVALUE) { #ifdef _OPENMP @@ -274,15 +274,15 @@ void allocate_banks() #pragma omp parallel { if (omp_get_thread_num() == 0) { - simulation::fission_bank.reserve(3*simulation::work); + simulation::fission_bank.reserve(3*simulation::work_per_rank); } else { int n_threads = omp_get_num_threads(); - simulation::fission_bank.reserve(3*simulation::work / n_threads); + simulation::fission_bank.reserve(3*simulation::work_per_rank / n_threads); } } - simulation::master_fission_bank.reserve(3*simulation::work); + simulation::master_fission_bank.reserve(3*simulation::work_per_rank); #else - simulation::fission_bank.reserve(3*simulation::work); + simulation::fission_bank.reserve(3*simulation::work_per_rank); #endif } } @@ -507,7 +507,7 @@ void calculate_work() int64_t work_i = i < remainder ? min_work + 1 : min_work; // Set number of particles - if (mpi::rank == i) simulation::work = work_i; + if (mpi::rank == i) simulation::work_per_rank = work_i; // Set index into source bank for rank i i_bank += work_i; diff --git a/src/source.cpp b/src/source.cpp index 36d66394c..0baa21b17 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -264,7 +264,7 @@ void initialize_source() } else { // Generation source sites from specified distribution in user input - for (int64_t i = 0; i < simulation::work; ++i) { + for (int64_t i = 0; i < simulation::work_per_rank; ++i) { // initialize random number seed int64_t id = simulation::total_gen*settings::n_particles + simulation::work_index[mpi::rank] + i + 1; @@ -330,7 +330,7 @@ void free_memory_source() void fill_source_bank_fixedsource() { if (settings::path_source.empty()) { - for (int64_t i = 0; i < simulation::work; ++i) { + for (int64_t i = 0; i < simulation::work_per_rank; ++i) { // initialize random number seed int64_t id = (simulation::total_gen + overall_generation()) * settings::n_particles + simulation::work_index[mpi::rank] + i + 1; diff --git a/src/state_point.cpp b/src/state_point.cpp index d657316f9..54f1cb38c 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -537,7 +537,7 @@ write_source_bank(hid_t group_id) H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); // Create another data space but for each proc individually - hsize_t count[] {static_cast(simulation::work)}; + hsize_t count[] {static_cast(simulation::work_per_rank)}; hid_t memspace = H5Screate_simple(1, count, nullptr); // Select hyperslab for this dataspace @@ -569,7 +569,7 @@ write_source_bank(hid_t group_id) // Save source bank sites since the souce_bank array is overwritten below #ifdef OPENMC_MPI std::vector temp_source {simulation::source_bank.begin(), - simulation::source_bank.begin() + simulation::work}; + simulation::source_bank.begin() + simulation::work_per_rank}; #endif for (int i = 0; i < mpi::n_procs; ++i) { @@ -607,7 +607,7 @@ write_source_bank(hid_t group_id) #endif } else { #ifdef OPENMC_MPI - MPI_Send(simulation::source_bank.data(), simulation::work, mpi::bank, + MPI_Send(simulation::source_bank.data(), simulation::work_per_rank, mpi::bank, 0, mpi::rank, mpi::intracomm); #endif } @@ -625,7 +625,7 @@ void read_source_bank(hid_t group_id) hid_t dset = H5Dopen(group_id, "source_bank", H5P_DEFAULT); // Create another data space but for each proc individually - hsize_t dims[] {static_cast(simulation::work)}; + hsize_t dims[] {static_cast(simulation::work_per_rank)}; hid_t memspace = H5Screate_simple(1, dims, nullptr); // Make sure source bank is big enough