| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #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/util.h> |
| #include <thrust/system/cuda/detail/parallel_for.h> |
| #include <thrust/distance.h> |
|
|
| THRUST_NAMESPACE_BEGIN |
| namespace cuda_cub { |
|
|
| namespace __fill { |
|
|
| |
| template<class Iterator, class T> |
| struct functor |
| { |
| Iterator it; |
| T value; |
|
|
| THRUST_FUNCTION |
| functor(Iterator it, T value) |
| : it(it), value(value) {} |
|
|
| template<class Size> |
| THRUST_DEVICE_FUNCTION void operator()(Size idx) |
| { |
| it[idx] = value; |
| } |
| }; |
|
|
| } |
|
|
| template <class Derived, class OutputIterator, class Size, class T> |
| OutputIterator __host__ __device__ |
| fill_n(execution_policy<Derived>& policy, |
| OutputIterator first, |
| Size count, |
| const T& value) |
| { |
| cuda_cub::parallel_for(policy, |
| __fill::functor<OutputIterator, T>( |
| first, |
| value), |
| count); |
|
|
| return first + count; |
| } |
|
|
| template <class Derived, class ForwardIterator, class T> |
| void __host__ __device__ |
| fill(execution_policy<Derived>& policy, |
| ForwardIterator first, |
| ForwardIterator last, |
| const T& value) |
| { |
| cuda_cub::fill_n(policy, first, thrust::distance(first,last), value); |
| } |
|
|
|
|
| } |
| THRUST_NAMESPACE_END |
| #endif |
|
|