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/OpticalGenAlgorithms.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Macros.hh"
0011 #include "corecel/Types.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "celeritas/optical/GeneratorDistributionData.hh"
0014 
0015 namespace celeritas
0016 {
0017 namespace detail
0018 {
0019 //---------------------------------------------------------------------------//
0020 template<MemSpace M>
0021 using GeneratorDistributionRef
0022     = Collection<::celeritas::optical::GeneratorDistributionData,
0023                  Ownership::reference,
0024                  M>;
0025 
0026 //---------------------------------------------------------------------------//
0027 struct IsInvalid
0028 {
0029     // Check if the distribution data is valid
0030     CELER_FUNCTION bool
0031     operator()(celeritas::optical::GeneratorDistributionData const& data) const
0032     {
0033         return !data;
0034     }
0035 };
0036 
0037 //---------------------------------------------------------------------------//
0038 // Remove all invalid distributions from the buffer.
0039 size_type remove_if_invalid(GeneratorDistributionRef<MemSpace::host> const&,
0040                             size_type,
0041                             size_type,
0042                             StreamId);
0043 size_type remove_if_invalid(GeneratorDistributionRef<MemSpace::device> const&,
0044                             size_type,
0045                             size_type,
0046                             StreamId);
0047 
0048 //---------------------------------------------------------------------------//
0049 // Count the number of optical photons in the distributions.
0050 size_type count_num_photons(GeneratorDistributionRef<MemSpace::host> const&,
0051                             size_type,
0052                             size_type,
0053                             StreamId);
0054 size_type count_num_photons(GeneratorDistributionRef<MemSpace::device> const&,
0055                             size_type,
0056                             size_type,
0057                             StreamId);
0058 
0059 //---------------------------------------------------------------------------//
0060 // Calculate the inclusive prefix sum of the number of optical photons
0061 size_type inclusive_scan_photons(
0062     GeneratorDistributionRef<MemSpace::host> const&,
0063     Collection<size_type, Ownership::reference, MemSpace::host> const&,
0064     size_type,
0065     StreamId);
0066 size_type inclusive_scan_photons(
0067     GeneratorDistributionRef<MemSpace::device> const&,
0068     Collection<size_type, Ownership::reference, MemSpace::device> const&,
0069     size_type,
0070     StreamId);
0071 
0072 //---------------------------------------------------------------------------//
0073 // INLINE DEFINITIONS
0074 //---------------------------------------------------------------------------//
0075 #if !CELER_USE_DEVICE
0076 inline size_type
0077 remove_if_invalid(GeneratorDistributionRef<MemSpace::device> const&,
0078                   size_type,
0079                   size_type,
0080                   StreamId)
0081 {
0082     CELER_NOT_CONFIGURED("CUDA OR HIP");
0083 }
0084 
0085 inline size_type
0086 count_num_photons(GeneratorDistributionRef<MemSpace::device> const&,
0087                   size_type,
0088                   size_type,
0089                   StreamId)
0090 {
0091     CELER_NOT_CONFIGURED("CUDA OR HIP");
0092 }
0093 
0094 inline size_type inclusive_scan_photons(
0095     GeneratorDistributionRef<MemSpace::device> const&,
0096     Collection<size_type, Ownership::reference, MemSpace::device> const&,
0097     size_type,
0098     StreamId)
0099 {
0100     CELER_NOT_CONFIGURED("CUDA OR HIP");
0101 }
0102 #endif
0103 //---------------------------------------------------------------------------//
0104 }  // namespace detail
0105 }  // namespace celeritas