Back to home page

EIC code displayed by LXR

 
 

    


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

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/track/TrackInitParams.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Types.hh"
0010 #include "corecel/data/CollectionMirror.hh"
0011 #include "corecel/data/Filler.hh"
0012 #include "corecel/data/ParamsDataInterface.hh"
0013 
0014 #include "TrackInitData.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Manage persistent track initializer data.
0021  *
0022  * \todo \c max_events could potentially be per thread, not global? And we
0023  * should differentiate between user events and events in flight.
0024  */
0025 class TrackInitParams final : public ParamsDataInterface<TrackInitParamsData>
0026 {
0027   public:
0028     //! Track initializer construction arguments
0029     struct Input
0030     {
0031         size_type capacity{};  //!< Max number of initializers
0032         size_type max_events{};  //!< Max simultaneous events
0033         TrackOrder track_order{TrackOrder::none};  //!< How to sort tracks
0034     };
0035 
0036   public:
0037     // Construct with capacity and number of events
0038     explicit TrackInitParams(Input const&);
0039 
0040     //! Maximum number of initializers
0041     size_type capacity() const { return host_ref().capacity; }
0042 
0043     //! Event number cannot exceed this value
0044     size_type max_events() const { return host_ref().max_events; }
0045 
0046     //! Track sorting strategy
0047     TrackOrder track_order() const { return host_ref().track_order; }
0048 
0049     //! Access primaries for contructing track initializer states
0050     HostRef const& host_ref() const final { return data_.host_ref(); }
0051 
0052     //! Access data on device
0053     DeviceRef const& device_ref() const final { return data_.device_ref(); }
0054 
0055     // Reset track counters in single-event mode
0056     template<MemSpace M>
0057     inline void
0058     reset_track_ids(StreamId stream,
0059                     TrackInitStateData<Ownership::reference, M>* state) const;
0060 
0061   private:
0062     // Host/device storage and reference
0063     CollectionMirror<TrackInitParamsData> data_;
0064 };
0065 
0066 //---------------------------------------------------------------------------//
0067 /*!
0068  * Reset track counters in single-event mode.
0069  */
0070 template<MemSpace M>
0071 void TrackInitParams::reset_track_ids(
0072     StreamId stream, TrackInitStateData<Ownership::reference, M>* state) const
0073 {
0074     CELER_EXPECT(state);
0075 
0076     Filler<size_type, M> fill_zero{0, stream};
0077     fill_zero(state->track_counters[AllItems<size_type, M>{}]);
0078 }
0079 
0080 //---------------------------------------------------------------------------//
0081 }  // namespace celeritas