-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmark.cu
71 lines (63 loc) · 2.2 KB
/
benchmark.cu
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
#ifndef CUDA_XBLOCK_SIZE
#define CUDA_XBLOCK_SIZE (1 << XBLOCK_SIZE_SCALE)
#endif
#ifndef CUDA_YBLOCK_SIZE
#define CUDA_YBLOCK_SIZE (1 << YBLOCK_SIZE_SCALE)
#endif
#ifndef CUDA_ZBLOCK_SIZE
#define CUDA_ZBLOCK_SIZE (1 << ZBLOCK_SIZE_SCALE)
#endif
#ifndef QUANTITY
#define QUANTITY (1 << QUANTITY_SCALE)
#endif
#ifndef SIZE
#define SIZE (1 << SIZE_SCALE)
#endif
#ifndef WINDOW_SIZE
#define WINDOW_SIZE (1 << WINDOW_SIZE_SCALE)
#endif
// for cuda error checking
#define cudaCheckErrors(msg) \
do { \
cudaError_t __err = cudaGetLastError(); \
if (__err != cudaSuccess) { \
fprintf(stderr, "Fatal error: %s (%s at %s:%d)\n", \
msg, cudaGetErrorString(__err), \
__FILE__, __LINE__); \
fprintf(stderr, "*** FAILED - ABORTING\n"); \
return; \
} \
} while (0)
#include <iostream> // std::cout
#include <string>
#include <utility>
#include <set>
#include "benchmarking/timing.hpp"
#include "benchmarking/data-generation.hpp"
#include "assert.h"
#include "sw_cuda_alpern.cu"
#include "sw_cuda_windowed.cu"
#include "sw_cuda_antidiagonal.cu"
#include "sw_cuda_hypothetical.cu"
int main(int argc, char** argv)
{
std::string version(argv[argc - 1]);
std::vector<std::string> versions_list = { "cuda-alpern", "cuda-windowed", "cuda-antidiagonal", "cuda-hypothetical" };
std::set<std::string> versions (versions_list.begin(), versions_list.end());
const bool is_in = versions.find(version) != versions.end();
if (!is_in) std::cout << "Incorrect version provided: " << version << std::endl;
assert (is_in);
// For random numbers, one must first seed the random number generator. This is the idiomatic
// approach for the random number generator libraries that we have chosen.
std::srand ( static_cast< uint32_t >( std::time(0) ) );
auto const test_cases = csc586::benchmark::uniform_rand_vec_of_vec< std::string >( QUANTITY, SIZE );
if (version == "cuda-alpern")
sw_cuda_alpern(test_cases);
else if (version == "cuda-windowed")
sw_cuda_windowed(test_cases);
else if (version == "cuda-antidiagonal")
sw_cuda_antidiagonal(test_cases);
else if (version == "cuda-hypothetical")
sw_cuda_hypothetical(test_cases);
return 0;
}