RMM  23.12
RAPIDS Memory Manager
exec_policy.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-2021, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #pragma once
23 
24 #include <rmm/cuda_stream_view.hpp>
26 
27 #include <rmm/detail/thrust_namespace.h>
28 #include <thrust/system/cuda/execution_policy.h>
29 #include <thrust/version.h>
30 
31 namespace rmm {
42  thrust::detail::execute_with_allocator<rmm::mr::thrust_allocator<char>,
43  thrust::cuda_cub::execute_on_stream_base>;
44 
50  public:
57  explicit exec_policy(cuda_stream_view stream = cuda_stream_default,
60  thrust::cuda::par(rmm::mr::thrust_allocator<char>(stream, mr)).on(stream.value()))
61  {
62  }
63 };
64 
65 #if THRUST_VERSION >= 101600
66 
71  thrust::detail::execute_with_allocator<rmm::mr::thrust_allocator<char>,
72  thrust::cuda_cub::execute_on_stream_nosync_base>;
80  public:
81  explicit exec_policy_nosync(
82  cuda_stream_view stream = cuda_stream_default,
85  thrust::cuda::par_nosync(rmm::mr::thrust_allocator<char>(stream, mr)).on(stream.value()))
86  {
87  }
88 };
89 
90 #else
91 
96  exec_policy;
97 #endif
98  // end of group
100 } // namespace rmm
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:41
Helper class usable as a Thrust CUDA execution policy that uses RMM for temporary memory allocation o...
Definition: exec_policy.hpp:49
exec_policy(cuda_stream_view stream=cuda_stream_default, rmm::mr::device_memory_resource *mr=mr::get_current_device_resource())
Construct a new execution policy object.
Definition: exec_policy.hpp:57
Base class for all libcudf device memory allocation.
Definition: device_memory_resource.hpp:89
device_memory_resource * get_current_device_resource()
Get the memory resource for the current device.
Definition: per_device_resource.hpp:207
thrust_exec_policy_t thrust_exec_policy_nosync_t
Definition: exec_policy.hpp:94
thrust::detail::execute_with_allocator< rmm::mr::thrust_allocator< char >, thrust::cuda_cub::execute_on_stream_base > thrust_exec_policy_t
Synchronous execution policy for allocations using thrust.
Definition: exec_policy.hpp:43
exec_policy exec_policy_nosync
When used with Thrust < 1.16.0, exec_policy_nosync is an alias for exec_policy.
Definition: exec_policy.hpp:96