Skip to content

Commit

Permalink
Add overload of get_random_data() for windows (#398)
Browse files Browse the repository at this point in the history
* Add overload of get_random_data() for windows

* Replace workarounds with seed_type modification

* Add modification for Windows
  • Loading branch information
stanleytsang-amd authored Apr 16, 2024
1 parent 370be20 commit 2813b11
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/test_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ std::vector<seed_type> get_seeds()
}

template <class T>
inline auto get_random_data(size_t size, T, T, uint64_t seed) ->
inline auto get_random_data(size_t size, T, T, seed_type seed) ->
typename std::enable_if<std::is_same<T, bool>::value, thrust::host_vector<T>>::type
{
std::random_device rd;
Expand All @@ -165,7 +165,7 @@ inline auto get_random_data(size_t size, T, T, uint64_t seed) ->
}

template <class T>
inline auto get_random_data(size_t size, T min, T max, uint64_t seed) ->
inline auto get_random_data(size_t size, T min, T max, seed_type seed) ->
typename std::enable_if<rocprim::is_integral<T>::value && !std::is_same<T, bool>::value,
thrust::host_vector<T>>::type
{
Expand All @@ -179,7 +179,7 @@ inline auto get_random_data(size_t size, T min, T max, uint64_t seed) ->
}

template <class T>
inline auto get_random_data(size_t size, T min, T max, uint64_t seed) ->
inline auto get_random_data(size_t size, T min, T max, seed_type seed) ->
typename std::enable_if<rocprim::is_floating_point<T>::value, thrust::host_vector<T>>::type
{
std::random_device rd;
Expand All @@ -193,7 +193,7 @@ inline auto get_random_data(size_t size, T min, T max, uint64_t seed) ->

#if defined(_WIN32) && defined(__clang__)
template <>
inline thrust::host_vector<unsigned char> get_random_data(size_t size, unsigned char min, unsigned char max, int seed_value)
inline thrust::host_vector<unsigned char> get_random_data(size_t size, unsigned char min, unsigned char max, seed_type seed_value)
{
std::random_device rd;
std::default_random_engine gen(rd());
Expand All @@ -205,7 +205,7 @@ inline thrust::host_vector<unsigned char> get_random_data(size_t size, unsigned
}

template <>
inline thrust::host_vector<signed char> get_random_data(size_t size, signed char min, signed char max, int seed_value)
inline thrust::host_vector<signed char> get_random_data(size_t size, signed char min, signed char max, seed_type seed_value)
{
std::random_device rd;
std::default_random_engine gen(rd());
Expand Down Expand Up @@ -625,4 +625,4 @@ template<>
struct precision_threshold<rocprim::half>
{
static constexpr float percentage = 0.075f;
};
};

0 comments on commit 2813b11

Please sign in to comment.