File indexing completed on 2026-01-07 10:01:43
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <vector>
0010
0011 #include "corecel/Macros.hh"
0012 #include "corecel/Types.hh"
0013 #include "corecel/data/Collection.hh"
0014 #include "corecel/data/CollectionBuilder.hh"
0015 #include "celeritas/Quantities.hh"
0016 #include "celeritas/Types.hh"
0017 #include "celeritas/phys/GeneratorCounters.hh"
0018
0019 namespace celeritas
0020 {
0021
0022
0023
0024
0025 struct OpticalAccumStats
0026 {
0027 using size_type = std::size_t;
0028 using OpticalBufferSize = GeneratorCounters<size_type>;
0029
0030 std::vector<OpticalBufferSize> generators;
0031
0032 size_type steps{0};
0033 size_type step_iters{0};
0034 size_type flushes{0};
0035 };
0036
0037
0038
0039
0040
0041
0042
0043 struct OffloadPreStepData
0044 {
0045 units::LightSpeed speed;
0046 Real3 pos{};
0047 real_type time{};
0048 OptMatId material;
0049
0050
0051 explicit CELER_FUNCTION operator bool() const
0052 {
0053 return material && speed > zero_quantity();
0054 }
0055 };
0056
0057
0058
0059
0060
0061 template<Ownership W, MemSpace M>
0062 struct OffloadStepStateData
0063 {
0064
0065
0066 template<class T>
0067 using StateItems = StateCollection<T, W, M>;
0068
0069
0070
0071
0072 StateItems<OffloadPreStepData> step;
0073
0074
0075
0076
0077 CELER_FUNCTION size_type size() const { return step.size(); }
0078
0079
0080 explicit CELER_FUNCTION operator bool() const { return !step.empty(); }
0081
0082
0083 template<Ownership W2, MemSpace M2>
0084 OffloadStepStateData& operator=(OffloadStepStateData<W2, M2>& other)
0085 {
0086 CELER_EXPECT(other);
0087 step = other.step;
0088 return *this;
0089 }
0090 };
0091
0092
0093
0094
0095
0096 template<MemSpace M>
0097 void resize(OffloadStepStateData<Ownership::value, M>* state,
0098 StreamId,
0099 size_type size)
0100 {
0101 CELER_EXPECT(size > 0);
0102 resize(&state->step, size);
0103 CELER_ENSURE(*state);
0104 }
0105
0106
0107 }