Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix conversion warning and missing namespace #124

Merged
merged 2 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions test/stdgpu/algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void
thread_check_min_max_integer(const stdgpu::index_t iterations)
{
// Generate true random numbers
size_t seed = test_utils::random_thread_seed();
std::size_t seed = test_utils::random_thread_seed();

std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));
std::uniform_int_distribution<T> dist(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
Expand Down Expand Up @@ -184,7 +184,7 @@ void
thread_check_min_max_float(const stdgpu::index_t iterations)
{
// Generate true random numbers
size_t seed = test_utils::random_thread_seed();
std::size_t seed = test_utils::random_thread_seed();

std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));
std::uniform_real_distribution<T> dist(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
Expand Down Expand Up @@ -228,7 +228,7 @@ void
thread_check_clamp_integer(const stdgpu::index_t iterations)
{
// Generate true random numbers
size_t seed = test_utils::random_thread_seed();
std::size_t seed = test_utils::random_thread_seed();

std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));
std::uniform_int_distribution<T> dist(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
Expand Down Expand Up @@ -298,7 +298,7 @@ void
thread_check_clamp_float(const stdgpu::index_t iterations)
{
// Generate true random numbers
size_t seed = test_utils::random_thread_seed();
std::size_t seed = test_utils::random_thread_seed();

std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));
std::uniform_real_distribution<T> dist(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
Expand Down
4 changes: 2 additions & 2 deletions test/stdgpu/cmath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ TEST_F(stdgpu_cmath, abs_infinity)
void
thread_positive_values(const stdgpu::index_t iterations)
{
size_t seed = test_utils::random_thread_seed();
std::size_t seed = test_utils::random_thread_seed();

std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));
std::uniform_real_distribution<float> dist(std::numeric_limits<float>::min(), std::numeric_limits<float>::max());
Expand All @@ -86,7 +86,7 @@ TEST_F(stdgpu_cmath, abs_positive_values)
void
thread_negative_values(const stdgpu::index_t iterations)
{
size_t seed = test_utils::random_thread_seed();
std::size_t seed = test_utils::random_thread_seed();

std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));
std::uniform_real_distribution<float> dist(std::numeric_limits<float>::lowest(), -std::numeric_limits<float>::min());
Expand Down
6 changes: 3 additions & 3 deletions test/stdgpu/cuda/atomic.cu
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class random_float
{
public:
STDGPU_HOST_DEVICE
random_float(const stdgpu::index_t seed,
random_float(const std::size_t seed,
const float min,
const float max)
: _seed(seed),
Expand All @@ -187,15 +187,15 @@ class random_float
STDGPU_HOST_DEVICE float
operator()(const stdgpu::index_t n) const
{
thrust::default_random_engine rng(_seed);
thrust::default_random_engine rng(static_cast<thrust::default_random_engine::result_type>(_seed));
thrust::uniform_real_distribution<float> dist(_min, _max);
rng.discard(n);

return dist(rng);
}

private:
stdgpu::index_t _seed;
std::size_t _seed;
float _min, _max;
};

Expand Down
46 changes: 23 additions & 23 deletions test/stdgpu/cuda/bit.cu
Original file line number Diff line number Diff line change
Expand Up @@ -44,90 +44,90 @@ class stdgpu_cuda_bit : public ::testing::Test

struct bit_width_functor
{
STDGPU_DEVICE_ONLY size_t
operator()(const size_t i) const
STDGPU_DEVICE_ONLY std::size_t
operator()(const std::size_t i) const
{
return stdgpu::cuda::bit_width(static_cast<unsigned long long>(1) << i);
}
};

TEST_F(stdgpu_cuda_bit, bit_width)
{
size_t* powers = createDeviceArray<size_t>(std::numeric_limits<size_t>::digits);
std::size_t* powers = createDeviceArray<std::size_t>(std::numeric_limits<std::size_t>::digits);
thrust::sequence(stdgpu::device_begin(powers), stdgpu::device_end(powers));

thrust::transform(stdgpu::device_begin(powers), stdgpu::device_end(powers),
stdgpu::device_begin(powers),
bit_width_functor());

size_t* host_powers = copyCreateDevice2HostArray<size_t>(powers, std::numeric_limits<size_t>::digits);
std::size_t* host_powers = copyCreateDevice2HostArray<std::size_t>(powers, std::numeric_limits<std::size_t>::digits);

for (size_t i = 0; i < std::numeric_limits<size_t>::digits; ++i)
for (std::size_t i = 0; i < std::numeric_limits<std::size_t>::digits; ++i)
{
EXPECT_EQ(host_powers[i], static_cast<size_t>(i + 1));
EXPECT_EQ(host_powers[i], static_cast<std::size_t>(i + 1));
}

destroyDeviceArray<size_t>(powers);
destroyHostArray<size_t>(host_powers);
destroyDeviceArray<std::size_t>(powers);
destroyHostArray<std::size_t>(host_powers);
}


struct popcount_pow2
{
STDGPU_DEVICE_ONLY size_t
operator()(const size_t i) const
STDGPU_DEVICE_ONLY std::size_t
operator()(const std::size_t i) const
{
return stdgpu::cuda::popcount(static_cast<unsigned long long>(1) << i);
}
};

TEST_F(stdgpu_cuda_bit, popcount_pow2)
{
size_t* powers = createDeviceArray<size_t>(std::numeric_limits<size_t>::digits);
std::size_t* powers = createDeviceArray<std::size_t>(std::numeric_limits<std::size_t>::digits);
thrust::sequence(stdgpu::device_begin(powers), stdgpu::device_end(powers));

thrust::transform(stdgpu::device_begin(powers), stdgpu::device_end(powers),
stdgpu::device_begin(powers),
popcount_pow2());

size_t* host_powers = copyCreateDevice2HostArray<size_t>(powers, std::numeric_limits<size_t>::digits);
std::size_t* host_powers = copyCreateDevice2HostArray<std::size_t>(powers, std::numeric_limits<std::size_t>::digits);

for (size_t i = 0; i < std::numeric_limits<size_t>::digits; ++i)
for (std::size_t i = 0; i < std::numeric_limits<std::size_t>::digits; ++i)
{
EXPECT_EQ(host_powers[i], 1);
}

destroyDeviceArray<size_t>(powers);
destroyHostArray<size_t>(host_powers);
destroyDeviceArray<std::size_t>(powers);
destroyHostArray<std::size_t>(host_powers);
}


struct popcount_pow2m1
{
STDGPU_DEVICE_ONLY size_t
operator()(const size_t i) const
STDGPU_DEVICE_ONLY std::size_t
operator()(const std::size_t i) const
{
return stdgpu::popcount((static_cast<size_t>(1) << i) - 1);
return stdgpu::popcount((static_cast<std::size_t>(1) << i) - 1);
}
};

TEST_F(stdgpu_cuda_bit, popcount_pow2m1)
{
size_t* powers = createDeviceArray<size_t>(std::numeric_limits<size_t>::digits);
std::size_t* powers = createDeviceArray<std::size_t>(std::numeric_limits<std::size_t>::digits);
thrust::sequence(stdgpu::device_begin(powers), stdgpu::device_end(powers));

thrust::transform(stdgpu::device_begin(powers), stdgpu::device_end(powers),
stdgpu::device_begin(powers),
popcount_pow2m1());

size_t* host_powers = copyCreateDevice2HostArray<size_t>(powers, std::numeric_limits<size_t>::digits);
std::size_t* host_powers = copyCreateDevice2HostArray<std::size_t>(powers, std::numeric_limits<std::size_t>::digits);

for (size_t i = 0; i < std::numeric_limits<size_t>::digits; ++i)
for (std::size_t i = 0; i < std::numeric_limits<std::size_t>::digits; ++i)
{
EXPECT_EQ(host_powers[i], i);
}

destroyDeviceArray<size_t>(powers);
destroyHostArray<size_t>(host_powers);
destroyDeviceArray<std::size_t>(powers);
destroyHostArray<std::size_t>(host_powers);
}

4 changes: 2 additions & 2 deletions test/stdgpu/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ check_integer_random()
const stdgpu::index_t N = 1000000;

// Generate true random numbers
size_t seed = test_utils::random_seed();
std::size_t seed = test_utils::random_seed();

std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));
std::uniform_int_distribution<T> dist(std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
Expand Down Expand Up @@ -222,7 +222,7 @@ check_floating_point_random()
const stdgpu::index_t N = 1000000;

// Generate true random numbers
size_t seed = test_utils::random_seed();
std::size_t seed = test_utils::random_seed();

std::default_random_engine rng(static_cast<std::default_random_engine::result_type>(seed));
std::uniform_real_distribution<T> dist(static_cast<T>(-1e38), static_cast<T>(1e38));
Expand Down
16 changes: 8 additions & 8 deletions test/stdgpu/iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ TEST_F(stdgpu_iterator, size_host_void)

TEST_F(stdgpu_iterator, size_nullptr_void)
{
EXPECT_EQ(stdgpu::size((void*)nullptr), static_cast<size_t>(0));
EXPECT_EQ(stdgpu::size((void*)nullptr), static_cast<std::size_t>(0));
}


TEST_F(stdgpu_iterator, size_device)
{
int* array = createDeviceArray<int>(42);

EXPECT_EQ(stdgpu::size(array), static_cast<size_t>(42));
EXPECT_EQ(stdgpu::size(array), static_cast<std::size_t>(42));

destroyDeviceArray<int>(array);
}
Expand All @@ -209,23 +209,23 @@ TEST_F(stdgpu_iterator, size_host)
{
int* array_result = createHostArray<int>(42);

EXPECT_EQ(stdgpu::size(array_result), static_cast<size_t>(42));
EXPECT_EQ(stdgpu::size(array_result), static_cast<std::size_t>(42));

destroyHostArray<int>(array_result);
}


TEST_F(stdgpu_iterator, size_nullptr)
{
EXPECT_EQ(stdgpu::size((int*)nullptr), static_cast<size_t>(0));
EXPECT_EQ(stdgpu::size((int*)nullptr), static_cast<std::size_t>(0));
}


TEST_F(stdgpu_iterator, size_device_shifted)
{
int* array = createDeviceArray<int>(42);

EXPECT_EQ(stdgpu::size(array + 24), static_cast<size_t>(0));
EXPECT_EQ(stdgpu::size(array + 24), static_cast<std::size_t>(0));

destroyDeviceArray<int>(array);
}
Expand All @@ -235,7 +235,7 @@ TEST_F(stdgpu_iterator, size_host_shifted)
{
int* array_result = createHostArray<int>(42);

EXPECT_EQ(stdgpu::size(array_result + 24), static_cast<size_t>(0));
EXPECT_EQ(stdgpu::size(array_result + 24), static_cast<std::size_t>(0));

destroyHostArray<int>(array_result);
}
Expand All @@ -245,7 +245,7 @@ TEST_F(stdgpu_iterator, size_device_wrong_alignment)
{
int* array = createDeviceArray<int>(1);

EXPECT_EQ(stdgpu::size(reinterpret_cast<size_t*>(array)), static_cast<size_t>(0));
EXPECT_EQ(stdgpu::size(reinterpret_cast<std::size_t*>(array)), static_cast<std::size_t>(0));

destroyDeviceArray<int>(array);
}
Expand All @@ -255,7 +255,7 @@ TEST_F(stdgpu_iterator, size_host_wrong_alignment)
{
int* array_result = createHostArray<int>(1);

EXPECT_EQ(stdgpu::size(reinterpret_cast<size_t*>(array_result)), static_cast<size_t>(0));
EXPECT_EQ(stdgpu::size(reinterpret_cast<std::size_t*>(array_result)), static_cast<std::size_t>(0));

destroyHostArray<int>(array_result);
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace test_utils

}

return static_cast<size_t>(std::chrono::system_clock::now().time_since_epoch().count());
return static_cast<std::size_t>(std::chrono::system_clock::now().time_since_epoch().count());
}


Expand Down