diff --git a/include/openmc/bank.h b/include/openmc/bank.h index b62982809..c3a49dbad 100644 --- a/include/openmc/bank.h +++ b/include/openmc/bank.h @@ -22,13 +22,6 @@ namespace simulation { extern std::vector source_bank; extern std::vector fission_bank; -//extern std::vector secondary_bank; -#ifdef _OPENMP -extern std::vector master_fission_bank; -#endif - -//#pragma omp threadprivate(fission_bank, secondary_bank) -#pragma omp threadprivate(fission_bank) } // namespace simulation diff --git a/include/openmc/particle.h b/include/openmc/particle.h index 3c6b8413d..f818299cd 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -311,6 +311,8 @@ public: // Secondary bank std::vector secondary_bank_; + + int64_t current_work_; // current work index }; } // namespace openmc diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index 4ee02a0f0..c06e854dc 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -28,7 +28,6 @@ namespace simulation { extern "C" int current_batch; //!< current batch extern "C" int current_gen; //!< current fission generation -extern "C" int64_t current_work; //!< index in source back of current particle extern "C" bool initialized; //!< has simulation been initialized? extern "C" double keff; //!< average k over batches extern "C" double keff_std; //!< standard deviation of average k @@ -53,7 +52,7 @@ extern std::vector work_index; // Threadprivate variables extern "C" bool trace; //!< flag to show debug information -#pragma omp threadprivate(current_work, trace) +#pragma omp threadprivate(trace) } // namespace simulation diff --git a/include/openmc/tallies/derivative.h b/include/openmc/tallies/derivative.h index 673afb0c9..d937116b1 100644 --- a/include/openmc/tallies/derivative.h +++ b/include/openmc/tallies/derivative.h @@ -65,13 +65,13 @@ void zero_flux_derivs(); // Explicit vector template specialization declaration of threadprivate variable // outside of the openmc namespace for the picky Intel compiler. -extern template class std::vector; +//extern template class std::vector; namespace openmc { namespace model { extern std::vector tally_derivs; -#pragma omp threadprivate(tally_derivs) +//#pragma omp threadprivate(tally_derivs) extern std::unordered_map tally_deriv_map; } // namespace model diff --git a/src/eigenvalue.cpp b/src/eigenvalue.cpp index 110f0100e..32fd56fff 100644 --- a/src/eigenvalue.cpp +++ b/src/eigenvalue.cpp @@ -351,6 +351,7 @@ void calculate_average_keff() } } +/* #ifdef _OPENMP void join_bank_from_threads() { @@ -384,6 +385,7 @@ void join_bank_from_threads() } } #endif +*/ int openmc_get_keff(double* k_combined) { diff --git a/src/particle.cpp b/src/particle.cpp index e7079aba8..d6867da5c 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -672,7 +672,7 @@ Particle::write_restart() const write_dataset(file_id, "id", id_); write_dataset(file_id, "type", static_cast(type_)); - int64_t i = simulation::current_work; + int64_t i = current_work_; write_dataset(file_id, "weight", simulation::source_bank[i-1].wgt); write_dataset(file_id, "energy", simulation::source_bank[i-1].E); write_dataset(file_id, "xyz", simulation::source_bank[i-1].r); diff --git a/src/simulation.cpp b/src/simulation.cpp index 1ba8844b8..dfb664ef9 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -950,8 +950,6 @@ int openmc_next_batch(int* status) // Start timer for transport simulation::time_transport.start(); - simulation::current_work = 1; - transport(); // Accumulate time for transport @@ -1032,25 +1030,7 @@ void allocate_banks() simulation::source_bank.resize(simulation::work_per_rank); if (settings::run_mode == RUN_MODE_EIGENVALUE) { -#ifdef _OPENMP - // If OpenMP is being used, each thread needs its own private fission - // bank. Since the private fission banks need to be combined at the end of - // a generation, there is also a 'master_fission_bank' that is used to - // collect the sites from each thread. - - #pragma omp parallel - { - if (omp_get_thread_num() == 0) { - simulation::fission_bank.reserve(3*simulation::work_per_rank); - } else { - int n_threads = omp_get_num_threads(); - simulation::fission_bank.reserve(3*simulation::work_per_rank / n_threads); - } - } - simulation::master_fission_bank.reserve(3*simulation::work_per_rank); -#else simulation::fission_bank.reserve(3*simulation::work_per_rank); -#endif } } @@ -1269,6 +1249,7 @@ void initialize_history(Particle* p, int64_t index_source) { // set defaults p->from_source(&simulation::source_bank[index_source - 1]); + p->current_work_ = index_source; // set identifier for particle p->id_ = simulation::work_index[mpi::rank] + index_source; diff --git a/src/tallies/derivative.cpp b/src/tallies/derivative.cpp index f6f10cf7a..c2e70ab0d 100644 --- a/src/tallies/derivative.cpp +++ b/src/tallies/derivative.cpp @@ -83,7 +83,7 @@ read_tally_derivatives(pugi::xml_node node) { // Populate the derivatives array. This must be done in parallel because // the derivatives are threadprivate. - #pragma omp parallel + //#pragma omp parallel { for (auto deriv_node : node.children("derivative")) model::tally_derivs.emplace_back(deriv_node); diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 059803e76..9b438ab34 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -1042,7 +1042,7 @@ setup_active_tallies() void free_memory_tally() { - #pragma omp parallel + //#pragma omp parallel { model::tally_derivs.clear(); }