mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Moved current_work variable to particle object, and removed threadprivate tag from tally_derivs
This commit is contained in:
parent
70c9b7dd51
commit
1bb03f004a
9 changed files with 11 additions and 34 deletions
|
|
@ -22,13 +22,6 @@ namespace simulation {
|
|||
|
||||
extern std::vector<Particle::Bank> source_bank;
|
||||
extern std::vector<Particle::Bank> fission_bank;
|
||||
//extern std::vector<Particle::Bank> secondary_bank;
|
||||
#ifdef _OPENMP
|
||||
extern std::vector<Particle::Bank> master_fission_bank;
|
||||
#endif
|
||||
|
||||
//#pragma omp threadprivate(fission_bank, secondary_bank)
|
||||
#pragma omp threadprivate(fission_bank)
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
|
|||
|
|
@ -311,6 +311,8 @@ public:
|
|||
|
||||
// Secondary bank
|
||||
std::vector<Particle::Bank> secondary_bank_;
|
||||
|
||||
int64_t current_work_; // current work index
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -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<int64_t> 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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<openmc::TallyDerivative>;
|
||||
//extern template class std::vector<openmc::TallyDerivative>;
|
||||
|
||||
namespace openmc {
|
||||
|
||||
namespace model {
|
||||
extern std::vector<TallyDerivative> tally_derivs;
|
||||
#pragma omp threadprivate(tally_derivs)
|
||||
//#pragma omp threadprivate(tally_derivs)
|
||||
extern std::unordered_map<int, int> tally_deriv_map;
|
||||
} // namespace model
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -672,7 +672,7 @@ Particle::write_restart() const
|
|||
write_dataset(file_id, "id", id_);
|
||||
write_dataset(file_id, "type", static_cast<int>(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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1042,7 +1042,7 @@ setup_active_tallies()
|
|||
void
|
||||
free_memory_tally()
|
||||
{
|
||||
#pragma omp parallel
|
||||
//#pragma omp parallel
|
||||
{
|
||||
model::tally_derivs.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue