Skip to content

Commit

Permalink
mem: add enableCoordinate param
Browse files Browse the repository at this point in the history
set enableCoordinate to true to enable coordinate control of cdp.
Also fix clang compile bug

Change-Id: Icdd86d225c8014b210cbc360cba4066921f90a5d
  • Loading branch information
happy-lx committed Dec 13, 2024
1 parent 530ae8d commit 8314813
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/mem/cache/prefetch/Prefetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ class CDP(QueuedPrefetcher):
on_write = False
on_data = True
on_inst = False
enable_coordinate = Param.Bool(True, "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
7 changes: 4 additions & 3 deletions src/mem/cache/prefetch/cdp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace prefetch
{
CDP::CDP(const CDPParams &p)
: Queued(p),
enableCoordinate(p.enable_coordinate),
depth_threshold(1),
degree(3),
throttle_aggressiveness(p.throttle_aggressiveness),
Expand Down Expand Up @@ -185,7 +186,7 @@ CDP::calculatePrefetch(const PrefetchInfo &pfi, std::vector<AddrPriority> &addre
DPRINTF(CDPUseful, "Miss addr: %#llx\n", addr);
}
if (!is_l1_prefetch && !is_l2_prefetch) {
prefetchUsed(pfi.getPaddr());
recordUsedPrefetch(pfi.getPaddr());
addToVpnTable(pfi.getAddr(), pf_hit_cdp);
}
return;
Expand Down Expand Up @@ -416,7 +417,7 @@ CDP::needFilter(Addr addr)
}

void
CDP::prefetchUsed(Addr addr)
CDP::recordUsedPrefetch(Addr addr)
{
// prefetch hit a cdp prefetched block
// decrement the confidence of related region (+1)
Expand All @@ -426,7 +427,7 @@ CDP::prefetchUsed(Addr addr)
}

void
CDP::prefetchUnused(Addr addr)
CDP::recordUnusedPrefetch(Addr addr)
{
// cache evicts a cdp prefetched block
// decrement the confidence of related region (-1)
Expand Down
48 changes: 25 additions & 23 deletions src/mem/cache/prefetch/cdp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ namespace prefetch
class CDP : public Queued
{


std::vector<bool> enable_prf_filter;
std::vector<bool> enable_prf_filter2;
bool enableCoordinate;
int depth_threshold;
int degree;
float throttle_aggressiveness;
Expand Down Expand Up @@ -392,7 +392,7 @@ class CDP : public Queued
mpki = l3_miss_info.second * 1000.0 / ins_num;
}
}
void recvCustomInfoFrmUpStream(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 @@ -424,8 +424,8 @@ class CDP : public Queued

void insertFilterTable(Addr addr, bool useful);
bool needFilter(Addr addr);
void prefetchUsed(Addr addr);
void prefetchUnused(Addr addr);
void recordUsedPrefetch(Addr addr);
void recordUnusedPrefetch(Addr addr);

Addr filterTableAddr(Addr addr) {
return addr >> filterEntryGranularityBits;
Expand Down Expand Up @@ -456,26 +456,28 @@ class CDP : public Queued
float cdpCoverage = getCdpTrueCoverage();
int throAction{0};

if (cdpCoverage >= Tcoverage) {
throAction = 0;
lowConf = false;
} else if (cdpAccuracy < Alow) {
throAction = 1;
lowConf = true;
} else if (cdpAccuracy < Ahigh) {
if (rivalCoverage >= RivalTcoverage) {
throAction = 2;
lowConf = true;
} else {
throAction = 3;
if (enableCoordinate) {
if (cdpCoverage >= Tcoverage) {
throAction = 0;
lowConf = false;
}
} else if (cdpAccuracy >= Ahigh) {
if (rivalCoverage < RivalTcoverage) {
throAction = 4;
lowConf = false;
} else {
throAction = 5;
} else if (cdpAccuracy < Alow) {
throAction = 1;
lowConf = true;
} else if (cdpAccuracy < Ahigh) {
if (rivalCoverage >= RivalTcoverage) {
throAction = 2;
lowConf = true;
} else {
throAction = 3;
lowConf = false;
}
} else if (cdpAccuracy >= Ahigh) {
if (rivalCoverage < RivalTcoverage) {
throAction = 4;
lowConf = false;
} else {
throAction = 5;
}
}
}
cdpStats.ThrottlingActionDist.sample(throAction);
Expand Down
4 changes: 2 additions & 2 deletions src/mem/cache/prefetch/l2_composite_with_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ L2CompositeWithWorkerPrefetcher::prefetchUnused(Addr paddr, PrefetchSourceType p
{
Base::prefetchUnused(pfSource);
if (pfSource == PrefetchSourceType::CDP) {
cdp->prefetchUnused(paddr);
cdp->recordUnusedPrefetch(paddr);
}
}

Expand Down Expand Up @@ -97,7 +97,7 @@ L2CompositeWithWorkerPrefetcher::notify(const PacketPtr &pkt, const PrefetchInfo
void
L2CompositeWithWorkerPrefetcher::recvCustomInfoFrmUpStream(CustomPfInfo& info)
{
cdp->recvCustomInfoFrmUpStream(info);
cdp->recvRivalCoverage(info);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/mem/ruby/structures/RubyPrefetcherProxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ RubyPrefetcherProxy::notifyPfEvict(Addr blkAddr, bool hwPrefetched, XsPFMetaData
// blkAddr, false, requestorID, *this);
// Maybe using the old DataUpdate here is enough
if (hwPrefetched) {
prefetcher->prefetchUnused(pfmeta.prefetchSource);
prefetcher->prefetchUnused(blkAddr, pfmeta.prefetchSource);
}
DataUpdate data_update(blkAddr, false);
// data_update.hwPrefetched = hwPrefetched;
Expand Down

0 comments on commit 8314813

Please sign in to comment.