Skip to content

Commit 41f9347

Browse files
committed
update hashPC hash function to prevent conflict due to address line offset
1 parent 41853f6 commit 41f9347

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/gpgpu-sim/gpu-cache.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,8 +2209,9 @@ enum cache_request_status data_cache::rd_hit_base_l1d(
22092209
// l1d_prediction_table[mf->get_pc()%256]--;
22102210
// //fprintf(stdout,"HIT Time: %d PC: %d Value: %d\n", time, storedhashedPC, l1d_prediction_table[storedhashedPC]);
22112211
// }
2212-
printf("CWPENG: PC:%d hit, update table[%d] to %d, ptr:%p\n", mf->get_pc()%256, storedhashedPC, l1d_prediction_table[storedhashedPC], l1d_prediction_table) ;
2213-
m_tag_array->set_hashed_pc_from_tag(addr, mf, (uint8_t) mf->get_pc()); //cwpeng
2212+
uint8_t hashed_pc = l1_cache::pc2hashed_pc(mf->get_pc()) ;
2213+
printf("CWPENG: PC:%d hit, update table[%d] to %d, ptr:%p\n", hashed_pc, storedhashedPC, l1d_prediction_table[storedhashedPC], l1d_prediction_table) ;
2214+
m_tag_array->set_hashed_pc_from_tag(addr, mf, hashed_pc); //cwpeng
22142215

22152216
m_tag_array->access(block_addr, time, cache_index, mf);
22162217
// Atomics treated as global read/write requests - Perform read, mark line as
@@ -2285,7 +2286,7 @@ enum cache_request_status data_cache::rd_miss_base_l1d(
22852286
bool isBypassed = false;
22862287
int threshold = 8; // From SDBP paper
22872288
//fprintf(stdout,"AISH, %s, %d\n",__func__, __LINE__);
2288-
if(l1d_prediction_table[mf->get_pc() % 256] >= threshold){
2289+
if(l1d_prediction_table[l1_cache::pc2hashed_pc(mf->get_pc())] >= threshold){
22892290
isBypassed = true;
22902291
}
22912292

@@ -2526,6 +2527,10 @@ enum cache_request_status l1_cache::access(new_addr_type addr, mem_fetch *mf,
25262527
return data_cache::access(addr, mf, time, events, l1_prediction_table);
25272528
}
25282529

2530+
uint8_t l1_cache::pc2hashed_pc(new_addr_type addr){ // cwpeng PC -> 256bit hash PC translation
2531+
return (addr >> 2) % 256 ;
2532+
}
2533+
25292534
// The l2 cache access function calls the base data_cache access
25302535
// implementation. When the L2 needs to diverge from L1, L2 specific
25312536
// changes should be made here.

src/gpgpu-sim/gpu-cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ class l1_cache : public data_cache {
18001800
);
18011801

18021802
uint8_t prediction_table[256] ; // cwpeng prediction table in L1 cache (4 bits each entry)
1803+
static uint8_t pc2hashed_pc(new_addr_type) ; // cwpeng PC -> 256bit hash PC translation
18031804

18041805
protected:
18051806
l1_cache(const char *name, cache_config &config, int core_id, int type_id,

src/gpgpu-sim/shader.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,9 +2869,9 @@ void ldst_unit::cycle() {
28692869
// on load miss only
28702870

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

28762876
if (CACHE_GLOBAL == mf->get_inst().cache_op || (m_L1D == NULL)) {
28772877
bypassL1D = true;
@@ -2895,7 +2895,7 @@ void ldst_unit::cycle() {
28952895
} else {
28962896
if (m_L1D->fill_port_free()) {
28972897
m_L1D->fill(mf, m_core->get_gpu()->gpu_sim_cycle +
2898-
m_core->get_gpu()->gpu_tot_sim_cycle, m_L1D->prediction_table, temp_pc);
2898+
m_core->get_gpu()->gpu_tot_sim_cycle, m_L1D->prediction_table, hashed_pc);
28992899
m_response_fifo.pop_front();
29002900
}
29012901
}

0 commit comments

Comments
 (0)