test/test_rocrand_philox_prng.cpp
// Checks if generators with the same seed and in the same state
// generate the same numbers
Checks if generators with the same seed and in the same state
generate the same numbers
Checks if generators with the same seed and in the same state generate the same numbers
TEST(rocrand_philox_prng_tests, same_seed_test)
{
    const unsigned long long seed = 0xdeadbeefdeadbeefULL;
    const size_t size = 1024;
    unsigned int * data;
    HIP_CHECK(hipMallocHelper(&data, sizeof(unsigned int) * size));
    rocrand_philox4x32_10 g0, g1;
    g0.set_seed(seed);
    g1.set_seed(seed);
    ROCRAND_CHECK(g0.generate(data, size));
    HIP_CHECK(hipDeviceSynchronize());
    unsigned int g0_host_data[size];
    HIP_CHECK(hipMemcpy(g0_host_data, data, sizeof(unsigned int) * size, hipMemcpyDeviceToHost));
    HIP_CHECK(hipDeviceSynchronize());
    ROCRAND_CHECK(g1.generate(data, size));
    HIP_CHECK(hipDeviceSynchronize());
    unsigned int g1_host_data[size];
    HIP_CHECK(hipMemcpy(g1_host_data, data, sizeof(unsigned int) * size, hipMemcpyDeviceToHost));
    HIP_CHECK(hipDeviceSynchronize());
    for(size_t i = 0; i < size; i++)
    {
        ASSERT_EQ(g0_host_data[i], g1_host_data[i]);
    }
    HIP_CHECK(hipFree(data));
}
TEST ( rocrand_philox_prng_tests , same_seed_test ) { const unsigned long long seed = 0xdeadbeefdeadbeefULL ; const size_t size = 1024 ; unsigned int * data ; HIP_CHECK ( hipMallocHelper ( & data , sizeof ( unsigned int ) * size ) ) ; rocrand_philox4x32_10 g0 , g1 ; g0 . set_seed ( seed ) ; g1 . set_seed ( seed ) ; ROCRAND_CHECK ( g0 . generate ( data , size ) ) ; HIP_CHECK ( hipDeviceSynchronize ( ) ) ; unsigned int g0_host_data [ size ] ; HIP_CHECK ( hipMemcpy ( g0_host_data , data , sizeof ( unsigned int ) * size , hipMemcpyDeviceToHost ) ) ; HIP_CHECK ( hipDeviceSynchronize ( ) ) ; ROCRAND_CHECK ( g1 . generate ( data , size ) ) ; HIP_CHECK ( hipDeviceSynchronize ( ) ) ; unsigned int g1_host_data [ size ] ; HIP_CHECK ( hipMemcpy ( g1_host_data , data , sizeof ( unsigned int ) * size , hipMemcpyDeviceToHost ) ) ; HIP_CHECK ( hipDeviceSynchronize ( ) ) ; for ( size_t i = 0 ; i < size ; i ++ ) { ASSERT_EQ ( g0_host_data [ i ] , g1_host_data [ i ] ) ; } HIP_CHECK ( hipFree ( data ) ) ; }
Checks if generators with the same seed and in the same state
generate the same numbers
Checks if generators with the same seed and in the same state generate the same numbers
// Device side data // Generators // Set same seeds // Generate using g0 and copy to host // Generate using g1 and copy to host // Numbers generated using same generator with same // seed should be the same