-
Notifications
You must be signed in to change notification settings - Fork 2
/
bbexps.c
56 lines (49 loc) · 1.21 KB
/
bbexps.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "bbsearch.h"
#include "dag.h"
#include "parser.h"
int main(int argc, char **argv) {
int m;
int timeout;
int do_dot = 0;
int input_err = 0;
if (argc == 3) {
do_dot = 1;
if (strcmp(argv[2], "dot") != 0) {
input_err = 1;
}
}
else if (argc == 4) {
if ((m = atoi(argv[2])) <= 0) {
input_err = 1;
}
timeout = atoi(argv[3]);
}
else {
input_err = 1;
}
if (input_err) {
printf("Usage: %s <patterson file> m timeout\n", argv[0]);
printf("or: %s <patterson file> \"dot\"\n", argv[0]);
return 1;
}
dag *g;
if (parse_patterson(argv[1], &g) != 0) {
printf("Parse failed\n");
return 1;
}
if (do_dot) {
print_dot(g, "out");
return 0;
}
clock_t start = clock();
int result = bbsearch(g, m, timeout);
clock_t end = clock();
double t = ((double)end - (double)start) / CLOCKS_PER_SEC;
// file, # nodes, m, schedule length, scheduling time
printf("%s, %zu, %u, %d, %f\n", argv[1], dag_size(g) - 2, m, result, t);
dag_destroy(g);
}