Mercurial > hg > Members > masakoha > testcode
changeset 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 | 6bbd1cbf90d0 |
files | regexParser/cerium/CeriumMain.cc regexParser/cerium/CeriumMain.h regexParser/cerium/ppe/Exec.cc regexParser/cerium/ppe/Print.cc |
diffstat | 4 files changed, 29 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/regexParser/cerium/CeriumMain.cc Sat Jan 30 21:19:05 2016 +0900 +++ b/regexParser/cerium/CeriumMain.cc Sun Jan 31 15:59:11 2016 +0900 @@ -7,6 +7,7 @@ #include "CeriumGrep.h" #include "subsetConstruction.h" #include "threadedSearch.h" +#include "CeriumMain.h" extern void task_init(); void TMend(TaskManager *); @@ -46,6 +47,20 @@ return tsv; } +ResultPtr resultPrint(ResultPtr r,const char* comment) { + ResultPtr prev = NULL; + printf("%s\n",comment); + for (;r;r = r->next) { + if (r->end == NULL) { + prev = r; + break; + } + fwrite(r->begin,r->end - r->begin-1,1,stdout); + puts("\n"); + } + return prev; +} + void ceriumCreateAnyState(TransitionGeneratorPtr tg) { tg->stateSkip = stateSkip; tg->stateMatch = stateMatch;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regexParser/cerium/CeriumMain.h Sun Jan 31 15:59:11 2016 +0900 @@ -0,0 +1,1 @@ +extern ResultPtr resultPrint(ResultPtr r,const char* comment);
--- a/regexParser/cerium/ppe/Exec.cc Sat Jan 30 21:19:05 2016 +0900 +++ b/regexParser/cerium/ppe/Exec.cc Sun Jan 31 15:59:11 2016 +0900 @@ -5,15 +5,20 @@ #include "regexParser.h" #include "threadedSearch.h" #include "FileMapReduce.h" +#include "CeriumMain.h" /* これは必須 */ SchedDefineTask1(Exec,blockedGrep); -TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff) { +TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff,int task_spawned) { TSValue tsv; tsv.buff = buff; tsv.tg = tg; - tsv.current = tg->anyState->tState; + if (task_spawned == 0) { + tsv.current = tg->stateList->tState; + } else { + tsv.current = tg->anyState->tState; + } tsv.result = NULL; tsv.resultEnd = &tsv.result; unsigned char *end = buff.buffend; @@ -37,12 +42,12 @@ static int blockedGrep(SchedTask *s, void *rbuf, void *wbuf) { - long task_spwaned = (long)s->get_param(0); + long task_spawned = (long)s->get_param(0); long division_size = (long)s->get_param(1); long length = (long)s->get_param(2); long out_size = (long)s->get_param(3); MapReduce *w = (MapReduce*)s->get_param(4); - long allocation = task_spwaned + (long)s->x; + long allocation = task_spawned + (long)s->x; unsigned char* i_data; unsigned long * o_data; if (division_size) { @@ -56,7 +61,8 @@ Buffer buff; buff.buff = buff.buffptr = buff.matchBegin = i_data; buff.buffend = buff.buff + length; - TSValue tsv = blockSearch(tg,buff); + TSValue tsv = blockSearch(tg,buff,task_spawned); + resultPrint(tsv.result,"Exec"); o_data[0] = (unsigned long)tsv.result; o_data[1] = (unsigned long)tsv.blockBegin->state; o_data[2] = (unsigned long)tsv.blockEnd->state;
--- a/regexParser/cerium/ppe/Print.cc Sat Jan 30 21:19:05 2016 +0900 +++ b/regexParser/cerium/ppe/Print.cc Sun Jan 31 15:59:11 2016 +0900 @@ -4,6 +4,7 @@ #include "Func.h" #include "FileMapReduce.h" #include "regexParser.h" +#include "CeriumMain.h" #define STATUS_NUM 2 /* これは必須 */ @@ -29,14 +30,7 @@ } r = r->next; } - for (;r;r = r->next) { - if (r->end == NULL) { - prev = r; - break; - } - fwrite(r->begin,r->end - r->begin,1,stdout); - puts("\n"); - } + prev = resultPrint(r,"Print"); } return 0; }