test/test_rocrand_sobol32_qrng.cpp
// Check that subsequent generations of different sizes produce one Sobol
// sequence without gaps, no matter how many values are generated per call.
Check that subsequent generations of different sizes produce one Sobol
sequence without gaps, no matter how many values are generated per call.
Check that subsequent generations of different sizes produce one Sobol sequence without gaps no matter how many values are generated per call .
TEST_P(rocrand_sobol32_qrng_continuity, continuity_test)
{
    const unsigned int dimensions = GetParam();
    const std::vector<size_t> sizes0({ 100, 1, 24783, 3, 2, 776543 });
    const std::vector<size_t> sizes1({ 1024, 56, 65536, 623456, 30, 111330 });
    const size_t s0 = std::accumulate(sizes0.cbegin(), sizes0.cend(), std::size_t{0});
    const size_t s1 = std::accumulate(sizes1.cbegin(), sizes1.cend(), std::size_t{0});
    const size_t size0 = s0 * dimensions;
    const size_t size1 = s1 * dimensions;
    unsigned int * data0;
    unsigned int * data1;
    hipMalloc(&data0, sizeof(unsigned int) * size0);
    hipMalloc(&data1, sizeof(unsigned int) * size1);
    rocrand_sobol32 g0;
    rocrand_sobol32 g1;
    g0.set_dimensions(dimensions);
    g1.set_dimensions(dimensions);
    std::vector<unsigned int> host_data0(size0);
    std::vector<unsigned int> host_data1(size1);
    size_t current0 = 0;
    for (size_t s : sizes0)
    {
        g0.generate(data0, s * dimensions);
        for(unsigned int d = 0; d < dimensions; d++)
        {
            hipMemcpy(
                host_data0.data() + s0 * d + current0,
                data0 + d * s,
                sizeof(unsigned int) * s, hipMemcpyDefault);
        }
        current0 += s;
    }
    size_t current1 = 0;
    for (size_t s : sizes1)
    {
        g1.generate(data1, s * dimensions);
        for(unsigned int d = 0; d < dimensions; d++)
        {
            hipMemcpy(
                host_data1.data() + s1 * d + current1,
                data1 + d * s,
                sizeof(unsigned int) * s, hipMemcpyDefault);
        }
        current1 += s;
    }
    for(unsigned int d = 0; d < dimensions; d++)
    {
        for(size_t i = 0; i < std::min(s0, s1); i++)
        {
            ASSERT_EQ(
                host_data0[d * s0 + i],
                host_data1[d * s1 + i]
            );
        }
    }
    hipFree(data0);
    hipFree(data1);
}
TEST_P ( rocrand_sobol32_qrng_continuity , continuity_test ) { const unsigned int dimensions = GetParam ( ) ; const std :: vector < size_t > sizes0 ( { 100 , 1 , 24783 , 3 , 2 , 776543 } ) ; const std :: vector < size_t > sizes1 ( { 1024 , 56 , 65536 , 623456 , 30 , 111330 } ) ; const size_t s0 = std :: accumulate ( sizes0 . cbegin ( ) , sizes0 . cend ( ) , std :: size_t { 0 } ) ; const size_t s1 = std :: accumulate ( sizes1 . cbegin ( ) , sizes1 . cend ( ) , std :: size_t { 0 } ) ; const size_t size0 = s0 * dimensions ; const size_t size1 = s1 * dimensions ; unsigned int * data0 ; unsigned int * data1 ; hipMalloc ( & data0 , sizeof ( unsigned int ) * size0 ) ; hipMalloc ( & data1 , sizeof ( unsigned int ) * size1 ) ; rocrand_sobol32 g0 ; rocrand_sobol32 g1 ; g0 . set_dimensions ( dimensions ) ; g1 . set_dimensions ( dimensions ) ; std :: vector < unsigned int > host_data0 ( size0 ) ; std :: vector < unsigned int > host_data1 ( size1 ) ; size_t current0 = 0 ; for ( size_t s : sizes0 ) { g0 . generate ( data0 , s * dimensions ) ; for ( unsigned int d = 0 ; d < dimensions ; d ++ ) { hipMemcpy ( host_data0 . data ( ) + s0 * d + current0 , data0 + d * s , sizeof ( unsigned int ) * s , hipMemcpyDefault ) ; } current0 += s ; } size_t current1 = 0 ; for ( size_t s : sizes1 ) { g1 . generate ( data1 , s * dimensions ) ; for ( unsigned int d = 0 ; d < dimensions ; d ++ ) { hipMemcpy ( host_data1 . data ( ) + s1 * d + current1 , data1 + d * s , sizeof ( unsigned int ) * s , hipMemcpyDefault ) ; } current1 += s ; } for ( unsigned int d = 0 ; d < dimensions ; d ++ ) { for ( size_t i = 0 ; i < std :: min ( s0 , s1 ) ; i ++ ) { ASSERT_EQ ( host_data0 [ d * s0 + i ] , host_data1 [ d * s1 + i ] ) ; } } hipFree ( data0 ) ; hipFree ( data1 ) ; }
Check that subsequent generations of different sizes produce one Sobol
sequence without gaps, no matter how many values are generated per call.
Check that subsequent generations of different sizes produce one Sobol sequence without gaps no matter how many values are generated per call .
// host_data0 contains all s0 values of dim0, then all s0 values of dim1... // host_data1 contains all s1 values of dim0, then all s1 values of dim1...