Mercurial > hg > Game > Cerium
changeset 1204:ffef576db4b3 draft
modify example/regex/
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 16 Jul 2011 17:25:40 +0900 |
parents | f96a3dc9cd38 |
children | 9a5e21195600 |
files | example/regex/Makefile.macosx example/regex/WordCount.h example/regex/grep example/regex/main.cc example/regex/main.cc~ example/regex/ppe/Exec.cc example/regex/ppe/Exec.cc~ |
diffstat | 7 files changed, 64 insertions(+), 227 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex/Makefile.macosx Thu Jul 14 18:57:43 2011 +0900 +++ b/example/regex/Makefile.macosx Sat Jul 16 17:25:40 2011 +0900 @@ -1,21 +1,13 @@ include ./Makefile.def SRCS_TMP = $(wildcard *.cc) -<<<<<<< local SRCS_EXCLUDE = grep_main.cc # 除外するファイルを書く -======= -SRCS_EXCLUDE = # 除外するファイルを書く ->>>>>>> other SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) OBJS = $(SRCS:.cc=.o) TASK_DIR = ppe TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc) -<<<<<<< local TASK_SRCS_EXCLUDE = switchGrep.cc -======= -TASK_SRCS_EXCLUDE = ->>>>>>> other TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) TASK_OBJS = $(TASK_SRCS:.cc=.o) @@ -33,11 +25,7 @@ $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) link: -<<<<<<< local $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) -======= - $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) ->>>>>>> other debug: $(TARGET) sudo gdb ./$(TARGET)
--- a/example/regex/WordCount.h Thu Jul 14 18:57:43 2011 +0900 +++ b/example/regex/WordCount.h Sat Jul 16 17:25:40 2011 +0900 @@ -17,21 +17,9 @@ int file_size; HTaskPtr t_print; -<<<<<<< local - -======= //regexのENVの成分 ->>>>>>> other bool print_count; bool print_filename; int count; char *filename; -<<<<<<< local } WordCount, ENV, *ENVP; - - -======= -}WordCount; - //} WordCount, ENV; -//typedef ENV *ENVP; ->>>>>>> other
--- a/example/regex/main.cc Thu Jul 14 18:57:43 2011 +0900 +++ b/example/regex/main.cc Sat Jul 16 17:25:40 2011 +0900 @@ -379,69 +379,69 @@ st_mmap_t st_mmap; st_mmap = my_mmap(filename); - ENV *w = (ENV*)manager->allocate(sizeof(ENV)); + ENV *env = (ENV*)manager->allocate(sizeof(ENV)); // ENV->filename - w->filename = filename; + env->filename = filename; - // bzero(w,sizeof(ENV)); + // bzero(env,sizeof(ENV)); - w->self = w; - //w->task_blocks = blocks; - w->task_spwaned = 0; + env->self = env; + //env->task_blocks = blocks; + env->task_spwaned = 0; /*sizeはdivision_sizeの倍数にしている。*/ - w->size = w->file_size = st_mmap.size; - w->file_mmap = st_mmap.file_mmap; - // printf("w %lx\n",(long)w); + env->size = env->file_size = st_mmap.size; + env->file_mmap = st_mmap.file_mmap; + // printf("env %lx\n",(long)env); /* 1task分のデータサイズ(byte) */ - if (w->size >= 1024*division) { - w->division_size = 1024 * division;/*16kbyte*/ + if (env->size >= 1024*division) { + env->division_size = 1024 * division;/*16kbyte*/ } else { - w->division_size = w->size; + env->division_size = env->size; } - printf("dvision_size %d\n",w->division_size); + printf("dvision_size %d\n",env->division_size); /* "word num" and "line num" */ - w->status_num = 2; + env->status_num = 2; /* taskの数 */ - w->task_num = w->size / w->division_size; - w->task_num = w->task_num + (w->division_size*w->task_num < w->size); - int out_task_num = w->task_num; + env->task_num = env->size / env->division_size; + env->task_num = env->task_num + (env->division_size*env->task_num < env->size); + int out_task_num = env->task_num; if(!all) { - w->task_blocks = blocks; + env->task_blocks = blocks; } else { - w->task_blocks = w->task_num; + env->task_blocks = env->task_num; } - w->out_task_num = out_task_num; - printf("task_num %d\n",w->task_num); - printf("out_task_num %d\n",w->out_task_num); + env->out_task_num = out_task_num; + printf("task_num %d\n",env->task_num); + printf("out_task_num %d\n",env->out_task_num); /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */ - - w->division_out_size = sizeof(unsigned long long)*4; - int out_size = w->division_out_size*out_task_num; - w->o_data = (unsigned long long *)manager->allocate(out_size); - w->out_size = 4; + /* + env->division_out_size = sizeof(unsigned long long)*4; + int out_size = env->division_out_size*out_task_num; + env->o_data = (unsigned long long *)manager->allocate(out_size); + env->out_size = 4; printf("out size %d\n",out_size); */ /*各SPEの結果を合計して出力するタスク*/ t_print = manager->create_task(TASK_PRINT, - (memaddr)&w->self,sizeof(memaddr),0,0); + (memaddr)&env->self,sizeof(memaddr),0,0); - w->t_print = t_print; + env->t_print = t_print; for(int i = 0;i<20;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, - (memaddr)&w->self,sizeof(memaddr),0,0); + (memaddr)&env->self,sizeof(memaddr),0,0); t_print->wait_for(t_exec); t_exec->spawn(); }
--- a/example/regex/main.cc~ Thu Jul 14 18:57:43 2011 +0900 +++ b/example/regex/main.cc~ Sat Jul 16 17:25:40 2011 +0900 @@ -9,20 +9,13 @@ #include "TaskManager.h" #include "SchedTask.h" #include "Func.h" -<<<<<<< local #include "grep.h" -======= -#include "WordCount.h" ->>>>>>> other extern void task_init(); -<<<<<<< local -======= #define _REGENUM_ 3 ->>>>>>> other int all = 0; int use_task_array = 1; int use_task_creater = 0; @@ -166,20 +159,13 @@ fprintf(stderr,"can't fstat %s\n",filename); } -<<<<<<< local + // printf("file size %d\n",(int)sb.st_size); -======= - printf("file size %d\n",(int)sb.st_size); ->>>>>>> other /*sizeをページングサイズの倍数にあわせる*/ st_mmap.size = fix_byte(sb.st_size,4096); -<<<<<<< local // printf("fix 4096byte file size %d\n",(int)st_mmap.size); -======= - printf("fix 4096byte file size %d\n",(int)st_mmap.size); ->>>>>>> other st_mmap.file_mmap = (char*)mmap(NULL,st_mmap.size,PROT_READ,map,fd,(off_t)0); if (st_mmap.file_mmap == (caddr_t)-1) { @@ -192,18 +178,11 @@ } -<<<<<<< local static unsigned char reg_num = 3; static bool first_line_flag = true; -======= ->>>>>>> other static void -<<<<<<< local run_tasks(SchedTask *manager, ENV *w, int task_count, HTaskPtr t_next, int size) -======= -run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) ->>>>>>> other { if (task_count < array_task_num) { @@ -263,12 +242,8 @@ Task **t_exec = (Task**)manager->allocate(sizeof(Task*)*spe_num); for (int k = 0; k < spe_num; k++) { -<<<<<<< local // task_array[k] = manager->create_task_array(TASK_EXEC,array_task_num,0,1,1); task_array[k] = manager->create_task_array(TASK_EXEC,array_task_num,0,2,1); -======= - task_array[k] = manager->create_task_array(TASK_EXEC,array_task_num,0,1,1); ->>>>>>> other t_exec[k] = 0; if (all) { w->t_print->wait_for(task_array[k]); @@ -284,17 +259,7 @@ int a = w->task_spwaned++; if (w->size < size) size = w->size; -<<<<<<< local -======= - - t_exec[k] = task_array[k]->next_task_array(TASK_EXEC,t_exec[k]); - // t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size); - //grepの為_REGENUM_分文字を被させる - t_exec[k]->set_inData(0, (w->file_mmap + a*w->division_size) - _REGENUM_, size); - // t_exec[k]->set_inData(1, w, sizeof(WordCount)); ->>>>>>> other -<<<<<<< local t_exec[k] = task_array[k]->next_task_array(TASK_EXEC,t_exec[k]); if(first_line_flag) { t_exec[k]->set_inData(0, (w->file_mmap + a*w->division_size) - reg_num , size + reg_num ); @@ -302,16 +267,10 @@ }else { t_exec[k]->set_inData(0, w->file_mmap + a*w->division_size, size ); } -======= ->>>>>>> other t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); -<<<<<<< local t_exec[k]->set_inData(1, (ENV*)w, sizeof(ENV)); -======= - ->>>>>>> other w->size -= size; w->task_num--; } @@ -385,11 +344,7 @@ static int run16(SchedTask *manager, void *in, void *out) { -<<<<<<< local ENV *w = *(ENV **)in; -======= - WordCount *w = *(WordCount **)in; ->>>>>>> other if (w->task_num < w->task_blocks) { // last case @@ -424,103 +379,69 @@ st_mmap_t st_mmap; st_mmap = my_mmap(filename); -<<<<<<< local - ENV *w = (ENV*)manager->allocate(sizeof(ENV)); + ENV *env = (ENV*)manager->allocate(sizeof(ENV)); // ENV->filename - w->filename = filename; + env->filename = filename; + + // bzero(env,sizeof(ENV)); - // bzero(w,sizeof(ENV)); -======= - WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount)); - // bzero(w,sizeof(WordCount)); ->>>>>>> other - - w->self = w; - //w->task_blocks = blocks; - w->task_spwaned = 0; + env->self = env; + //env->task_blocks = blocks; + env->task_spwaned = 0; /*sizeはdivision_sizeの倍数にしている。*/ - w->size = w->file_size = st_mmap.size; - w->file_mmap = st_mmap.file_mmap; -<<<<<<< local - // printf("w %lx\n",(long)w); -======= - printf("w %lx\n",(long)w); ->>>>>>> other + env->size = env->file_size = st_mmap.size; + env->file_mmap = st_mmap.file_mmap; + // printf("env %lx\n",(long)env); /* 1task分のデータサイズ(byte) */ - if (w->size >= 1024*division) { - w->division_size = 1024 * division;/*16kbyte*/ + if (env->size >= 1024*division) { + env->division_size = 1024 * division;/*16kbyte*/ } else { - w->division_size = w->size; + env->division_size = env->size; } - printf("dvision_size %d\n",w->division_size); + printf("dvision_size %d\n",env->division_size); /* "word num" and "line num" */ - w->status_num = 2; + env->status_num = 2; /* taskの数 */ - w->task_num = w->size / w->division_size; - w->task_num = w->task_num + (w->division_size*w->task_num < w->size); - int out_task_num = w->task_num; - -<<<<<<< local -======= - + env->task_num = env->size / env->division_size; + env->task_num = env->task_num + (env->division_size*env->task_num < env->size); + int out_task_num = env->task_num; - // grepする時にかぶせる文字分をdivisionに追加 - w->division_size += _REGENUM_; - // regexのENVの設定 - w->print_count = false; - w->print_filename = false; - w->count = 0; - w->filename = filename; - - ->>>>>>> other if(!all) { - w->task_blocks = blocks; + env->task_blocks = blocks; } else { - w->task_blocks = w->task_num; + env->task_blocks = env->task_num; } - w->out_task_num = out_task_num; - printf("task_num %d\n",w->task_num); -<<<<<<< local - // printf("out_task_num %d\n",w->out_task_num); -======= - printf("out_task_num %d\n",w->out_task_num); ->>>>>>> other + env->out_task_num = out_task_num; + printf("task_num %d\n",env->task_num); + printf("out_task_num %d\n",env->out_task_num); /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */ - w->division_out_size = sizeof(unsigned long long)*4; - int out_size = w->division_out_size*out_task_num; - w->o_data = (unsigned long long *)manager->allocate(out_size); -<<<<<<< local - /* -======= ->>>>>>> other - w->out_size = 4; + env->division_out_size = sizeof(unsigned long long)*4; + int out_size = env->division_out_size*out_task_num; + env->o_data = (unsigned long long *)manager->allocate(out_size); + env->out_size = 4; printf("out size %d\n",out_size); -<<<<<<< local */ -======= ->>>>>>> other /*各SPEの結果を合計して出力するタスク*/ t_print = manager->create_task(TASK_PRINT, - (memaddr)&w->self,sizeof(memaddr),0,0); + (memaddr)&env->self,sizeof(memaddr),0,0); - w->t_print = t_print; + env->t_print = t_print; for(int i = 0;i<20;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, - (memaddr)&w->self,sizeof(memaddr),0,0); + (memaddr)&env->self,sizeof(memaddr),0,0); t_print->wait_for(t_exec); t_exec->spawn(); }
--- a/example/regex/ppe/Exec.cc Thu Jul 14 18:57:43 2011 +0900 +++ b/example/regex/ppe/Exec.cc Sat Jul 16 17:25:40 2011 +0900 @@ -216,7 +216,7 @@ // char *i_data = (char *)rbuf; char *i_data = (char *)s->get_input(rbuf, 0); int length = (int)s->get_inputSize(0); - WordCount *env = (WordCount*)s->get_input(rbuf, 1); + ENV *env = (ENV*)s->get_input(rbuf, 1); UCHARP beg, buf, end; beg = buf = (UCHARP)i_data; end = beg + length - 1;
--- a/example/regex/ppe/Exec.cc~ Thu Jul 14 18:57:43 2011 +0900 +++ b/example/regex/ppe/Exec.cc~ Sat Jul 16 17:25:40 2011 +0900 @@ -2,16 +2,11 @@ #include <string.h> #include "Exec.h" #include "Func.h" -<<<<<<< local -#include "WordCount.h" -======= -#include "grep.c" ->>>>>>> other +#include "grep.h" /* これは必須 */ SchedDefineTask(Exec); -<<<<<<< local typedef unsigned char UCHAR; typedef unsigned char* UCHARP; @@ -215,73 +210,18 @@ -======= ->>>>>>> other static int run(SchedTask *s, void *rbuf, void *wbuf) { -<<<<<<< local // char *i_data = (char *)rbuf; char *i_data = (char *)s->get_input(rbuf, 0); -======= - char *i_data = (char *)rbuf; - unsigned long long *o_data = (unsigned long long*)wbuf; - unsigned long long *head_tail_flag = o_data +2; ->>>>>>> other int length = (int)s->get_inputSize(0); -<<<<<<< local -======= - int word_flag = 0; - int word_num = 0; - int line_num = 0; - int i = 0; - - head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); - word_num -= 1-head_tail_flag[0]; ->>>>>>> other - -<<<<<<< local WordCount *env = (WordCount*)s->get_input(rbuf, 1); -======= - /* - for (; i < length; i++) { - if (i_data[i] == 0x20) { - word_flag = 1; - } else if (i_data[i] == 0x0A) { - line_num += 1; - word_flag = 1; - } else { - word_num += word_flag; - word_flag = 0; - } - } - */ - unsigned char *beg, *buf, *end; - beg = buf = (unsigned char*)rbuf; - end = beg + length; - ENVP env = malloc(sizeof(ENVP)); - filter(beg, buf, end, env); ->>>>>>> other - -<<<<<<< local UCHARP beg, buf, end; beg = buf = (UCHARP)i_data; end = beg + length - 1; -======= ->>>>>>> other - -<<<<<<< local + s0(beg, buf, end, (ENVP)env); -======= - - word_num += word_flag; - head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); - - // s->printf("SPE word %d line %d\n",word_num,line_num); - - o_data[0] = (unsigned long long)word_num; - o_data[1] = (unsigned long long)line_num; ->>>>>>> other return 0; }