-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsisd_scan.cpp
71 lines (56 loc) · 2.06 KB
/
sisd_scan.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
69
70
71
#include <iostream>
#include <immintrin.h>
#include <bitset>
#include <random>
#include <algorithm>
#include <fstream>
#include "common.hpp"
#ifdef AUTO_VECTORIZATION
#define ALGORITHM_NAME "SISD_AUTO_VEC"
#else
#define ALGORITHM_NAME "SISD_NO_AUTO_VEC"
#endif
#ifndef AUTO_VECTORIZATION
__attribute__((optimize("no-tree-vectorize")))
#endif
int sisd_scan() {
volatile int total_results = 0;
for(pos_t i = 0; i < col_a.size(); ++i) {
if(col_a[i] == first_scan_value && col_b[i] == second_scan_value) {
++total_results;
}
}
return total_results;
}
int main(int argc, char* argv[]) {
if (argc < 3) {
std::cout << "Usage ./program TABLE_SIZE DISTINCT_VALUES";
return -1;
}
PAPI_library_init(PAPI_VER_CURRENT);
const std::string program_name = std::string(argv[0]);
const size_t table_size = std::stol(argv[1]);
const size_t distinct_values = std::stol(argv[2]);
if (distinct_values > table_size) {
std::string empty_papi_string = "";
for (size_t i = 0; i < num_events; ++i) {
empty_papi_string.append("-1,");
}
std::cout << ALGORITHM_NAME << "," << table_size << "," << distinct_values << "," << -1 << "," << empty_papi_string << 0 << "," << 0 << std::endl;
return 0;
}
col_a = std::vector<value_id_t>(table_size);
col_b = std::vector<value_id_t>(table_size);
fill_vector(col_a, distinct_values);
fill_vector(col_b, distinct_values);
auto ptr_a = std::make_shared<std::vector<value_id_t>>(col_a);
auto ptr_b = std::make_shared<std::vector<value_id_t>>(col_b);
auto run_info = run_n_times(sisd_scan, {ptr_a, ptr_b});
std::string papi_string = "";
for (auto papi_median : run_info.papi_medians) {
papi_string.append(std::to_string(papi_median));
papi_string.append(",");
}
std::cout << ALGORITHM_NAME << "," << table_size << "," << distinct_values << "," << run_info.duration << "," << papi_string << run_info.qualifying_rows << "," << run_info.result_sum << std::endl;
return 0;
}