Skip to content

Commit 6b1b019

Browse files
committed
Added verbose flag
1 parent a750f59 commit 6b1b019

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.o
2+
src/predictor

src/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ usage()
2323
fprintf(stderr," bunzip -kc trace.bz2 | predictor <options>\n");
2424
fprintf(stderr," Options:\n");
2525
fprintf(stderr," --help Print this message\n");
26+
fprintf(stderr," --verbose Print predictions on stdout\n");
2627
fprintf(stderr," --<type> Branch prediction scheme:\n");
2728
fprintf(stderr," static\n"
2829
" gshare:<# ghistory>\n"
@@ -48,6 +49,8 @@ handle_option(char *arg)
4849
sscanf(arg+13,"%d:%d:%d", &ghistoryBits, &lhistoryBits, &pcIndexBits);
4950
} else if (!strcmp(arg,"--custom")) {
5051
bpType = CUSTOM;
52+
} else if (!strcmp(arg,"--verbose")) {
53+
verbose = 1;
5154
} else {
5255
return 0;
5356
}
@@ -80,6 +83,7 @@ main(int argc, char *argv[])
8083
// Set defaults
8184
stream = stdin;
8285
bpType = STATIC;
86+
verbose = 0;
8387

8488
// Process cmdline Arguments
8589
for (int i = 1; i < argc; ++i) {
@@ -111,9 +115,13 @@ main(int argc, char *argv[])
111115
num_branches++;
112116

113117
// Make a prediction and compare with actual outcome
114-
if (make_prediction(pc) != outcome) {
118+
uint8_t prediction = make_prediction(pc);
119+
if (prediction != outcome) {
115120
mispredictions++;
116121
}
122+
if (verbose != 0) {
123+
printf ("%d\n", prediction);
124+
}
117125

118126
// Train the predictor
119127
train_predictor(pc, outcome);

src/predictor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ int ghistoryBits; // Number of bits used for Global History
2727
int lhistoryBits; // Number of bits used for Local History
2828
int pcIndexBits; // Number of bits used for PC index
2929
int bpType; // Branch Prediction Type
30+
int verbose;
3031

3132
//------------------------------------//
3233
// Predictor Data Structures //

src/predictor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extern int ghistoryBits; // Number of bits used for Global History
4545
extern int lhistoryBits; // Number of bits used for Local History
4646
extern int pcIndexBits; // Number of bits used for PC index
4747
extern int bpType; // Branch Prediction Type
48+
extern int verbose;
4849

4950
//------------------------------------//
5051
// Predictor Function Prototypes //

0 commit comments

Comments
 (0)