51 #include "debug/RubyCacheTrace.hh"
52 #include "debug/RubySystem.hh"
76 m_cache_recorder(NULL)
114 for (
int idx = 0; idx <
m_networks.size(); ++idx) {
120 fatal_if(network_id < 0,
"Could not add MachineID %s. Network not found",
143 MachineID mach_id = cntrl->getMachineID();
147 "No machineID %s. Does not belong to a Ruby network?",
158 for (
auto id = 0;
id <
params()->system->maxRequestors(); ++
id) {
172 uint64_t cache_trace_size,
173 uint64_t block_size_bytes)
180 if (sequencer_ptr == NULL) {
181 sequencer_ptr = sequencer_map[cntrl];
185 assert(sequencer_ptr != NULL);
188 if (sequencer_map[cntrl] == NULL) {
189 sequencer_map[cntrl] = sequencer_ptr;
200 sequencer_map, block_size_bytes);
209 DPRINTF(RubyCacheTrace,
"Recording Cache Trace\n");
214 DPRINTF(RubyCacheTrace,
"Cache Trace Complete\n");
218 DPRINTF(RubyCacheTrace,
"Recording current tick %ld\n", curtick_original);
226 DPRINTF(RubyCacheTrace,
"Event %s auto-deletes when descheduled,"
227 " not recording\n", curr_head->
name());
229 original_events.push_back(make_pair(curr_head, curr_head->
when()));
235 DPRINTF(RubyCacheTrace,
"Starting cache flush\n");
238 DPRINTF(RubyCacheTrace,
"Cache flush complete\n");
251 while (!original_events.empty()) {
254 original_events.pop_back();
268 warn_once(
"Ruby memory writeback is experimental. Continuing simulation "
269 "afterwards may not always work as intended.");
277 uint64_t uncompressed_trace_size)
282 int fd = creat(thefile.c_str(), 0664);
285 fatal(
"Can't open memory trace file '%s'\n", filename);
288 gzFile compressedMemory = gzdopen(
fd,
"wb");
289 if (compressedMemory == NULL)
290 fatal(
"Insufficient memory to allocate compression state for %s\n",
293 if (gzwrite(compressedMemory, raw_data, uncompressed_trace_size) !=
294 uncompressed_trace_size) {
295 fatal(
"Write failed on memory trace file '%s'\n", filename);
298 if (gzclose(compressedMemory)) {
299 fatal(
"Close failed on memory trace file '%s'\n", filename);
317 fatal(
"Call memWriteback() before serialize() to create ruby trace");
321 uint8_t *raw_data =
new uint8_t[4096];
324 string cache_trace_file =
name() +
".cache.gz";
344 uint64_t &uncompressed_trace_size)
347 gzFile compressedTrace;
350 int fd = open(filename.c_str(), O_RDONLY);
353 fatal(
"Unable to open trace file %s", filename);
356 compressedTrace = gzdopen(
fd,
"rb");
357 if (compressedTrace == NULL) {
358 fatal(
"Insufficient memory to allocate compression state for %s\n",
362 raw_data =
new uint8_t[uncompressed_trace_size];
363 if (gzread(compressedTrace, raw_data, uncompressed_trace_size) <
364 uncompressed_trace_size) {
365 fatal(
"Unable to read complete trace from file %s\n", filename);
368 if (gzclose(compressedTrace)) {
369 fatal(
"Failed to close cache trace file '%s'\n", filename);
376 uint8_t *uncompressed_trace = NULL;
384 string cache_trace_file;
385 uint64_t cache_trace_size = 0;
389 cache_trace_file =
cp.getCptDir() +
"/" + cache_trace_file;
427 DPRINTF(RubyCacheTrace,
"Starting ruby cache warmup\n");
472 network->resetStats();
482 AccessPermission access_perm = AccessPermission_NotPresent;
486 unsigned int num_ro = 0;
487 unsigned int num_rw = 0;
488 unsigned int num_busy = 0;
489 unsigned int num_maybe_stale = 0;
490 unsigned int num_backing_store = 0;
491 unsigned int num_invalid = 0;
504 for (
auto& cntrl :
netCntrls[request_net_id]) {
505 access_perm = cntrl-> getAccessPermission(line_address);
506 if (access_perm == AccessPermission_Read_Only){
508 if (ctrl_ro ==
nullptr) ctrl_ro = cntrl;
510 else if (access_perm == AccessPermission_Read_Write){
512 if (ctrl_rw ==
nullptr) ctrl_rw = cntrl;
514 else if (access_perm == AccessPermission_Busy)
516 else if (access_perm == AccessPermission_Maybe_Stale)
518 else if (access_perm == AccessPermission_Backing_Store) {
524 if (ctrl_backing_store ==
nullptr)
525 ctrl_backing_store = cntrl;
527 else if (access_perm == AccessPermission_Invalid ||
528 access_perm == AccessPermission_NotPresent)
540 int num_controllers =
netCntrls[request_net_id].size();
541 if (num_invalid == (num_controllers - 1) && num_backing_store == 1) {
545 }
else if (num_ro > 0 || num_rw >= 1) {
550 warn(
"More than one Abstract Controller with RW permission for "
551 "addr: %#x on cacheline: %#x.", address, line_address);
559 num_maybe_stale, num_busy, num_ro, num_rw);
569 }
else if ((num_busy + num_maybe_stale) > 0) {
574 "(num_maybe_stale=%d, num_busy = %d)\n",
575 num_maybe_stale, num_busy);
576 for (
auto& cntrl :
netCntrls[request_net_id]) {
577 if (cntrl->functionalReadBuffers(pkt))
581 "(num_maybe_stale=%d, num_busy = %d)\n",
582 num_maybe_stale, num_busy);
584 if (network->functionalRead(pkt))
601 AccessPermission access_perm = AccessPermission_NotPresent;
605 uint32_t M5_VAR_USED num_functional_writes = 0;
612 for (
auto& cntrl :
netCntrls[request_net_id]) {
613 num_functional_writes += cntrl->functionalWriteBuffers(pkt);
615 access_perm = cntrl->getAccessPermission(line_addr);
616 if (access_perm != AccessPermission_Invalid &&
617 access_perm != AccessPermission_NotPresent) {
618 num_functional_writes +=
619 cntrl->functionalWrite(line_addr, pkt);
624 if (cntrl->getCPUSequencer()) {
625 num_functional_writes +=
626 cntrl->getCPUSequencer()->functionalWrite(pkt);
628 if (cntrl->getDMASequencer()) {
629 num_functional_writes +=
630 cntrl->getDMASequencer()->functionalWrite(pkt);
635 num_functional_writes += network->functionalWrite(pkt);
643 RubySystemParams::create()