Mercurial > hg > Applications > Grep
comparison regexParser/cerium/ppe/Exec.cc @ 279:6cc1d9779f45
add CeriumMain.h
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 31 Jan 2016 15:59:11 +0900 |
parents | 99d635926ef3 |
children | b74e3b4b11d7 |
comparison
equal
deleted
inserted
replaced
278:99d635926ef3 | 279:6cc1d9779f45 |
---|---|
3 #include "Exec.h" | 3 #include "Exec.h" |
4 #include "Func.h" | 4 #include "Func.h" |
5 #include "regexParser.h" | 5 #include "regexParser.h" |
6 #include "threadedSearch.h" | 6 #include "threadedSearch.h" |
7 #include "FileMapReduce.h" | 7 #include "FileMapReduce.h" |
8 #include "CeriumMain.h" | |
8 | 9 |
9 /* これは必須 */ | 10 /* これは必須 */ |
10 SchedDefineTask1(Exec,blockedGrep); | 11 SchedDefineTask1(Exec,blockedGrep); |
11 | 12 |
12 TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff) { | 13 TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff,int task_spawned) { |
13 TSValue tsv; | 14 TSValue tsv; |
14 tsv.buff = buff; | 15 tsv.buff = buff; |
15 tsv.tg = tg; | 16 tsv.tg = tg; |
16 tsv.current = tg->anyState->tState; | 17 if (task_spawned == 0) { |
18 tsv.current = tg->stateList->tState; | |
19 } else { | |
20 tsv.current = tg->anyState->tState; | |
21 } | |
17 tsv.result = NULL; | 22 tsv.result = NULL; |
18 tsv.resultEnd = &tsv.result; | 23 tsv.resultEnd = &tsv.result; |
19 unsigned char *end = buff.buffend; | 24 unsigned char *end = buff.buffend; |
20 buff.buffend = buff.buff+1; | 25 buff.buffend = buff.buff+1; |
21 tSearch(tsv); | 26 tSearch(tsv); |
35 } | 40 } |
36 | 41 |
37 static int | 42 static int |
38 blockedGrep(SchedTask *s, void *rbuf, void *wbuf) | 43 blockedGrep(SchedTask *s, void *rbuf, void *wbuf) |
39 { | 44 { |
40 long task_spwaned = (long)s->get_param(0); | 45 long task_spawned = (long)s->get_param(0); |
41 long division_size = (long)s->get_param(1); | 46 long division_size = (long)s->get_param(1); |
42 long length = (long)s->get_param(2); | 47 long length = (long)s->get_param(2); |
43 long out_size = (long)s->get_param(3); | 48 long out_size = (long)s->get_param(3); |
44 MapReduce *w = (MapReduce*)s->get_param(4); | 49 MapReduce *w = (MapReduce*)s->get_param(4); |
45 long allocation = task_spwaned + (long)s->x; | 50 long allocation = task_spawned + (long)s->x; |
46 unsigned char* i_data; | 51 unsigned char* i_data; |
47 unsigned long * o_data; | 52 unsigned long * o_data; |
48 if (division_size) { | 53 if (division_size) { |
49 i_data = (unsigned char*)s->get_input(rbuf,0) + allocation*division_size; | 54 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; | 55 o_data = (unsigned long *)s->get_output(wbuf,1) + allocation*out_size; |
54 } | 59 } |
55 TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; | 60 TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; |
56 Buffer buff; | 61 Buffer buff; |
57 buff.buff = buff.buffptr = buff.matchBegin = i_data; | 62 buff.buff = buff.buffptr = buff.matchBegin = i_data; |
58 buff.buffend = buff.buff + length; | 63 buff.buffend = buff.buff + length; |
59 TSValue tsv = blockSearch(tg,buff); | 64 TSValue tsv = blockSearch(tg,buff,task_spawned); |
65 resultPrint(tsv.result,"Exec"); | |
60 o_data[0] = (unsigned long)tsv.result; | 66 o_data[0] = (unsigned long)tsv.result; |
61 o_data[1] = (unsigned long)tsv.blockBegin->state; | 67 o_data[1] = (unsigned long)tsv.blockBegin->state; |
62 o_data[2] = (unsigned long)tsv.blockEnd->state; | 68 o_data[2] = (unsigned long)tsv.blockEnd->state; |
63 return 0; | 69 return 0; |
64 } | 70 } |