test/test_rocrand_philox_prng.cpp
// Check if the philox state counter is calculated correctly during
// random number generation.
Check if the philox state counter is calculated correctly during
random number generation.
Check if the philox state counter is calculated correctly during random number generation .
TEST(rocrand_philox_prng_state_tests, discard_test)
{
    rocrand_philox4x32_10_engine_type_test engine;
    rocrand_philox4x32_10_engine_type_test::state_type& state = engine.internal_state_ref();
    EXPECT_EQ(state.counter.x, 0U);
    EXPECT_EQ(state.counter.y, 0U);
    EXPECT_EQ(state.counter.z, 0U);
    EXPECT_EQ(state.counter.w, 0U);
    engine.discard(UINT_MAX * 4ULL);
    EXPECT_EQ(state.counter.x, UINT_MAX);
    EXPECT_EQ(state.counter.y, 0U);
    EXPECT_EQ(state.counter.z, 0U);
    EXPECT_EQ(state.counter.w, 0U);
    engine.discard(UINT_MAX * 4ULL);
    EXPECT_EQ(state.counter.x, UINT_MAX - 1);
    EXPECT_EQ(state.counter.y, 1U);
    EXPECT_EQ(state.counter.z, 0U);
    EXPECT_EQ(state.counter.w, 0U);
    engine.discard(2 * 4ULL);
    EXPECT_EQ(state.counter.x, 0U);
    EXPECT_EQ(state.counter.y, 2U);
    EXPECT_EQ(state.counter.z, 0U);
    EXPECT_EQ(state.counter.w, 0U);
    state.counter.x = UINT_MAX;
    state.counter.y = UINT_MAX;
    state.counter.z = UINT_MAX;
    engine.discard(1 * 4ULL);
    EXPECT_EQ(state.counter.x, 0U);
    EXPECT_EQ(state.counter.y, 0U);
    EXPECT_EQ(state.counter.z, 0U);
    EXPECT_EQ(state.counter.w, 1U);
    state.counter.x = UINT_MAX;
    state.counter.y = UINT_MAX;
    state.counter.z = UINT_MAX;
    engine.discard(1 * 4ULL);
    EXPECT_EQ(state.counter.x, 0U);
    EXPECT_EQ(state.counter.y, 0U);
    EXPECT_EQ(state.counter.z, 0U);
    EXPECT_EQ(state.counter.w, 2U);
    state.counter.x = 123;
    state.counter.y = 456;
    state.counter.z = 789;
    state.counter.w = 999;
    engine.discard(1 * 4ULL);
    EXPECT_EQ(state.counter.x, 124U);
    EXPECT_EQ(state.counter.y, 456U);
    EXPECT_EQ(state.counter.z, 789U);
    EXPECT_EQ(state.counter.w, 999U);
    state.counter.x = 123;
    state.counter.y = 0;
    state.counter.z = 0;
    state.counter.w = 0;
    engine.discard(1 * 4ULL);
    EXPECT_EQ(state.counter.x, 124U);
    EXPECT_EQ(state.counter.y, 0U);
    EXPECT_EQ(state.counter.z, 0U);
    EXPECT_EQ(state.counter.w, 0U);
    state.counter.x = UINT_MAX - 1;
    state.counter.y = 2;
    state.counter.z = 3;
    state.counter.w = 4;
    engine.discard(((1ull << 32) + 2ull) * 4ULL);
    EXPECT_EQ(state.counter.x, 0U);
    EXPECT_EQ(state.counter.y, 4U);
    EXPECT_EQ(state.counter.z, 3U);
    EXPECT_EQ(state.counter.w, 4U);
}
TEST ( rocrand_philox_prng_state_tests , discard_test ) { rocrand_philox4x32_10_engine_type_test engine ; rocrand_philox4x32_10_engine_type_test :: state_type & state = engine . internal_state_ref ( ) ; EXPECT_EQ ( state . counter . x , 0U ) ; EXPECT_EQ ( state . counter . y , 0U ) ; EXPECT_EQ ( state . counter . z , 0U ) ; EXPECT_EQ ( state . counter . w , 0U ) ; engine . discard ( UINT_MAX * 4ULL ) ; EXPECT_EQ ( state . counter . x , UINT_MAX ) ; EXPECT_EQ ( state . counter . y , 0U ) ; EXPECT_EQ ( state . counter . z , 0U ) ; EXPECT_EQ ( state . counter . w , 0U ) ; engine . discard ( UINT_MAX * 4ULL ) ; EXPECT_EQ ( state . counter . x , UINT_MAX - 1 ) ; EXPECT_EQ ( state . counter . y , 1U ) ; EXPECT_EQ ( state . counter . z , 0U ) ; EXPECT_EQ ( state . counter . w , 0U ) ; engine . discard ( 2 * 4ULL ) ; EXPECT_EQ ( state . counter . x , 0U ) ; EXPECT_EQ ( state . counter . y , 2U ) ; EXPECT_EQ ( state . counter . z , 0U ) ; EXPECT_EQ ( state . counter . w , 0U ) ; state . counter . x = UINT_MAX ; state . counter . y = UINT_MAX ; state . counter . z = UINT_MAX ; engine . discard ( 1 * 4ULL ) ; EXPECT_EQ ( state . counter . x , 0U ) ; EXPECT_EQ ( state . counter . y , 0U ) ; EXPECT_EQ ( state . counter . z , 0U ) ; EXPECT_EQ ( state . counter . w , 1U ) ; state . counter . x = UINT_MAX ; state . counter . y = UINT_MAX ; state . counter . z = UINT_MAX ; engine . discard ( 1 * 4ULL ) ; EXPECT_EQ ( state . counter . x , 0U ) ; EXPECT_EQ ( state . counter . y , 0U ) ; EXPECT_EQ ( state . counter . z , 0U ) ; EXPECT_EQ ( state . counter . w , 2U ) ; state . counter . x = 123 ; state . counter . y = 456 ; state . counter . z = 789 ; state . counter . w = 999 ; engine . discard ( 1 * 4ULL ) ; EXPECT_EQ ( state . counter . x , 124U ) ; EXPECT_EQ ( state . counter . y , 456U ) ; EXPECT_EQ ( state . counter . z , 789U ) ; EXPECT_EQ ( state . counter . w , 999U ) ; state . counter . x = 123 ; state . counter . y = 0 ; state . counter . z = 0 ; state . counter . w = 0 ; engine . discard ( 1 * 4ULL ) ; EXPECT_EQ ( state . counter . x , 124U ) ; EXPECT_EQ ( state . counter . y , 0U ) ; EXPECT_EQ ( state . counter . z , 0U ) ; EXPECT_EQ ( state . counter . w , 0U ) ; state . counter . x = UINT_MAX - 1 ; state . counter . y = 2 ; state . counter . z = 3 ; state . counter . w = 4 ; engine . discard ( ( ( 1ull << 32 ) + 2ull ) * 4ULL ) ; EXPECT_EQ ( state . counter . x , 0U ) ; EXPECT_EQ ( state . counter . y , 4U ) ; EXPECT_EQ ( state . counter . z , 3U ) ; EXPECT_EQ ( state . counter . w , 4U ) ; }
Check if the philox state counter is calculated correctly during
random number generation.
Check if the philox state counter is calculated correctly during random number generation .