@@ -43,12 +43,51 @@ __host__ __device__ constexpr bool test_set_counter()
4343 return true ;
4444}
4545
46+ __host__ __device__ constexpr bool test_against_reference ()
47+ {
48+ // reference values obtained from other standard library implementations
49+ const int seeds[] = {10823018 , 0 , 23 };
50+ const int discards[] = {0 , 5 , 100 };
51+ const cuda::std::uint64_t reference_values_64[] = {
52+ 597860052874975753ull ,
53+ 16480731654955167298ull ,
54+ 4676222276634405366ull ,
55+ 1609277786247541068ull ,
56+ 4455796210202625458ull ,
57+ 12591023382997339072ull ,
58+ 13350274857560636235ull ,
59+ 5430341342746607840ull ,
60+ 4983921884708484958ull };
61+ const cuda::std::uint32_t reference_values_32[] = {
62+ 1514423753u , 254961463u , 4167151386u , 1713891541u , 1555169499u , 444026393u , 1368340107u , 2016696101u , 1090885419u };
63+
64+ int ref_index = 0 ;
65+ for (auto seed : seeds)
66+ {
67+ for (auto discard : discards)
68+ {
69+ cuda::std::philox4x64 rng (seed);
70+ cuda::std::philox4x32 rng32 (seed);
71+ rng.discard (discard);
72+ rng32.discard (discard);
73+ assert (rng () == reference_values_64[ref_index]);
74+ assert (rng32 () == reference_values_32[ref_index]);
75+ ref_index++;
76+ }
77+ }
78+ return true ;
79+ }
80+
4681__host__ __device__ constexpr bool test ()
4782{
4883 test_engine<cuda::std::philox4x32, 1955073260u >();
4984 test_engine<cuda::std::philox4x64, 3409172418970261260ull >();
5085 test_set_counter<cuda::std::philox4x32>();
86+ static_assert (test_set_counter<cuda::std::philox4x32>());
5187 test_set_counter<cuda::std::philox4x64>();
88+ static_assert (test_set_counter<cuda::std::philox4x64>());
89+ test_against_reference ();
90+ static_assert (test_against_reference ());
5291 return true ;
5392}
5493
0 commit comments