| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #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 <iterator> |
| #include <thrust/system/cuda/config.h> |
|
|
| #include <thrust/system/cuda/detail/for_each.h> |
| #include <thrust/distance.h> |
|
|
| THRUST_NAMESPACE_BEGIN |
| namespace cuda_cub { |
|
|
| |
| template <class Generator> |
| struct generate_f |
| { |
| Generator generator; |
|
|
| THRUST_FUNCTION |
| generate_f(Generator generator_) : generator(generator_) {} |
|
|
| template<class T> |
| THRUST_DEVICE_FUNCTION void operator()(T const& value) |
| { |
| T & lvalue = const_cast<T&>(value); |
| lvalue = generator(); |
| } |
| }; |
|
|
| |
| template <class Derived, |
| class OutputIt, |
| class Size, |
| class Generator> |
| OutputIt __host__ __device__ |
| generate_n(execution_policy<Derived> &policy, |
| OutputIt result, |
| Size count, |
| Generator generator) |
| { |
| return cuda_cub::for_each_n(policy, |
| result, |
| count, |
| generate_f<Generator>(generator)); |
| } |
|
|
| |
| template <class Derived, |
| class OutputIt, |
| class Generator> |
| void __host__ __device__ |
| generate(execution_policy<Derived> &policy, |
| OutputIt first, |
| OutputIt last, |
| Generator generator) |
| { |
| cuda_cub::generate_n(policy, first, thrust::distance(first, last), generator); |
| } |
|
|
| } |
| THRUST_NAMESPACE_END |
| #endif |
|
|