-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathac_gpu.cl
57 lines (44 loc) · 1.34 KB
/
ac_gpu.cl
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
struct ACSM3_USERDATA {
void* id; // 4 bytes
uint ref_count; // 4 bytes
};
struct ACSM3_PATTERN {
struct ACSM3_PATTERN* next; // 8
struct ACSM3_USERDATA* udata; // 8
uchar* patrn; // 8
uchar* casepatrn; // 8
void* rule_option_tree; // 8
void* neg_list; // 8
int n;
int nocase;
int negative;
};
struct ACSM3_STATETABLE {
/* Alphabet Size */
int NextState[256]; // 1024
int FailState; // 4
struct ACSM3_PATTERN* MatchList; // 8
};
void kernel ac_gpu(
__global uchar* Pbuff, // text body
__global int* Plen, // text length
__global struct ACSM3_STATETABLE* StateTable,
__global int* Nfound // number of matched bytes
) {
int index = get_global_id(0);
int n = Plen[index];
int state = 0;
/* Max Packet Size */
__global uchar* T = Pbuff + index * (16 * 1024);
__global uchar* Tend = T + n;
Nfound[index] = 0;
for(; T < Tend; T++) {
state = StateTable[state].NextState[*T];
/*
printf("%c %d %p\n", *T, state, StateTable[state].MatchList);
*/
if(StateTable[state].MatchList != 0) {
Nfound[index]++;
}
}
}