File indexing completed on 2026-11-27 10:26:31
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/cont/Span.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "corecel/math/Algorithms.hh"
0014
0015 namespace celeritas
0016 {
0017 namespace optical
0018 {
0019 namespace detail
0020 {
0021
0022 template<class T, MemSpace M>
0023 using ItemsRef = Collection<T, Ownership::reference, M>;
0024
0025
0026
0027
0028
0029
0030
0031
0032 inline CELER_FUNCTION size_type find_distribution_index(
0033 Span<size_type> offsets, size_type value)
0034 {
0035 CELER_EXPECT(!offsets.empty());
0036
0037 auto iter = celeritas::lower_bound(offsets.begin(), offsets.end(), value);
0038 CELER_ASSERT(iter != offsets.end());
0039
0040 if (value == *iter)
0041 {
0042 ++iter;
0043 }
0044 return iter - offsets.begin();
0045 }
0046
0047
0048
0049 template<class T>
0050 size_type inclusive_scan_photons(ItemsRef<T, MemSpace::host> const&,
0051 ItemsRef<size_type, MemSpace::host> const&,
0052 size_type,
0053 StreamId);
0054 template<class T>
0055 size_type inclusive_scan_photons(ItemsRef<T, MemSpace::device> const&,
0056 ItemsRef<size_type, MemSpace::device> const&,
0057 size_type,
0058 StreamId);
0059
0060
0061
0062
0063 #if !CELER_USE_DEVICE
0064 template<class T>
0065 inline size_type inclusive_scan_photons(
0066 ItemsRef<T, MemSpace::device> const&,
0067 ItemsRef<size_type, MemSpace::device> const&,
0068 size_type,
0069 StreamId)
0070 {
0071 CELER_NOT_CONFIGURED("CUDA OR HIP");
0072 }
0073 #endif
0074
0075
0076 }
0077 }
0078 }