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 virtual std::string_view deviceName() const override;
46
48
49 private:
51 ToolHandle<IMemoryResourceTool> m_mrTool{
52 this, "MRTool", "", "Tool providing the memory resource to be cached"};
53
54 std::unique_ptr<std::pmr::memory_resource> m_cachedMR;
56 std::unique_ptr<std::pmr::memory_resource> m_syncedMR;
57
60
62 vecmem::pool_memory_resource::options m_opts;
63
64 Gaudi::Property<std::size_t> m_minBlocksPerChunk{
65 this, "MinBlocksPerChunk", m_opts.min_blocks_per_chunk,
66 [this](Gaudi::Details::PropertyBase&) {
67 m_opts.min_blocks_per_chunk = m_minBlocksPerChunk;
68 }};
69 Gaudi::Property<std::size_t> m_maxBlocksPerChunk{
70 this, "MaxBlocksPerChunk", m_opts.max_blocks_per_chunk,
71 [this](Gaudi::Details::PropertyBase&) {
72 m_opts.max_blocks_per_chunk = m_maxBlocksPerChunk;
73 }};
74 Gaudi::Property<std::size_t> m_minBytesPerChunk{
75 this, "MinBytesPerChunk", m_opts.min_bytes_per_chunk,
76 [this](Gaudi::Details::PropertyBase&) {
77 m_opts.min_bytes_per_chunk = m_minBytesPerChunk;
78 }};
79 Gaudi::Property<std::size_t> m_maxBytesPerChunk{
80 this, "MaxBytesPerChunk", m_opts.max_bytes_per_chunk,
81 [this](Gaudi::Details::PropertyBase&) {
82 m_opts.max_bytes_per_chunk = m_maxBytesPerChunk;
83 }};
84
85 Gaudi::Property<std::size_t> m_smallestBlockSize{
86 this, "SmallestBlockSize", m_opts.smallest_block_size,
87 [this](Gaudi::Details::PropertyBase&) {
88 m_opts.smallest_block_size = m_smallestBlockSize;
89 }};
90 Gaudi::Property<std::size_t> m_largestBlockSize{
91 this, "LargestBlockSize", m_opts.largest_block_size,
92 [this](Gaudi::Details::PropertyBase&) {
93 m_opts.largest_block_size = m_largestBlockSize;
94 }};
95
96 Gaudi::Property<std::size_t> m_alignment{
97 this, "Alignment", m_opts.alignment,
98 [this](Gaudi::Details::PropertyBase&) {
99 m_opts.alignment = m_alignment;
100 }};
101
102 Gaudi::Property<bool> m_cacheOversized{
103 this, "CacheOversized", m_opts.cache_oversized,
104 [this](Gaudi::Details::PropertyBase&) {
105 m_opts.cache_oversized = m_cacheOversized;
106 }};
107 Gaudi::Property<std::size_t> m_cachedSizeCutoffFactor{
108 this, "CachedSizeCutoffFactor", m_opts.cached_size_cutoff_factor,
109 [this](Gaudi::Details::PropertyBase&) {
110 m_opts.cached_size_cutoff_factor = m_cachedSizeCutoffFactor;
111 }};
112 Gaudi::Property<std::size_t> m_cachedAlignmentCutoffFactor{
113 this, "CachedAlignmentCutoffFactor",
114 m_opts.cached_alignment_cutoff_factor,
115 [this](Gaudi::Details::PropertyBase&) {
116 m_opts.cached_alignment_cutoff_factor = m_cachedAlignmentCutoffFactor;
117 }};
118
120
121}; // class PoolMemoryResourceSvc
122
123} // namespace AthDevice
124
125#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
virtual StatusCode initialize() override
Initialize the service.
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.
virtual std::string_view deviceName() const override
The name of the device for which the memory resource is provided.
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