| | #pragma once |
| |
|
| | #include <thrust/detail/config.h> |
| |
|
| | #if THRUST_CPP_DIALECT >= 2014 |
| |
|
| | #include <thrust/async/scan.h> |
| |
|
| | #include <thrust/scan.h> |
| |
|
| | #include <async/mixin.h> |
| |
|
| | namespace testing |
| | { |
| | namespace async |
| | { |
| | namespace exclusive_scan |
| | { |
| |
|
| | namespace mixin |
| | { |
| |
|
| | |
| | namespace postfix_args |
| | { |
| |
|
| | template <typename value_type, typename alternate_binary_op = thrust::maximum<>> |
| | struct all_overloads |
| | { |
| | using postfix_args_type = std::tuple< |
| | std::tuple<>, |
| | std::tuple<value_type>, |
| | std::tuple<value_type, alternate_binary_op> |
| | >; |
| |
|
| | static postfix_args_type generate_postfix_args() |
| | { |
| | return postfix_args_type{std::tuple<>{}, |
| | std::make_tuple(value_type{42}), |
| | std::make_tuple(value_type{42}, |
| | alternate_binary_op{})}; |
| | } |
| | }; |
| |
|
| | } |
| |
|
| | |
| | namespace invoke_reference |
| | { |
| |
|
| | template <typename input_value_type, |
| | typename output_value_type = input_value_type> |
| | struct host_synchronous |
| | { |
| | template <typename InputType, |
| | typename OutputType, |
| | typename PostfixArgTuple, |
| | std::size_t... PostfixArgIndices> |
| | static void invoke_reference(InputType const& input, |
| | OutputType& output, |
| | PostfixArgTuple&& postfix_tuple, |
| | std::index_sequence<PostfixArgIndices...>) |
| | { |
| | |
| | thrust::host_vector<input_value_type> host_input(input.cbegin(), |
| | input.cend()); |
| | thrust::host_vector<output_value_type> host_output(host_input.size()); |
| |
|
| | |
| | thrust::exclusive_scan(host_input.cbegin(), |
| | host_input.cend(), |
| | host_output.begin(), |
| | std::get<PostfixArgIndices>( |
| | THRUST_FWD(postfix_tuple))...); |
| |
|
| | |
| | output = host_output; |
| | } |
| | }; |
| |
|
| | } |
| |
|
| | |
| | namespace invoke_async |
| | { |
| |
|
| | struct simple |
| | { |
| | template <typename PrefixArgTuple, |
| | std::size_t... PrefixArgIndices, |
| | typename InputType, |
| | typename OutputType, |
| | typename PostfixArgTuple, |
| | std::size_t... PostfixArgIndices> |
| | static auto invoke_async(PrefixArgTuple&& prefix_tuple, |
| | std::index_sequence<PrefixArgIndices...>, |
| | InputType const& input, |
| | OutputType& output, |
| | PostfixArgTuple&& postfix_tuple, |
| | std::index_sequence<PostfixArgIndices...>) |
| | { |
| | auto e = thrust::async::exclusive_scan( |
| | std::get<PrefixArgIndices>(THRUST_FWD(prefix_tuple))..., |
| | input.cbegin(), |
| | input.cend(), |
| | output.begin(), |
| | std::get<PostfixArgIndices>(THRUST_FWD(postfix_tuple))...); |
| | return e; |
| | } |
| | }; |
| |
|
| | } |
| |
|
| | } |
| | } |
| | } |
| | } |
| |
|
| | #endif |
| |
|