changeset 1660:8b50b1ee068e draft

change result position to match_num.
author Masa <e085726@ie.u-ryukyu.ac.jp>
date Tue, 16 Jul 2013 13:06:31 +0900
parents 0d25364759e0
children 19ab54c76d6f
files example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc example/regex_mas/ppe/Print.cc
diffstat 3 files changed, 13 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/example/regex_mas/main.cc	Mon Jul 15 18:46:35 2013 +0900
+++ b/example/regex_mas/main.cc	Tue Jul 16 13:06:31 2013 +0900
@@ -424,11 +424,12 @@
     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)*256;
+    w->division_out_size = sizeof(unsigned long long)*1;
     int out_size = w->division_out_size*out_task_num;
     w->o_data = (unsigned long long *)manager->allocate(out_size);
-    w->out_size = 256;
+    w->out_size = 1;
 
     /*各SPEの結果を合計して出力するタスク*/
 
@@ -482,7 +483,6 @@
             spe_num = atoi(argv[i+1]);
             if (spe_num==0) spe_num = 1;
         } else if (strcmp(argv[i], "-sw") == 0) {
-            //strcpy(search_word,argv[i+1]);
             search_word = (unsigned char*)argv[i+1];
         }
     }
--- a/example/regex_mas/ppe/Exec.cc	Mon Jul 15 18:46:35 2013 +0900
+++ b/example/regex_mas/ppe/Exec.cc	Tue Jul 16 13:06: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 long long *match_string)
+              unsigned char *pattern,int *sw_len)
 {
     int skip[256];
     int text_len = (long int)text_length;
     int pattern_len = (long int)sw_len;
     int i = 0;
-    int k = 0;
+    int match_num = 0;
 
     for (i = 0; i < 256; ++i){
         skip[i] = pattern_len;
@@ -32,18 +32,16 @@
         int j = pattern_len - 1;
         while (text[i] == pattern[j]){
             if (j == 0){
-                match_string[2*k] = text[i];
-                int position = (long int)offset + i + 1; 
-                match_string[2*k+1] = position;
 
-                k++;
+                match_num++;
+
             }
             --i;
             --j;
         }
         i = i + max((int)skip[(int)text[i]],pattern_len - j);
     }
-    return 0;
+    return match_num;
 }
 
 static int
@@ -64,9 +62,8 @@
     //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);
 
-    BM_method(i_data,offset,length,search_word,sw_len,o_data);
+    o_data[0] = BM_method(i_data,offset,length,search_word);
     //s->printf("in Exec.cc\n");
 
-   
     return 0;
 }
--- a/example/regex_mas/ppe/Print.cc	Mon Jul 15 18:46:35 2013 +0900
+++ b/example/regex_mas/ppe/Print.cc	Tue Jul 16 13:06:31 2013 +0900
@@ -15,20 +15,11 @@
     unsigned int idata_task_num = w->out_size * w->out_task_num;
     int match_count = 0;
 
-    s->printf("position\n");
-    for (int i = 0;i < idata_task_num/2;i++) {
+
+    for (int i = 0;i < idata_task_num;i++) {
+        match_count += idata[i];
+    }
     
-       // if(idata[2*i] == 0x61){
-
-            s->printf("%d ",(int)idata[2*i+1]);
-            s->printf("%c\n",(unsigned char)idata[2*i]);
-            //s->printf("%d:%c\n",2*i,(unsigned char)idata[2*i]);
-            //s->printf("%d:%d ",2*i+1,(int)idata[2*i+1]);
-            match_count++;
-
-       // }
-    }
     s->printf("HIT:%d\n",match_count);
-    s->printf("task num : %d\n",w->task_spwaned);
     return 0;
 }