CPPuddle
hip_recycling_device_buffer.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 HIP_RECYCLING_BUFFER_HPP
7 #define HIP_RECYCLING_BUFFER_HPP
8 
9 // import recycle_allocator_hip_device
11 
15 //
16 namespace cppuddle {
17 namespace memory_recycling {
18 
21 template <typename T, std::enable_if_t<std::is_trivial<T>::value, int> = 0>
26 
27  hip_device_buffer(size_t number_of_elements, size_t device_id)
29  assert(device_id < max_number_gpus);
31  allocator.allocate(number_of_elements);
32  }
35  }
36  // not yet implemented
37  hip_device_buffer(hip_device_buffer const &other) = delete;
39  hip_device_buffer(hip_device_buffer const &&other) = delete;
41 
42 };
43 
46 template <typename T, typename Host_Allocator, std::enable_if_t<std::is_trivial<T>::value, int> = 0>
50  hip_aggregated_device_buffer(size_t number_of_elements, Host_Allocator &alloc)
51  : number_of_elements(number_of_elements), alloc(alloc) {
53  alloc.allocate(number_of_elements);
54  }
56  alloc.deallocate(device_side_buffer, number_of_elements);
57  }
58  // not yet implemented
63 
64 private:
65  Host_Allocator &alloc; // will stay valid for the entire aggregation region and hence
66  // for the entire lifetime of this buffer
67 };
68 
69 } // namespace memory_recycling
70 } // end namespace cppuddle
71 #endif
Definition: config.hpp:31
constexpr size_t max_number_gpus
Definition: config.hpp:52
Definition: buffer_management.hpp:770
Definition: hip_recycling_device_buffer.hpp:47
hip_aggregated_device_buffer(hip_aggregated_device_buffer const &&other)=delete
size_t number_of_elements
Definition: hip_recycling_device_buffer.hpp:49
hip_aggregated_device_buffer(size_t number_of_elements, Host_Allocator &alloc)
Definition: hip_recycling_device_buffer.hpp:50
~hip_aggregated_device_buffer()
Definition: hip_recycling_device_buffer.hpp:55
hip_aggregated_device_buffer(hip_aggregated_device_buffer const &other)=delete
hip_aggregated_device_buffer operator=(hip_aggregated_device_buffer const &&other)=delete
T * device_side_buffer
Definition: hip_recycling_device_buffer.hpp:48
hip_aggregated_device_buffer operator=(hip_aggregated_device_buffer const &other)=delete
Definition: hip_recycling_device_buffer.hpp:22
hip_device_buffer operator=(hip_device_buffer const &&other)=delete
recycle_allocator_hip_device< T > allocator
Definition: hip_recycling_device_buffer.hpp:23
hip_device_buffer operator=(hip_device_buffer const &other)=delete
hip_device_buffer(hip_device_buffer const &other)=delete
hip_device_buffer(hip_device_buffer const &&other)=delete
size_t number_of_elements
Definition: hip_recycling_device_buffer.hpp:25
T * device_side_buffer
Definition: hip_recycling_device_buffer.hpp:24
~hip_device_buffer()
Definition: hip_recycling_device_buffer.hpp:33
hip_device_buffer(size_t number_of_elements, size_t device_id)
Definition: hip_recycling_device_buffer.hpp:27