File indexing completed on 2025-02-22 10:31:28
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Types.hh"
0011 #include "corecel/cont/Range.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "corecel/data/CollectionAlgorithms.hh"
0014 #include "corecel/data/CollectionBuilder.hh"
0015 #include "corecel/sys/Device.hh"
0016 #include "corecel/sys/ThreadId.hh"
0017 #include "celeritas/Types.hh"
0018 #include "celeritas/optical/TrackInitializer.hh"
0019
0020 namespace celeritas
0021 {
0022 namespace optical
0023 {
0024
0025
0026
0027
0028 template<Ownership W, MemSpace M>
0029 struct TrackInitParamsData
0030 {
0031 size_type capacity{0};
0032
0033
0034
0035
0036 explicit CELER_FUNCTION operator bool() const { return capacity > 0; }
0037
0038
0039 template<Ownership W2, MemSpace M2>
0040 TrackInitParamsData& operator=(TrackInitParamsData<W2, M2> const& other)
0041 {
0042 CELER_EXPECT(other);
0043 capacity = other.capacity;
0044 return *this;
0045 }
0046 };
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 template<Ownership W, MemSpace M>
0059 struct TrackInitStateData
0060 {
0061
0062
0063 template<class T>
0064 using StateItems = StateCollection<T, W, M>;
0065 template<class T>
0066 using Items = Collection<T, W, M>;
0067
0068
0069
0070 Items<TrackInitializer> initializers;
0071 StateItems<TrackSlotId> vacancies;
0072
0073
0074
0075
0076 explicit CELER_FUNCTION operator bool() const
0077 {
0078 return !initializers.empty() && !vacancies.empty();
0079 }
0080
0081
0082 template<Ownership W2, MemSpace M2>
0083 TrackInitStateData& operator=(TrackInitStateData<W2, M2>& other)
0084 {
0085 CELER_EXPECT(other);
0086
0087 initializers = other.initializers;
0088 vacancies = other.vacancies;
0089
0090 return *this;
0091 }
0092 };
0093
0094
0095
0096
0097
0098
0099
0100
0101 template<MemSpace M>
0102 void resize(TrackInitStateData<Ownership::value, M>* data,
0103 HostCRef<TrackInitParamsData> const& params,
0104 StreamId stream,
0105 size_type size)
0106 {
0107 CELER_EXPECT(params);
0108 CELER_EXPECT(size > 0);
0109
0110 resize(&data->initializers, params.capacity);
0111 resize(&data->vacancies, size);
0112
0113
0114 fill_sequence(&data->vacancies, stream);
0115
0116 CELER_ENSURE(*data);
0117 }
0118
0119
0120
0121 }
0122 }