mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 14:35:27 -04:00
Parallelize sampling external sources and threadsafe rejection counters (#3830)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
0ab46dfa35
commit
2bd06660c5
6 changed files with 114 additions and 37 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#ifndef OPENMC_SOURCE_H
|
||||
#define OPENMC_SOURCE_H
|
||||
|
||||
#include <atomic>
|
||||
#include <limits>
|
||||
#include <unordered_set>
|
||||
|
||||
|
|
@ -25,10 +26,18 @@ namespace openmc {
|
|||
// source_rejection_fraction
|
||||
constexpr int EXTSRC_REJECT_THRESHOLD {10000};
|
||||
|
||||
// Maximum number of source rejections allowed while sampling a single site
|
||||
constexpr int64_t MAX_SOURCE_REJECTIONS_PER_SAMPLE {1'000'000};
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
//==============================================================================
|
||||
|
||||
// Cumulative counters for source rejection diagnostics. These are atomic to
|
||||
// allow thread-safe concurrent sampling of external sources.
|
||||
extern std::atomic<int64_t> source_n_accept;
|
||||
extern std::atomic<int64_t> source_n_reject;
|
||||
|
||||
class Source;
|
||||
|
||||
namespace model {
|
||||
|
|
@ -265,6 +274,9 @@ SourceSite sample_external_source(uint64_t* seed);
|
|||
|
||||
void free_memory_source();
|
||||
|
||||
//! Reset cumulative source rejection counters
|
||||
void reset_source_rejection_counters();
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_SOURCE_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue