Incorporation of comments from code review.

This commit is contained in:
John Tramm 2020-01-27 17:02:39 +00:00
parent 48a550aaf7
commit 02470bc630
8 changed files with 43 additions and 41 deletions

View file

@ -142,7 +142,7 @@ materials in the problem and is specified using a :ref:`mesh_element`.
----------------------------
Determines whether to use event-based parallelism instead of the default
history based parallelism.
history-based parallelism.
*Default*: false
@ -227,9 +227,9 @@ to false.
*Default*: true
-----------------------
``<max_in_flight_particles>`` Element
-----------------------
----------------------------------------
``<max_particles_in_flight>`` Element
----------------------------------------
This element indicates the number of neutrons to run in flight concurrently
when using event-based parallelism. A higher value uses more memory, but

View file

@ -31,6 +31,7 @@ extern "C" bool cmfd_run; //!< is a CMFD run?
extern "C" bool dagmc; //!< indicator of DAGMC geometry
extern bool delayed_photon_scaling; //!< Scale fission photon yield to include delayed
extern "C" bool entropy_on; //!< calculate Shannon entropy?
extern bool event_based; //!< use event-based mode (instead of history-based)
extern bool legendre_to_tabular; //!< convert Legendre distributions to tabular?
extern bool material_cell_offsets; //!< create material cells offsets?
extern "C" bool output_summary; //!< write summary.h5?
@ -52,7 +53,6 @@ extern bool ufs_on; //!< uniform fission site method on?
extern bool urr_ptables_on; //!< use unresolved resonance prob. tables?
extern bool write_all_tracks; //!< write track files for every particle?
extern bool write_initial_source; //!< write out initial source file?
extern bool event_based; //!< use event-based mode (instead of history-based)
// Paths to various files
extern std::string path_cross_sections; //!< path to cross_sections.xml
@ -69,7 +69,7 @@ extern "C" int32_t gen_per_batch; //!< number of generations per batch
extern "C" int64_t n_particles; //!< number of particles per generation
extern "C" int64_t max_in_flight_particles; //!< Max num. event-based particles in flight
extern int64_t max_particles_in_flight; //!< Max num. event-based particles in flight
extern ElectronTreatment electron_treatment; //!< how to treat secondary electrons
extern std::array<double, 4> energy_cutoff; //!< Energy cutoff in [eV] for each particle type

View file

@ -4,7 +4,7 @@
//! \file shared_array.h
//! \brief Shared array data structure
#include<memory>
#include <memory>
namespace openmc {
@ -24,14 +24,6 @@ namespace openmc {
template <typename T>
class SharedArray {
private:
//==========================================================================
// Data members
std::unique_ptr<T[]> data_; //!< A pointer to hold the data
int64_t size_ {0}; //!< The current size of the SharedArray.
int64_t capacity_ {0}; //!< The maximum capacity of the SharedArray.
public:
//==========================================================================
// Constructors
@ -55,6 +47,7 @@ public:
//! Return a reference to the element at specified location i. No bounds
//! checking is performed.
T& operator[](int64_t i) {return data_[i];}
const T& operator[](int64_t i) const { return data_[i]; }
//! Allocate space in the container for the specified number of elements.
//! reserve() does not change the size of the container.
@ -116,6 +109,15 @@ public:
//! Return pointer to the underlying array serving as element storage.
T* data() {return data_.get();}
const T* data() const {return data_.get();}
private:
//==========================================================================
// Data members
std::unique_ptr<T[]> data_; //!< A pointer to hold the data
int64_t size_ {0}; //!< The current size of the SharedArray.
int64_t capacity_ {0}; //!< The maximum capacity of the SharedArray.
};

View file

@ -71,7 +71,7 @@ class Settings(object):
material_cell_offsets : bool
Generate an "offset table" for material cells by default. These tables
are necessary when a particular instance of a cell needs to be tallied.
max_in_flight_particles : int
max_particles_in_flight : int
Number of neutrons to run concurrently when using event-based
parallelism.
max_order : None or int
@ -236,7 +236,7 @@ class Settings(object):
self._dagmc = False
self._event_based = None
self._max_in_flight_particles = None
self._max_particles_in_flight = None
@property
def run_mode(self):
@ -391,8 +391,8 @@ class Settings(object):
return self._event_based
@property
def max_in_flight_particles(self):
return self._max_in_flight_particles
def max_particles_in_flight(self):
return self._max_particles_in_flight
@run_mode.setter
def run_mode(self, run_mode):
@ -727,11 +727,11 @@ class Settings(object):
cv.check_type('event based', value, bool)
self._event_based = value
@max_in_flight_particles.setter
def max_in_flight_particles(self, value):
cv.check_type('max in flight particles', value, Integral)
cv.check_greater_than('max in flight particles', value, 0)
self._max_in_flight_particles = value
@max_particles_in_flight.setter
def max_particles_in_flight(self, value):
cv.check_type('max particles in flight', value, Integral)
cv.check_greater_than('max particles in flight', value, 0)
self._max_particles_in_flight = value
@material_cell_offsets.setter
def material_cell_offsets(self, value):
@ -982,10 +982,10 @@ class Settings(object):
elem = ET.SubElement(root, "event_based")
elem.text = str(self._event_based).lower()
def _create_max_in_flight_particles_subelement(self, root):
if self._max_in_flight_particles is not None:
elem = ET.SubElement(root, "max_in_flight_particles")
elem.text = str(self._max_in_flight_particles).lower()
def _create_max_particles_in_flight_subelement(self, root):
if self._max_particles_in_flight is not None:
elem = ET.SubElement(root, "max_particles_in_flight")
elem.text = str(self._max_particles_in_flight).lower()
def _create_material_cell_offsets_subelement(self, root):
if self._material_cell_offsets is not None:
@ -1233,10 +1233,10 @@ class Settings(object):
if text is not None:
self.event_based = text in ('true', '1')
def _max_in_flight_particles_from_xml_element(self, root):
text = get_text(root, 'max_in_flight_particles')
def _max_particles_in_flight_from_xml_element(self, root):
text = get_text(root, 'max_particles_in_flight')
if text is not None:
self.max_in_flight_particles = int(text)
self.max_particles_in_flight = int(text)
def _material_cell_offsets_from_xml_element(self, root):
text = get_text(root, 'material_cell_offsets')
@ -1299,7 +1299,7 @@ class Settings(object):
self._create_create_fission_neutrons_subelement(root_element)
self._create_delayed_photon_scaling_subelement(root_element)
self._create_event_based_subelement(root_element)
self._create_max_in_flight_particles_subelement(root_element)
self._create_max_particles_in_flight_subelement(root_element)
self._create_material_cell_offsets_subelement(root_element)
self._create_log_grid_bins_subelement(root_element)
self._create_dagmc_subelement(root_element)
@ -1368,7 +1368,7 @@ class Settings(object):
settings._create_fission_neutrons_from_xml_element(root)
settings._delayed_photon_scaling_from_xml_element(root)
settings._event_based_from_xml_element(root)
settings._max_in_flight_particles_from_xml_element(root)
settings._max_particles_in_flight_from_xml_element(root)
settings._material_cell_offsets_from_xml_element(root)
settings._log_grid_bins_from_xml_element(root)
settings._dagmc_from_xml_element(root)

View file

@ -39,7 +39,7 @@ element settings {
element material_cell_offsets { xsd:boolean }? &
element max_in_flight_particles { xsd:positiveInteger }? &
element max_particles_in_flight { xsd:positiveInteger }? &
element max_order { xsd:nonNegativeInteger }? &

View file

@ -93,7 +93,7 @@
</element>
</optional>
<optional>
<element name="max_in_flight_particles">
<element name="max_particles_in_flight">
<data type="positiveInteger"/>
</element>
</optional>

View file

@ -82,7 +82,7 @@ int32_t n_inactive {0};
int32_t gen_per_batch {1};
int64_t n_particles {-1};
int64_t max_in_flight_particles {100000};
int64_t max_particles_in_flight {100000};
ElectronTreatment electron_treatment {ElectronTreatment::TTB};
std::array<double, 4> energy_cutoff {0.0, 1000.0, 0.0, 0.0};
@ -132,9 +132,9 @@ void get_run_parameters(pugi::xml_node node_base)
}
// Get maximum number of in flight particles for event-based mode
if (check_for_node(node_base, "max_in_flight_particles")) {
max_in_flight_particles = std::stoll(get_node_value(node_base,
"max_in_flight_particles"));
if (check_for_node(node_base, "max_particles_in_flight")) {
max_particles_in_flight = std::stoll(get_node_value(node_base,
"max_particles_in_flight"));
}
// Get number of basic batches

View file

@ -77,7 +77,7 @@ int openmc_simulation_init()
// and event queues
if (settings::event_based) {
int64_t event_buffer_length = std::min(simulation::work_per_rank,
settings::max_in_flight_particles);
settings::max_particles_in_flight);
init_event_queues(event_buffer_length);
}
@ -617,7 +617,7 @@ void transport_event_based()
// loop is executed multiple times until all particles have been completed.
while (remaining_work > 0) {
// Figure out # of particles to run for this subiteration
int64_t n_particles = std::min(remaining_work, settings::max_in_flight_particles);
int64_t n_particles = std::min(remaining_work, settings::max_particles_in_flight);
// Initialize all particle histories for this subiteration
process_init_events(n_particles, source_offset);