#include #include #include #include static const size_t num_samples = 10000; template struct rebind_vector; template struct rebind_vector, U> { using alloc_traits = typename cuda::std::allocator_traits; using new_alloc = typename alloc_traits::template rebind_alloc; using type = thrust::host_vector; }; template struct rebind_vector, U> { using type = thrust::device_vector::other>; }; template struct rebind_vector, U> { using type = thrust::universal_vector::other>; }; #define BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(name, reference_operator, functor) \ template \ void TestFunctionalPlaceholdersBinary##name() \ { \ using T = typename Vector::value_type; \ using bool_vector = typename rebind_vector::type; \ Vector lhs = unittest::random_samples(num_samples); \ Vector rhs = unittest::random_samples(num_samples); \ \ bool_vector reference(lhs.size()); \ thrust::transform(lhs.begin(), lhs.end(), rhs.begin(), reference.begin(), functor()); \ \ using namespace thrust::placeholders; \ bool_vector result(lhs.size()); \ thrust::transform(lhs.begin(), lhs.end(), rhs.begin(), result.begin(), _1 reference_operator _2); \ \ ASSERT_EQUAL(reference, result); \ } \ DECLARE_VECTOR_UNITTEST(TestFunctionalPlaceholdersBinary##name); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(EqualTo, ==, ::cuda::std::equal_to); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(NotEqualTo, !=, ::cuda::std::not_equal_to); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(Greater, >, ::cuda::std::greater); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(Less, <, ::cuda::std::less); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(GreaterEqual, >=, ::cuda::std::greater_equal); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(LessEqual, <=, ::cuda::std::less_equal);