changeset 1774:39734c8cbcfe draft

To created BMsearch skip table method move Exec.cc to main.cc:run_start
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Sat, 23 Nov 2013 17:28:22 +0900
parents 83ef550db0a8
children 72e8c18bfbf6
files example/regex_mas/WordCount.h example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc
diffstat 3 files changed, 28 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/example/regex_mas/WordCount.h	Sat Nov 23 10:22:21 2013 +0900
+++ b/example/regex_mas/WordCount.h	Sat Nov 23 17:28:22 2013 +0900
@@ -13,10 +13,12 @@
     int out_task_num;
     char *file_mmap;
     int file_size;
+    HTaskPtr t_print;
+    /*set input Data variables*/
     int last_task_size;
     unsigned char *search_word;
+    int *BMskip_table;
     int search_word_len;
     int extra_len;
-    HTaskPtr t_print;
 } WordCount;
 
--- a/example/regex_mas/main.cc	Sat Nov 23 10:22:21 2013 +0900
+++ b/example/regex_mas/main.cc	Sat Nov 23 17:28:22 2013 +0900
@@ -38,7 +38,7 @@
  * これにメチャクチャハマったので注意
  * いつかはcreate_task_arrayを消したい
  */
-int set_inData_num = 2;
+int set_inData_num = 3;
 int set_param_num = 2;
 int set_out_num = 1;
 
@@ -152,6 +152,7 @@
                         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(2,w->BMskip_table, sizeof(int)*256);
 
                     t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size);
 
@@ -255,6 +256,21 @@
 static int blocks = 48;
 //static int blocks = 31 * 6 * 24;
 
+static int*
+create_BMskiptable(unsigned char *search_word,int search_word_len,int *skip_table)
+{
+
+    for(int i = 0; i < 256; ++i){
+        skip_table[i] = search_word_len;
+    }
+
+    for(int j = 0; j < search_word_len - 1; ++j){
+        skip_table[(int)search_word[j]] = search_word_len - j - 1;
+    }
+    return skip_table;
+}
+
+
 static void
 run_start(TaskManager *manager, char *filename,unsigned char *search_word)
 {
@@ -267,8 +283,10 @@
     // bzero(w,sizeof(WordCount));
 
     /* prepare BMSearch*/
+    int *skip = (int*)manager->allocate(sizeof(int)*256);
     w->search_word = search_word;
     w->search_word_len = strlen((const char*)w->search_word);
+    w->BMskip_table = create_BMskiptable(w->search_word, w->search_word_len, skip);
 
     //w->task_blocks = blocks;
     w->self = w;
@@ -382,10 +400,6 @@
     unsigned char *search_word = (unsigned char*)manager->allocate(sizeof(char)*sw_len);
     strcpy((char*)search_word, (const char*)sword);
 
-    printf("%p\n",&search_word);
-    printf("%p\n",&sword);
-
-
     if (filename < 0) {
         return -1;
     }
--- a/example/regex_mas/ppe/Exec.cc	Sat Nov 23 10:22:21 2013 +0900
+++ b/example/regex_mas/ppe/Exec.cc	Sat Nov 23 17:28:22 2013 +0900
@@ -47,8 +47,14 @@
 {
     unsigned char *i_data = (unsigned char *)s->get_input(rbuf,0);
     unsigned char *search_word = (unsigned char*)s->get_input(rbuf,1);
+    int *skip_table = (int *)s->get_input(rbuf,2);
     int length = (int)s->get_inputSize(0);
     int sw_len = (int)s->get_inputSize(1);
+
+
+    for(int i = 0; i < 256;i++){
+        s->printf("skip[%d]:%d\n",i,skip_table[i]);
+    }
     //unsigned char search_word[] = "doing";
 
     unsigned long long *o_data = (unsigned long long*)wbuf;