changeset 1645:4698c92bf2ca draft

Regex_mas implement time measurement.
author Masa <e085726@ie.u-ryukyu.ac.jp>
date Mon, 24 Jun 2013 17:28:28 +0900
parents b9f46cc511d3
children ab6b11476e02
files example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc example/regex_mas/ppe/Print.cc
diffstat 3 files changed, 29 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/example/regex_mas/main.cc	Mon Jun 24 12:23:36 2013 +0900
+++ b/example/regex_mas/main.cc	Mon Jun 24 17:28:28 2013 +0900
@@ -20,23 +20,24 @@
 
 extern void task_init();
 void TMend(TaskManager *);
-//static double st_time;
-//static double ed_time;
+static double st_time;
+static double ed_time;
 int all = 0;
 int use_task_array = 1;
 int use_task_creater = 0;
 int use_compat = 0;
 int array_task_num = 8;
 int spe_num = 1;
+char search_word[256];
 CPU_TYPE spe_cpu = SPE_ANY;
 const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-file filename]\n";
 
-//static double
-//getTime() {
-//    struct timeval tv;
-//    gettimeofday(&tv, NULL);
-//    return tv.tv_sec + (double)tv.tv_usec*1e-6;
-//}
+static double
+getTime() {
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    return tv.tv_sec + (double)tv.tv_usec*1e-6;
+}
 
 typedef struct {
     caddr_t file_mmap;
@@ -272,6 +273,7 @@
                     const int ARRAY_LENGTH_SIZE = spe_num * ONE_TASK_LENGTH;
                     int offset = ONE_LOOP_LENGTH * i + ARRAY_LENGTH_SIZE*j + ONE_TASK_LENGTH*k;
                     t_exec[k]->set_param(1,(memaddr)offset);
+                    //printf("%s\n",search_word);
                     t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size + EXTRA_LENGTH);  //ここっぽい
                     t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size);
 
@@ -473,6 +475,8 @@
         } else if (strcmp(argv[i], "-cpu") == 0) {
             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]);
         }
     }
     if (filename==0) {
@@ -497,7 +501,16 @@
 
     task_init();
     run_start(manager, filename);
+    st_time = getTime();
+    manager->set_TMend(TMend);
     return 0;
 }
 
+void
+TMend(TaskManager *manager)
+{
+    ed_time = getTime();
+    printf("Time: %0.6f\n",ed_time-st_time);
+}
+
 /* end */
--- a/example/regex_mas/ppe/Exec.cc	Mon Jun 24 12:23:36 2013 +0900
+++ b/example/regex_mas/ppe/Exec.cc	Mon Jun 24 17:28:28 2013 +0900
@@ -57,7 +57,7 @@
 
     //printf("offset = %ld\n",(long int)offset);
     BM_method(i_data,offset,length,search_word,o_data);
-    s->printf("in Exec.cc\n");
+    //s->printf("in Exec.cc\n");
 
    
     return 0;
--- a/example/regex_mas/ppe/Print.cc	Mon Jun 24 12:23:36 2013 +0900
+++ b/example/regex_mas/ppe/Print.cc	Mon Jun 24 17:28:28 2013 +0900
@@ -13,16 +13,20 @@
     WordCount *w = *(WordCount**)rbuf;
     unsigned long long *idata = w->o_data;
     unsigned int idata_task_num = w->out_size * w->out_task_num;
+    int match_count = 0;
     
     s->printf("task num : %d\n",w->task_spwaned);
 
     s->printf("position\n");
     for (int i = 0;i < idata_task_num/2;i++) {
     
-        if(idata[2*i] == 0x50){
-            s->printf("%d ",(int)idata[2*i+1]);
-            s->printf("%c\n",(unsigned char)idata[2*i]);
+        if(idata[2*i] != 0x00){
+            //s->printf("%d ",(int)idata[2*i+1]);
+            //s->printf("%c\n",(unsigned char)idata[2*i]);
+            match_count++;
+
         }
     }
+    s->printf("HIT:%d\n",match_count);
     return 0;
 }