prefetch.hpp
1 /*
2  * Copyright (c) 2024-2025, 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 
17 #pragma once
18 
20 
21 #include <rmm/device_uvector.hpp>
22 
23 #include <atomic>
24 
25 namespace CUDF_EXPORT cudf {
26 namespace prefetch {
27 
28 namespace detail {
29 
30 std::atomic_bool& enabled();
31 
32 std::atomic_bool& debug();
33 
42 void prefetch(void const* ptr,
43  std::size_t size,
44  rmm::cuda_stream_view stream,
46 
61 cudaError_t prefetch_noexcept(
62  void const* ptr,
63  std::size_t size,
64  rmm::cuda_stream_view stream,
65  rmm::cuda_device_id device_id = rmm::get_current_cuda_device()) noexcept;
66 
77 template <typename T>
78 void prefetch(rmm::device_uvector<T> const& v,
79  rmm::cuda_stream_view stream,
80  rmm::cuda_device_id device_id = rmm::get_current_cuda_device())
81 {
82  if (v.is_empty()) { return; }
83  prefetch(v.data(), v.size(), stream, device_id);
84 }
85 
86 } // namespace detail
87 
94 void enable() noexcept;
95 
99 void disable() noexcept;
100 
106 void enable_debugging() noexcept;
107 
113 void disable_debugging() noexcept;
114 
115 } // namespace prefetch
116 } // namespace CUDF_EXPORT cudf
cuda_device_id get_current_cuda_device()
void prefetch(void const *ptr, std::size_t size, rmm::cuda_device_id device, rmm::cuda_stream_view stream)
cuDF interfaces
Definition: host_udf.hpp:37