Skip to content

Commit 91b4b43

Browse files
committed
Refactor out some calls to rand() in tests.
1 parent 6ab779a commit 91b4b43

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

testing/stable_sort_by_key_large.cu

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ void _TestStableSortByKeyWithLargeKeys(void)
2525

2626
for(size_t i = 0; i < n; i++)
2727
{
28-
h_keys[i] = FixedVector<T,N>(static_cast<T>(rand()));
29-
h_vals[i] = static_cast<unsigned int>(i);
28+
const auto uint_i = static_cast<unsigned int>(i);
29+
const auto rand_int = unittest::generate_random_integer<T>()(uint_i);
30+
h_keys[i] = FixedVector<T,N>(rand_int);
31+
h_vals[i] = uint_i;
3032
}
3133

3234
thrust::device_vector< FixedVector<T,N> > d_keys = h_keys;
@@ -69,7 +71,10 @@ void _TestStableSortByKeyWithLargeValues(void)
6971

7072
for(size_t i = 0; i < n; i++)
7173
{
72-
h_keys[i] = static_cast<unsigned int>(rand());
74+
const auto uint_i = static_cast<unsigned int>(i);
75+
const auto rand_int =
76+
unittest::generate_random_integer<unsigned int>()(uint_i);
77+
h_keys[i] = rand_int;
7378
h_vals[i] = FixedVector<T,N>(static_cast<T>(i));
7479
}
7580

@@ -120,7 +125,9 @@ void _TestStableSortByKeyWithLargeKeysAndValues(void)
120125

121126
for(size_t i = 0; i < n; i++)
122127
{
123-
h_keys[i] = FixedVector<T,N>(static_cast<T>(rand()));
128+
const auto uint_i = static_cast<unsigned int>(i);
129+
const auto rand_int = unittest::generate_random_integer<T>()(uint_i);
130+
h_keys[i] = FixedVector<T,N>(rand_int);
124131
h_vals[i] = FixedVector<T,N>(static_cast<T>(i));
125132
}
126133

0 commit comments

Comments
 (0)