fetch_impl.hh (13453:4a7a060ea26e) | fetch_impl.hh (13559:e9983a972327) |
---|---|
1/* 2 * Copyright (c) 2010-2014 ARM Limited 3 * Copyright (c) 2012-2013 AMD 4 * All rights reserved. 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 65 unchanged lines hidden (view full) --- 74#include "sim/full_system.hh" 75#include "sim/system.hh" 76#include "cpu/o3/isa_specific.hh" 77 78using namespace std; 79 80template<class Impl> 81DefaultFetch<Impl>::DefaultFetch(O3CPU *_cpu, DerivO3CPUParams *params) | 1/* 2 * Copyright (c) 2010-2014 ARM Limited 3 * Copyright (c) 2012-2013 AMD 4 * All rights reserved. 5 * 6 * The license below extends only to copyright in the software and shall 7 * not be construed as granting a license to any other intellectual 8 * property including but not limited to intellectual property relating --- 65 unchanged lines hidden (view full) --- 74#include "sim/full_system.hh" 75#include "sim/system.hh" 76#include "cpu/o3/isa_specific.hh" 77 78using namespace std; 79 80template<class Impl> 81DefaultFetch<Impl>::DefaultFetch(O3CPU *_cpu, DerivO3CPUParams *params) |
82 : cpu(_cpu), | 82 : fetchPolicy(params->smtFetchPolicy), 83 cpu(_cpu), |
83 branchPred(nullptr), 84 decodeToFetchDelay(params->decodeToFetchDelay), 85 renameToFetchDelay(params->renameToFetchDelay), 86 iewToFetchDelay(params->iewToFetchDelay), 87 commitToFetchDelay(params->commitToFetchDelay), 88 fetchWidth(params->fetchWidth), 89 decodeWidth(params->decodeWidth), 90 retryPkt(NULL), --- 16 unchanged lines hidden (view full) --- 107 fetchWidth, static_cast<int>(Impl::MaxWidth)); 108 if (fetchBufferSize > cacheBlkSize) 109 fatal("fetch buffer size (%u bytes) is greater than the cache " 110 "block size (%u bytes)\n", fetchBufferSize, cacheBlkSize); 111 if (cacheBlkSize % fetchBufferSize) 112 fatal("cache block (%u bytes) is not a multiple of the " 113 "fetch buffer (%u bytes)\n", cacheBlkSize, fetchBufferSize); 114 | 84 branchPred(nullptr), 85 decodeToFetchDelay(params->decodeToFetchDelay), 86 renameToFetchDelay(params->renameToFetchDelay), 87 iewToFetchDelay(params->iewToFetchDelay), 88 commitToFetchDelay(params->commitToFetchDelay), 89 fetchWidth(params->fetchWidth), 90 decodeWidth(params->decodeWidth), 91 retryPkt(NULL), --- 16 unchanged lines hidden (view full) --- 108 fetchWidth, static_cast<int>(Impl::MaxWidth)); 109 if (fetchBufferSize > cacheBlkSize) 110 fatal("fetch buffer size (%u bytes) is greater than the cache " 111 "block size (%u bytes)\n", fetchBufferSize, cacheBlkSize); 112 if (cacheBlkSize % fetchBufferSize) 113 fatal("cache block (%u bytes) is not a multiple of the " 114 "fetch buffer (%u bytes)\n", cacheBlkSize, fetchBufferSize); 115 |
115 std::string policy = params->smtFetchPolicy; 116 117 // Convert string to lowercase 118 std::transform(policy.begin(), policy.end(), policy.begin(), 119 (int(*)(int)) tolower); 120 | |
121 // Figure out fetch policy | 116 // Figure out fetch policy |
122 if (policy == "singlethread") { 123 fetchPolicy = SingleThread; 124 if (numThreads > 1) 125 panic("Invalid Fetch Policy for a SMT workload."); 126 } else if (policy == "roundrobin") { 127 fetchPolicy = RoundRobin; 128 DPRINTF(Fetch, "Fetch policy set to Round Robin\n"); 129 } else if (policy == "branch") { 130 fetchPolicy = Branch; 131 DPRINTF(Fetch, "Fetch policy set to Branch Count\n"); 132 } else if (policy == "iqcount") { 133 fetchPolicy = IQ; 134 DPRINTF(Fetch, "Fetch policy set to IQ count\n"); 135 } else if (policy == "lsqcount") { 136 fetchPolicy = LSQ; 137 DPRINTF(Fetch, "Fetch policy set to LSQ count\n"); 138 } else { 139 fatal("Invalid Fetch Policy. Options Are: {SingleThread," 140 " RoundRobin,LSQcount,IQcount}\n"); 141 } | 117 panic_if(fetchPolicy == FetchPolicy::SingleThread && numThreads > 1, 118 "Invalid Fetch Policy for a SMT workload."); |
142 143 // Get the size of an instruction. 144 instSize = sizeof(TheISA::MachInst); 145 146 for (int i = 0; i < Impl::MaxThreads; i++) { 147 fetchStatus[i] = Idle; 148 decoder[i] = nullptr; 149 pc[i] = 0; --- 1002 unchanged lines hidden (view full) --- 1152 1153template<class Impl> 1154void 1155DefaultFetch<Impl>::fetch(bool &status_change) 1156{ 1157 ////////////////////////////////////////// 1158 // Start actual fetch 1159 ////////////////////////////////////////// | 119 120 // Get the size of an instruction. 121 instSize = sizeof(TheISA::MachInst); 122 123 for (int i = 0; i < Impl::MaxThreads; i++) { 124 fetchStatus[i] = Idle; 125 decoder[i] = nullptr; 126 pc[i] = 0; --- 1002 unchanged lines hidden (view full) --- 1129 1130template<class Impl> 1131void 1132DefaultFetch<Impl>::fetch(bool &status_change) 1133{ 1134 ////////////////////////////////////////// 1135 // Start actual fetch 1136 ////////////////////////////////////////// |
1160 ThreadID tid = getFetchingThread(fetchPolicy); | 1137 ThreadID tid = getFetchingThread(); |
1161 1162 assert(!cpu->switchedOut()); 1163 1164 if (tid == InvalidThreadID) { 1165 // Breaks looping condition in tick() 1166 threadFetched = numFetchingThreads; 1167 1168 if (numThreads == 1) { // @todo Per-thread stats --- 272 unchanged lines hidden (view full) --- 1441 1442/////////////////////////////////////// 1443// // 1444// SMT FETCH POLICY MAINTAINED HERE // 1445// // 1446/////////////////////////////////////// 1447template<class Impl> 1448ThreadID | 1138 1139 assert(!cpu->switchedOut()); 1140 1141 if (tid == InvalidThreadID) { 1142 // Breaks looping condition in tick() 1143 threadFetched = numFetchingThreads; 1144 1145 if (numThreads == 1) { // @todo Per-thread stats --- 272 unchanged lines hidden (view full) --- 1418 1419/////////////////////////////////////// 1420// // 1421// SMT FETCH POLICY MAINTAINED HERE // 1422// // 1423/////////////////////////////////////// 1424template<class Impl> 1425ThreadID |
1449DefaultFetch<Impl>::getFetchingThread(FetchPriority &fetch_priority) | 1426DefaultFetch |
1450{ 1451 if (numThreads > 1) { | 1427{ 1428 if (numThreads > 1) { |
1452 switch (fetch_priority) { 1453 1454 case SingleThread: 1455 return 0; 1456 1457 case RoundRobin: | 1429 switch (fetchPolicy) { 1430 case FetchPolicy::RoundRobin: |
1458 return roundRobin(); | 1431 return roundRobin(); |
1459 1460 case IQ: | 1432 case FetchPolicy::IQCount: |
1461 return iqCount(); | 1433 return iqCount(); |
1462 1463 case LSQ: | 1434 case FetchPolicy::LSQCount: |
1464 return lsqCount(); | 1435 return lsqCount(); |
1465 1466 case Branch: | 1436 case FetchPolicy::Branch: |
1467 return branchCount(); | 1437 return branchCount(); |
1468 | |
1469 default: 1470 return InvalidThreadID; 1471 } 1472 } else { 1473 list<ThreadID>::iterator thread = activeThreads->begin(); 1474 if (thread == activeThreads->end()) { 1475 return InvalidThreadID; 1476 } --- 210 unchanged lines hidden --- | 1438 default: 1439 return InvalidThreadID; 1440 } 1441 } else { 1442 list<ThreadID>::iterator thread = activeThreads->begin(); 1443 if (thread == activeThreads->end()) { 1444 return InvalidThreadID; 1445 } --- 210 unchanged lines hidden --- |