#include #include #include #include static const size_t num_samples = 10000; template struct rebind_vector; template struct rebind_vector, U> { typedef typename thrust::detail::allocator_traits alloc_traits; typedef typename alloc_traits::template rebind_alloc new_alloc; typedef thrust::host_vector type; }; template struct rebind_vector, U> { typedef thrust::device_vector::other> type; }; template struct rebind_vector, U> { typedef thrust::universal_vector::other> type; }; #define BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(name, reference_operator, functor) \ template \ void TestFunctionalPlaceholdersBinary##name(void) \ { \ typedef typename Vector::value_type T; \ typedef typename rebind_vector::type bool_vector; \ 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, ==, thrust::equal_to); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(NotEqualTo, !=, thrust::not_equal_to); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(Greater, >, thrust::greater); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(Less, <, thrust::less); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(GreaterEqual, >=, thrust::greater_equal); BINARY_FUNCTIONAL_PLACEHOLDERS_TEST(LessEqual, <=, thrust::less_equal);