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