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/OffloadParams.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/data/AuxInterface.hh"
0011 #include "corecel/data/CollectionMirror.hh"
0012 #include "corecel/data/CollectionStateStore.hh"
0013 #include "corecel/data/ParamsDataInterface.hh"
0014 
0015 #include "../OffloadData.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace detail
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Manage metadata for optical offload generation.
0024  */
0025 class OffloadParams final : public AuxParamsInterface,
0026                             public ParamsDataInterface<OffloadParamsData>
0027 {
0028   public:
0029     // Construct with aux ID and optical data
0030     OffloadParams(AuxId aux_id, OffloadOptions const& setup);
0031 
0032     //!@{
0033     //! \name Aux interface
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     //! Access data on host
0045     HostRef const& host_ref() const final { return data_.host_ref(); }
0046     //! Access data on device
0047     DeviceRef const& device_ref() const final { return data_.device_ref(); }
0048     //!@}
0049 
0050   private:
0051     AuxId aux_id_;
0052     CollectionMirror<OffloadParamsData> data_;
0053 };
0054 
0055 //---------------------------------------------------------------------------//
0056 /*!
0057  * Manage optical generation states.
0058  */
0059 template<MemSpace M>
0060 struct OpticalOffloadState : public AuxStateInterface
0061 {
0062     CollectionStateStore<OffloadStateData, M> store;
0063     OffloadBufferSize buffer_size;
0064 
0065     //! True if states have been allocated
0066     explicit operator bool() const { return static_cast<bool>(store); }
0067 };
0068 
0069 //---------------------------------------------------------------------------//
0070 }  // namespace detail
0071 }  // namespace celeritas