ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthDevice
AthDeviceComps
src
MemoryMonitorSvc.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_MEMORYMONITORSVC_H
5
#define ATHDEVICECOMPS_MEMORYMONITORSVC_H
6
7
// Framework include(s).
8
#include "
AthenaBaseComps/AthService.h
"
9
10
// AthDevice include(s).
11
#include "
AthDeviceInterfaces/IMemoryMonitorSvc.h
"
12
13
// System include(s).
14
#include <map>
15
#include <mutex>
16
17
namespace
AthDevice
{
18
20
class
MemoryMonitorSvc
:
public
extends<AthService, IMemoryMonitorSvc> {
21
22
public
:
23
// Inherit the base class's constructor(s).
24
using
extends::extends;
25
28
30
virtual
StatusCode
finalize
()
override
;
31
33
35
38
40
virtual
void
memoryAllocated
(
const
std::string& component,
41
const
std::string& device,
42
std::size_t bytes)
override
;
43
45
virtual
void
memoryDeallocated
(
const
std::string& component,
46
const
std::string& device,
47
std::size_t bytes)
override
;
48
50
virtual
void
memoryCopied
(
const
std::string& component,
51
vecmem::copy::type::copy_type
type
,
52
std::size_t bytes)
override
;
53
55
56
private
:
59
61
struct
MemoryAllocKey
{
63
std::string
component
;
65
std::string
device
;
66
68
bool
operator<
(
const
MemoryAllocKey
& other)
const
{
69
if
(
device
!= other.device) {
70
return
device
< other.device;
71
}
else
{
72
return
component
< other.component;
73
}
74
}
75
};
76
78
std::map<MemoryAllocKey, std::size_t>
m_allocations
;
80
std::mutex
m_allocationsMutex
;
82
std::map<MemoryAllocKey, std::size_t>
m_deallocations
;
84
std::mutex
m_deallocationsMutex
;
85
87
struct
MemoryCopyKey
{
89
std::string
component
;
91
vecmem::copy::type::copy_type
type
;
92
94
bool
operator<
(
const
MemoryCopyKey
& other)
const
{
95
if
(
component
!= other.component) {
96
return
component
< other.component;
97
}
else
{
98
return
type
< other.type;
99
}
100
}
101
};
102
104
std::map<MemoryCopyKey, std::size_t>
m_copies
;
106
std::mutex
m_copiesMutex
;
107
109
110
};
// class MemoryMonitorSvc
111
112
}
// namespace AthDevice
113
114
#endif
// ATHDEVICECOMPS_MEMORYMONITORSVC_H
AthService.h
IMemoryMonitorSvc.h
AthDevice::MemoryMonitorSvc
Service providing "device memory monitoring".
Definition
MemoryMonitorSvc.h:20
AthDevice::MemoryMonitorSvc::memoryDeallocated
virtual void memoryDeallocated(const std::string &component, const std::string &device, std::size_t bytes) override
Notify the service that a memory deallocation has been made.
Definition
MemoryMonitorSvc.cxx:88
AthDevice::MemoryMonitorSvc::m_copies
std::map< MemoryCopyKey, std::size_t > m_copies
All the memory copies.
Definition
MemoryMonitorSvc.h:104
AthDevice::MemoryMonitorSvc::memoryCopied
virtual void memoryCopied(const std::string &component, vecmem::copy::type::copy_type type, std::size_t bytes) override
Notify the service that a memory copy has been made.
Definition
MemoryMonitorSvc.cxx:96
AthDevice::MemoryMonitorSvc::m_deallocations
std::map< MemoryAllocKey, std::size_t > m_deallocations
All the memory deallocations.
Definition
MemoryMonitorSvc.h:82
AthDevice::MemoryMonitorSvc::finalize
virtual StatusCode finalize() override
Finalize the service.
Definition
MemoryMonitorSvc.cxx:35
AthDevice::MemoryMonitorSvc::m_deallocationsMutex
std::mutex m_deallocationsMutex
Mutex for m_deallocations.
Definition
MemoryMonitorSvc.h:84
AthDevice::MemoryMonitorSvc::m_copiesMutex
std::mutex m_copiesMutex
Mutex for m_copies.
Definition
MemoryMonitorSvc.h:106
AthDevice::MemoryMonitorSvc::m_allocationsMutex
std::mutex m_allocationsMutex
Mutex for m_allocations.
Definition
MemoryMonitorSvc.h:80
AthDevice::MemoryMonitorSvc::m_allocations
std::map< MemoryAllocKey, std::size_t > m_allocations
All the memory allocations.
Definition
MemoryMonitorSvc.h:78
AthDevice::MemoryMonitorSvc::memoryAllocated
virtual void memoryAllocated(const std::string &component, const std::string &device, std::size_t bytes) override
Notify the service that a memory allocation has been made.
Definition
MemoryMonitorSvc.cxx:80
AthDevice
Definition
BinaryPageMemoryResourceSvc.cxx:15
AthDevice::MemoryMonitorSvc::MemoryAllocKey
Key used in the memory allocation/deallocation monitoring maps.
Definition
MemoryMonitorSvc.h:61
AthDevice::MemoryMonitorSvc::MemoryAllocKey::component
std::string component
Athena component making the memory (de)allocation.
Definition
MemoryMonitorSvc.h:63
AthDevice::MemoryMonitorSvc::MemoryAllocKey::operator<
bool operator<(const MemoryAllocKey &other) const
Comparison operator, to make the type usable as a key in a map.
Definition
MemoryMonitorSvc.h:68
AthDevice::MemoryMonitorSvc::MemoryAllocKey::device
std::string device
Name/identifier of the device on which the (de)allocation was made.
Definition
MemoryMonitorSvc.h:65
AthDevice::MemoryMonitorSvc::MemoryCopyKey
Key used in the memory copy monitoring map.
Definition
MemoryMonitorSvc.h:87
AthDevice::MemoryMonitorSvc::MemoryCopyKey::type
vecmem::copy::type::copy_type type
Type of the memory copy.
Definition
MemoryMonitorSvc.h:91
AthDevice::MemoryMonitorSvc::MemoryCopyKey::component
std::string component
Athena component making the memory copy.
Definition
MemoryMonitorSvc.h:89
AthDevice::MemoryMonitorSvc::MemoryCopyKey::operator<
bool operator<(const MemoryCopyKey &other) const
Comparison operator, to make the type usable as a key in a map.
Definition
MemoryMonitorSvc.h:94
type
Generated on
for ATLAS Offline Software by
1.17.0