File indexing completed on 2025-12-15 10:10:59
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/cont/Span.hh"
0010 #include "corecel/data/AuxInterface.hh"
0011 #include "corecel/data/CollectionStateStore.hh"
0012 #include "corecel/data/ObserverPtr.hh"
0013 #include "celeritas/Types.hh"
0014 #include "celeritas/track/CoreStateCounters.hh"
0015
0016 #include "CoreTrackData.hh"
0017 #include "TrackInitializer.hh"
0018
0019 namespace celeritas
0020 {
0021 namespace optical
0022 {
0023 class CoreParams;
0024
0025
0026
0027
0028
0029
0030
0031
0032 class CoreStateInterface : public AuxStateInterface
0033 {
0034 public:
0035
0036
0037 using size_type = TrackSlotId::size_type;
0038
0039
0040 public:
0041
0042 ~CoreStateInterface() override;
0043
0044
0045 virtual StreamId stream_id() const = 0;
0046
0047
0048 virtual CoreStateCounters const& counters() const = 0;
0049
0050
0051 virtual size_type size() const = 0;
0052
0053
0054 virtual void insert_primaries(Span<TrackInitializer const> host_primaries)
0055 = 0;
0056
0057 protected:
0058 CoreStateInterface() = default;
0059 CELER_DEFAULT_COPY_MOVE(CoreStateInterface);
0060 };
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 template<MemSpace M>
0073 class CoreState final : public CoreStateInterface
0074 {
0075 public:
0076
0077
0078 template<template<Ownership, MemSpace> class S>
0079 using StateRef = S<Ownership::reference, M>;
0080
0081 using Ref = StateRef<CoreStateData>;
0082 using Ptr = ObserverPtr<Ref, M>;
0083
0084
0085 public:
0086
0087 CoreState(CoreParams const& params,
0088 StreamId stream_id,
0089 size_type num_track_slots);
0090
0091
0092 StreamId stream_id() const final { return this->ref().stream_id; }
0093
0094
0095 size_type size() const final { return states_.size(); }
0096
0097
0098 bool warming_up() const;
0099
0100
0101
0102
0103 Ref& ref() { return states_.ref(); }
0104
0105
0106 Ref const& ref() const { return states_.ref(); }
0107
0108
0109 Ptr ptr() { return ptr_; }
0110
0111
0112
0113
0114 CoreStateCounters& counters() { return counters_; }
0115
0116
0117 CoreStateCounters const& counters() const final { return counters_; }
0118
0119
0120 void insert_primaries(Span<TrackInitializer const> host_primaries) final;
0121
0122 private:
0123
0124 CollectionStateStore<CoreStateData, M> states_;
0125
0126
0127 DeviceVector<Ref> device_ref_vec_;
0128
0129
0130 Ptr ptr_;
0131
0132
0133 CoreStateCounters counters_;
0134 };
0135
0136
0137 }
0138 }