CPPuddle
Loading...
Searching...
No Matches
cuda_recycling_allocators.hpp
Go to the documentation of this file.
1// LANL Copyright Notice:
2//
3//© 2026. Triad National Security, LLC. All rights reserved.
4//
5// This program was produced under U.S. Government contract 89233218CNA000001
6// for Los Alamos National Laboratory (LANL), which is operated by Triad
7// National Security, LLC for the U.S. Department of Energy/National Nuclear
8// Security Administration. All rights in the program are reserved by Triad
9// National Security, LLC, and the U.S. Department of Energy/National Nuclear
10// Security Administration. The Government is granted for itself and others
11// acting on its behalf a nonexclusive, paid-up, irrevocable worldwide license
12// in this material to reproduce, prepare. derivative works, distribute copies
13// to the public, perform publicly and display publicly, and to permit others
14// to do so.
15//
16//
17// Distributed under the Boost Software License, Version 1.0. (See accompanying
18// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
19
20#ifndef CUDA_RECYCLING_ALLOCATORS_HPP
21#define CUDA_RECYCLING_ALLOCATORS_HPP
22
24// import underlying cuda allocators used here
26
31
32namespace cppuddle {
33namespace memory_recycling {
34
35// Tell cppuddle how to select the device for the cuda allocators
36namespace device_selection {
38template <typename T>
39struct select_device_functor<T, detail::cuda_pinned_allocator<T>> {
40 void operator()(const size_t device_id) { cudaSetDevice(device_id); }
41};
42
43template <typename T>
44struct select_device_functor<T, detail::cuda_device_allocator<T>> {
45 void operator()(const size_t device_id) { cudaSetDevice(device_id); }
46};
47} // namespace device_selection
48
50template <typename T, std::enable_if_t<std::is_trivial<T>::value, int> = 0>
54template <typename T, std::enable_if_t<std::is_trivial<T>::value, int> = 0>
57
58template <typename T, std::enable_if_t<std::is_trivial<T>::value, int> = 0>
61
62} // namespace memory_recycling
63} // end namespace cppuddle
64#endif
Definition buffer_management.hpp:79
Definition aligned_recycling_allocators.hpp:19
CPPuddle namespace containing the memory recycling functionality.
Definition aligned_recycling_allocators.hpp:17
detail::aggressive_recycle_allocator< T, detail::cuda_managed_memory_allocator< T > > recycle_allocator_cuda_managed
Definition cuda_recycling_allocators.hpp:59
detail::aggressive_recycle_allocator< T, detail::cuda_pinned_allocator< T > > recycle_allocator_cuda_host
Recycling allocator for CUDA pinned host memory.
Definition cuda_recycling_allocators.hpp:51
detail::recycle_allocator< T, detail::cuda_device_allocator< T > > recycle_allocator_cuda_device
Recycling allocator for CUDA device memory.
Definition cuda_recycling_allocators.hpp:55
Definition config.hpp:31
Recycles not only allocations but also the contents of a buffer.
Definition buffer_management.hpp:865
Definition buffer_management.hpp:795
void operator()(const size_t device_id)
Definition cuda_recycling_allocators.hpp:40
void operator()(const size_t device_id)
Definition cuda_recycling_allocators.hpp:45
Default device selector - No MultGPU support.
Definition buffer_management.hpp:69