Mercurial > hg > Game > Cerium
changeset 1761:b98e23499add draft
refactoring in regex_mas
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 22 Nov 2013 22:48:05 +0900 |
parents | 06fc317e17a3 |
children | 2cf65c7687a5 |
files | example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc |
diffstat | 2 files changed, 8 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/main.cc Fri Nov 22 20:10:59 2013 +0900 +++ b/example/regex_mas/main.cc Fri Nov 22 22:48:05 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 @@ -44,7 +45,7 @@ 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 @@ -329,7 +329,6 @@ { char *filename = 0; - unsigned char *search_word = 0; for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-file") == 0) { @@ -359,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) { @@ -376,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 Fri Nov 22 20:10:59 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Fri Nov 22 22:48:05 2013 +0900 @@ -9,8 +9,8 @@ SchedDefineTask(Exec); //ボイヤームーア法による文字列検索アルゴリズム -int BM_method(unsigned char *text,int text_length, - unsigned char *pattern,int sw_len,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; @@ -26,8 +26,6 @@ skip[(int)pattern[i]] = pattern_len - i - 1; } - - i = pattern_len - 1; while ( i < text_len){ @@ -49,13 +47,13 @@ { unsigned char *i_data = (unsigned char *)s->get_input(rbuf,0); unsigned char *search_word = (unsigned char*)s->get_input(rbuf,1); - - unsigned long long *o_data = (unsigned long long*)wbuf; int length = (int)s->get_inputSize(0); int sw_len = (int)s->get_inputSize(1); //unsigned char search_word[] = "doing"; - o_data[0] = BM_method(i_data,length,search_word,sw_len,o_data); + unsigned long long *o_data = (unsigned long long*)wbuf; + + o_data[0] = BM_method(i_data,length,search_word,sw_len); //s->printf("in Exec.cc\n");