@@ -667,10 +667,10 @@ void tag_array::fill(new_addr_type addr, unsigned time, //on-fill
667667 // redundant memory request
668668
669669 if (isBypassed){
670- l1_cache::inst_state [hashed_pc].bypass_time ++ ;
670+ l1_cache::inst_stats [hashed_pc].bypass_time ++ ;
671671 }
672672 else {
673- l1_cache::inst_state [hashed_pc].not_bypass_time ++ ;
673+ l1_cache::inst_stats [hashed_pc].not_bypass_time ++ ;
674674 }
675675
676676 if (!isBypassed){ // cwpeng
@@ -2429,11 +2429,7 @@ enum cache_request_status data_cache::process_tag_probe(
24292429
24302430 cache_request_status access_status = probe_status;
24312431
2432- if (access_status == HIT || access_status == HIT_RESERVED){
2433- l1_cache::inst_state[l1_cache::pc2hashed_pc (mf->get_pc ())].hit_time ++ ;
2434- }else if (access_status == MISS || access_status == SECTOR_MISS){
2435- l1_cache::inst_state[l1_cache::pc2hashed_pc (mf->get_pc ())].miss_time ++;
2436- }
2432+
24372433
24382434 if (wr) { // Write
24392435 if (probe_status == HIT) {
@@ -2452,18 +2448,18 @@ enum cache_request_status data_cache::process_tag_probe(
24522448 }
24532449 } else { // Read
24542450 if (probe_status == HIT) {
2455- // l1_cache::inst_state [l1_cache::pc2hashed_pc(mf->get_pc())].hit_time++ ;
2451+ // l1_cache::inst_stats [l1_cache::pc2hashed_pc(mf->get_pc())].hit_time++ ;
24562452 access_status =
24572453 (this ->*m_rd_hit_l1d)(addr, cache_index, mf, time, events, probe_status, l1d_prediction_table);
24582454 } else if (probe_status != RESERVATION_FAIL) {
24592455 if (probe_status == MISS || probe_status == SECTOR_MISS) {
2460- // l1_cache::inst_state [l1_cache::pc2hashed_pc(mf->get_pc())].miss_time++;
2456+ // l1_cache::inst_stats [l1_cache::pc2hashed_pc(mf->get_pc())].miss_time++;
24612457 } else if (probe_status == HIT_RESERVED) {
24622458 // A HIT_RESERVED is a hit in the MSHR, which means the data is on its
24632459 // way. It's not a true miss that generates a new memory request.
24642460 // Let's count it as a hit to align with how miss rate is typically
24652461 // calculated.
2466- // l1_cache::inst_state [l1_cache::pc2hashed_pc(mf->get_pc())].hit_time++;
2462+ // l1_cache::inst_stats [l1_cache::pc2hashed_pc(mf->get_pc())].hit_time++;
24672463 }
24682464 access_status =
24692465 (this ->*m_rd_miss_l1d)(addr, cache_index, mf, time, events, probe_status, l1d_prediction_table, victim_valid);
@@ -2526,6 +2522,14 @@ enum cache_request_status data_cache::access(new_addr_type addr, mem_fetch *mf,
25262522 // else if(access_status == MISS){
25272523 // printf("L1D MISS Time: %d PC: %d\n", time, mf->get_pc());
25282524 // }
2525+ uint8_t hashed_pc = l1_cache::pc2hashed_pc (mf->get_pc ()) ;
2526+ enum cache_request_status final_status = m_stats.select_stats_status (probe_status, access_status) ;
2527+ if (final_status == HIT || final_status == HIT_RESERVED){
2528+ l1_cache::inst_stats[l1_cache::pc2hashed_pc (mf->get_pc ())].hit_time ++ ;
2529+ }else if (final_status == MISS || final_status == SECTOR_MISS){
2530+ l1_cache::inst_stats[l1_cache::pc2hashed_pc (mf->get_pc ())].miss_time ++;
2531+ }
2532+
25292533 m_stats.inc_stats (mf->get_access_type (),
25302534 m_stats.select_stats_status (probe_status, access_status),
25312535 mf->get_streamID ());
@@ -2545,17 +2549,18 @@ enum cache_request_status l1_cache::access(new_addr_type addr, mem_fetch *mf,
25452549 return data_cache::access (addr, mf, time, events);
25462550}
25472551
2548- ldst_inst_state l1_cache::inst_state [256 ];
2552+ ldst_inst_stats l1_cache::inst_stats [256 ];
25492553
25502554enum cache_request_status l1_cache::access (new_addr_type addr, mem_fetch *mf,
25512555 unsigned time,
25522556 std::list<cache_event> &events,
25532557 uint8_t * l1_prediction_table) { // cwpeng
2554- inst_state [pc2hashed_pc (mf->get_pc ())].access_time ++ ;
2558+ inst_stats [pc2hashed_pc (mf->get_pc ())].access_time ++ ;
25552559 return data_cache::access (addr, mf, time, events, l1_prediction_table);
25562560}
25572561
25582562uint8_t l1_cache::pc2hashed_pc (new_addr_type addr){ // cwpeng PC -> 256bit hash PC translation
2563+ assert (addr != (new_addr_type)-1 ) ;
25592564 return (addr >> 3 ) % 256 ;
25602565}
25612566
@@ -2594,15 +2599,15 @@ void l1_cache::print_prediction_table(FILE *fp, unsigned core_id) const {
25942599 fprintf (fp, " ========================================================================\n " );
25952600}
25962601
2597- void l1_cache::print_ldst_inst_state (FILE *fp){
2602+ void l1_cache::print_ldst_inst_stats (FILE *fp){
25982603 fprintf (fp, " L1D Prediction Table State:\n " );
25992604 for (unsigned i = 0 ; i < 256 ; i++){
26002605 fprintf (fp, " HashPC:%3d: access time %d, hit_rate:%f, L2 access time:%d, bypass_rate:%f\n " ,
26012606 i,
2602- inst_state [i].access_time ,
2603- inst_state [i].get_hit_rate (),
2604- inst_state [i].get_l2_access_time (),
2605- inst_state [i].get_bypass_rate ()
2607+ inst_stats [i].access_time ,
2608+ inst_stats [i].get_hit_rate (),
2609+ inst_stats [i].get_l2_access_time (),
2610+ inst_stats [i].get_bypass_rate ()
26062611 );
26072612 }
26082613 fprintf (fp, " ========================================================================\n " );
0 commit comments