-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add along-step and tracking cut optical executors (#1540)
* Add along-step and tracking cut actions * Fix assertion failure when no cherenkov photons are generated * Reset step length * Reset scoped log color * Accumulate number of generated optical tracks * Feedback and fix cuda build * Fix single-precision errors
- Loading branch information
Showing
21 changed files
with
567 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/optical/action/AlongStepAction.cc | ||
//---------------------------------------------------------------------------// | ||
#include "AlongStepAction.hh" | ||
|
||
#include "celeritas/optical/CoreParams.hh" | ||
#include "celeritas/optical/CoreState.hh" | ||
|
||
#include "ActionLauncher.hh" | ||
#include "TrackSlotExecutor.hh" | ||
|
||
#include "detail/AlongStepExecutor.hh" | ||
#include "detail/PropagateExecutor.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace optical | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Construct with action ID. | ||
*/ | ||
AlongStepAction::AlongStepAction(ActionId aid) | ||
: StaticConcreteAction(aid, "along-step", "move to interaction or boundary") | ||
{ | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Launch the boundary action on host. | ||
*/ | ||
void AlongStepAction::step(CoreParams const& params, CoreStateHost& state) const | ||
{ | ||
auto propagate_and_update = [](CoreTrackView& track) { | ||
detail::PropagateExecutor{}(track); | ||
detail::AlongStepExecutor{}(track); | ||
}; | ||
auto execute = make_active_thread_executor( | ||
params.ptr<MemSpace::native>(), state.ptr(), propagate_and_update); | ||
return launch_action(state, execute); | ||
} | ||
|
||
#if !CELER_USE_DEVICE | ||
void AlongStepAction::step(CoreParams const&, CoreStateDevice&) const | ||
{ | ||
CELER_NOT_CONFIGURED("CUDA OR HIP"); | ||
} | ||
#endif | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace optical | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//---------------------------------*-CUDA-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/optical/action/AlongStepAction.cu | ||
//---------------------------------------------------------------------------// | ||
#include "AlongStepAction.hh" | ||
|
||
#include "corecel/io/Logger.hh" | ||
#include "celeritas/optical/CoreParams.hh" | ||
#include "celeritas/optical/CoreState.hh" | ||
|
||
#include "ActionLauncher.device.hh" | ||
#include "TrackSlotExecutor.hh" | ||
|
||
#include "detail/AlongStepExecutor.hh" | ||
#include "detail/PropagateExecutor.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace optical | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Launch the along-step action on device. | ||
*/ | ||
void AlongStepAction::step(CoreParams const& params, | ||
CoreStateDevice& state) const | ||
{ | ||
{ | ||
// Propagate | ||
auto execute | ||
= make_active_thread_executor(params.ptr<MemSpace::native>(), | ||
state.ptr(), | ||
detail::PropagateExecutor{}); | ||
|
||
static ActionLauncher<decltype(execute)> const launch_kernel( | ||
*this, "propagate"); | ||
launch_kernel(state, execute); | ||
} | ||
{ | ||
// Update state | ||
auto execute | ||
= make_active_thread_executor(params.ptr<MemSpace::native>(), | ||
state.ptr(), | ||
detail::AlongStepExecutor{}); | ||
|
||
static ActionLauncher<decltype(execute)> const launch_kernel(*this); | ||
launch_kernel(state, execute); | ||
} | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace optical | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/optical/action/AlongStepAction.hh | ||
//---------------------------------------------------------------------------// | ||
#pragma once | ||
|
||
#include "ActionInterface.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace optical | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Move a track to the next boundary or interaction. | ||
*/ | ||
class AlongStepAction final : public OpticalStepActionInterface, | ||
public StaticConcreteAction | ||
{ | ||
public: | ||
// Construct with ID | ||
explicit AlongStepAction(ActionId); | ||
|
||
// Launch kernel with host data | ||
void step(CoreParams const&, CoreStateHost&) const final; | ||
|
||
// Launch kernel with device data | ||
void step(CoreParams const&, CoreStateDevice&) const final; | ||
|
||
//! Dependency ordering of the action | ||
StepActionOrder order() const final { return StepActionOrder::along; } | ||
}; | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace optical | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/optical/action/TrackingCutAction.cc | ||
//---------------------------------------------------------------------------// | ||
#include "TrackingCutAction.hh" | ||
|
||
#include "corecel/io/Logger.hh" | ||
#include "celeritas/optical/CoreParams.hh" | ||
#include "celeritas/optical/CoreState.hh" | ||
|
||
#include "ActionLauncher.hh" | ||
#include "TrackSlotExecutor.hh" | ||
|
||
#include "detail/TrackingCutExecutor.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace optical | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Construct with action ID. | ||
*/ | ||
TrackingCutAction::TrackingCutAction(ActionId aid) | ||
: StaticConcreteAction( | ||
aid, "tracking-cut", "kill a track and deposit its energy") | ||
{ | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Launch the boundary action on host. | ||
*/ | ||
void TrackingCutAction::step(CoreParams const& params, | ||
CoreStateHost& state) const | ||
{ | ||
auto execute = make_action_thread_executor(params.ptr<MemSpace::native>(), | ||
state.ptr(), | ||
this->action_id(), | ||
detail::TrackingCutExecutor{}); | ||
return launch_action(state, execute); | ||
} | ||
|
||
#if !CELER_USE_DEVICE | ||
void TrackingCutAction::step(CoreParams const&, CoreStateDevice&) const | ||
{ | ||
CELER_NOT_CONFIGURED("CUDA OR HIP"); | ||
} | ||
#endif | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace optical | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//---------------------------------*-CUDA-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/optical/action/TrackingCutAction.cu | ||
//---------------------------------------------------------------------------// | ||
#include "TrackingCutAction.hh" | ||
|
||
#include "corecel/io/Logger.hh" | ||
#include "celeritas/optical/CoreParams.hh" | ||
#include "celeritas/optical/CoreState.hh" | ||
|
||
#include "ActionLauncher.device.hh" | ||
#include "TrackSlotExecutor.hh" | ||
|
||
#include "detail/TrackingCutExecutor.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace optical | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Launch the tracking cut action on device. | ||
*/ | ||
void TrackingCutAction::step(CoreParams const& params, | ||
CoreStateDevice& state) const | ||
{ | ||
auto execute = make_action_thread_executor(params.ptr<MemSpace::native>(), | ||
state.ptr(), | ||
this->action_id(), | ||
detail::TrackingCutExecutor{}); | ||
|
||
static ActionLauncher<decltype(execute)> const launch_kernel(*this); | ||
launch_kernel(state, execute); | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace optical | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file celeritas/optical/action/TrackingCutAction.hh | ||
//---------------------------------------------------------------------------// | ||
#pragma once | ||
|
||
#include "ActionInterface.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace optical | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Kill misbehaving photons and deposit energy locally. | ||
*/ | ||
class TrackingCutAction final : public OpticalStepActionInterface, | ||
public StaticConcreteAction | ||
{ | ||
public: | ||
// Construct with ID | ||
explicit TrackingCutAction(ActionId); | ||
|
||
// Launch kernel with host data | ||
void step(CoreParams const&, CoreStateHost&) const final; | ||
|
||
// Launch kernel with device data | ||
void step(CoreParams const&, CoreStateDevice&) const final; | ||
|
||
//! Dependency ordering of the action | ||
StepActionOrder order() const final { return StepActionOrder::post; } | ||
}; | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace optical | ||
} // namespace celeritas |
Oops, something went wrong.