Mercurial > hg > Applications > Grep
annotate regexParser/cerium/ppe/Exec.cc @ 303:cc770cd8d000
parallel retrying seach worked
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Feb 2016 11:56:13 +0900 |
parents | 27414e6fb33c |
children | c48a8671ce34 |
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" | |
279
6cc1d9779f45
add CeriumMain.h
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
8 #include "CeriumMain.h" |
266 | 9 |
10 /* これは必須 */ | |
11 SchedDefineTask1(Exec,blockedGrep); | |
12 | |
303
cc770cd8d000
parallel retrying seach worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
13 TSValue blockSearch(TSValue tsv,Buffer buff,int task_spawned) { |
cc770cd8d000
parallel retrying seach worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
14 tsv.current = tsv.tg->stateStart->tState; |
292 | 15 tsv.blk->result = NULL; |
281
b74e3b4b11d7
parallel search done
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
279
diff
changeset
|
16 ResultPtr result = NULL; |
292 | 17 tsv.blk->resultEnd = &result; |
303
cc770cd8d000
parallel retrying seach worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
18 tsv.blk->blockBegin = tsv.current; |
281
b74e3b4b11d7
parallel search done
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
279
diff
changeset
|
19 tsv = tSearch(tsv); |
292 | 20 tsv.blk->blockEnd = tsv.current; |
302
27414e6fb33c
retrying blocked search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
298
diff
changeset
|
21 addResult(tsv,true,buff.buff,buff.buffend); // entire buffer |
292 | 22 if (tsv.blk->blockEnd->state->bitState.bitContainer != 1) { |
23 if (tsv.matchBegin != tsv.buff.buffptr) { | |
282
87a801c14117
fix match condition (parallel search doesn't work)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
281
diff
changeset
|
24 // partial match case at block end. |
302
27414e6fb33c
retrying blocked search
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
298
diff
changeset
|
25 addResult(tsv,true,tsv.matchBegin,tsv.matchEnd); |
281
b74e3b4b11d7
parallel search done
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
279
diff
changeset
|
26 // printf("Exec %lx r->begin : %p r->end : %p\n",tsv.blockEnd->state->bitState.bitContainer, r->begin,r->end); |
282
87a801c14117
fix match condition (parallel search doesn't work)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
281
diff
changeset
|
27 } |
266 | 28 } |
292 | 29 tsv.blk->result = result; |
266 | 30 return tsv; |
31 } | |
32 | |
33 static int | |
34 blockedGrep(SchedTask *s, void *rbuf, void *wbuf) | |
35 { | |
279
6cc1d9779f45
add CeriumMain.h
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
36 long task_spawned = (long)s->get_param(0); |
266 | 37 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
|
38 long length = (long)s->get_param(2); |
266 | 39 long out_size = (long)s->get_param(3); |
40 MapReduce *w = (MapReduce*)s->get_param(4); | |
279
6cc1d9779f45
add CeriumMain.h
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
278
diff
changeset
|
41 long allocation = task_spawned + (long)s->x; |
272 | 42 unsigned char* i_data; |
43 unsigned long * o_data; | |
266 | 44 if (division_size) { |
272 | 45 i_data = (unsigned char*)s->get_input(rbuf,0) + allocation*division_size; |
46 o_data = (unsigned long *)s->get_output(wbuf,1) + allocation*out_size; | |
266 | 47 } else { |
272 | 48 i_data = (unsigned char*)s->get_input(0); |
49 o_data = (unsigned long *)s->get_output(0); | |
266 | 50 } |
51 TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; | |
52 Buffer buff; | |
292 | 53 buff.buff = buff.buffptr = i_data; |
275
8879eb8c64a8
remove segmentation fault
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
272
diff
changeset
|
54 buff.buffend = buff.buff + length; |
303
cc770cd8d000
parallel retrying seach worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
55 BlockOutput blk; |
cc770cd8d000
parallel retrying seach worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
56 TSValue tsv = createTSValue(tg,buff); |
cc770cd8d000
parallel retrying seach worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
57 tsv.blk = &blk; |
cc770cd8d000
parallel retrying seach worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
58 tsv = blockSearch(tsv,buff,task_spawned); |
281
b74e3b4b11d7
parallel search done
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
279
diff
changeset
|
59 // resultPrint(tsv.result,"Exec"); |
292 | 60 o_data[0] = (unsigned long)tsv.blk->result; |
303
cc770cd8d000
parallel retrying seach worked
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
302
diff
changeset
|
61 o_data[1] = (unsigned long)tsv.blk->blockBegin->state; // never used now |
292 | 62 o_data[2] = (unsigned long)tsv.blk->blockEnd->state; |
266 | 63 return 0; |
64 } | |
298 | 65 |
66 /* end */ |