Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:54:46

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/optical/detail/OffloadParams.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/data/AuxInterface.hh"
0010 #include "corecel/data/CollectionMirror.hh"
0011 #include "corecel/data/CollectionStateStore.hh"
0012 #include "corecel/data/ParamsDataInterface.hh"
0013 
0014 #include "../OffloadData.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace detail
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Manage metadata for optical offload generation.
0023  */
0024 class OffloadParams final : public AuxParamsInterface,
0025                             public ParamsDataInterface<OffloadParamsData>
0026 {
0027   public:
0028     // Construct with aux ID and optical data
0029     OffloadParams(AuxId aux_id, OffloadOptions const& setup);
0030 
0031     //!@{
0032     //! \name Aux interface
0033 
0034     //! Short name for the action
0035     std::string_view label() const final { return "optical-offload"; }
0036     //! Index of this class instance in its registry
0037     AuxId aux_id() const final { return aux_id_; }
0038     // Build state data for a stream
0039     UPState create_state(MemSpace, StreamId, size_type) const final;
0040     //!@}
0041 
0042     //!@{
0043     //! \name Data interface
0044 
0045     //! Access data on host
0046     HostRef const& host_ref() const final { return data_.host_ref(); }
0047     //! Access data on device
0048     DeviceRef const& device_ref() const final { return data_.device_ref(); }
0049     //!@}
0050 
0051   private:
0052     AuxId aux_id_;
0053     CollectionMirror<OffloadParamsData> data_;
0054 };
0055 
0056 //---------------------------------------------------------------------------//
0057 /*!
0058  * Manage counters for optical generation states.
0059  */
0060 struct OpticalOffloadStateBase : public AuxStateInterface
0061 {
0062     //! Buffer sizes to be sent to GPU
0063     OpticalOffloadCounters<size_type> buffer_size;
0064     //! Counts accumulated over the event for diagnostics
0065     OpticalAccumStats accum;
0066 };
0067 
0068 //---------------------------------------------------------------------------//
0069 /*!
0070  * Store optical generation states in aux data.
0071  */
0072 template<MemSpace M>
0073 struct OpticalOffloadState : public OpticalOffloadStateBase
0074 {
0075     CollectionStateStore<OffloadStateData, M> store;
0076 
0077     //! True if states have been allocated
0078     explicit operator bool() const { return static_cast<bool>(store); }
0079 };
0080 
0081 //---------------------------------------------------------------------------//
0082 }  // namespace detail
0083 }  // namespace celeritas