changeset 1948:6b03da068fbe draft

fix
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Thu, 06 Feb 2014 01:23:17 +0900
parents ef751840b388
children f3e9f811c387
files example/regex_mas/WordCount.h example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc example/regex_mas/ppe/Read.cc
diffstat 4 files changed, 20 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/example/regex_mas/WordCount.h	Wed Feb 05 22:23:36 2014 +0900
+++ b/example/regex_mas/WordCount.h	Thu Feb 06 01:23:17 2014 +0900
@@ -3,15 +3,9 @@
     struct wordCount *self;
     /* read task variable */
     int fd;
-    long read_division_size;
-    long read_task_number;
-    int read_task_num;
     long long read_filesize;
-    long long read_left_size;
-    int read_task_blocks;
     CPU_TYPE read_cpu;
 
-
     long long size;             // remaining file size
     int division_size;    // for each word count task
     int division_out_size;
--- a/example/regex_mas/main.cc	Wed Feb 05 22:23:36 2014 +0900
+++ b/example/regex_mas/main.cc	Thu Feb 06 01:23:17 2014 +0900
@@ -169,37 +169,33 @@
 {
     WordCount *w = *(WordCount **)in;
 
+    HTaskPtr t_read = NULL;
+
     if (w->task_num < w->task_blocks) {
         // last case
         while (w->size >= w->division_size)
-            run_tasks(manager,w,w->task_num,0,w->t_print, w->division_size + w->extra_len);
+            run_tasks(manager,w,w->task_num,t_read,w->t_print, w->division_size + w->extra_len);
         // remaining data
         while (w->size>0)
-            run_tasks(manager,w,1,0,w->t_print, w->size);
+            run_tasks(manager,w,1,t_read,w->t_print, w->size);
         // printf("run16 last %d\n",w->task_num);
     } else {
+        t_read = manager->create_task(READ_TASK, (memaddr)&w->self,sizeof(memaddr),0,0);
+
         HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS,
                                                (memaddr)&w->self,sizeof(memaddr),0,0);
         w->t_print->wait_for(t_next);
-        if (divide_read_flag != 0) {
-            long task_spawned = w->task_spawned;
-            HTaskPtr t_read = manager->create_task(READ_TASK,
-                                                   (memaddr)&w->self,sizeof(memaddr),0,0);
-
-            t_read->set_cpu(read_spe_cpu);
-            t_read->set_param(0,task_spawned*w->division_size);
-
-            run_tasks(manager,w, w->task_blocks,t_read, t_next, w->division_size + w->extra_len);
+        t_read->set_cpu(read_spe_cpu);
+        long task_spawned = w->task_spawned;
+        t_read->set_param(0,task_spawned*w->division_size);
+        t_read->set_outData(0, w->file_mmap + task_spawned * w->division_size, task_spawned * w->division_size);
 
-             task_spawned = w->task_spawned;
-            t_read->set_param(1,task_spawned*w->division_size);
-            t_read->set_param(2,(long)w->fd);
+        run_tasks(manager,w, w->task_blocks,t_read, t_next, w->division_size + w->extra_len);
 
-            t_read->spawn();
+        task_spawned = w->task_spawned;
+        t_read->set_param(1,task_spawned*w->division_size);
 
-        }else{
-            run_tasks(manager,w, w->task_blocks,0, t_next, w->division_size + w->extra_len);
-        }
+        t_read->spawn();
         t_next->spawn();
         // printf("run16 next %d\n",w->task_num);
     }
@@ -246,23 +242,13 @@
 
     w->self = w;
     w->fd = fd;
-    w->read_cpu = read_spe_cpu;
-    w->read_task_blocks = 16;
     w->read_filesize = sb->st_size;
-    w->read_left_size = w->read_filesize;
-    w->read_division_size = READ_DIVISION_SIZE;
-    w->read_task_num = w->read_filesize / READ_DIVISION_SIZE;
-    w->read_task_num += ((w->read_filesize % READ_DIVISION_SIZE) != 0);
-
-    // printf("filesize     : %lld\n",w->read_filesize);
-    // printf("one_task_size: %ld\n",w->read_division_size);
-    // printf("task_num     : %d\n",w->read_task_num);
 
     HTaskPtr r_read = NULL;
 
     if (divide_read_flag != 0) {
         printf("[divide read mode]\n");
-        w->file_mmap = (char*)manager->allocate(sizeof(w->file_size));
+        w->file_mmap = (char*)manager->allocate(sizeof(w->read_filesize));
     }else {
         printf("[mmap mode]\n");
         r_read = manager->create_task(MMAP , (memaddr)&w->self, sizeof(memaddr),0,0);
--- a/example/regex_mas/ppe/Exec.cc	Wed Feb 05 22:23:36 2014 +0900
+++ b/example/regex_mas/ppe/Exec.cc	Thu Feb 06 01:23:17 2014 +0900
@@ -45,9 +45,9 @@
     o_data[0] = 0;
     o_data[0] = BM_method(i_data,length,search_word,sw_len,skip_table);
 
-    //printf("match count : %llu\n",o_data[0]);
-    //long task_count = (long)s->get_param(0);  //何番目のtaskか
-    //s->printf("[start exec No: %lld]\n",task_count+1);
+    printf("match count : %llu\n",o_data[0]);
+    long task_count = (long)s->get_param(0);  //何番目のtaskか
+    s->printf("[start exec No: %lld]\n",task_count+1);
 
 
     return 0;
--- a/example/regex_mas/ppe/Read.cc	Wed Feb 05 22:23:36 2014 +0900
+++ b/example/regex_mas/ppe/Read.cc	Thu Feb 06 01:23:17 2014 +0900
@@ -20,12 +20,12 @@
     WordCount *w = *(WordCount **)rbuf;
     long start_read = (long)s->get_param(0);
     long end_read = (long)s->get_param(1);
-    long fd = (long)s->get_param(2);
+    char *read_text = (char*)s->get_output(wbuf,0);
+    long fd = w->fd;
 
     long read_size = end_read - start_read;
 
     //char *read_text = (char*)s->get_output(wbuf,0);
-    char *read_text = w->file_mmap + start_read;
     //s->printf("[read No %d : wbuf addr 0x%llx]\n",task_number,read_text);
 
     pread(fd, read_text, read_size , start_read);