Skip to content

Commit

Permalink
mem: disable coordinate in cdp
Browse files Browse the repository at this point in the history
Change-Id: If362bac0b8f4211f24b6579d220f3be7db61ea7e
  • Loading branch information
happy-lx committed Dec 18, 2024
1 parent b0f9af3 commit a232a05
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/mem/cache/prefetch/Prefetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class CDP(QueuedPrefetcher):
on_write = False
on_data = True
on_inst = False
enable_coordinate = Param.Bool(True, "enable coordinate throttling or not")
enable_coordinate = Param.Bool(False, "enable coordinate throttling or not")
use_byteorder = Param.Bool(True,"")
vpn_sub_entries = Param.Unsigned(4,
"Sub entry number of each of vpnEntry")
Expand Down
69 changes: 46 additions & 23 deletions src/mem/cache/prefetch/cdp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class CDP : public Queued
exist(false),
hot(false)
{}
void init(uint64_t _debug_vpn1, uint64_t _debug_vpn2, bool pf_hit_cdp) {
void init(uint64_t _debug_vpn1, uint64_t _debug_vpn2, bool pf_hit_cdp)
{
if (pf_hit_cdp) {
refCnt = 4;
} else {
Expand All @@ -111,22 +112,25 @@ class CDP : public Queued
debug_vpn1 = _debug_vpn1;
debug_vpn2 = _debug_vpn2;
}
void discard() {
void discard()
{
refCnt = 0;
prevRefCnt = 0;
hot = false;
exist = false;
debug_vpn1 = 0;
debug_vpn2 = 0;
}
void access(bool pf_hit_cdp) {
void access(bool pf_hit_cdp)
{
if (pf_hit_cdp) {
refCnt += 4;
} else {
refCnt++;
}
}
void updateHot(bool low_conf) {
void updateHot(bool low_conf)
{
if (low_conf) {
if (prevRefCnt > (resetPeriod / 16)) {
hot = true;
Expand All @@ -141,11 +145,13 @@ class CDP : public Queued
}
}
}
void decr(bool low_conf) {
void decr(bool low_conf)
{
prevRefCnt = prevRefCnt == 0 ? 0 : (prevRefCnt - 1);
updateHot(low_conf);
}
void periodReset(float throttle_aggressiveness, bool enable_thro, bool low_conf) {
void periodReset(float throttle_aggressiveness, bool enable_thro, bool low_conf)
{
if (enable_thro) {
prevRefCnt = throttle_aggressiveness * refCnt;
} else {
Expand Down Expand Up @@ -179,23 +185,28 @@ class CDP : public Queued
}
subEntryBits = ceil(log2(subEntryNum));
}
void discard() {
void discard()
{
for (int i = 0; i < subEntryNum; i++) {
subEntries[i].discard();
}
}
void init(uint64_t vpn1, uint64_t vpn2, bool pf_hit_cdp) {
void init(uint64_t vpn1, uint64_t vpn2, bool pf_hit_cdp)
{
uint64_t sub_idx = ((vpn2 << 9) | vpn1) & ((1UL << subEntryBits) - 1);
assert(sub_idx < subEntryNum);
subEntries[sub_idx].init(vpn1, vpn2, pf_hit_cdp);
}
void access(uint64_t idx, bool pf_hit_cdp) {
void access(uint64_t idx, bool pf_hit_cdp)
{
subEntries[idx].access(pf_hit_cdp);
}
void decr(uint64_t idx, bool low_conf) {
void decr(uint64_t idx, bool low_conf)
{
subEntries[idx].decr(low_conf);
}
void periodReset(float throttle_aggressiveness, bool enable_thro, bool low_conf) {
void periodReset(float throttle_aggressiveness, bool enable_thro, bool low_conf)
{
for (int i = 0; i < subEntryNum; i++) {
if (subEntries[i].getExist()) {
subEntries[i].periodReset(throttle_aggressiveness, enable_thro, low_conf);
Expand Down Expand Up @@ -232,7 +243,8 @@ class CDP : public Queued
assert(_subEntryNum % 2 == 0 && _subEntryNum < 512);
_subEntryBits = ceil(log2(_subEntryNum));
}
void add(int vpn2, int vpn1, bool pf_hit_cdp) {
void add(int vpn2, int vpn1, bool pf_hit_cdp)
{
_resetCounter++;
Addr cat_addr = (vpn2 << 9) | vpn1;
uint64_t sub_idx = cat_addr & ((1UL << _subEntryBits) - 1);
Expand Down Expand Up @@ -337,32 +349,38 @@ class CDP : public Queued
bit_map.assign(size, SatCounter8{2, 2});
}

void reset() {
void reset()
{
bit_map.assign(bit_map.size(), SatCounter8{2, 2});
}

uint64_t getInnerAddr(Addr addr) const {
uint64_t getInnerAddr(Addr addr) const
{
// Note:
// addr is the `blockIndex(block address)`
return addr % bit_map.size();
}

bool needFilter(Addr addr) const {
bool needFilter(Addr addr) const
{
uint64_t idx = getInnerAddr(addr);
return bit_map[idx].isSaturated();
}

uint64_t getValue(Addr addr) {
uint64_t getValue(Addr addr)
{
uint64_t idx = getInnerAddr(addr);
return bit_map[idx].rawCounter();
}

void setFilter(Addr addr) {
void setFilter(Addr addr)
{
uint64_t idx = getInnerAddr(addr);
bit_map[idx]++;
}

void unSetFilter(Addr addr) {
void unSetFilter(Addr addr)
{
uint64_t idx = getInnerAddr(addr);
bit_map[idx]--;
}
Expand Down Expand Up @@ -392,7 +410,8 @@ class CDP : public Queued
mpki = l3_miss_info.second * 1000.0 / ins_num;
}
}
void recvRivalCoverage(CustomPfInfo& info) {
void recvRivalCoverage(CustomPfInfo& info)
{
rivalCoverage = info.coverage;
}
bool sendPFWithFilter(Addr addr, std::vector<AddrPriority> &addresses, int prio, PrefetchSourceType pfSource,
Expand Down Expand Up @@ -427,11 +446,13 @@ class CDP : public Queued
void recordUsedPrefetch(Addr addr);
void recordUnusedPrefetch(Addr addr);

Addr filterTableAddr(Addr addr) {
Addr filterTableAddr(Addr addr)
{
return addr >> filterEntryGranularityBits;
}

float getCdpTrueAccuracy() const {
float getCdpTrueAccuracy() const
{
float trueAccuracy = 1;
if (prefetchStatsPtr->pfIssued_srcs[PrefetchSourceType::CDP].value() > 100) {
trueAccuracy = (prefetchStatsPtr->pfUseful_srcs[PrefetchSourceType::CDP].value() * 1.0) /
Expand All @@ -440,7 +461,8 @@ class CDP : public Queued
return trueAccuracy;
}

float getCdpTrueCoverage() const {
float getCdpTrueCoverage() const
{
float trueCoverage = 1;
if (prefetchStatsPtr->pfUseful_srcs[PrefetchSourceType::CDP].value() > 100) {
trueCoverage = (prefetchStatsPtr->pfUseful_srcs[PrefetchSourceType::CDP].value() * 1.0) /
Expand All @@ -450,7 +472,8 @@ class CDP : public Queued
return trueCoverage;
}

bool isLowConfidence() const {
bool isLowConfidence() const
{
static bool lowConf{false};
float cdpAccuracy = getCdpTrueAccuracy();
float cdpCoverage = getCdpTrueCoverage();
Expand Down
3 changes: 1 addition & 2 deletions src/mem/cache/prefetch/l2_composite_with_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ void
L2CompositeWithWorkerPrefetcher::addToQueue(std::list<DeferredPacket> &queue, DeferredPacket &dpp)
{
if (&queue == &pfq) {
// DPRINTF(CDPFilter, "addToQueue source: %#llx, vaddr: %#llx, paddr: %#llx\n",
// dpp.pkt->req->getXsMetadata().prefetchSource, dpp.pkt->getAddr(), dpp.pkt->req->getPaddr());
// Check whether the cdp prefetch request needs to be filtered out
if (dpp.pkt->req->getXsMetadata().prefetchSource == PrefetchSourceType::CDP) {
if (cdp->needFilter(dpp.pkt->req->getPaddr())) {
delete dpp.pkt;
Expand Down

0 comments on commit a232a05

Please sign in to comment.