Commit 7f951047 authored by michael's avatar michael

blatt3: fix GAs

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