Mercurial > hg > Game > Cerium
changeset 1765:2cf65c7687a5 draft
merged
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 23 Nov 2013 01:10:55 +0900 |
parents | 6929e4c02c4d (current diff) b98e23499add (diff) |
children | 71bf632092c8 |
files | |
diffstat | 2 files changed, 15 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/main.cc Sat Nov 23 01:10:28 2013 +0900 +++ b/example/regex_mas/main.cc Sat Nov 23 01:10:55 2013 +0900 @@ -29,6 +29,7 @@ int array_task_num = 8; int spe_num = 1; +unsigned char *sword = 0; /* * set_inData_num * task_array[k] = manager->create_task_array @@ -38,13 +39,13 @@ * いつかはcreate_task_arrayを消したい */ int set_inData_num = 2; -int set_param_num = 1; +int set_param_num = 2; int set_out_num = 1; static int division = 16; // in Kbyte //static 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"; +const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-sw search_word] [-file filename]\n"; static double getTime() { @@ -97,7 +98,6 @@ } return st_mmap; - } static void @@ -143,15 +143,15 @@ t_exec[k] = task_array[k]->next_task_array(TASK_EXEC,t_exec[k]); + t_exec[k]->set_param(0,&w->search_word_len); if(size != w->size){ //最後のタスクかどうかの判定 - t_exec[k]->set_param(0,&w->division_size + w->extra_len); + t_exec[k]->set_param(1,&w->division_size + w->extra_len); t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, w->division_size + w->extra_len); - t_exec[k]->set_inData(1,w->search_word, w->search_word_len); }else{ - t_exec[k]->set_param(0,&w->last_task_size); + t_exec[k]->set_param(1,&w->division_size); t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, w->division_size); - t_exec[k]->set_inData(1,w->search_word, w->search_word_len); } + t_exec[k]->set_inData(1,w->search_word, w->search_word_len); t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); @@ -283,7 +283,6 @@ } else { w->division_size = w->size; } - w->last_task_size = w->size % w->division_size; /* exec output only "match_num" */ w->status_num = 1; @@ -330,7 +329,6 @@ { char *filename = 0; - unsigned char *search_word = 0; for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-file") == 0) { @@ -360,7 +358,7 @@ spe_num = atoi(argv[i+1]); if (spe_num==0) spe_num = 1; } else if (strcmp(argv[i], "-sw") == 0) { - search_word = (unsigned char*)argv[i+1]; + sword = (unsigned char*)argv[i+1]; } } if (filename==0) { @@ -377,19 +375,10 @@ { char *filename = 0; - unsigned char *sword = 0; - filename = init(argc, argv); - for (int i = 1; argv[i]; ++i) { - if (strcmp(argv[i], "-sw") == 0) { - sword = (unsigned char*)argv[i+1]; - } - } - int sw_len = strlen((const char*)sword); - //search_word = (unsigned char*)malloc(sizeof(char)* sw_len); unsigned char *search_word = (unsigned char*)manager->allocate(sizeof(char)*sw_len); strcpy((char*)search_word, (const char*)sword);
--- a/example/regex_mas/ppe/Exec.cc Sat Nov 23 01:10:28 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Sat Nov 23 01:10:55 2013 +0900 @@ -9,12 +9,12 @@ SchedDefineTask(Exec); //ボイヤームーア法による文字列検索アルゴリズム -int BM_method(unsigned char *text,int text_length, - unsigned char *pattern,unsigned long long *match_string) +static int BM_method(unsigned char *text,int text_length, + unsigned char *pattern,int sw_len) { int skip[256]; int text_len = (long int)text_length; - int pattern_len = strlen((char *)pattern); + int pattern_len = sw_len; int i = 0; int match_counter = 0; @@ -26,8 +26,6 @@ skip[(int)pattern[i]] = pattern_len - i - 1; } - - i = pattern_len - 1; while ( i < text_len){ @@ -49,12 +47,13 @@ { unsigned char *i_data = (unsigned char *)s->get_input(rbuf,0); unsigned char *search_word = (unsigned char*)s->get_input(rbuf,1); + int length = (int)s->get_inputSize(0); + int sw_len = (int)s->get_inputSize(1); + //unsigned char search_word[] = "doing"; unsigned long long *o_data = (unsigned long long*)wbuf; - int length = (int)s->get_inputSize(0); - //unsigned char search_word[] = "doing"; - o_data[0] = BM_method(i_data,length,search_word,o_data); + o_data[0] = BM_method(i_data,length,search_word,sw_len); //s->printf("in Exec.cc\n");