Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:09

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/action/detail/TrackInitAlgorithms.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "corecel/Types.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "celeritas/Types.hh"
0014 
0015 namespace celeritas
0016 {
0017 namespace optical
0018 {
0019 namespace detail
0020 {
0021 //---------------------------------------------------------------------------//
0022 template<MemSpace M>
0023 using TrackSlotRef = StateCollection<TrackSlotId, Ownership::reference, M>;
0024 template<MemSpace M>
0025 using TrackStatusRef = StateCollection<TrackStatus, Ownership::reference, M>;
0026 
0027 //---------------------------------------------------------------------------//
0028 //! Whether the track slot is vacant
0029 struct IsVacant
0030 {
0031     CELER_FUNCTION bool operator()(TrackStatus status) const
0032     {
0033         return status != TrackStatus::alive;
0034     }
0035 };
0036 
0037 //---------------------------------------------------------------------------//
0038 // Compact the \c TrackSlotIds of the inactive tracks
0039 size_type copy_if_vacant(TrackStatusRef<MemSpace::host> const&,
0040                          TrackSlotRef<MemSpace::host> const&,
0041                          StreamId);
0042 size_type copy_if_vacant(TrackStatusRef<MemSpace::device> const&,
0043                          TrackSlotRef<MemSpace::device> const&,
0044                          StreamId);
0045 
0046 //---------------------------------------------------------------------------//
0047 // INLINE DEFINITIONS
0048 //---------------------------------------------------------------------------//
0049 #if !CELER_USE_DEVICE
0050 inline size_type copy_if_vacant(TrackStatusRef<MemSpace::device> const&,
0051                                 TrackSlotRef<MemSpace::device> const&,
0052                                 StreamId)
0053 {
0054     CELER_NOT_CONFIGURED("CUDA or HIP");
0055 }
0056 #endif
0057 //---------------------------------------------------------------------------//
0058 }  // namespace detail
0059 }  // namespace optical
0060 }  // namespace celeritas