File indexing completed on 2026-10-26 09:34:37
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "corecel/Types.hh"
0012 #include "corecel/data/Collection.hh"
0013 #include "corecel/random/data/RanluxppTypes.hh"
0014
0015 namespace celeritas
0016 {
0017
0018
0019
0020
0021
0022 struct RanluxppRngParamsDataImpl
0023 {
0024
0025
0026
0027 RanluxppUInt seed = 0;
0028
0029
0030 static constexpr int max_position = sizeof(RanluxppArray9) * 8;
0031
0032
0033 RanluxppArray9 advance_state;
0034
0035
0036 RanluxppArray9 advance_sequence;
0037
0038
0039
0040
0041 explicit CELER_CONSTEXPR_FUNCTION operator bool() const
0042 {
0043 return advance_state[0] != 0 && advance_sequence[0] != 0;
0044 }
0045 };
0046
0047 template<Ownership W, MemSpace M>
0048 struct RanluxppRngParamsData : RanluxppRngParamsDataImpl
0049 {
0050
0051 template<Ownership W2, MemSpace M2>
0052 RanluxppRngParamsData& operator=(RanluxppRngParamsData<W2, M2> const& other)
0053 {
0054 CELER_EXPECT(other);
0055 static_cast<RanluxppRngParamsDataImpl&>(*this) = other;
0056 return *this;
0057 }
0058 };
0059
0060
0061
0062
0063
0064 struct RanluxppRngState
0065 {
0066
0067
0068 RanluxppNumber value;
0069
0070
0071 int position;
0072 };
0073
0074
0075
0076
0077
0078 struct RanluxppRngStateInitializer
0079 {
0080
0081 RanluxppNumber value;
0082 };
0083
0084
0085
0086
0087
0088 struct RanluxppInitializer
0089 {
0090
0091 RanluxppUInt seed{0ull};
0092
0093
0094 RanluxppUInt subsequence{0ull};
0095
0096
0097 RanluxppUInt offset{0ull};
0098 };
0099
0100
0101
0102
0103
0104 template<Ownership W, MemSpace M>
0105 struct RanluxppRngStateData
0106 {
0107
0108 template<class T>
0109 using StateItems = StateCollection<T, W, M>;
0110
0111
0112
0113 StateItems<RanluxppRngState> state;
0114
0115
0116
0117 explicit CELER_FUNCTION operator bool() const { return !state.empty(); }
0118
0119
0120 CELER_FUNCTION size_type size() const { return state.size(); }
0121
0122
0123 template<Ownership W2, MemSpace M2>
0124 RanluxppRngStateData& operator=(RanluxppRngStateData<W2, M2>& other)
0125 {
0126 CELER_EXPECT(other);
0127 state = other.state;
0128 return *this;
0129 }
0130 };
0131
0132
0133
0134 template<MemSpace M>
0135 void resize(RanluxppRngStateData<Ownership::value, M>* state,
0136 HostCRef<RanluxppRngParamsData> const& params,
0137 StreamId stream,
0138 size_type size);
0139
0140
0141 }