summaryrefslogtreecommitdiff
path: root/src/cpu/o3/fetch_impl.hh
diff options
context:
space:
mode:
authorNikos Nikoleris <nikos.nikoleris@arm.com>2019-01-03 17:45:56 +0000
committerNikos Nikoleris <nikos.nikoleris@arm.com>2019-01-17 11:09:08 +0000
commit38339e0a7f7ce119feefc95591703df2f851ee4d (patch)
tree3f99ddbd0e1b9073c23becf8aba1c28417e5a436 /src/cpu/o3/fetch_impl.hh
parent8ddec57062bdde7935bb0472f2d993fb0c38c680 (diff)
downloadgem5-38339e0a7f7ce119feefc95591703df2f851ee4d.tar.xz
cpu-o3: Make the smtFetchPolicy a Param.ScopedEnum
The smtFetchPolicy is a parameter in the o3 cpu that can have 5 different values. Previously this setting was done through a string and a parser function would turn it into a c++ enum value. This changeset turns the string into a python Param.ScopedEnum. Change-Id: Iafb4b4b27587541185ea912e5ed581bce09695f5 Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/15396 Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com> Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>
Diffstat (limited to 'src/cpu/o3/fetch_impl.hh')
-rw-r--r--src/cpu/o3/fetch_impl.hh53
1 files changed, 11 insertions, 42 deletions
diff --git a/src/cpu/o3/fetch_impl.hh b/src/cpu/o3/fetch_impl.hh
index 537f93089..73c1ed156 100644
--- a/src/cpu/o3/fetch_impl.hh
+++ b/src/cpu/o3/fetch_impl.hh
@@ -79,7 +79,8 @@ using namespace std;
template<class Impl>
DefaultFetch<Impl>::DefaultFetch(O3CPU *_cpu, DerivO3CPUParams *params)
- : cpu(_cpu),
+ : fetchPolicy(params->smtFetchPolicy),
+ cpu(_cpu),
branchPred(nullptr),
decodeToFetchDelay(params->decodeToFetchDelay),
renameToFetchDelay(params->renameToFetchDelay),
@@ -112,33 +113,9 @@ DefaultFetch<Impl>::DefaultFetch(O3CPU *_cpu, DerivO3CPUParams *params)
fatal("cache block (%u bytes) is not a multiple of the "
"fetch buffer (%u bytes)\n", cacheBlkSize, fetchBufferSize);
- std::string policy = params->smtFetchPolicy;
-
- // Convert string to lowercase
- std::transform(policy.begin(), policy.end(), policy.begin(),
- (int(*)(int)) tolower);
-
// Figure out fetch policy
- if (policy == "singlethread") {
- fetchPolicy = SingleThread;
- if (numThreads > 1)
- panic("Invalid Fetch Policy for a SMT workload.");
- } else if (policy == "roundrobin") {
- fetchPolicy = RoundRobin;
- DPRINTF(Fetch, "Fetch policy set to Round Robin\n");
- } else if (policy == "branch") {
- fetchPolicy = Branch;
- DPRINTF(Fetch, "Fetch policy set to Branch Count\n");
- } else if (policy == "iqcount") {
- fetchPolicy = IQ;
- DPRINTF(Fetch, "Fetch policy set to IQ count\n");
- } else if (policy == "lsqcount") {
- fetchPolicy = LSQ;
- DPRINTF(Fetch, "Fetch policy set to LSQ count\n");
- } else {
- fatal("Invalid Fetch Policy. Options Are: {SingleThread,"
- " RoundRobin,LSQcount,IQcount}\n");
- }
+ panic_if(fetchPolicy == FetchPolicy::SingleThread && numThreads > 1,
+ "Invalid Fetch Policy for a SMT workload.");
// Get the size of an instruction.
instSize = sizeof(TheISA::MachInst);
@@ -1157,7 +1134,7 @@ DefaultFetch<Impl>::fetch(bool &status_change)
//////////////////////////////////////////
// Start actual fetch
//////////////////////////////////////////
- ThreadID tid = getFetchingThread(fetchPolicy);
+ ThreadID tid = getFetchingThread();
assert(!cpu->switchedOut());
@@ -1446,26 +1423,18 @@ DefaultFetch<Impl>::recvReqRetry()
///////////////////////////////////////
template<class Impl>
ThreadID
-DefaultFetch<Impl>::getFetchingThread(FetchPriority &fetch_priority)
+DefaultFetch<Impl>::getFetchingThread()
{
if (numThreads > 1) {
- switch (fetch_priority) {
-
- case SingleThread:
- return 0;
-
- case RoundRobin:
+ switch (fetchPolicy) {
+ case FetchPolicy::RoundRobin:
return roundRobin();
-
- case IQ:
+ case FetchPolicy::IQCount:
return iqCount();
-
- case LSQ:
+ case FetchPolicy::LSQCount:
return lsqCount();
-
- case Branch:
+ case FetchPolicy::Branch:
return branchCount();
-
default:
return InvalidThreadID;
}