changeset 1805:8c79f9697179 draft

merge
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Tue, 10 Dec 2013 01:02:34 +0900
parents 1febe61a935a (current diff) e08f6133f5d7 (diff)
children a77876642bb3
files
diffstat 3 files changed, 32 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/example/fileread/main.cc	Mon Dec 09 20:41:11 2013 +0900
+++ b/example/fileread/main.cc	Tue Dec 10 01:02:34 2013 +0900
@@ -73,21 +73,36 @@
     }
 
     int filesize = sb->st_size;
-    int task_num = filesize / ONE_TASK_SIZE; 
+    int task_num = filesize / ONE_TASK_SIZE;
     task_num += ((filesize % ONE_TASK_SIZE) != 0);
+    int last_task_size = filesize % ONE_TASK_SIZE;
 
     printf("filesize     : %d\n",filesize);
     printf("one_task_size: %d\n",ONE_TASK_SIZE);
     printf("task_num     : %d\n",task_num);
 
+    int task_number = 0;
+
+    for(task_number = 0; task_number < task_num - 1; task_number++){
+        read = manager->create_task(READ_TASK);
+        read->set_cpu(spe_cpu);
+
+        //ファイルディスクリプタをそのままタスクに渡してあげる
+        read->set_inData(0,(memaddr)fd,sizeof(int*));
+        read->set_param(0,(long)ONE_TASK_SIZE);  //1つのタスクが読み込む量
+        read->set_param(1,(long)task_number);  //生成するTaskが何番目か
+        read->spawn();
+    }
+
+    //Last case
     read = manager->create_task(READ_TASK);
     read->set_cpu(spe_cpu);
 
     //ファイルディスクリプタをそのままタスクに渡してあげる
-    read->set_inData(0,(memaddr)fd,sizeof(int*)); 
-
-    read->set_param(0,ONE_TASK_SIZE);  //1つのタスクが読み込む量
-    read->iterate(task_num);           //タスク数分イテレートする
+    read->set_inData(0,(memaddr)fd,sizeof(int*));
+    read->set_param(0,(long)last_task_size);  //1つのタスクが読み込む量
+    read->set_param(1,(long)task_number);  //生成するTaskが何番目か
+    read->spawn();
 }
 
 
--- a/example/fileread/ppe/Read.cc	Mon Dec 09 20:41:11 2013 +0900
+++ b/example/fileread/ppe/Read.cc	Tue Dec 10 01:02:34 2013 +0900
@@ -13,24 +13,24 @@
 /* これは必須 */
 SchedDefineTask(Read);
 
-
-
 static int
 run(SchedTask *s, void *rbuf, void *wbuf)
 {
     int *fd = (int *)s->get_input(rbuf,0);  ///ファイルディスクリプタの受取
 
     long readsize = (long)s->get_param(0);
+    long task_number = (long)s->get_param(1);
 
-    char text[(long int)readsize];
+    char text[(long)readsize];
 
     //lseekで読み込む場所を教えてあげる
     //s->xはiteraterで繰り返した数
-    lseek(*fd,readsize*s->x,SEEK_SET);  
-    read(*fd,text,(unsigned long)readsize);
+    //lseek(*fd,readsize*task_number,SEEK_SET);
+    read(*fd,text,(long)readsize);
 
-    //s->printf("[task No. %d]\n%s\n",s->x + 1,text);
-    s->printf("[task No. %d]\n",s->x + 1);
+    s->printf("[start task No. %d]\n",task_number);
+    s->printf("%s\n",text);
+    //s->printf("[end task No. %d]\n",task_number);
 
     return 0;
 }
--- a/example/regex_mas/main.cc	Mon Dec 09 20:41:11 2013 +0900
+++ b/example/regex_mas/main.cc	Tue Dec 10 01:02:34 2013 +0900
@@ -146,7 +146,7 @@
                 h_exec->spawn();
             }
             w->size -= size;
-            w->task_num--; 
+            w->task_num--;
         }
         if (use_task_array) {
             task_array->spawn_task_array(t_exec->next());
@@ -183,7 +183,7 @@
                                                (memaddr)&w->self,sizeof(memaddr),0,0);
         w->t_print->wait_for(t_next);
 
-        run_tasks(manager,w, w->task_blocks, t_next, w->division_size);
+        run_tasks(manager,w, w->task_blocks, t_next, w->division_size + w->extra_len);
 
         t_next->spawn();
         // printf("run16 next %d\n",w->task_num);
@@ -271,15 +271,15 @@
                                    (memaddr)&w->self,sizeof(memaddr),0,0);
     w->t_print = t_print;
 
-    //    for(int i = 0;i<2;i++) {
+    //  for(int i = 0;i<2;i++) {
         /* Task を task_blocks ずつ起動する Task */
         /* serialize されていると仮定する... */
         HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS,
                                                (memaddr)&w->self,sizeof(memaddr),0,0);
         t_print->wait_for(t_exec);
         t_exec->iterate(2);
-        //        t_exec->spawn();
-        //    }
+    //      t_exec->spawn();
+    //  }
 
     t_print->spawn();
 }