vecmem 1.14.0
Loading...
Searching...
No Matches
pool_memory_resource.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2023-2024 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8#pragma once
9
10// Local include(s).
11#include "vecmem/memory/details/memory_resource_base.hpp"
12#include "vecmem/memory/memory_resource.hpp"
13#include "vecmem/vecmem_core_export.hpp"
14
15// System include(s).
16#include <cstddef>
17#include <memory>
18
19namespace vecmem {
20
21// Forward declaration(s).
22namespace details {
23class pool_memory_resource_impl;
24}
25
40
41public:
44
51
55 std::size_t min_blocks_per_chunk = 16;
58 std::size_t min_bytes_per_chunk = 1024;
62 std::size_t max_blocks_per_chunk = static_cast<std::size_t>(1) << 20;
65 std::size_t max_bytes_per_chunk = static_cast<std::size_t>(1) << 30;
66
70 std::size_t smallest_block_size = alignof(std::max_align_t);
75 std::size_t largest_block_size = static_cast<std::size_t>(1) << 20;
76
81 std::size_t alignment = alignof(std::max_align_t);
82
85 bool cache_oversized = true;
86
93 std::size_t cached_size_cutoff_factor = 16;
100 std::size_t cached_alignment_cutoff_factor = 16;
101
102 }; // struct options
103
110 pool_memory_resource(memory_resource& upstream,
111 const options& opts = options{});
117
121
127
128private:
131
134 virtual void* do_allocate(std::size_t, std::size_t) override final;
137 virtual void do_deallocate(void* p, std::size_t,
138 std::size_t) override final;
139
141
143 std::unique_ptr<details::pool_memory_resource_impl> m_impl;
144
145}; // class pool_memory_resource
146
147} // namespace vecmem
Base class for implementations of the vecmem::memory_resource interface.
Definition memory_resource_base.hpp:25
Memory resource pooling allocations of various sizes.
Definition pool_memory_resource.hpp:39
virtual VECMEM_CORE_EXPORT void * do_allocate(std::size_t, std::size_t) override final
Allocate a blob of memory.
pool_memory_resource(const pool_memory_resource &)=delete
Disallow copying the memory resource.
VECMEM_CORE_EXPORT pool_memory_resource & operator=(pool_memory_resource &&rhs)
Move assignment operator.
virtual VECMEM_CORE_EXPORT void do_deallocate(void *p, std::size_t, std::size_t) override final
De-allocate a previously allocated memory blob.
pool_memory_resource & operator=(const pool_memory_resource &)=delete
Disallow copying the memory resource.
VECMEM_CORE_EXPORT pool_memory_resource(pool_memory_resource &&parent)
Move constructor.
VECMEM_CORE_EXPORT ~pool_memory_resource()
Destructor, freeing all allocations.
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35
Runtime options for vecmem::pool_memory_resource.
Definition pool_memory_resource.hpp:43