Mercurial > hg > Game > Cerium
changeset 1690:aff937b6a26a draft
fix
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 12 Sep 2013 17:13:52 +0900 |
parents | c595245aa59e |
children | 6b3991ac3f07 |
files | example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc |
diffstat | 2 files changed, 27 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/main.cc Tue Aug 20 13:34:20 2013 +0900 +++ b/example/regex_mas/main.cc Thu Sep 12 17:13:52 2013 +0900 @@ -7,6 +7,8 @@ #include <fcntl.h> #include <unistd.h> #include <sys/time.h> +#include <iostream> +#include <vector> #include "TaskManager.h" #include "SchedTask.h" #include "Func.h" @@ -108,7 +110,7 @@ HTask **task_array = (HTask**)manager->allocate(sizeof(HTask*)*spe_num); Task **t_exec = (Task**)manager->allocate(sizeof(Task*)*spe_num); - for (int k = 0; k < spe_num; k++) { //このfor文いらない?? + for (int k = 0; k < spe_num; k++) { task_array[k] = manager->create_task_array(TASK_EXEC,array_task_num,1,1,1); t_exec[k] = 0; if (all) { @@ -134,10 +136,6 @@ t_exec[k] = task_array[k]->next_task_array(TASK_EXEC,t_exec[k]); t_exec[k]->set_param(0,(memaddr)offset); - /*set_inDataで多めに文字を取ってきているが、 - *Exec.ccに文字列検索をさせるときにはset_param(1)で - *設定した文字列しか検索してくれないようになっている。 - */ if(size != w->size){ //最後のタスクかどうかの判定 t_exec[k]->set_param(1,(memaddr)set_one_task_length + EXTRA_LENGTH); t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size+EXTRA_LENGTH); @@ -145,6 +143,7 @@ t_exec[k]->set_param(1,(memaddr)set_one_task_length); t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size); } + t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); w->size -= size; @@ -300,7 +299,7 @@ (memaddr)&w->self,sizeof(memaddr),0,0); w->t_print = t_print; - for(int i = 0;i<20;i++) { + for(int i = 0;i<2;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS,
--- a/example/regex_mas/ppe/Exec.cc Tue Aug 20 13:34:20 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Thu Sep 12 17:13:52 2013 +0900 @@ -1,5 +1,8 @@ #include <stdio.h> #include <string.h> +#include <iostream> +#include <vector> +#include <cstdlib> #include "Exec.h" #include "Func.h" #include "SchedTask.h" @@ -12,19 +15,28 @@ int BM_method(unsigned char *text,int *offset,int *text_length, unsigned char *pattern,unsigned long long *match_string) { - int skip[256]; + using std::vector; + //int skip[256]; int text_len = (long int)text_length; int pattern_len = strlen((char *)pattern); int i = 0; int match_counter = 0; - for (i = 0; i < 256; ++i){ - skip[i] = pattern_len; - } + std::vector<int> vecSkipTable(256,pattern_len); + //for (i = 0; i < 256; ++i){ + // skip[i] = pattern_len; + //} - for (i = 0; i < pattern_len-1 ; ++i){ - skip[(int)pattern[i]] = pattern_len - i - 1; - } + vecSkipTable[100] = 4; + vecSkipTable[111] = 3; + vecSkipTable[105] = 2; + vecSkipTable[110] = 1; + + //for (i = 0; i < pattern_len-1 ; ++i){ + // skip[(int)pattern[i]] = pattern_len - i - 1; + //} + + i = pattern_len - 1; @@ -37,7 +49,8 @@ --i; --j; } - i = i + max((int)skip[(int)text[i]],pattern_len - j); + //i = i + max((int)skip[(int)text[i]],pattern_len - j); + i = i + max((int)vecSkipTable[(int)text[i]],pattern_len - j); } return match_counter; } @@ -49,6 +62,7 @@ unsigned long long *o_data = (unsigned long long*)wbuf; int *offset = (int*)s->get_param(0); int *length = (int*)s->get_param(1); + //unsigned char *search_word = (unsigned char*)s->get_input(2); unsigned char search_word[] = "doing"; o_data[0] = BM_method(i_data,offset,length,search_word,o_data);