Formatting fixed.
Reformatted.
MODIFY
test/test_generate.cpp
test/test_generate.cpp
// HIP API
#if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_HCC
+
#include <hip/hip_runtime.h>
#include <hip/hip_runtime_api.h>
-#include "test_utils.hpp"
#include "test_assertions.hpp"
+#include "test_utils.hpp"
#define HIP_CHECK(condition) ASSERT_EQ(condition, hipSuccess)
#endif // THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_HCC
@@ -44,19 +45,25 @@ __THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN
#if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_HCC
-template <class InputType> struct Params { using input_type = InputType; };
+template<class InputType> struct Params
+{
+ using input_type = InputType;
+};
-template <class Params> class GenerateTests : public ::testing::Test {
+template<class Params> class GenerateTests : public ::testing::Test
+{
public:
using input_type = typename Params::input_type;
};
-template <class Params> class GenerateVectorTests : public ::testing::Test {
+template<class Params> class GenerateVectorTests : public ::testing::Test
+{
public:
using input_type = typename Params::input_type;
};
-template <class Params> class GenerateVariablesTests : public ::testing::Test {
+template<class Params> class GenerateVariablesTests : public ::testing::Test
+{
public:
using input_type = typename Params::input_type;
};
@@ -99,18 +106,29 @@ TYPED_TEST_CASE(GenerateTests, GenerateTestsParams);
TYPED_TEST_CASE(GenerateVectorTests, VectorParams);
TYPED_TEST_CASE(GenerateVariablesTests, GenerateTestsVariableParams);
-template <typename T> struct return_value {
+TEST(ReplaceTests, UsingHip)
+{
+ ASSERT_EQ(THRUST_DEVICE_SYSTEM, THRUST_DEVICE_SYSTEM_HIP);
+}
+
+template<typename T> struct return_value
+{
T val;
- return_value(void) {}
- return_value(T v) : val(v) {}
+ return_value(void)
+ {
+ }
- __host__ __device__ T operator()(void) { return val; }
-};
+ return_value(T v) :
+ val(v)
+ {
+ }
-TEST(ReplaceTests, UsingHip) {
- ASSERT_EQ(THRUST_DEVICE_SYSTEM, THRUST_DEVICE_SYSTEM_HIP);
+ __host__ __device__ T operator()(void)
+ {
+ return val;
}
+};
TYPED_TEST(GenerateVectorTests, TestGenerateSimple)
{
@@ -132,9 +150,9 @@ TYPED_TEST(GenerateVectorTests, TestGenerateSimple)
ASSERT_EQ(result[4], value);
}
-template <typename ForwardIterator, typename Generator>
-__host__ __device__ void generate(my_system &system, ForwardIterator,
- ForwardIterator, Generator) {
+template<typename ForwardIterator, typename Generator> __host__ __device__ void
+generate(my_system& system, ForwardIterator, ForwardIterator, Generator)
+{
system.validate_dispatch();
}
@@ -148,9 +166,9 @@ TEST(GenerateTests, TestGenerateDispatchExplicit)
ASSERT_EQ(true, sys.is_valid());
}
-template <typename ForwardIterator, typename Generator>
-__host__ __device__ void generate(my_tag, ForwardIterator first,
- ForwardIterator, Generator) {
+template<typename ForwardIterator, typename Generator> __host__ __device__ void
+generate(my_tag, ForwardIterator first, ForwardIterator, Generator)
+{
*first = 13;
}
@@ -158,8 +176,8 @@ TEST(GenerateTests, TestGenerateDispatchImplicit)
{
thrust::device_vector<int> vec(1);
- thrust::generate(thrust::retag<my_tag>(vec.begin()),
- thrust::retag<my_tag>(vec.end()), 0);
+ thrust::generate(
+ thrust::retag<my_tag>(vec.begin()), thrust::retag<my_tag>(vec.end()), 0);
ASSERT_EQ(13, vec.front());
}
@@ -170,7 +188,8 @@ TYPED_TEST(GenerateVariablesTests, TestGenerate)
using T = typename Vector::value_type;
const std::vector<size_t> sizes = get_sizes();
- for (auto size : sizes) {
+ for (auto size : sizes)
+ {
thrust::host_vector<T> h_result(size);
thrust::device_vector<T> d_result(size);
@@ -222,9 +241,9 @@ TYPED_TEST(GenerateVectorTests, TestGenerateNSimple)
}
template<typename ForwardIterator, typename Size, typename Generator>
-__host__ __device__ ForwardIterator generate_n(my_system &system,
- ForwardIterator first, Size,
- Generator) {
+__host__ __device__ ForwardIterator
+generate_n(my_system& system, ForwardIterator first, Size, Generator)
+{
system.validate_dispatch();
return first;
}
@@ -240,8 +259,9 @@ TEST(GenerateTests, TestGenerateNDispatchExplicit)
}
template<typename ForwardIterator, typename Size, typename Generator>
-__host__ __device__ ForwardIterator generate_n(my_tag, ForwardIterator first,
- Size, Generator) {
+__host__ __device__ ForwardIterator
+generate_n(my_tag, ForwardIterator first, Size, Generator)
+{
*first = 13;
return first;
}
@@ -261,17 +281,16 @@ TYPED_TEST(GenerateVariablesTests, TestGenerateNToDiscardIterator)
using T = typename Vector::value_type;
const std::vector<size_t> sizes = get_sizes();
- for (auto size : sizes) {
+ for (auto size : sizes)
+ {
T value = 13;
return_value<T> f(value);
- thrust::discard_iterator<thrust::host_system_tag> h_result =
- thrust::generate_n(thrust::discard_iterator<thrust::host_system_tag>(),
- size, f);
+ thrust::discard_iterator<thrust::host_system_tag> h_result = thrust::generate_n(
+ thrust::discard_iterator<thrust::host_system_tag>(), size, f);
- thrust::discard_iterator<thrust::device_system_tag> d_result =
- thrust::generate_n(
+ thrust::discard_iterator<thrust::device_system_tag> d_result = thrust::generate_n(
thrust::discard_iterator<thrust::device_system_tag>(), size, f);
thrust::discard_iterator<> reference(size);

Formatting fixed.

Reformatted.