// Wrap thrust and cub in different enclosing namespaces // (In practice, you probably want these to be the same, in which case just // set THRUST_CUB_WRAPPED_NAMESPACE to set both). #define THRUST_WRAPPED_NAMESPACE wrap_thrust #define CUB_WRAPPED_NAMESPACE wrap_cub #include #include #include #include #include #include // Test that we can use a few common utilities and algorithms from a wrapped // namespace at runtime. More extensive testing is performed by the header // tests and the check_namespace.cmake test. void TestWrappedNamespace() { const std::size_t n = 2048; const auto in_1_begin = ::wrap_thrust::thrust::make_constant_iterator(12); const auto in_2_begin = ::wrap_thrust::thrust::make_counting_iterator(1024); // Check that the qualifier resolves properly: THRUST_NS_QUALIFIER::device_vector d_out(n); ::wrap_thrust::thrust::transform(in_1_begin, in_1_begin + n, in_2_begin, d_out.begin(), ::wrap_thrust::thrust::plus<>{}); ::wrap_thrust::thrust::host_vector h_out(d_out); for (std::size_t i = 0; i < n; ++i) { ASSERT_EQUAL(h_out[i], static_cast(i) + 1024 + 12); } } DECLARE_UNITTEST(TestWrappedNamespace);