-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocsim_driver.cpp
More file actions
executable file
·96 lines (84 loc) · 2.24 KB
/
procsim_driver.cpp
File metadata and controls
executable file
·96 lines (84 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <cstdio>
#include <cinttypes>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include "procsim.hpp"
FILE* inFile = stdin;
void print_help_and_exit(void) {
printf("procsim [OPTIONS]\n");
printf(" -j k0\t\tNumber of k0 FUs\n");
printf(" -k k1\t\tNumber of k1 FUs\n");
printf(" -l k2\t\tNumber of k2 FUs\n");
printf(" -m M\t\tNumber of blocks per set is 2^S\n");
printf(" -f N\t\tNumber of instructions to fetch\n");
printf(" -d D\t\tDispatch Queue Multiplier\n");
printf(" -i traces/file.trace\n");
printf(" -h\t\tThis helpful output\n");
exit(0);
}
//void print_statistics(proc_stats_t* p_stats);
int main(int argc, char* argv[]) {
int opt;
int f = DEFAULT_F;
int m = DEFAULT_M;
int k0 = DEFAULT_K0;
int k1 = DEFAULT_K1;
int k2 = DEFAULT_K2;
int d = DEFAULT_D;
/* Read arguments */
while(-1 != (opt = getopt(argc, argv, "d:i:j:k:l:f:m:h"))) {
switch(opt) {
case 'd':
d = atoi(optarg);
break;
case 'j':
k0 = atoi(optarg);
break;
case 'k':
k1 = atoi(optarg);
break;
case 'l':
k2 = atoi(optarg);
break;
case 'm':
m = atoi(optarg);
break;
case 'f':
f = atoi(optarg);
break;
case 'i':
inFile = fopen(optarg, "r");
if (inFile == NULL)
{
fprintf(stderr, "Failed to open %s for reading\n", optarg);
print_help_and_exit();
}
break;
case 'h':
/* Fall through */
default:
print_help_and_exit();
break;
}
}
dout("Processor Settings\n");
dout("D: %i\n", d);
dout("k0: %i\n", k0);
dout("k1: %i\n", k1);
dout("k2: %i\n", k2);
dout("F: %i\n", f);
dout("M: %i\n", m);
dout("\n");
/* Setup the processor */
setup_proc(inFile, d, k0, k1, k2, f, m);
/* Setup statistics */
proc_stats_t stats;
memset(&stats, 0, sizeof(proc_stats_t));
/* Run the processor */
run_proc(&stats);
/* Finalize stats */
complete_proc(&stats);
print_statistics(&stats);
return 0;
}