Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:26

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file celeritas/optical/detail/OpticalLaunchAction.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <string_view>
0012 
0013 #include "corecel/Macros.hh"
0014 #include "corecel/data/AuxInterface.hh"
0015 #include "celeritas/global/ActionInterface.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 template<class P, template<MemSpace M> class S>
0021 class ActionGroups;
0022 class CoreParams;
0023 
0024 namespace optical
0025 {
0026 class CoreParams;
0027 template<MemSpace M>
0028 class CoreState;
0029 class MaterialParams;
0030 }  // namespace optical
0031 
0032 namespace detail
0033 {
0034 class OffloadParams;
0035 }
0036 
0037 namespace detail
0038 {
0039 //---------------------------------------------------------------------------//
0040 /*!
0041  * Manage optical params and state, launching the optical stepping loop.
0042  *
0043  * This stores the optical tracking loop's core params, initializing them at
0044  * the beginning of the run, and stores the optical core state as "aux"
0045  * data.
0046  */
0047 class OpticalLaunchAction : public AuxParamsInterface,
0048                             public CoreStepActionInterface
0049 {
0050   public:
0051     //!@{
0052     //! \name Type aliases
0053     using SPOffloadParams = std::shared_ptr<detail::OffloadParams>;
0054     using SPConstMaterial = std::shared_ptr<optical::MaterialParams const>;
0055     //!@}
0056 
0057   public:
0058     // Construct and add to core params
0059     static std::shared_ptr<OpticalLaunchAction>
0060     make_and_insert(CoreParams const& core,
0061                     SPConstMaterial material,
0062                     SPOffloadParams offload,
0063                     size_type primary_capacity);
0064 
0065     // Construct with IDs, core for copying params, offload gen data
0066     OpticalLaunchAction(ActionId id,
0067                         AuxId data_id,
0068                         CoreParams const& core,
0069                         SPConstMaterial material,
0070                         SPOffloadParams offload,
0071                         size_type primary_capacity);
0072 
0073     //!@{
0074     //! \name Aux/action metadata interface
0075     //! Short name for the action
0076     std::string_view label() const final { return "optical-offload-launch"; }
0077     // Name of the action (for user output)
0078     std::string_view description() const final;
0079     //!@}
0080 
0081     //!@{
0082     //! \name Aux interface
0083     //! Index of this class instance in its registry
0084     AuxId aux_id() const final { return aux_id_; }
0085     // Build optical core state data for a stream
0086     UPState create_state(MemSpace, StreamId, size_type) const final;
0087     //!@}
0088 
0089     //!@{
0090     //! \name Action interface
0091     //! ID of the model
0092     ActionId action_id() const final { return action_id_; }
0093     //! Dependency ordering of the action
0094     StepActionOrder order() const final { return StepActionOrder::user_post; }
0095     // Launch kernel with host data
0096     void step(CoreParams const&, CoreStateHost&) const final;
0097     // Launch kernel with device data
0098     void step(CoreParams const&, CoreStateDevice&) const final;
0099     //!@}
0100 
0101     // TODO: local end run to flush initializers??
0102 
0103   private:
0104     using ActionGroupsT = ActionGroups<optical::CoreParams, optical::CoreState>;
0105     using SPOpticalParams = std::shared_ptr<optical::CoreParams>;
0106     using SPActionGroups = std::shared_ptr<ActionGroupsT>;
0107 
0108     //// DATA ////
0109 
0110     ActionId action_id_;
0111     AuxId aux_id_;
0112     SPOffloadParams offload_params_;
0113     SPOpticalParams optical_params_;
0114     SPActionGroups optical_actions_;
0115 
0116     //// HELPERS ////
0117 
0118     template<MemSpace M>
0119     void execute_impl(CoreParams const&, CoreState<M>&) const;
0120 };
0121 
0122 //---------------------------------------------------------------------------//
0123 }  // namespace detail
0124 }  // namespace celeritas