Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
exercises
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
advanced_computer_architecture
exercises
Commits
7f951047
Commit
7f951047
authored
May 13, 2016
by
michael
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blatt3: fix GAs
parent
38d2d820
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
20 deletions
+29
-20
aufgaben/blatt03/BPConfig.py
aufgaben/blatt03/BPConfig.py
+7
-4
aufgaben/blatt03/gem5/src/cpu/pred/GAsBP.cc
aufgaben/blatt03/gem5/src/cpu/pred/GAsBP.cc
+18
-15
aufgaben/blatt03/gem5/src/cpu/pred/GAsBP.hh
aufgaben/blatt03/gem5/src/cpu/pred/GAsBP.hh
+4
-1
No files found.
aufgaben/blatt03/BPConfig.py
View file @
7f951047
...
...
@@ -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
()
...
...
aufgaben/blatt03/gem5/src/cpu/pred/GAsBP.cc
View file @
7f951047
...
...
@@ -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
),
global
PredictorSize
(
params
->
globalPredictor
Size
),
global
HistorySize
(
params
->
globalHistory
Size
),
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
);
// Spe
kulatives update des globalen History Registers
// Spe
culative 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
}
}
...
...
aufgaben/blatt03/gem5/src/cpu/pred/GAsBP.hh
View file @
7f951047
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment