File indexing completed on 2025-09-14 08:50:55
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010
0011 #include "corecel/Types.hh"
0012
0013 #include "AuxInterface.hh"
0014 #include "CollectionStateStore.hh"
0015 #include "ParamsDataInterface.hh"
0016
0017 namespace celeritas
0018 {
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 template<template<Ownership, MemSpace> class S, MemSpace M>
0031 class AuxStateData final : public AuxStateInterface
0032 {
0033 public:
0034
0035
0036 using Ref = S<Ownership::reference, M>;
0037
0038
0039 public:
0040
0041 template<template<Ownership, MemSpace> class P>
0042 inline AuxStateData(HostCRef<P> const& p,
0043 StreamId stream_id,
0044 size_type size);
0045
0046
0047 explicit operator bool() const { return static_cast<bool>(store_); }
0048
0049
0050 size_type size() const { return store_.size(); }
0051
0052
0053 Ref& ref() { return store_.ref(); }
0054
0055
0056 Ref const& ref() const { return store_.ref(); }
0057
0058 private:
0059 CollectionStateStore<S, M> store_;
0060 };
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 template<template<Ownership, MemSpace> class S, template<Ownership, MemSpace> class P>
0073 std::unique_ptr<AuxStateInterface>
0074 make_aux_state(ParamsDataInterface<P> const& params,
0075 MemSpace m,
0076 StreamId stream_id,
0077 size_type size)
0078 {
0079 if (m == MemSpace::host)
0080 {
0081 using ASD = AuxStateData<S, MemSpace::host>;
0082 return std::make_unique<ASD>(params.host_ref(), stream_id, size);
0083 }
0084 else if (m == MemSpace::device)
0085 {
0086 using ASD = AuxStateData<S, MemSpace::device>;
0087 return std::make_unique<ASD>(params.host_ref(), stream_id, size);
0088 }
0089 CELER_ASSERT_UNREACHABLE();
0090 }
0091
0092
0093
0094
0095
0096
0097
0098 template<template<Ownership, MemSpace> class S, MemSpace M>
0099 template<template<Ownership, MemSpace> class P>
0100 AuxStateData<S, M>::AuxStateData(HostCRef<P> const& p,
0101 StreamId stream_id,
0102 size_type size)
0103 : store_{p, stream_id, size}
0104 {
0105 }
0106
0107
0108 }