Mercurial > hg > Members > masakoha > testcode
view regexParser/cerium/ppe/Exec.cc @ 298:63213964502a
refactoring ....
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 03 Feb 2016 12:24:34 +0900 |
parents | bcb3b0cd5604 |
children | 27414e6fb33c |
line wrap: on
line source
#include <stdio.h> #include <string.h> #include "Exec.h" #include "Func.h" #include "regexParser.h" #include "threadedSearch.h" #include "FileMapReduce.h" #include "CeriumMain.h" /* これは必須 */ SchedDefineTask1(Exec,blockedGrep); TSValue blockSearch(TransitionGeneratorPtr tg,Buffer buff,int task_spawned) { TSValue tsv = createTSValue(tg,buff); BlockOutput blk; tsv.blk = &blk; if (task_spawned == 0) { tsv.current = tg->stateStart->tState; } else { tsv.current = tg->anyState->tState; } tsv.blk->result = NULL; ResultPtr result = NULL; tsv.blk->resultEnd = &result; unsigned char *end = tsv.buff.buffend; tsv.buff.buffend = tsv.buff.buff+1; tsv = tSearch(tsv); tsv.blk->blockBegin = tsv.current; tsv.buff.buffend = end; tsv = tSearch(tsv); tsv.blk->blockEnd = tsv.current; if (tsv.blk->blockEnd->state->bitState.bitContainer != 1) { if (tsv.matchBegin != tsv.buff.buffptr) { // partial match case at block end. ResultPtr r = NEW(Result); r->continued = true; r->begin = tsv.matchBegin; r->end = tsv.matchEnd; *tsv.blk->resultEnd = r; r->next = NULL; tsv.blk->resultEnd = &r->next; // printf("Exec %lx r->begin : %p r->end : %p\n",tsv.blockEnd->state->bitState.bitContainer, r->begin,r->end); } } tsv.blk->result = result; return tsv; } static int blockedGrep(SchedTask *s, void *rbuf, void *wbuf) { 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_spawned + (long)s->x; unsigned char* i_data; unsigned long * o_data; if (division_size) { i_data = (unsigned char*)s->get_input(rbuf,0) + allocation*division_size; o_data = (unsigned long *)s->get_output(wbuf,1) + allocation*out_size; } else { i_data = (unsigned char*)s->get_input(0); o_data = (unsigned long *)s->get_output(0); } TransitionGeneratorPtr tg = (TransitionGeneratorPtr)w->global; Buffer buff; buff.buff = buff.buffptr = i_data; buff.buffend = buff.buff + length; TSValue tsv = blockSearch(tg,buff,task_spawned); // resultPrint(tsv.result,"Exec"); o_data[0] = (unsigned long)tsv.blk->result; o_data[1] = (unsigned long)tsv.blk->blockBegin->state; o_data[2] = (unsigned long)tsv.blk->blockEnd->state; return 0; } /* end */