diff --git a/app/celer-sim/Runner.cc b/app/celer-sim/Runner.cc index 58634299c5..94238649e5 100644 --- a/app/celer-sim/Runner.cc +++ b/app/celer-sim/Runner.cc @@ -464,6 +464,7 @@ void Runner::build_transporter_input(RunnerInput const& inp) transporter_input_->store_step_times = inp.write_step_times; transporter_input_->action_times = inp.action_times; transporter_input_->params = core_params_; + transporter_input_->log_progress = inp.log_progress; } //---------------------------------------------------------------------------// diff --git a/app/celer-sim/RunnerInput.hh b/app/celer-sim/RunnerInput.hh index b110a80b61..b25c2631c9 100644 --- a/app/celer-sim/RunnerInput.hh +++ b/app/celer-sim/RunnerInput.hh @@ -98,6 +98,8 @@ struct RunnerInput std::string slot_diagnostic_prefix; //!< Base name for slot diagnostic bool write_track_counts{true}; //!< Output track counts for each step bool write_step_times{true}; //!< Output elapsed times for each step + bool transporter_result{true}; //!< Output transporter result event data + size_type log_progress{1}; //!< CELER_LOG progress every N events // Control unsigned int seed{}; @@ -140,7 +142,7 @@ struct RunnerInput && num_track_slots > 0 && max_steps > 0 && initializer_capacity > 0 && secondary_stack_factor > 0 && (step_diagnostic_bins > 0 || !step_diagnostic) - && (field == no_field() || field_options); + && log_progress > 0 && (field == no_field() || field_options); } }; diff --git a/app/celer-sim/RunnerInputIO.json.cc b/app/celer-sim/RunnerInputIO.json.cc index 0723a26aec..53c1d9a7bb 100644 --- a/app/celer-sim/RunnerInputIO.json.cc +++ b/app/celer-sim/RunnerInputIO.json.cc @@ -78,6 +78,8 @@ void from_json(nlohmann::json const& j, RunnerInput& v) LDIO_LOAD_OPTION(slot_diagnostic_prefix); LDIO_LOAD_OPTION(write_track_counts); LDIO_LOAD_OPTION(write_step_times); + LDIO_LOAD_OPTION(transporter_result); + LDIO_LOAD_OPTION(log_progress); LDIO_LOAD_DEPRECATED(max_num_tracks, num_track_slots); LDIO_LOAD_DEPRECATED(sync, action_times); @@ -177,6 +179,8 @@ void to_json(nlohmann::json& j, RunnerInput const& v) LDIO_SAVE_OPTION(slot_diagnostic_prefix); LDIO_SAVE(write_track_counts); LDIO_SAVE(write_step_times); + LDIO_SAVE(transporter_result); + LDIO_SAVE(log_progress); LDIO_SAVE(seed); LDIO_SAVE(num_track_slots); diff --git a/app/celer-sim/Transporter.cc b/app/celer-sim/Transporter.cc index 13ae4a436b..203ac8be5c 100644 --- a/app/celer-sim/Transporter.cc +++ b/app/celer-sim/Transporter.cc @@ -19,8 +19,8 @@ #include "corecel/grid/VectorUtils.hh" #include "corecel/io/Logger.hh" #include "corecel/io/ScopedTimeLog.hh" -#include "corecel/sys/TraceCounter.hh" #include "corecel/sys/ScopedSignalHandler.hh" +#include "corecel/sys/TraceCounter.hh" #include "celeritas/Types.hh" #include "celeritas/global/ActionSequence.hh" #include "celeritas/global/CoreParams.hh" @@ -33,6 +33,22 @@ namespace celeritas { namespace app { +namespace +{ +//---------------------------------------------------------------------------// +/*! + * Log progress after N events when requested. + */ +void log_progress(EventId const id, size_type const num_primaries) +{ + CELER_EXPECT(id); + CELER_EXPECT(num_primaries > 0); + CELER_LOG_LOCAL(status) + << "Event " << id.unchecked_get() << ": transporting " << num_primaries + << (num_primaries == 1 ? " primary" : " primaries"); +} +} // namespace + //---------------------------------------------------------------------------// //! Default virtual destructor TransporterBase::~TransporterBase() = default; @@ -45,10 +61,12 @@ template Transporter::Transporter(TransporterInput inp) : max_steps_(inp.max_steps) , num_streams_(inp.params->max_streams()) + , log_progress_(inp.log_progress) , store_track_counts_(inp.store_track_counts) , store_step_times_(inp.store_step_times) { CELER_EXPECT(inp); + CELER_VALIDATE(log_progress_ > 0, << "log_progress must be positive"); // Create stepper CELER_LOG_LOCAL(status) << "Creating states"; @@ -126,8 +144,12 @@ auto Transporter::operator()(SpanConstPrimary primaries) -> TransporterResult #else ScopedSignalHandler interrupted{SIGINT}; #endif - CELER_LOG_LOCAL(status) - << "Transporting " << primaries.size() << " primaries"; + + if (auto const evt_id = primaries.front().event_id; + evt_id.get() % log_progress_ == 0) + { + log_progress(evt_id, primaries.size()); + } StepTimer record_step_time{store_step_times_ ? &result.step_times : nullptr}; diff --git a/app/celer-sim/Transporter.hh b/app/celer-sim/Transporter.hh index f0290b3051..bf65f3e780 100644 --- a/app/celer-sim/Transporter.hh +++ b/app/celer-sim/Transporter.hh @@ -44,13 +44,15 @@ struct TransporterInput size_type max_steps{}; bool store_track_counts{}; //!< Store track counts at each step bool store_step_times{}; //!< Store time elapsed for each step + size_type log_progress{}; //!< CELER_LOG progress every N events StreamId stream_id{0}; //! True if all params are assigned explicit operator bool() const { - return params && num_track_slots > 0 && max_steps > 0; + return params && num_track_slots > 0 && max_steps > 0 + && log_progress > 0; } }; @@ -137,6 +139,7 @@ class Transporter final : public TransporterBase std::shared_ptr> stepper_; size_type max_steps_; size_type num_streams_; + size_type log_progress_; bool store_track_counts_; bool store_step_times_; }; diff --git a/app/celer-sim/celer-sim.cc b/app/celer-sim/celer-sim.cc index f29d2c35a9..12be331631 100644 --- a/app/celer-sim/celer-sim.cc +++ b/app/celer-sim/celer-sim.cc @@ -92,7 +92,10 @@ void run(std::istream* is, std::shared_ptr output) Runner run_stream(*run_input, output); SimulationResult result; result.setup_time = get_setup_time(); - result.events.resize(run_stream.num_events()); + if (run_input->transporter_result) + { + result.events.resize(run_stream.num_events()); + } // Allocate device streams, or use the default stream if there is only one. size_type num_streams = run_stream.num_streams(); @@ -115,7 +118,11 @@ void run(std::istream* is, std::shared_ptr output) if (run_input->merge_events) { // Run all events simultaneously on a single stream - result.events.front() = run_stream(); + auto event_result = run_stream(); + if (run_input->transporter_result) + { + result.events.front() = std::move(event_result); + } } else { @@ -130,12 +137,18 @@ void run(std::istream* is, std::shared_ptr output) activate_device_local(); // Run a single event on a single thread - CELER_TRY_HANDLE(result.events[event] = run_stream( + TransporterResult event_result; + CELER_TRY_HANDLE(event_result = run_stream( StreamId(get_openmp_thread()), EventId(event)), capture_exception); + if (run_input->transporter_result) + { + result.events[event] = std::move(event_result); + } } log_and_rethrow(std::move(capture_exception)); } + result.action_times = run_stream.get_action_times(); result.total_time = get_transport_time(); record_mem = {};