ltage.cc (13627:ec1395943cd2) | ltage.cc (13685:bb3377c81303) |
---|---|
1/* 2 * Copyright (c) 2014 The University of Wisconsin 3 * 4 * Copyright (c) 2006 INRIA (Institut National de Recherche en 5 * Informatique et en Automatique / French National Research Institute 6 * for Computer Science and Applied Mathematics) 7 * 8 * All rights reserved. --- 28 unchanged lines hidden (view full) --- 37/* @file 38 * Implementation of a L-TAGE branch predictor 39 */ 40 41#include "cpu/pred/ltage.hh" 42 43#include "base/intmath.hh" 44#include "base/logging.hh" | 1/* 2 * Copyright (c) 2014 The University of Wisconsin 3 * 4 * Copyright (c) 2006 INRIA (Institut National de Recherche en 5 * Informatique et en Automatique / French National Research Institute 6 * for Computer Science and Applied Mathematics) 7 * 8 * All rights reserved. --- 28 unchanged lines hidden (view full) --- 37/* @file 38 * Implementation of a L-TAGE branch predictor 39 */ 40 41#include "cpu/pred/ltage.hh" 42 43#include "base/intmath.hh" 44#include "base/logging.hh" |
45#include "base/random.hh" |
|
45#include "base/trace.hh" 46#include "debug/Fetch.hh" 47#include "debug/LTage.hh" 48 49LTAGE::LTAGE(const LTAGEParams *params) 50 : TAGE(params), loopPredictor(params->loop_predictor) 51{ 52} 53 | 46#include "base/trace.hh" 47#include "debug/Fetch.hh" 48#include "debug/LTage.hh" 49 50LTAGE::LTAGE(const LTAGEParams *params) 51 : TAGE(params), loopPredictor(params->loop_predictor) 52{ 53} 54 |
55void 56LTAGE::init() 57{ 58 TAGE::init(); 59} 60 |
|
54//prediction 55bool 56LTAGE::predict(ThreadID tid, Addr branch_pc, bool cond_branch, void* &b) 57{ 58 LTageBranchInfo *bi = new LTageBranchInfo(*tage, *loopPredictor); 59 b = (void*)(bi); 60 61 bool pred_taken = tage->tagePredict(tid, branch_pc, cond_branch, --- 15 unchanged lines hidden (view full) --- 77 } 78 79 // record final prediction 80 bi->lpBranchInfo->predTaken = pred_taken; 81 82 return pred_taken; 83} 84 | 61//prediction 62bool 63LTAGE::predict(ThreadID tid, Addr branch_pc, bool cond_branch, void* &b) 64{ 65 LTageBranchInfo *bi = new LTageBranchInfo(*tage, *loopPredictor); 66 b = (void*)(bi); 67 68 bool pred_taken = tage->tagePredict(tid, branch_pc, cond_branch, --- 15 unchanged lines hidden (view full) --- 84 } 85 86 // record final prediction 87 bi->lpBranchInfo->predTaken = pred_taken; 88 89 return pred_taken; 90} 91 |
92// PREDICTOR UPDATE |
|
85void 86LTAGE::update(ThreadID tid, Addr branch_pc, bool taken, void* bp_history, 87 bool squashed, const StaticInstPtr & inst, Addr corrTarget) 88{ 89 assert(bp_history); 90 91 LTageBranchInfo* bi = static_cast<LTageBranchInfo*>(bp_history); 92 --- 7 unchanged lines hidden (view full) --- 100 101 if (bi->tageBranchInfo->condBranch) { 102 loopPredictor->squashLoop(bi->lpBranchInfo); 103 } 104 } 105 return; 106 } 107 | 93void 94LTAGE::update(ThreadID tid, Addr branch_pc, bool taken, void* bp_history, 95 bool squashed, const StaticInstPtr & inst, Addr corrTarget) 96{ 97 assert(bp_history); 98 99 LTageBranchInfo* bi = static_cast<LTageBranchInfo*>(bp_history); 100 --- 7 unchanged lines hidden (view full) --- 108 109 if (bi->tageBranchInfo->condBranch) { 110 loopPredictor->squashLoop(bi->lpBranchInfo); 111 } 112 } 113 return; 114 } 115 |
108 int nrand = TAGEBase::getRandom() & 3; | 116 int nrand = random_mt.random<int>() & 3; |
109 if (bi->tageBranchInfo->condBranch) { 110 DPRINTF(LTage, "Updating tables for branch:%lx; taken?:%d\n", 111 branch_pc, taken); 112 tage->updateStats(taken, bi->tageBranchInfo); 113 114 loopPredictor->updateStats(taken, bi->lpBranchInfo); 115 116 loopPredictor->condBranchUpdate(tid, branch_pc, taken, | 117 if (bi->tageBranchInfo->condBranch) { 118 DPRINTF(LTage, "Updating tables for branch:%lx; taken?:%d\n", 119 branch_pc, taken); 120 tage->updateStats(taken, bi->tageBranchInfo); 121 122 loopPredictor->updateStats(taken, bi->lpBranchInfo); 123 124 loopPredictor->condBranchUpdate(tid, branch_pc, taken, |
117 bi->tageBranchInfo->tagePred, bi->lpBranchInfo, instShiftAmt, 118 TAGEBase::getRandom(), TAGEBase::getRandom(), 119 TAGEBase::getRandom()); | 125 bi->tageBranchInfo->tagePred, bi->lpBranchInfo, instShiftAmt); |
120 121 tage->condBranchUpdate(tid, branch_pc, taken, bi->tageBranchInfo, | 126 127 tage->condBranchUpdate(tid, branch_pc, taken, bi->tageBranchInfo, |
122 nrand, corrTarget); | 128 nrand, corrTarget, bi->lpBranchInfo->predTaken); |
123 } 124 125 tage->updateHistories(tid, branch_pc, taken, bi->tageBranchInfo, false, 126 inst, corrTarget); 127 128 delete bi; 129} 130 --- 23 unchanged lines hidden --- | 129 } 130 131 tage->updateHistories(tid, branch_pc, taken, bi->tageBranchInfo, false, 132 inst, corrTarget); 133 134 delete bi; 135} 136 --- 23 unchanged lines hidden --- |