Commit 7f951047 authored by michael's avatar michael

blatt3: fix GAs

parent 38d2d820
......@@ -3,9 +3,9 @@ from m5.objects import *
import argparse
import sys
import pandas
import shlex
parser = argparse.ArgumentParser(description='Simulate benchmark')
# parser.add_argument('--type', help='CPU Type (one of: o3, minor, timing)')
parser.add_argument('--o3', help='use DerivO3Cpu instead of TimingSimpleCpu', action="store_true")
parser.add_argument('-c', help='binary to execute')
parser.add_argument('-w', help='width of pipeline')
......@@ -31,9 +31,9 @@ class L1Cache(BaseCache):
if (args.b == 'local' or args.b == 'bht'):
CPU.branchPred = LocalBP(localPredictorSize=256,localCtrBits=2)
elif (args.b == 'gas'):
CPU.branchPred = GAsBP(localPredictorSize=256, globalHistorySize=8, localCtrBits=2, speculativeUpdate=False);
CPU.branchPred = GAsBP(localPredictorSize=256, globalHistorySize=3, localCtrBits=2, speculativeUpdate=False);
elif (args.b == 'gas_speculative'):
CPU.branchPred = GAsBP(localPredictorSize=256, globalHistorySize=8, localCtrBits=2, speculativeUpdate=True);
CPU.branchPred = GAsBP(localPredictorSize=256, globalHistorySize=3, localCtrBits=2, speculativeUpdate=True);
elif (args.b == "tournament"):
CPU.branchPred = TournamentBP(localPredictorSize=256,
globalPredictorSize=256,
......@@ -74,7 +74,10 @@ system.mem_ctrl.port = system.membus.master
process = LiveProcess()
process.cmd = [args.c] if not args.o else [args.c]+str.split(args.o)
process.cmd = shlex.split(args.c)
if args.o:
process.cmd += shlex.split(args.o)
print process.cmd
system.cpu.workload = process
system.cpu.createThreads()
......
......@@ -33,11 +33,12 @@
#include "base/trace.hh"
#include "cpu/pred/GAsBP.hh"
#include "debug/Fetch.hh"
#include <math.h>
GAsBP::GAsBP(const GAsBPParams *params)
: BPredUnit(params),
localPredictorSize(params->localPredictorSize),
globalPredictorSize(params->globalPredictorSize),
globalHistorySize(params->globalHistorySize),
localCtrBits(params->localCtrBits),
speculativeUpdate(params->speculativeUpdate),
speculativeUpdateCounters(params->speculativeUpdateCounters)
......@@ -45,27 +46,31 @@ GAsBP::GAsBP(const GAsBPParams *params)
if (!isPowerOf2(localPredictorSize)) {
fatal("Invalid local predictor size!\n");
}
// if (!isPowerOf2(globalPredictorSize)) {
// fatal("Invalid global history register size!\n");
// }
localPredictorSets = localPredictorSize / localCtrBits;
if (!isPowerOf2(localPredictorSets)) {
fatal("Invalid number of local predictor sets! Check localCtrBits.\n");
}
DPRINTF(Fetch, "global history size: %i\n", globalHistorySize);
globalPredictorSize = std::pow(2, globalHistorySize);
DPRINTF(Fetch, "global predictor size: %i\n", globalPredictorSize);
// Setup the index mask.
indexMask = localPredictorSets - 1;
DPRINTF(Fetch, "index mask: %#x\n", indexMask);
DPRINTF(Fetch, "local index mask: %#x\n", indexMask);
// Setup the global history register and mask
globalHistoryBits = 0;
globalHistoryBitsSpeculative = 0;
globalHistoryMask = globalPredictorSize - 1;
DPRINTF(Fetch, "global index mask: %i\n", globalHistoryMask);
// Setup the array of counters for the local predictor and the global history register.
localCtrs.resize(localPredictorSets);
for (unsigned i = 0; i < localPredictorSets; ++i)
......@@ -113,8 +118,7 @@ GAsBP::lookup(Addr branch_addr, void * &bp_history)
if (speculativeUpdate)
global_history_idx = globalHistoryBitsSpeculative;
DPRINTF(Fetch, "Looking up index %#x\n",
local_predictor_idx);
DPRINTF(Fetch, "Looking up index %#x, %#x\n", local_predictor_idx, global_history_idx);
counter_val = localCtrs[local_predictor_idx][global_history_idx].read();
......@@ -123,7 +127,7 @@ GAsBP::lookup(Addr branch_addr, void * &bp_history)
taken = getPrediction(counter_val);
// Spekulatives update des globalen History Registers
// Speculative update.
if (speculativeUpdate) {
if (taken) {
DPRINTF(Fetch, "Speculative update as taken.\n");
......@@ -149,21 +153,20 @@ GAsBP::update(Addr branch_addr, bool taken, void *bp_history, bool squashed)
local_predictor_idx = getLocalIndex(branch_addr);
global_history_idx = globalHistoryBits;
DPRINTF(Fetch, "Looking up index %#x\n", local_predictor_idx);
DPRINTF(Fetch, "Looking up index %#x, %#x\n", local_predictor_idx, global_history_idx);
if (taken) {
DPRINTF(Fetch, "Branch updated as taken.\n");
///A1: Update des Branch Predictors im Fall taken
//A1: Update des Branch Predictors im Fall taken
} else {
DPRINTF(Fetch, "Branch updated as not taken.\n");
///A1: Update des Branch Predictors im Fall not taken
//A1: Update des Branch Predictors im Fall not taken
}
globalHistoryBits &= globalHistoryMask;
if (squashed) {
DPRINTF(Fetch, "Squashed resetting speculative global history\n");
//A2 (bonus): Wie kann mit diesen Fehlvorhersagen umgegangen werden
DPRINTF(Fetch, "Squashed.\n");
//A2 (bonus): Wie kann mit diesen Fehlvorhersagen umgegangen werden
}
}
......
......@@ -114,7 +114,10 @@ class GAsBP : public BPredUnit
std::vector< std::vector<SatCounter> > localCtrs;
/** Size of the local predictor. */
unsigned localPredictorySize;
unsigned localPredictorSize;
/** Size of the global predictor. */
unsigned globalPredictorSize;
/** Size of the global history register. */
unsigned globalHistorySize;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment