| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #pragma once |
|
|
| #include <thrust/detail/config.h> |
|
|
| #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) |
| # pragma GCC system_header |
| #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) |
| # pragma clang system_header |
| #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) |
| # pragma system_header |
| #endif |
|
|
| #if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC |
| #include <thrust/system/cuda/detail/execution_policy.h> |
|
|
| THRUST_NAMESPACE_BEGIN |
| namespace cuda_cub { |
|
|
| template <class Derived, class ItemsIt, class ResultIt> |
| ResultIt __host__ __device__ |
| reverse_copy(execution_policy<Derived> &policy, |
| ItemsIt first, |
| ItemsIt last, |
| ResultIt result); |
|
|
| template <class Derived, class ItemsIt> |
| void __host__ __device__ |
| reverse(execution_policy<Derived> &policy, |
| ItemsIt first, |
| ItemsIt last); |
|
|
| } |
| THRUST_NAMESPACE_END |
|
|
| #include <thrust/advance.h> |
| #include <thrust/distance.h> |
| #include <thrust/system/cuda/detail/swap_ranges.h> |
| #include <thrust/system/cuda/detail/copy.h> |
| #include <thrust/iterator/reverse_iterator.h> |
|
|
| THRUST_NAMESPACE_BEGIN |
| namespace cuda_cub { |
|
|
| template <class Derived, |
| class ItemsIt, |
| class ResultIt> |
| ResultIt __host__ __device__ |
| reverse_copy(execution_policy<Derived> &policy, |
| ItemsIt first, |
| ItemsIt last, |
| ResultIt result) |
| { |
| return cuda_cub::copy(policy, |
| thrust::make_reverse_iterator(last), |
| thrust::make_reverse_iterator(first), |
| result); |
| } |
|
|
| template <class Derived, |
| class ItemsIt> |
| void __host__ __device__ |
| reverse(execution_policy<Derived> &policy, |
| ItemsIt first, |
| ItemsIt last) |
| { |
| typedef typename thrust::iterator_difference<ItemsIt>::type difference_type; |
|
|
| |
| difference_type N = thrust::distance(first, last); |
| ItemsIt mid(first); |
| thrust::advance(mid, N / 2); |
|
|
| cuda_cub::swap_ranges(policy, first, mid, thrust::make_reverse_iterator(last)); |
| } |
|
|
|
|
| } |
| THRUST_NAMESPACE_END |
| #endif |
|
|