Skip to content

Commit b0afe84

Browse files
committed
Fix wrong hashPC when decide bypass or fill, correct the profiling timing
1 parent 9ab5565 commit b0afe84

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

src/gpgpu-sim/gpu-cache.cc

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

25502554
enum 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

25582562
uint8_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");

src/gpgpu-sim/gpu-cache.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ class data_cache : public baseline_cache {
17701770
};
17711771

17721772

1773-
class ldst_inst_state{ // cwpeng
1773+
class ldst_inst_stats{ // cwpeng
17741774
public:
17751775
uint64_t access_time ;
17761776
uint64_t hit_time ;
@@ -1827,8 +1827,8 @@ class l1_cache : public data_cache {
18271827
static uint8_t pc2hashed_pc(new_addr_type) ; // cwpeng PC -> 256bit hash PC translation
18281828
void print_prediction_table(FILE *fp, unsigned core_id) const; // print prediction table at program end
18291829

1830-
static ldst_inst_state inst_state[256] ; // cwpeng load/store instruction state table
1831-
static void print_ldst_inst_state(FILE *fp) ; // cwpeng print load/store instruction state table at program end
1830+
static ldst_inst_stats inst_stats[256] ; // cwpeng load/store instruction state table
1831+
static void print_ldst_inst_stats(FILE *fp) ; // cwpeng print load/store instruction state table at program end
18321832

18331833
protected:
18341834
l1_cache(const char *name, cache_config &config, int core_id, int type_id,

src/gpgpu-sim/gpu-sim.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ void gpgpu_sim::gpu_print_stat(unsigned long long streamID) {
15161516
// shader_print_l1_miss_stat( stdout );
15171517
shader_print_cache_stats(stdout);
15181518

1519-
l1_cache::print_ldst_inst_state(stdout) ;
1519+
l1_cache::print_ldst_inst_stats(stdout) ;
15201520

15211521
cache_stats core_cache_stats;
15221522
core_cache_stats.clear();

src/gpgpu-sim/shader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,7 @@ void ldst_unit::cycle() {
28702870

28712871
bool bypassL1D = false;
28722872
address_type currPC = mf->get_pc();
2873-
address_type temp_pc = (currPC == -1) ? (uint8_t) mf->get_original_mf()->get_pc() : currPC; //cwpeng
2873+
address_type temp_pc = (currPC == -1) ? mf->get_original_mf()->get_pc() : currPC; //cwpeng
28742874
uint8_t hashed_pc = l1_cache::pc2hashed_pc(temp_pc) ;
28752875

28762876
if (CACHE_GLOBAL == mf->get_inst().cache_op || (m_L1D == NULL)) {

0 commit comments

Comments
 (0)