Mercurial > hg > Applications > Grep
annotate regexParser/cerium/ppe/Exec.cc @ 272:5aa9d01926f1
Cerium version no compile errors
author | kono |
---|---|
date | Fri, 29 Jan 2016 20:38:18 +0900 |
parents | 6640b0d5bf13 |
children | 8879eb8c64a8 |
rev | line source |
---|---|
266 | 1 #include <stdio.h> |
2 #include <string.h> | |
3 #include "Exec.h" | |
4 #include "Func.h" | |
272 | 5 #include "regexParser.h" |
6 #include "threadedSearch.h" | |
7 #include "FileMapReduce.h" | |
266 | 8 |
9 /* これは必須 */ | |
10 SchedDefineTask1(Exec,blockedGrep); | |
11 | |
272 | 12 static |
266 | 13 TSValue stateNothing(TSValue tsv) { |
14 return tsv; | |
15 } | |
16 | |
272 | 17 static |
266 | 18 TSValue stateSkip(TSValue tsv) { |
19 tsv.buff.matchBegin = tsv.buff.buffptr; | |
20 return tsv; | |
21 } | |
22 | |
272 | 23 static |
266 | 24 TSValue stateMatch(TSValue tsv) { |
25 ResultPtr r = NEW(Result); | |
26 r->begin = tsv.buff.matchBegin; | |
27 r->end = tsv.buff.buffptr; | |
28 *tsv.resultEnd = r; | |
29 r->next = NULL; | |
30 tsv.resultEnd = &r->next; | |
31 tsv.current = tsv.tg->stateList->tState; | |
32 tsv.buff.buffptr--; | |
33 tsv = stateSkip(tsv); | |
34 return tsv; | |
35 } | |
36 | |
272 | 37 TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff) { |
266 | 38 TSValue tsv; |
39 tsv.buff = buff; | |
40 tsv.tg = tg; | |
41 tsv.result = NULL; | |
42 tsv.resultEnd = &tsv.result; | |
271
6640b0d5bf13
remove anystate processing in sequential seqrch
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
266
diff
changeset
|
43 tsv.current = tg->anyState->tState; |
266 | 44 tsv.tg->stateSkip = stateSkip; |
45 tsv.tg->stateMatch = stateMatch; | |
46 tsv.tg->stateNothing = stateNothing; | |
47 unsigned char *end = buff.buffend; | |
48 buff.buffend = buff.buff+1; | |
49 tSearch(tsv); | |
50 tsv.blockBegin = tsv.current; | |
51 buff.buffend = end; | |
52 tSearch(tsv); | |
53 tsv.blockEnd = tsv.current; | |
272 | 54 if (tsv.blockEnd->state->bitState.bitContainer != 1) { |
266 | 55 ResultPtr r = NEW(Result); |
56 r->begin = tsv.buff.matchBegin; | |
57 r->end = NULL; | |
58 *tsv.resultEnd = r; | |
59 r->next = NULL; | |
60 tsv.resultEnd = &r->next; | |
61 } | |
62 return tsv; | |
63 } | |
64 | |
65 static int | |
66 blockedGrep(SchedTask *s, void *rbuf, void *wbuf) | |
67 { | |
68 long task_spwaned = (long)s->get_param(0); | |
69 long division_size = (long)s->get_param(1); | |
272 | 70 // long length = (long)s->get_param(2); |
266 | 71 long out_size = (long)s->get_param(3); |
72 MapReduce *w = (MapReduce*)s->get_param(4); | |
73 long allocation = task_spwaned + (long)s->x; | |
272 | 74 unsigned char* i_data; |
75 unsigned long * o_data; | |
266 | 76 if (division_size) { |
272 | 77 i_data = (unsigned char*)s->get_input(rbuf,0) + allocation*division_size; |
78 o_data = (unsigned long *)s->get_output(wbuf,1) + allocation*out_size; | |
266 | 79 } else { |
272 | 80 i_data = (unsigned char*)s->get_input(0); |
81 o_data = (unsigned long *)s->get_output(0); | |
266 | 82 } |
83 TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; | |
84 Buffer buff; | |
85 buff.buff = buff.buffptr = buff.matchBegin = i_data; | |
86 buff.buffend = buff.buff + division_size; | |
272 | 87 TSValue tsv = blockSearch(tg,buff); |
88 o_data[0] = (unsigned long)tsv.result; | |
89 o_data[1] = (unsigned long)tsv.blockBegin; | |
90 o_data[2] = (unsigned long)tsv.blockEnd; | |
266 | 91 return 0; |
92 } |