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