Skip to content

Commit

Permalink
Enable optical stepping loop (#1546)
Browse files Browse the repository at this point in the history
* Mark errored tracks for printing with tracking cut action
* Update maximum optical steps to 1k
* Reset killed tracks at start of loop
* Update tests
  • Loading branch information
sethrj authored Dec 11, 2024
1 parent 442b9ac commit 6338b6c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/celeritas/optical/CoreTrackView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ CELER_FUNCTION void CoreTrackView::apply_errored()
{
auto sim = this->sim();
CELER_EXPECT(is_track_valid(sim.status()));
sim.status(TrackStatus::killed);
sim.post_step_action({});
sim.status(TrackStatus::errored);
sim.post_step_action(params_.scalars.tracking_cut_action);
}

//---------------------------------------------------------------------------//
Expand Down
5 changes: 5 additions & 0 deletions src/celeritas/optical/action/detail/PreStepExecutor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ struct PreStepExecutor
CELER_FUNCTION void PreStepExecutor::operator()(CoreTrackView const& track)
{
auto sim = track.sim();
if (sim.status() == TrackStatus::killed)
{
// Deactivate tracks killed in previous loop
sim.status(TrackStatus::inactive);
}
if (sim.status() == TrackStatus::inactive)
{
// Clear step limit and actions for an empty track slot
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/optical/detail/OpticalLaunchAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void OpticalLaunchAction::execute_impl(CoreParams const&,
CELER_ASSERT(offload_state);
CELER_ASSERT(optical_state.size() > 0);

constexpr size_type max_step_iters{1};
constexpr size_type max_step_iters{1024};
size_type num_step_iters{0};
size_type num_steps{0};

Expand Down
13 changes: 6 additions & 7 deletions test/celeritas/optical/OpticalCollector.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -518,16 +518,15 @@ TEST_F(LArSphereOffloadTest, host_generate_small)
"Celeritas core state initialization complete",
"No Cherenkov photons to generate",
"Generated 964 Scintillation photons from 2 distributions",
R"(Exceeded step count of 1: aborting optical transport loop with 32 active tracks, 0 alive tracks, 32 vacancies, and 932 queued)",
R"(Generated 964 optical photons which completed 32 total steps over 1 iterations)",
R"(Generated 964 optical photons which completed 964 total steps over 31 iterations)",
"Deallocating host core state (stream 0)",
};
if (CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_DOUBLE)
{
EXPECT_VEC_EQ(expected_log_messages, scoped_log_.messages());
}
static char const* const expected_log_levels[]
= {"status", "status", "debug", "debug", "error", "debug", "debug"};
= {"status", "status", "debug", "debug", "debug", "debug"};
EXPECT_VEC_EQ(expected_log_levels, scoped_log_.levels());
}

Expand All @@ -548,15 +547,15 @@ TEST_F(LArSphereOffloadTest, host_generate)
"Celeritas core state initialization complete",
"Generated 4258 Cherenkov photons from 4 distributions",
"Generated 319935 Scintillation photons from 4 distributions",
R"(Exceeded step count of 1: aborting optical transport loop with 262144 active tracks, 0 alive tracks, 262144 vacancies, and 62049 queued)",
R"(Generated 324193 optical photons which completed 262144 total steps over 1 iterations)",
"Deallocating host core state (stream 0)"};
R"(Generated 324193 optical photons which completed 324193 total steps over 2 iterations)",
"Deallocating host core state (stream 0)",
};
if (CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_DOUBLE)
{
EXPECT_VEC_EQ(expected_log_messages, scoped_log_.messages());
}
static char const* const expected_log_levels[]
= {"status", "status", "debug", "debug", "error", "debug", "debug"};
= {"status", "status", "debug", "debug", "debug", "debug"};
EXPECT_VEC_EQ(expected_log_levels, scoped_log_.levels());

EXPECT_EQ(2, result.optical_launch_step);
Expand Down

0 comments on commit 6338b6c

Please sign in to comment.