| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #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 |
| #include <thrust/system/cuda/detail/guarded_cuda_runtime_api.h> |
| #include <thrust/system/cuda/detail/execution_policy.h> |
| #include <thrust/system/cuda/detail/util.h> |
|
|
| #include <thrust/detail/allocator_aware_execution_policy.h> |
|
|
| #if THRUST_CPP_DIALECT >= 2011 |
| # include <thrust/detail/dependencies_aware_execution_policy.h> |
| #endif |
|
|
|
|
| THRUST_NAMESPACE_BEGIN |
| namespace cuda_cub { |
|
|
| template <class Derived> |
| struct execute_on_stream_base : execution_policy<Derived> |
| { |
| private: |
| cudaStream_t stream; |
|
|
| public: |
| __thrust_exec_check_disable__ |
| __host__ __device__ |
| execute_on_stream_base(cudaStream_t stream_ = default_stream()) |
| : stream(stream_){} |
|
|
| THRUST_RUNTIME_FUNCTION |
| Derived |
| on(cudaStream_t const &s) const |
| { |
| Derived result = derived_cast(*this); |
| result.stream = s; |
| return result; |
| } |
|
|
| private: |
| friend __host__ __device__ |
| cudaStream_t |
| get_stream(const execute_on_stream_base &exec) |
| { |
| return exec.stream; |
| } |
| }; |
|
|
| template <class Derived> |
| struct execute_on_stream_nosync_base : execution_policy<Derived> |
| { |
| private: |
| cudaStream_t stream; |
|
|
| public: |
| __host__ __device__ |
| execute_on_stream_nosync_base(cudaStream_t stream_ = default_stream()) |
| : stream(stream_){} |
|
|
| THRUST_RUNTIME_FUNCTION |
| Derived |
| on(cudaStream_t const &s) const |
| { |
| Derived result = derived_cast(*this); |
| result.stream = s; |
| return result; |
| } |
|
|
| private: |
| friend __host__ __device__ |
| cudaStream_t |
| get_stream(const execute_on_stream_nosync_base &exec) |
| { |
| return exec.stream; |
| } |
|
|
| friend __host__ __device__ |
| bool |
| must_perform_optional_stream_synchronization(const execute_on_stream_nosync_base &) |
| { |
| return false; |
| } |
| }; |
|
|
| struct execute_on_stream : execute_on_stream_base<execute_on_stream> |
| { |
| typedef execute_on_stream_base<execute_on_stream> base_t; |
|
|
| __host__ __device__ |
| execute_on_stream() : base_t(){}; |
| __host__ __device__ |
| execute_on_stream(cudaStream_t stream) |
| : base_t(stream){}; |
| }; |
|
|
| struct execute_on_stream_nosync : execute_on_stream_nosync_base<execute_on_stream_nosync> |
| { |
| typedef execute_on_stream_nosync_base<execute_on_stream_nosync> base_t; |
|
|
| __host__ __device__ |
| execute_on_stream_nosync() : base_t(){}; |
| __host__ __device__ |
| execute_on_stream_nosync(cudaStream_t stream) |
| : base_t(stream){}; |
| }; |
|
|
|
|
| struct par_t : execution_policy<par_t>, |
| thrust::detail::allocator_aware_execution_policy< |
| execute_on_stream_base> |
| #if THRUST_CPP_DIALECT >= 2011 |
| , thrust::detail::dependencies_aware_execution_policy< |
| execute_on_stream_base> |
| #endif |
| { |
| typedef execution_policy<par_t> base_t; |
|
|
| __host__ __device__ |
| constexpr par_t() : base_t() {} |
|
|
| typedef execute_on_stream stream_attachment_type; |
|
|
| THRUST_RUNTIME_FUNCTION |
| stream_attachment_type |
| on(cudaStream_t const &stream) const |
| { |
| return execute_on_stream(stream); |
| } |
| }; |
|
|
| struct par_nosync_t : execution_policy<par_nosync_t>, |
| thrust::detail::allocator_aware_execution_policy< |
| execute_on_stream_nosync_base> |
| #if THRUST_CPP_DIALECT >= 2011 |
| , thrust::detail::dependencies_aware_execution_policy< |
| execute_on_stream_nosync_base> |
| #endif |
| { |
| typedef execution_policy<par_nosync_t> base_t; |
|
|
| __host__ __device__ |
| constexpr par_nosync_t() : base_t() {} |
|
|
| typedef execute_on_stream_nosync stream_attachment_type; |
|
|
| THRUST_RUNTIME_FUNCTION |
| stream_attachment_type |
| on(cudaStream_t const &stream) const |
| { |
| return execute_on_stream_nosync(stream); |
| } |
|
|
| private: |
| |
| |
| friend __host__ __device__ |
| bool |
| must_perform_optional_stream_synchronization(const par_nosync_t &) |
| { |
| return false; |
| } |
| }; |
|
|
| THRUST_INLINE_CONSTANT par_t par; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| THRUST_INLINE_CONSTANT par_nosync_t par_nosync; |
| } |
|
|
| namespace system { |
| namespace cuda { |
| using thrust::cuda_cub::par; |
| using thrust::cuda_cub::par_nosync; |
| namespace detail { |
| using thrust::cuda_cub::par_t; |
| using thrust::cuda_cub::par_nosync_t; |
| } |
| } |
| } |
|
|
| namespace cuda { |
| using thrust::cuda_cub::par; |
| using thrust::cuda_cub::par_nosync; |
| } |
|
|
| THRUST_NAMESPACE_END |
|
|
|
|