SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
memory_profiler.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2015 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_SYSTEMC_MEMORY_PROFILER_H
17#define SIMICS_SYSTEMC_MEMORY_PROFILER_H
18
19#include <simics/base/types.h> // conf_object_t
20#include <simics/malloc_allocator.h>
21
22#include <sysc/kernel/sc_process.h>
23
24#include <map>
25#include <cstddef> // size_t
26#include <utility> // pair
27#include <functional> // less
28
29namespace simics {
30namespace systemc {
31
32struct Allocation {
33 Allocation(void *addr, std::size_t size, bool array_form)
35
36 void *addr;
37 size_t size;
39};
40
41// adapter -> profiling enabled
42typedef MallocAllocator<std::pair<conf_object_t*, bool> >
44typedef std::map<conf_object_t*, bool, std::less<conf_object_t*>,
46
47// address -> allocation (allocations)
48typedef MallocAllocator<std::pair<void *, Allocation> >
50typedef std::map<void *, Allocation, std::less<void *>,
52
53// process -> allocations
54typedef MallocAllocator<std::pair<sc_core::sc_process_b *,
56typedef std::map<sc_core::sc_process_b *, AllocationMap,
57 std::less<sc_core::sc_process_b *>,
59
61 public:
63
64 void recordAllocation(void *addr, size_t size, bool array_form);
65 void recordDeletion(void *addr, bool array_form);
66
67 AllocationMap *allocations(sc_core::sc_process_b *process);
69
70 bool profilingForAdapter(conf_object_t *obj);
71 void setProfilingForAdapter(conf_object_t *obj, bool enable);
72
73 private:
74 AdapterMap adapters_;
75 ProcessMap processes_;
76 bool is_recording_;
77
78 AdapterMap::iterator adapter(conf_object_t *obj);
79 bool hasAllocation(void *addr,
80 AllocationMap::iterator *out_allocation,
81 AllocationMap **out_process);
82};
83
84} // namespace systemc
85} // namespace simics
86
87#endif // SIMICS_SYSTEMC_MEMORY_PROFILER_H
Definition: memory_profiler.h:60
void setProfilingForAdapter(conf_object_t *obj, bool enable)
void recordDeletion(void *addr, bool array_form)
void recordAllocation(void *addr, size_t size, bool array_form)
bool profilingForAdapter(conf_object_t *obj)
AllocationMap * allocations(sc_core::sc_process_b *process)
std::map< sc_core::sc_process_b *, AllocationMap, std::less< sc_core::sc_process_b * >, ProcessAllocator > ProcessMap
Definition: memory_profiler.h:58
MallocAllocator< std::pair< conf_object_t *, bool > > AdapterAllocator
Definition: memory_profiler.h:43
std::map< void *, Allocation, std::less< void * >, AllocationAllocator > AllocationMap
Definition: memory_profiler.h:51
MallocAllocator< std::pair< void *, Allocation > > AllocationAllocator
Definition: memory_profiler.h:49
MallocAllocator< std::pair< sc_core::sc_process_b *, AllocationMap > > ProcessAllocator
Definition: memory_profiler.h:55
std::map< conf_object_t *, bool, std::less< conf_object_t * >, AdapterAllocator > AdapterMap
Definition: memory_profiler.h:45
Definition: pci_bus_interface.h:24
Definition: memory_profiler.h:32
Allocation(void *addr, std::size_t size, bool array_form)
Definition: memory_profiler.h:33
bool array_form
Definition: memory_profiler.h:38
size_t size
Definition: memory_profiler.h:37
void * addr
Definition: memory_profiler.h:36