-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
65 lines (60 loc) · 1.56 KB
/
main.c
File metadata and controls
65 lines (60 loc) · 1.56 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
#include "benchmarks.h"
#include <string.h>
int main(int argc, char *argv[])
{
if (argc == 1)
{
FILE *fp = fopen("results.csv", "w");
if (!fp)
{
printf("Error: could not open results.csv\n");
return 1;
}
printf("MEMORY PERFORMANCE TEST\n");
run_latency_test(fp, -1, 5);
run_bandwidth_test(fp, -1, 5);
run_matrix_test(fp, -1, 5);
run_sequential_test(fp, -1, 5);
run_random_test(fp, -1, 5);
run_stride_test(fp, -1, 5);
fclose(fp);
printf("\nResults saved to results.csv \n");
return 0;
}
if (argc >= 4)
{
char *test_type = argv[1];
int size = atoi(argv[2]);
char *output_file = argv[3];
int iterations = 5;
if (argc >= 5)
{
iterations = atoi(argv[4]);
}
FILE *fp =
fopen(output_file,
"w");
if (!fp)
{
printf("Error: could not open %s\n", output_file);
return 1;
}
if (strcmp(test_type, "latency") == 0)
run_latency_test(fp, size, iterations);
else if (strcmp(test_type, "bandwidth") == 0)
run_bandwidth_test(fp, size, iterations);
else if (strcmp(test_type, "matrix") == 0)
run_matrix_test(fp, size, iterations);
else if (strcmp(test_type, "sequential") == 0)
run_sequential_test(fp, size, iterations);
else if (strcmp(test_type, "random") == 0)
run_random_test(fp, size, iterations);
else if (strcmp(test_type, "stride") == 0)
run_stride_test(fp, size, iterations);
else
printf("Unknown test type: %s\n", test_type);
fclose(fp);
return 0;
}
return 1;
}