ATLAS Offline Software
Loading...
Searching...
No Matches
PoolMemoryResourceSvc.h
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3//
4#ifndef ATHDEVICECOMPS_POOLMEMORYRESOURCESVC_H
5#define ATHDEVICECOMPS_POOLMEMORYRESOURCESVC_H
6
7// Framework include(s).
9#include "GaudiKernel/ToolHandle.h"
10
11// AthDevice include(s).
14
15// VecMem include(s).
16#include <vecmem/memory/pool_memory_resource.hpp>
17
18namespace AthDevice {
19
24class PoolMemoryResourceSvc : public extends<AthService, IMemoryResourceSvc> {
25
26 public:
27 // Inherit the base class's constructor(s).
28 using extends::extends;
29
32
34 virtual StatusCode initialize() override;
35
37
40
42 virtual std::pmr::memory_resource& mr() const override;
43
45
46 private:
48 ToolHandle<IMemoryResourceTool> m_mrTool{
49 this, "MRTool", "", "Tool providing the memory resource to be cached"};
50
51 std::unique_ptr<std::pmr::memory_resource> m_cachedMR;
53 std::unique_ptr<std::pmr::memory_resource> m_syncedMR;
54
57
59 vecmem::pool_memory_resource::options m_opts;
60
61 Gaudi::Property<std::size_t> m_minBlocksPerChunk{
62 this, "MinBlocksPerChunk", m_opts.min_blocks_per_chunk,
63 [this](Gaudi::Details::PropertyBase&) {
64 m_opts.min_blocks_per_chunk = m_minBlocksPerChunk;
65 }};
66 Gaudi::Property<std::size_t> m_maxBlocksPerChunk{
67 this, "MaxBlocksPerChunk", m_opts.max_blocks_per_chunk,
68 [this](Gaudi::Details::PropertyBase&) {
69 m_opts.max_blocks_per_chunk = m_maxBlocksPerChunk;
70 }};
71 Gaudi::Property<std::size_t> m_minBytesPerChunk{
72 this, "MinBytesPerChunk", m_opts.min_bytes_per_chunk,
73 [this](Gaudi::Details::PropertyBase&) {
74 m_opts.min_bytes_per_chunk = m_minBytesPerChunk;
75 }};
76 Gaudi::Property<std::size_t> m_maxBytesPerChunk{
77 this, "MaxBytesPerChunk", m_opts.max_bytes_per_chunk,
78 [this](Gaudi::Details::PropertyBase&) {
79 m_opts.max_bytes_per_chunk = m_maxBytesPerChunk;
80 }};
81
82 Gaudi::Property<std::size_t> m_smallestBlockSize{
83 this, "SmallestBlockSize", m_opts.smallest_block_size,
84 [this](Gaudi::Details::PropertyBase&) {
85 m_opts.smallest_block_size = m_smallestBlockSize;
86 }};
87 Gaudi::Property<std::size_t> m_largestBlockSize{
88 this, "LargestBlockSize", m_opts.largest_block_size,
89 [this](Gaudi::Details::PropertyBase&) {
90 m_opts.largest_block_size = m_largestBlockSize;
91 }};
92
93 Gaudi::Property<std::size_t> m_alignment{
94 this, "Alignment", m_opts.alignment,
95 [this](Gaudi::Details::PropertyBase&) {
96 m_opts.alignment = m_alignment;
97 }};
98
99 Gaudi::Property<bool> m_cacheOversized{
100 this, "CacheOversized", m_opts.cache_oversized,
101 [this](Gaudi::Details::PropertyBase&) {
102 m_opts.cache_oversized = m_cacheOversized;
103 }};
104 Gaudi::Property<std::size_t> m_cachedSizeCutoffFactor{
105 this, "CachedSizeCutoffFactor", m_opts.cached_size_cutoff_factor,
106 [this](Gaudi::Details::PropertyBase&) {
107 m_opts.cached_size_cutoff_factor = m_cachedSizeCutoffFactor;
108 }};
109 Gaudi::Property<std::size_t> m_cachedAlignmentCutoffFactor{
110 this, "CachedAlignmentCutoffFactor",
111 m_opts.cached_alignment_cutoff_factor,
112 [this](Gaudi::Details::PropertyBase&) {
113 m_opts.cached_alignment_cutoff_factor = m_cachedAlignmentCutoffFactor;
114 }};
115
117
118}; // class PoolMemoryResourceSvc
119
120} // namespace AthDevice
121
122#endif // ATHDEVICECOMPS_POOLMEMORYRESOURCESVC_H
Service implementing "pooled" caching on top of another memory resource.
Gaudi::Property< std::size_t > m_minBytesPerChunk
Gaudi::Property< std::size_t > m_alignment
Gaudi::Property< std::size_t > m_largestBlockSize
Gaudi::Property< std::size_t > m_smallestBlockSize
Gaudi::Property< bool > m_cacheOversized
virtual StatusCode initialize() override
Initialize the tool.
Gaudi::Property< std::size_t > m_cachedAlignmentCutoffFactor
Gaudi::Property< std::size_t > m_maxBlocksPerChunk
std::unique_ptr< std::pmr::memory_resource > m_cachedMR
The memory resource that this tool uses for caching.
Gaudi::Property< std::size_t > m_maxBytesPerChunk
vecmem::pool_memory_resource::options m_opts
Options object for the underlying pool memory resource.
Gaudi::Property< std::size_t > m_cachedSizeCutoffFactor
virtual std::pmr::memory_resource & mr() const override
Get the provided std::pmr::memory_resource object.
ToolHandle< IMemoryResourceTool > m_mrTool
Handle to the tool providing the underlying memory resource.
std::unique_ptr< std::pmr::memory_resource > m_syncedMR
The memory resource that this tool uses for synchronization.
Gaudi::Property< std::size_t > m_minBlocksPerChunk