ChampSim
spp_dev.h
Go to the documentation of this file.
1 #ifndef SPP_H
2 #define SPP_H
3 
4 #include <cstdint>
5 #include <vector>
6 
7 namespace spp
8 {
9 // SPP functional knobs
10 constexpr bool LOOKAHEAD_ON = true;
11 constexpr bool FILTER_ON = true;
12 constexpr bool GHR_ON = true;
13 constexpr bool SPP_SANITY_CHECK = true;
14 constexpr bool SPP_DEBUG_PRINT = false;
15 
16 // Signature table parameters
17 constexpr std::size_t ST_SET = 1;
18 constexpr std::size_t ST_WAY = 256;
19 constexpr unsigned ST_TAG_BIT = 16;
20 constexpr uint32_t ST_TAG_MASK = ((1 << ST_TAG_BIT) - 1);
21 constexpr unsigned SIG_SHIFT = 3;
22 constexpr unsigned SIG_BIT = 12;
23 constexpr uint32_t SIG_MASK = ((1 << SIG_BIT) - 1);
24 constexpr unsigned SIG_DELTA_BIT = 7;
25 
26 // Pattern table parameters
27 constexpr std::size_t PT_SET = 512;
28 constexpr std::size_t PT_WAY = 4;
29 constexpr unsigned C_SIG_BIT = 4;
30 constexpr unsigned C_DELTA_BIT = 4;
31 constexpr uint32_t C_SIG_MAX = ((1 << C_SIG_BIT) - 1);
32 constexpr uint32_t C_DELTA_MAX = ((1 << C_DELTA_BIT) - 1);
33 
34 // Prefetch filter parameters
35 constexpr unsigned QUOTIENT_BIT = 10;
36 constexpr unsigned REMAINDER_BIT = 6;
37 constexpr unsigned HASH_BIT = (QUOTIENT_BIT + REMAINDER_BIT + 1);
38 constexpr std::size_t FILTER_SET = (1 << QUOTIENT_BIT);
39 constexpr uint32_t FILL_THRESHOLD = 90;
40 constexpr uint32_t PF_THRESHOLD = 25;
41 
42 // Global register parameters
43 constexpr unsigned GLOBAL_COUNTER_BIT = 10;
44 constexpr uint32_t GLOBAL_COUNTER_MAX = ((1 << GLOBAL_COUNTER_BIT) - 1);
45 constexpr std::size_t MAX_GHR_ENTRY = 8;
46 
47 enum FILTER_REQUEST { SPP_L2C_PREFETCH, SPP_LLC_PREFETCH, L2C_DEMAND, L2C_EVICT }; // Request type for prefetch filter
48 uint64_t get_hash(uint64_t key);
49 
51 {
52 public:
55 
57  {
58  for (uint32_t set = 0; set < ST_SET; set++)
59  for (uint32_t way = 0; way < ST_WAY; way++) {
60  valid[set][way] = 0;
61  tag[set][way] = 0;
62  last_offset[set][way] = 0;
63  sig[set][way] = 0;
64  lru[set][way] = way;
65  }
66  };
67 
68  void read_and_update_sig(uint64_t page, uint32_t page_offset, uint32_t& last_sig, uint32_t& curr_sig, int32_t& delta);
69 };
70 
72 {
73 public:
76 
78  {
79  for (uint32_t set = 0; set < PT_SET; set++) {
80  for (uint32_t way = 0; way < PT_WAY; way++) {
81  delta[set][way] = 0;
82  c_delta[set][way] = 0;
83  }
84  c_sig[set] = 0;
85  }
86  }
87 
88  void update_pattern(uint32_t last_sig, int curr_delta), read_pattern(uint32_t curr_sig, std::vector<int>&prefetch_delta, std::vector<uint32_t>&confidence_q,
89  uint32_t&lookahead_way, uint32_t&lookahead_conf, uint32_t&pf_q_tail, uint32_t&depth);
90 };
91 
93 {
94 public:
96  bool valid[FILTER_SET], // Consider this as "prefetched"
97  useful[FILTER_SET]; // Consider this as "used"
98 
100  {
101  for (uint32_t set = 0; set < FILTER_SET; set++) {
102  remainder_tag[set] = 0;
103  valid[set] = 0;
104  useful[set] = 0;
105  }
106  }
107 
108  bool check(uint64_t pf_addr, FILTER_REQUEST filter_request);
109 };
110 
112 {
113 public:
114  // Global counters to calculate global prefetching accuracy
115  uint32_t pf_useful, pf_issued;
116  uint32_t global_accuracy; // Alpha value in Section III. Equation 3
117 
118  // Global History Register (GHR) entries
122 
124  {
125  pf_useful = 0;
126  pf_issued = 0;
127  global_accuracy = 0;
128 
129  for (uint32_t i = 0; i < MAX_GHR_ENTRY; i++) {
130  valid[i] = 0;
131  sig[i] = 0;
132  confidence[i] = 0;
133  offset[i] = 0;
134  delta[i] = 0;
135  }
136  }
137 
138  void update_entry(uint32_t pf_sig, uint32_t pf_confidence, uint32_t pf_offset, int pf_delta);
139  uint32_t check_entry(uint32_t page_offset);
140 };
141 } // namespace spp
142 
143 #endif
Definition: spp_dev.h:112
uint32_t pf_issued
Definition: spp_dev.h:115
uint32_t sig[MAX_GHR_ENTRY]
Definition: spp_dev.h:120
uint32_t confidence[MAX_GHR_ENTRY]
Definition: spp_dev.h:120
uint32_t offset[MAX_GHR_ENTRY]
Definition: spp_dev.h:120
void update_entry(uint32_t pf_sig, uint32_t pf_confidence, uint32_t pf_offset, int pf_delta)
Definition: spp_dev.cc:499
GLOBAL_REGISTER()
Definition: spp_dev.h:123
uint32_t global_accuracy
Definition: spp_dev.h:116
uint32_t check_entry(uint32_t page_offset)
Definition: spp_dev.cc:553
uint32_t pf_useful
Definition: spp_dev.h:115
int delta[MAX_GHR_ENTRY]
Definition: spp_dev.h:121
uint8_t valid[MAX_GHR_ENTRY]
Definition: spp_dev.h:119
Definition: spp_dev.h:72
void update_pattern(uint32_t last_sig, int curr_delta)
Definition: spp_dev.cc:297
int delta[PT_SET][PT_WAY]
Definition: spp_dev.h:74
uint32_t c_sig[PT_SET]
Definition: spp_dev.h:75
void read_pattern(uint32_t curr_sig, std::vector< int > &prefetch_delta, std::vector< uint32_t > &confidence_q, uint32_t &lookahead_way, uint32_t &lookahead_conf, uint32_t &pf_q_tail, uint32_t &depth)
Definition: spp_dev.cc:357
PATTERN_TABLE()
Definition: spp_dev.h:77
uint32_t c_delta[PT_SET][PT_WAY]
Definition: spp_dev.h:75
Definition: spp_dev.h:93
bool check(uint64_t pf_addr, FILTER_REQUEST filter_request)
Definition: spp_dev.cc:406
uint64_t remainder_tag[FILTER_SET]
Definition: spp_dev.h:95
bool useful[FILTER_SET]
Definition: spp_dev.h:97
PREFETCH_FILTER()
Definition: spp_dev.h:99
bool valid[FILTER_SET]
Definition: spp_dev.h:96
Definition: spp_dev.h:51
uint32_t lru[ST_SET][ST_WAY]
Definition: spp_dev.h:54
uint32_t tag[ST_SET][ST_WAY]
Definition: spp_dev.h:54
void read_and_update_sig(uint64_t page, uint32_t page_offset, uint32_t &last_sig, uint32_t &curr_sig, int32_t &delta)
Definition: spp_dev.cc:179
uint32_t sig[ST_SET][ST_WAY]
Definition: spp_dev.h:54
bool valid[ST_SET][ST_WAY]
Definition: spp_dev.h:53
uint32_t last_offset[ST_SET][ST_WAY]
Definition: spp_dev.h:54
SIGNATURE_TABLE()
Definition: spp_dev.h:56
Definition: spp_dev.cc:158
constexpr std::size_t MAX_GHR_ENTRY
Definition: spp_dev.h:45
constexpr bool GHR_ON
Definition: spp_dev.h:12
constexpr bool FILTER_ON
Definition: spp_dev.h:11
uint64_t get_hash(uint64_t key)
Definition: spp_dev.cc:160
constexpr std::size_t PT_SET
Definition: spp_dev.h:27
constexpr unsigned QUOTIENT_BIT
Definition: spp_dev.h:35
constexpr uint32_t C_DELTA_MAX
Definition: spp_dev.h:32
constexpr std::size_t ST_WAY
Definition: spp_dev.h:18
constexpr unsigned REMAINDER_BIT
Definition: spp_dev.h:36
constexpr uint32_t C_SIG_MAX
Definition: spp_dev.h:31
constexpr unsigned ST_TAG_BIT
Definition: spp_dev.h:19
constexpr uint32_t GLOBAL_COUNTER_MAX
Definition: spp_dev.h:44
constexpr uint32_t SIG_MASK
Definition: spp_dev.h:23
constexpr bool SPP_DEBUG_PRINT
Definition: spp_dev.h:14
constexpr uint32_t FILL_THRESHOLD
Definition: spp_dev.h:39
constexpr unsigned GLOBAL_COUNTER_BIT
Definition: spp_dev.h:43
constexpr bool SPP_SANITY_CHECK
Definition: spp_dev.h:13
constexpr uint32_t ST_TAG_MASK
Definition: spp_dev.h:20
constexpr unsigned SIG_DELTA_BIT
Definition: spp_dev.h:24
constexpr std::size_t PT_WAY
Definition: spp_dev.h:28
constexpr unsigned SIG_SHIFT
Definition: spp_dev.h:21
constexpr std::size_t FILTER_SET
Definition: spp_dev.h:38
constexpr unsigned SIG_BIT
Definition: spp_dev.h:22
constexpr unsigned C_SIG_BIT
Definition: spp_dev.h:29
constexpr std::size_t ST_SET
Definition: spp_dev.h:17
constexpr unsigned HASH_BIT
Definition: spp_dev.h:37
constexpr unsigned C_DELTA_BIT
Definition: spp_dev.h:30
FILTER_REQUEST
Definition: spp_dev.h:47
@ SPP_LLC_PREFETCH
Definition: spp_dev.h:47
@ SPP_L2C_PREFETCH
Definition: spp_dev.h:47
@ L2C_EVICT
Definition: spp_dev.h:47
@ L2C_DEMAND
Definition: spp_dev.h:47
constexpr uint32_t PF_THRESHOLD
Definition: spp_dev.h:40
constexpr bool LOOKAHEAD_ON
Definition: spp_dev.h:10