Mercurial > hg > Game > Cerium
changeset 1662:d865530672fa draft
fix regex_mas
author | Masa <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 16 Jul 2013 16:42:31 +0900 |
parents | 19ab54c76d6f |
children | ce031df3dd32 99f8130793b4 |
files | example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc example/regex_mas/ppe/Print.cc |
diffstat | 3 files changed, 28 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/main.cc Tue Jul 16 14:46:50 2013 +0900 +++ b/example/regex_mas/main.cc Tue Jul 16 16:42:31 2013 +0900 @@ -12,7 +12,7 @@ #include "Func.h" #include "WordCount.h" -#define EXTRA_LENGTH 4 //多く取ってくる文字数(search word length - 1) +#define EXTRA_LENGTH 2 //多く取ってくる文字数(search word length - 1) /* ;TODO * PS3でCPU数が2以上の時に、あまりが計算されてない @@ -28,7 +28,7 @@ int use_compat = 0; int array_task_num = 8; int spe_num = 1; -unsigned char* search_word; +unsigned char *search_word; CPU_TYPE spe_cpu = SPE_ANY; const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-file filename]\n"; @@ -271,18 +271,16 @@ const int ONE_LOOP_LENGTH = array_task_num*spe_num*ONE_TASK_LENGTH; const int ARRAY_LENGTH_SIZE = spe_num * ONE_TASK_LENGTH; int offset = ONE_LOOP_LENGTH * i + ARRAY_LENGTH_SIZE*j + ONE_TASK_LENGTH*k; - int sw_len = strlen((char *)search_word); - //printf("%d\n",sw_len); - t_exec[k]->set_inData(0,search_word,sizeof(search_word)); + t_exec[k]->set_param(0,(memaddr)length); + t_exec[k]->set_param(1,(memaddr)offset); + //printf("%s\n",search_word); if(size != w->size){ //ラストのタスクかどうかの判定 - t_exec[k]->set_inData(1,w->file_mmap + a*w->division_size, size+EXTRA_LENGTH); + t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size+EXTRA_LENGTH); }else{ - t_exec[k]->set_inData(1,w->file_mmap + a*w->division_size, size); + t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size); } - t_exec[k]->set_outData(1,w->o_data + a*w->out_size, w->division_out_size); - t_exec[k]->set_param(0,length); //1タスクのtextの長さ - t_exec[k]->set_param(1,offset); //何文字目かどうかを送る - t_exec[k]->set_param(2,sw_len); //検索する文字の長さ + t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); + w->size -= size; w->task_num--; } @@ -424,7 +422,6 @@ w->out_task_num = out_task_num; /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */ - /* 1task当たりのo_data数*/ w->division_out_size = sizeof(unsigned long long)*1; int out_size = w->division_out_size*out_task_num; @@ -520,4 +517,4 @@ printf("Time: %0.6f\n",ed_time-st_time); } -/*end*/ +/* end */
--- a/example/regex_mas/ppe/Exec.cc Tue Jul 16 14:46:50 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Tue Jul 16 16:42:31 2013 +0900 @@ -10,13 +10,13 @@ //ボイヤームーア法による文字列検索アルゴリズム int BM_method(unsigned char *text,int *offset,int *text_length, - unsigned char *pattern,int *sw_len) + unsigned char *pattern,unsigned long long *match_string) { int skip[256]; int text_len = (long int)text_length; - int pattern_len = (long int)sw_len; + int pattern_len = strlen((char *)pattern); int i = 0; - int match_num = 0; + int match_counter = 0; for (i = 0; i < 256; ++i){ skip[i] = pattern_len; @@ -32,38 +32,30 @@ int j = pattern_len - 1; while (text[i] == pattern[j]){ if (j == 0){ - - match_num++; - + match_counter++; } --i; --j; } i = i + max((int)skip[(int)text[i]],pattern_len - j); } - return match_num; + return match_counter; } static int run(SchedTask *s, void *rbuf, void *wbuf) { - unsigned char *search_word = (unsigned char *)s->get_input(rbuf, 0); - unsigned char *i_data = (unsigned char *)s->get_input(rbuf, 1); - //unsigned char *search_word = (unsigned char *)s->get_inputAddr(0); - //unsigned char *i_data = (unsigned char *)s->get_inputAddr(1); - s->printf("input word : %s\n",search_word); - unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf,0); - s->printf("in(1):%d in(2):%d\n",s->get_inputSize(0),s->get_inputSize(1)); - - + unsigned char *i_data = (unsigned char *)rbuf; + unsigned long long *o_data = (unsigned long long*)wbuf; int *length = (int*)s->get_param(0); int *offset = (int*)s->get_param(1); - int *sw_len = (int*)s->get_param(2); - //unsigned char search_word[] = "doing"; - s->printf("length:%ld,offset:%ld,sw_len:%d,search_word:%s,i_data:%s\n",length,offset,sw_len,search_word,i_data); + unsigned char search_word[] = "aba"; - o_data[0] = BM_method(i_data,offset,length,search_word); + o_data[0] = BM_method(i_data,offset,length,search_word,o_data); + + s->printf("%d\n",o_data[0]); //s->printf("in Exec.cc\n"); + return 0; }
--- a/example/regex_mas/ppe/Print.cc Tue Jul 16 14:46:50 2013 +0900 +++ b/example/regex_mas/ppe/Print.cc Tue Jul 16 16:42:31 2013 +0900 @@ -13,13 +13,14 @@ WordCount *w = *(WordCount**)rbuf; unsigned long long *idata = w->o_data; unsigned int idata_task_num = w->out_size * w->out_task_num; - int match_count = 0; - + int match_counter = 0; for (int i = 0;i < idata_task_num;i++) { - match_count += idata[i]; + + match_counter += idata[i]; + //s->printf("idata[%d]=:%d\n",i,idata[i]); + } - - s->printf("HIT:%d\n",match_count); + s->printf("HIT:%d\n",match_counter); return 0; }