![]() |
|
|||
File indexing completed on 2025-09-17 08:53:39
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file celeritas/global/ActionSequence.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <memory> 0010 #include <type_traits> 0011 #include <vector> 0012 0013 #include "corecel/Types.hh" 0014 0015 #include "ActionGroups.hh" 0016 #include "ActionInterface.hh" 0017 0018 namespace celeritas 0019 { 0020 //---------------------------------------------------------------------------// 0021 class ActionRegistry; 0022 class StatusChecker; 0023 0024 //---------------------------------------------------------------------------// 0025 /*! 0026 * Sequence of step actions to invoke as part of a single step. 0027 * 0028 * TODO accessors here are used by diagnostic output from celer-sim etc.; 0029 * perhaps make this public or add a diagnostic output for it? 0030 * 0031 * \todo Refactor action times as "aux data" and as an end-gather action so 0032 * that this class can merge across states. Currently there's one sequence per 0033 * stepper which isn't right. 0034 */ 0035 class ActionSequence 0036 { 0037 public: 0038 //!@{ 0039 //! \name Type aliases 0040 using ActionGroupsT = ActionGroups<CoreParams, CoreState>; 0041 using VecDouble = std::vector<double>; 0042 //!@} 0043 0044 public: 0045 //! Construction/execution options 0046 struct Options 0047 { 0048 bool action_times{false}; //!< Call DeviceSynchronize and add timer 0049 }; 0050 0051 public: 0052 // Construct from an action registry and sequence options 0053 ActionSequence(ActionRegistry const&, Options options); 0054 0055 //// INVOCATION //// 0056 0057 // Call beginning-of-run actions. 0058 template<MemSpace M> 0059 void begin_run(CoreParams const& params, CoreState<M>& state); 0060 0061 // Launch all actions with the given memory space. 0062 template<MemSpace M> 0063 void step(CoreParams const&, CoreState<M>& state); 0064 0065 //// ACCESSORS //// 0066 0067 //! Whether synchronization is taking place 0068 bool action_times() const { return options_.action_times; } 0069 0070 //! Get the ordered vector of actions in the sequence 0071 ActionGroupsT const& actions() const { return actions_; } 0072 0073 //! Get the corresponding accumulated time, if 'sync' or host called 0074 VecDouble const& accum_time() const { return accum_time_; } 0075 0076 private: 0077 ActionGroupsT actions_; 0078 Options options_; 0079 VecDouble accum_time_; 0080 std::shared_ptr<StatusChecker const> status_checker_; 0081 }; 0082 0083 //---------------------------------------------------------------------------// 0084 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |