Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions resources/wrappers/ramulator2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,33 @@ void Ramulator2::print_stats_yaml(std::ostream& os) {
ramulator2_memorysystem->print_stats(os);
}

namespace {
/** Walk a collect_stats() tree, summing row_misses + row_conflicts wherever they appear. */
uint64_t sum_row_activations(const Ramulator::ConfigNode& node) {
uint64_t acts = 0;
if (node.is_sequence()) {
for (const auto& child : node.seq())
acts += sum_row_activations(child);
return acts;
}
if (!node.is_map())
return 0;
for (const auto& [key, child] : node.map()) {
if (child.is_map() || child.is_sequence())
acts += sum_row_activations(child);
else if (key == "row_misses" || key == "row_conflicts")
acts += child.as<uint64_t>(uint64_t{0});
}
return acts;
}
} // namespace

uint64_t Ramulator2::row_activations() const {
if (ramulator2_memorysystem == nullptr)
return 0;
return sum_row_activations(ramulator2_memorysystem->collect_stats());
}

void Ramulator2::finish() {
finalize_once();
print_stats_yaml(std::cout);
Expand Down
29 changes: 19 additions & 10 deletions resources/wrappers/ramulator2.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,23 @@ class Ramulator2 {
void return_queue_push_back(mem_fetch* mf);
bool returnq_full() const;

int interval_reads() const { return num_reads; }
int interval_writes() const { return num_writes; }
uint64_t interval_reads() const { return num_reads; }
uint64_t interval_writes() const { return num_writes; }
void reset_interval_bw_counters() {
num_reads = 0;
num_writes = 0;
}
int total_reads() const { return tot_reads; }
int total_writes() const { return tot_writes; }
uint64_t total_reads() const { return tot_reads; }
uint64_t total_writes() const { return tot_writes; }

/**
* Row activations (each a PRE+ACT pair on an open-row policy) served by this
* memory system, summed over its controllers. Ramulator2 has no ACT command
* counter, so this is derived from the per-controller request stats: a row
* hit needs no ACT, while a miss (closed bank) and a conflict (other row
* open) each need one. Refresh-driven activations are not included.
*/
uint64_t row_activations() const;

private:
std::string std_name;
Expand All @@ -65,14 +74,14 @@ class Ramulator2 {
int num_channels;
uint64_t cycle_count = 0;
int log_interval = 10000;
int num_reqs;
int num_reads;
int num_writes;
uint64_t num_reqs;
uint64_t num_reads;
uint64_t num_writes;
unsigned req_size = 0;
unsigned freq_mhz = 0;
int tot_reqs;
int tot_reads;
int tot_writes;
uint64_t tot_reqs;
uint64_t tot_reads;
uint64_t tot_writes;
};

#endif // __RAMULATOR2_HH__