-
Notifications
You must be signed in to change notification settings - Fork 5
/
countPassFilter.cc
150 lines (110 loc) · 3.29 KB
/
countPassFilter.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* vector_filterMain.c
*
* Created on: Nov 12, 2013
* Author: hxin
*/
//#ifndef BOOST_PP_IS_ITERATING
//#include "print.h"
#include <string>
#include <sys/times.h>
#include <unistd.h>
#include <stdint.h>
#include "vector_filter.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BATCH_RUN 1000000
using namespace std;
#include "mask.h"
//char read[128];
//char ref[128];
char init_all_NULL[128] = "";
char read_t[128] __aligned__;// = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
char ref_t[128] __aligned__;// = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
int main(int argc, char* argv[]) {
string *read_strs = new string [BATCH_RUN];
string *ref_strs = new string [BATCH_RUN];
bool *valid_buff = new bool [BATCH_RUN];
if (argc != 2) {
printf("Usage: $>bin error\n");
exit(1);
}
int error = atoi(argv[1]);
size_t lineLength;
size_t length;
char* tempstr = NULL;
long long unsigned int passNum = 0;
long long unsigned int totalNum = 0;
long long read_size;
long long read_idx;
bool stop = false;
tms start_time;
tms end_time;
tms elp_time;
elp_time.tms_stime = 0;
elp_time.tms_utime = 0;
elp_time.tms_cstime = 0;
elp_time.tms_cutime = 0;
do {
//clear past result
// strncpy(read, init_all_NULL, 128);
// strncpy(ref, init_all_NULL, 128);
for (read_size = 0; read_size < BATCH_RUN; read_size++) {
//get read
getline(&tempstr, &lineLength, stdin);
length = strlen(tempstr);
//Get rid of the new line character
tempstr[length - 1] = '\0';
if (strcmp(tempstr, "end_of_file\0") == 0) {
stop = true;
break;
}
read_strs[read_size].assign(tempstr);
//get ref
getline(&tempstr, &lineLength, stdin);
length = strlen(tempstr);
//Get rid of the new line character
tempstr[length - 1] = '\0';
ref_strs[read_size].assign(tempstr);
valid_buff[read_size] = false;
}
times(&start_time);
for (read_idx = 0; read_idx < read_size; read_idx++) {
strncpy(read_t, init_all_NULL, 128);
strncpy(ref_t, init_all_NULL, 128);
length = read_strs[read_idx].length();
if (length > 128)
length = 128;
strncpy(read_t, read_strs[read_idx].c_str(), length);
length = ref_strs[read_idx].length();
//Get rid of the new line character
if (length > 128)
length = 128;
strncpy(ref_t, ref_strs[read_idx].c_str(), length);
if (bit_vec_filter_sse1(read_t, ref_t, length, error))
valid_buff[read_idx] = true;
}
times(&end_time);
for (read_idx = 0; read_idx < read_size; read_idx++) {
if (valid_buff[read_idx]) {
fprintf(stderr, "%.*s\n", 128, read_strs[read_idx].c_str() );
fprintf(stderr, "%.*s\n", 128, ref_strs[read_idx].c_str() );
passNum++;
}
totalNum++;
}
elp_time.tms_stime += end_time.tms_stime - start_time.tms_stime;
elp_time.tms_utime += end_time.tms_utime - start_time.tms_utime;
if (stop)
break;
} while (1);
fprintf(stderr, "end_of_file\n");
printf("passNum:\t%lld\n", passNum);
printf("totalNum:\t%lld\n", totalNum);
printf("total_time: %f\n", (double) elp_time.tms_utime / sysconf(_SC_CLK_TCK) );
delete [] read_strs;
delete [] ref_strs;
return 0;
}
//#endif