-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark_main.cc
79 lines (71 loc) · 3.2 KB
/
benchmark_main.cc
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
#include <iostream>
#include <vector>
#include "CycleTimer.h"
#include "gpu_graham_scan.h"
#include "gpu_graham_scan_test.h"
int kRuns = 5;
unsigned long kPoints = 1000000;
bool test_int = true;
bool test_float = true;
bool test_double = true;
int main() {
if (test_int) {
std::cout << "Testing type == int:\n";
std::vector<gpu_graham_scan::Point<int>> serial_output;
double serial_min_time = gpu_graham_scan_test::Benchmark(
kRuns, gpu_graham_scan_test::SolveSerial<int>, kPoints, serial_output);
printf("[Graham-Scan serial %lu points]:\t\t%.3f ms\t%.3fX speedup\n",
kPoints, serial_min_time * 1000, 1.);
std::vector<gpu_graham_scan::Point<int>> parallel_output;
double parallel_min_time = gpu_graham_scan_test::Benchmark(
kRuns, gpu_graham_scan_test::SolveParallel<int>, kPoints,
parallel_output);
printf("[Graham-Scan parallel %lu points]:\t\t%.3f ms\t%.3fX speedup\n",
kPoints, parallel_min_time * 1000,
serial_min_time / parallel_min_time);
if (!gpu_graham_scan_test::ValidateSolution(serial_output,
parallel_output)) {
std::cout << "Solution did not match serial implementation\n";
}
}
if (test_float) {
std::cout << "\nTesting type == float:\n";
std::vector<gpu_graham_scan::Point<float>> serial_output;
double serial_min_time = gpu_graham_scan_test::Benchmark(
kRuns, gpu_graham_scan_test::SolveSerial<float>, kPoints,
serial_output);
printf("[Graham-Scan serial %lu points]:\t\t%.3f ms\t%.3fX speedup\n",
kPoints, serial_min_time * 1000, 1.);
std::vector<gpu_graham_scan::Point<float>> parallel_output;
double parallel_min_time = gpu_graham_scan_test::Benchmark(
kRuns, gpu_graham_scan_test::SolveParallel<float>, kPoints,
parallel_output);
printf("[Graham-Scan parallel %lu points]:\t\t%.3f ms\t%.3fX speedup\n",
kPoints, parallel_min_time * 1000,
serial_min_time / parallel_min_time);
if (!gpu_graham_scan_test::ValidateSolution(serial_output,
parallel_output)) {
std::cout << "Solution did not match serial implementation\n";
}
}
if (test_double) {
std::cout << "\nTesting type == double:\n";
std::vector<gpu_graham_scan::Point<double>> serial_output;
double serial_min_time = gpu_graham_scan_test::Benchmark(
kRuns, gpu_graham_scan_test::SolveSerial<double>, kPoints,
serial_output);
printf("[Graham-Scan serial %lu points]:\t\t%.3f ms\t%.3fX speedup\n",
kPoints, serial_min_time * 1000, 1.);
std::vector<gpu_graham_scan::Point<double>> parallel_output;
double parallel_min_time = gpu_graham_scan_test::Benchmark(
kRuns, gpu_graham_scan_test::SolveParallel<double>, kPoints,
parallel_output);
printf("[Graham-Scan parallel %lu points]:\t\t%.3f ms\t%.3fX speedup\n",
kPoints, parallel_min_time * 1000,
serial_min_time / parallel_min_time);
if (!gpu_graham_scan_test::ValidateSolution(serial_output,
parallel_output)) {
std::cout << "Solution did not match serial implementation\n";
}
}
}