-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i#3068: API for accessing cache model metrics #5020
Changes from 5 commits
3692ad7
334395a
f5c83c6
343d5bf
49b4030
a609f67
38011c0
333eec1
81db1b8
1e08634
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ | |
#include "cache.h" | ||
#include "snoop_filter.h" | ||
|
||
enum cache_split_t { DATA, INSTRUCTION }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Safer to put inside the class and not in the global namespace (xref #4343). Or see other suggestions for the enum below. |
||
|
||
class cache_simulator_t : public simulator_t { | ||
public: | ||
// This constructor is used when the cache hierarchy is configured | ||
|
@@ -60,12 +62,19 @@ class cache_simulator_t : public simulator_t { | |
bool | ||
print_results() override; | ||
|
||
int_least64_t | ||
get_cache_metric(unsigned level, metric_name_t metric, unsigned core = 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would re-order the parameters with the metric first and grouping the 3 identifiers of which cache (level, core, split) together. |
||
cache_split_t split = DATA) const; | ||
|
||
// Exposed to make it easy to test | ||
bool | ||
check_warmed_up(); | ||
uint64_t | ||
remaining_sim_refs() const; | ||
|
||
const cache_simulator_knobs_t & | ||
get_knobs() const; | ||
|
||
protected: | ||
// Create a cache_t object with a specific replacement policy. | ||
virtual cache_t * | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
|
||
#include "caching_device_block.h" | ||
#include <string> | ||
#include <map> | ||
#include <stdint.h> | ||
#ifdef HAS_ZLIB | ||
# include <zlib.h> | ||
|
@@ -49,6 +50,20 @@ enum invalidation_type_t { | |
INVALIDATION_COHERENCE, | ||
}; | ||
|
||
enum metric_name_t { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know the existing code has global scope enums but we're trying to avoid that going forward (xref #4343), and here we have very simple names that could conflict. We do require C++11 so this could be a scoped enum ( |
||
HITS, | ||
MISSES, | ||
HITS_AT_RESET, | ||
MISSES_AT_RESET, | ||
CHILD_HITS, | ||
CHILD_HITS_AT_RESET, | ||
INCLUSIVE_INVALIDATES, | ||
COHERENCE_INVALIDATES, | ||
PREFETCH_HITS, | ||
PREFETCH_MISSES, | ||
FLUSHES | ||
}; | ||
|
||
class caching_device_stats_t { | ||
public: | ||
explicit caching_device_stats_t(const std::string &miss_file, | ||
|
@@ -81,6 +96,17 @@ class caching_device_stats_t { | |
virtual void | ||
invalidate(invalidation_type_t invalidation_type); | ||
|
||
int_least64_t | ||
get_metric(metric_name_t metric) const | ||
{ | ||
if (stats_map_.find(metric) != stats_map_.end()) { | ||
return stats_map_.at(metric); | ||
} else { | ||
ERRMSG("Wrong metric name.\n"); | ||
return 0; | ||
} | ||
} | ||
|
||
protected: | ||
bool success_; | ||
|
||
|
@@ -115,6 +141,10 @@ class caching_device_stats_t { | |
// Print out write invalidations if cache is coherent. | ||
bool is_coherent_; | ||
|
||
// References to the properties with statistics are held in the map with the | ||
// statistic name as the key. Sample map element: {HITS, num_hits_} | ||
std::map<metric_name_t, int_least64_t &> stats_map_; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add some kind of test. Maybe in drcachesim_unit_tests or a new similar test? Xref #4842. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added unit test in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, best to put a |
||
// We provide a feature of dumping misses to a file. | ||
bool dump_misses_; | ||
#ifdef HAS_ZLIB | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xref the top-level thread: I would vote for returning an error. Could go so far as error enum types; or just return -1 (document that's the error return code) either w/ or w/o the print (could see the print useful if there's no errno; could see it annoying linked into a large system that maybe doesn't know the cache layout and is passing all possible levels and using return code to find the bounds of the layout -- there an errno would be nice).
Ditto below.