From 8afcc8fb8bc18463435c46fb061e7116eb5d3e99 Mon Sep 17 00:00:00 2001 From: Luchang Jin Date: Sun, 18 Sep 2016 14:13:40 -0400 Subject: [PATCH] fix state size --- lib/lattice/Lattice_rng.h | 4 ++-- lib/lattice/rng/rng-state.h | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/lattice/Lattice_rng.h b/lib/lattice/Lattice_rng.h index 92a12ee6..1f0da80d 100644 --- a/lib/lattice/Lattice_rng.h +++ b/lib/lattice/Lattice_rng.h @@ -119,9 +119,9 @@ namespace Grid { // One generator per site. // Uniform and Gaussian distributions from these generators. #ifdef RNG_SPRNG_SHA256 - typedef uint64_t RngStateType; + typedef uint32_t RngStateType; typedef SprngSha256 RngEngine; - static const int RngStateCount = 16; + static const int RngStateCount = 22; #elif defined RNG_RANLUX typedef uint64_t RngStateType; typedef std::ranlux48 RngEngine; diff --git a/lib/lattice/rng/rng-state.h b/lib/lattice/rng/rng-state.h index af1ea815..b7d00a68 100644 --- a/lib/lattice/rng/rng-state.h +++ b/lib/lattice/rng/rng-state.h @@ -112,7 +112,7 @@ struct RngState } }; -const size_t RNG_STATE_SIZE_OF_INT32 = 2 + 8 + 2 + 3 * 2 + 2 + 1 + 1; +const size_t RNG_STATE_NUM_OF_INT32 = 2 + 8 + 2 + 3 * 2 + 2 + 1 + 1; inline uint64_t patchTwoUint32(const uint32_t a, const uint32_t b) { @@ -128,8 +128,8 @@ inline void splitTwoUint32(uint32_t& a, uint32_t& b, const uint64_t x) inline void exportRngState(std::vector& v, const RngState& rs) { - assert(22 == RNG_STATE_SIZE_OF_INT32); - v.resize(RNG_STATE_SIZE_OF_INT32); + assert(22 == RNG_STATE_NUM_OF_INT32); + v.resize(RNG_STATE_NUM_OF_INT32); splitTwoUint32(v[0], v[1], rs.numBytes); for (int i = 0; i < 8; ++i) { v[2 + i] = rs.hash[i]; @@ -146,8 +146,8 @@ inline void exportRngState(std::vector& v, const RngState& rs) inline void importRngState(RngState& rs, const std::vector& v) { - assert(RNG_STATE_SIZE_OF_INT32 == v.size()); - assert(22 == RNG_STATE_SIZE_OF_INT32); + assert(RNG_STATE_NUM_OF_INT32 == v.size()); + assert(22 == RNG_STATE_NUM_OF_INT32); rs.numBytes = patchTwoUint32(v[0], v[1]); for (int i = 0; i < 8; ++i) { rs.hash[i] = v[2 + i]; @@ -164,7 +164,7 @@ inline void importRngState(RngState& rs, const std::vector& v) inline std::ostream& operator<<(std::ostream& os, const RngState& rs) { - std::vector v(RNG_STATE_SIZE_OF_INT32); + std::vector v(RNG_STATE_NUM_OF_INT32); exportRngState(v, rs); for (size_t i = 0; i < v.size() - 1; ++i) { os << v[i] << " "; @@ -175,7 +175,7 @@ inline std::ostream& operator<<(std::ostream& os, const RngState& rs) inline std::istream& operator>>(std::istream& is, RngState& rs) { - std::vector v(RNG_STATE_SIZE_OF_INT32); + std::vector v(RNG_STATE_NUM_OF_INT32); for (size_t i = 0; i < v.size(); ++i) { is >> v[i]; }