CPPuddle
Loading...
Searching...
No Matches
cuda_recycling_allocators.hpp
Go to the documentation of this file.
1// Copyright (c) 2020-2024 Gregor Daiß
2//
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef CUDA_RECYCLING_ALLOCATORS_HPP
7#define CUDA_RECYCLING_ALLOCATORS_HPP
8
10// import cuda_pinned_allocator and cuda_device_allocator
12
17
18namespace cppuddle {
19namespace memory_recycling {
20
21// Tell cppuddle how to select the device for the cuda allocators
22namespace device_selection {
24template <typename T>
25struct select_device_functor<T, detail::cuda_pinned_allocator<T>> {
26 void operator()(const size_t device_id) { cudaSetDevice(device_id); }
27};
29template <typename T>
30struct select_device_functor<T, detail::cuda_device_allocator<T>> {
31 void operator()(const size_t device_id) { cudaSetDevice(device_id); }
32};
33} // namespace device_selection
34
36template <typename T, std::enable_if_t<std::is_trivial<T>::value, int> = 0>
40template <typename T, std::enable_if_t<std::is_trivial<T>::value, int> = 0>
43
44} // namespace memory_recycling
45} // end namespace cppuddle
46#endif
Definition config.hpp:31
Recycles not only allocations but also the contents of a buffer.
Definition buffer_management.hpp:840
Definition buffer_management.hpp:770
void operator()(const size_t device_id)
Definition cuda_recycling_allocators.hpp:26
void operator()(const size_t device_id)
Definition cuda_recycling_allocators.hpp:31
Default device selector - No MultGPU support.
Definition buffer_management.hpp:55