Mercurial > hg > Applications > Grep
annotate regexParser/cerium/ppe/Exec.cc @ 278:99d635926ef3
ceriumCreateAnyState implemented
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 30 Jan 2016 21:19:05 +0900 |
parents | 8879eb8c64a8 |
children | 6cc1d9779f45 |
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 TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff) { |
266 | 13 TSValue tsv; |
14 tsv.buff = buff; | |
15 tsv.tg = tg; | |
278
99d635926ef3
ceriumCreateAnyState implemented
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
275
diff
changeset
|
16 tsv.current = tg->anyState->tState; |
266 | 17 tsv.result = NULL; |
18 tsv.resultEnd = &tsv.result; | |
19 unsigned char *end = buff.buffend; | |
20 buff.buffend = buff.buff+1; | |
21 tSearch(tsv); | |
22 tsv.blockBegin = tsv.current; | |
23 buff.buffend = end; | |
24 tSearch(tsv); | |
25 tsv.blockEnd = tsv.current; | |
272 | 26 if (tsv.blockEnd->state->bitState.bitContainer != 1) { |
266 | 27 ResultPtr r = NEW(Result); |
28 r->begin = tsv.buff.matchBegin; | |
29 r->end = NULL; | |
30 *tsv.resultEnd = r; | |
31 r->next = NULL; | |
32 tsv.resultEnd = &r->next; | |
33 } | |
34 return tsv; | |
35 } | |
36 | |
37 static int | |
38 blockedGrep(SchedTask *s, void *rbuf, void *wbuf) | |
39 { | |
40 long task_spwaned = (long)s->get_param(0); | |
41 long division_size = (long)s->get_param(1); | |
275
8879eb8c64a8
remove segmentation fault
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
272
diff
changeset
|
42 long length = (long)s->get_param(2); |
266 | 43 long out_size = (long)s->get_param(3); |
44 MapReduce *w = (MapReduce*)s->get_param(4); | |
45 long allocation = task_spwaned + (long)s->x; | |
272 | 46 unsigned char* i_data; |
47 unsigned long * o_data; | |
266 | 48 if (division_size) { |
272 | 49 i_data = (unsigned char*)s->get_input(rbuf,0) + allocation*division_size; |
50 o_data = (unsigned long *)s->get_output(wbuf,1) + allocation*out_size; | |
266 | 51 } else { |
272 | 52 i_data = (unsigned char*)s->get_input(0); |
53 o_data = (unsigned long *)s->get_output(0); | |
266 | 54 } |
55 TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; | |
56 Buffer buff; | |
57 buff.buff = buff.buffptr = buff.matchBegin = i_data; | |
275
8879eb8c64a8
remove segmentation fault
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
272
diff
changeset
|
58 buff.buffend = buff.buff + length; |
272 | 59 TSValue tsv = blockSearch(tg,buff); |
60 o_data[0] = (unsigned long)tsv.result; | |
275
8879eb8c64a8
remove segmentation fault
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
272
diff
changeset
|
61 o_data[1] = (unsigned long)tsv.blockBegin->state; |
8879eb8c64a8
remove segmentation fault
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
272
diff
changeset
|
62 o_data[2] = (unsigned long)tsv.blockEnd->state; |
266 | 63 return 0; |
64 } |