-
Notifications
You must be signed in to change notification settings - Fork 2
/
cuda_test.cpp
68 lines (60 loc) · 1.98 KB
/
cuda_test.cpp
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
#include "cuda.cu"
#include "CRC_polynomial_cuda_wrapper.h"
#include <algorithm>
#include <string>
#include <vector>
#include <fstream>
#include <gtest/gtest.h>
using std::string;
using std::move;
vector<uint64_t> read_file(const string& s) {
std::vector<uint64_t> S;
std::ifstream f(s);
std::string line;
while (std::getline(f, line)) {
std::istringstream iss(line);
uint64_t v;
while (iss >> v) S.push_back(v);
}
f.close();
return move(S);
}
TEST(find_CRC_polynomials, 2_64_8) {
std::vector<uint64_t> S = read_file("./test_files/output_cuda_t_2_da_64_dc_8");
std::vector<uint64_t> O = CRC_polynomial_cuda_t2_wrapper<64,8>();
std::sort(S.begin(), S.end());
std::sort(O.begin(), O.end());
ASSERT_TRUE(S == O);
}
TEST(find_CRC_polynomials, 2_64_16) {
std::vector<uint64_t> S = read_file("./test_files/output_cuda_t_2_da_64_dc_16");
std::vector<uint64_t> O = CRC_polynomial_cuda_t2_wrapper<64,16>();
std::sort(S.begin(), S.end());
std::sort(O.begin(), O.end());
ASSERT_TRUE(S == O);
}
TEST(find_CRC_polynomials, 2_128_16) {
std::vector<uint64_t> S = read_file("./test_files/output_cuda_t_2_da_128_dc_16");
std::vector<uint64_t> O = CRC_polynomial_cuda_t2_wrapper<128,16>();
std::sort(S.begin(), S.end());
std::sort(O.begin(), O.end());
ASSERT_TRUE(S == O);
}
TEST(find_CRC_polynomials, 2_256_12) {
std::vector<uint64_t> S = read_file("./test_files/output_cuda_t_2_da_256_dc_12");
std::vector<uint64_t> O = CRC_polynomial_cuda_t2_wrapper<256,12>();
std::sort(S.begin(), S.end());
std::sort(O.begin(), O.end());
ASSERT_TRUE(S == O);
}
TEST(find_CRC_polynomials, 2_256_16) {
std::vector<uint64_t> S = read_file("./test_files/output_cuda_t_2_da_256_dc_16");
std::vector<uint64_t> O = CRC_polynomial_cuda_t2_wrapper<256,16>();
std::sort(S.begin(), S.end());
std::sort(O.begin(), O.end());
ASSERT_TRUE(S == O);
}
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}