changeset 1917:64bd56aed386 draft

merge
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Tue, 21 Jan 2014 17:45:58 +0900
parents 68ee760e1c7e (diff) effb5653fd5c (current diff)
children 15e8c50ed570
files
diffstat 4 files changed, 17 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/example/regex_mas/main.cc	Mon Jan 20 21:59:56 2014 +0900
+++ b/example/regex_mas/main.cc	Tue Jan 21 17:45:58 2014 +0900
@@ -37,9 +37,9 @@
 int task_count = 0;
 
 static int division = 16; // in Kbyte
-//static unsigned char* search_word;
 CPU_TYPE spe_cpu = SPE_ANY;
 CPU_TYPE read_spe_cpu = SPE_ANY;
+
 const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-sw search_word] [-file filename]\n       Required filename & search_word\n";
 
 static double
@@ -81,9 +81,7 @@
 static int
 read_run(SchedTask *manager, void *in, void *out) {
 
-    manager->printf("[in divide read mode]\n");
     WordCountPtr w = (WordCountPtr)in;
-    char* read_text = (char*)out;
     HTaskPtr wait;
 
     for (int i = 0; (w->read_left_size > 0) && (i < w->read_task_blocks); i++) {
@@ -101,9 +99,8 @@
         }
         read->set_param(3,(long)w->fd);  //fdの番号の受け渡し
 
-        read->set_outData(0,read_text + w->read_task_number*w->read_division_size, w->read_division_size);
+        read->set_outData(0,w->file_mmap + w->read_task_number*w->read_division_size, w->read_division_size);
 
-        w->t_print->wait_for(w->t_exec);
         w->t_exec->wait_for(read);
         read->spawn();
 
@@ -113,7 +110,7 @@
 
     if (w->read_left_size > 0) {
 
-        HTaskPtr next = manager->create_task(RUN_READ_BLOCKS, (memaddr)&w->self, sizeof(memaddr),read_text,w->read_filesize);
+        HTaskPtr next = manager->create_task(RUN_READ_BLOCKS, (memaddr)&w->self, sizeof(memaddr),0,0);
 
         w->t_print->wait_for(next);
         w->t_exec->wait_for(next);
@@ -128,8 +125,6 @@
 static int
 my_mmap(SchedTask *s, void *in, void *out)
 {
-    s->printf("[in mmap mode]\n");
-
     WordCountPtr w = (WordCountPtr)in;
     /*マッピングだよ!*/
 
@@ -256,7 +251,6 @@
 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;
     }
@@ -273,7 +267,7 @@
 {
     long   fd = (long)manager->allocate(sizeof(long));
     struct stat *sb = (struct stat*)manager->allocate(sizeof(struct stat));
-    HTaskPtr t_exec = NULL;
+    HTaskPtr t_exec;
 
     if ((fd=open(filename,O_RDONLY,0666))==0) {
         fprintf(stderr,"can't open %s\n",filename);
@@ -283,7 +277,6 @@
         fprintf(stderr,"can't fstat %s\n",filename);
     }
 
-    //WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount));
     WordCountPtr w = (WordCountPtr)manager->allocate(sizeof(WordCount));
 
     w->self = w;
@@ -295,7 +288,6 @@
     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);
-    w->t_exec = t_exec;
 
     printf("filesize     : %d\n",w->read_filesize);
     printf("one_task_size: %d\n",w->read_division_size);
@@ -304,13 +296,16 @@
     HTaskPtr r_run = NULL;
 
     if (divide_read_flag != 0) {
-        char *read_text = (char*)manager->allocate(w->read_filesize);
-        r_run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&w->self, sizeof(memaddr),read_text,w->read_filesize);
-        w->read_text = read_text;
+        printf("[divide read mode]\n");
+        w->file_mmap = (char*)manager->allocate(w->read_filesize);
+        r_run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&w->self, sizeof(memaddr),0,0);
     }else {
+        printf("[mmap mode]\n");
         r_run = manager->create_task(MMAP , (memaddr)&w->self, sizeof(memaddr),0,0);
     }
 
+    r_run->spawn();
+
     /* prepare BMSearch*/
     int *skip = (int*)manager->allocate(256 * sizeof(int));
     w->search_word = search_word;
@@ -321,9 +316,6 @@
     /* original */
     HTaskPtr t_print;
 
-    //st_mmap_t st_mmap;
-    //st_mmap = my_mmap(filename);
-
     //w->task_blocks = blocks;
     w->self = w;
     w->task_spwaned = 0;
@@ -340,7 +332,7 @@
         w->division_size = w->size;
     }
 
-    printf("dvision_size %d\n",w->division_size);
+    printf("division_size %d\n",w->division_size);
 
     /* "word num" and "line num" */
     w->status_num = 2;
@@ -361,11 +353,11 @@
 
     /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */
 
-    w->division_out_size = sizeof(unsigned long long)*4;
+    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_ = out_size;
-    w->out_size = 4;
+    w->out_size = 1;
     printf("out size %d\n",out_size);
 
     /*各SPEの結果を合計して出力するタスク*/
@@ -384,8 +376,8 @@
         //    t_exec->iterate(4);
         t_exec->spawn();
     }
-    t_print->wait_for(r_run);
-    r_run->spawn();
+    w->t_exec = t_exec;
+
     t_print->spawn();
 }
 
--- a/example/regex_mas/ppe/Exec.cc	Mon Jan 20 21:59:56 2014 +0900
+++ b/example/regex_mas/ppe/Exec.cc	Tue Jan 21 17:45:58 2014 +0900
@@ -42,7 +42,7 @@
 
     //get_param
     //long task_count = (long)s->get_param(0);  //何番目のtaskか
-    //s->printf("[exec No: %lld]\n",task_count+1);
+    //s->printf("[start exec No: %lld]\n",task_count+1);
 
     unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf,0);
 
--- a/example/regex_mas/ppe/Read.cc	Mon Jan 20 21:59:56 2014 +0900
+++ b/example/regex_mas/ppe/Read.cc	Tue Jan 21 17:45:58 2014 +0900
@@ -25,7 +25,7 @@
 
     pread(fd, read_text, (long)read_size , division_size*task_number);
 
-    //s->printf("[start task No. %d]\n",task_number);
+    //s->printf("[start read task No. %d]\n",task_number);
     //s->printf("%s\n",read_text);
     //s->printf("in divide_read\n");
     return 0;
--- a/example/regex_mas/task_init.cc	Mon Jan 20 21:59:56 2014 +0900
+++ b/example/regex_mas/task_init.cc	Tue Jan 21 17:45:58 2014 +0900
@@ -9,7 +9,6 @@
 SchedExternTask(READ_TASK);
 SchedExternTask(RUN_READ_BLOCKS);
 SchedExternTask(MMAP);
-SchedExternTask(TASK_EXEC);
 SchedExternTask(RUN_TASK_BLOCKS);
 SchedExternTask(PRINT_TASK);