Mercurial > hg > Game > Cerium
changeset 1862:64c571a30bdb draft
change Cerium Task to function() divide read ( cannot running )
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 23 Dec 2013 22:26:18 +0900 |
parents | 9e96c8c52574 |
children | 3f058fee44d2 |
files | example/regex_mas/Func.h example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc example/regex_mas/ppe/Read.cc example/regex_mas/task_init.cc |
diffstat | 5 files changed, 18 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/Func.h Mon Dec 23 16:54:13 2013 +0900 +++ b/example/regex_mas/Func.h Mon Dec 23 22:26:18 2013 +0900 @@ -3,7 +3,6 @@ Task_exec, Task_read, Task_print, - RUN_READ, RUN_TASK_BLOCKS, RUN_READ_BLOCKS, };
--- a/example/regex_mas/main.cc Mon Dec 23 16:54:13 2013 +0900 +++ b/example/regex_mas/main.cc Mon Dec 23 22:26:18 2013 +0900 @@ -52,7 +52,7 @@ } st_mmap_t; typedef struct fileread { - struct filesize *self; + struct fileread *self; char *filename; long fd; long division_size; @@ -112,15 +112,9 @@ return 0; } -SchedDefineTask1(RUN_READ,divide_read); - -static int -//divide_read(TaskManager *manager,char *filename, FilereadPtr fr) -divide_read(SchedTask *manager, void *in, void *out) { - - FilereadPtr fr = (FilereadPtr)in; - char *filename = fr->filename; - +static st_mmap_t +divide_read(TaskManager *manager,HTaskPtr run,char *filename, FilereadPtr fr) +{ st_mmap_t st_mmap; long fd = (long)manager->allocate(sizeof(long)); struct stat sb; @@ -136,6 +130,7 @@ st_mmap.size = fix_byte(sb.st_size,division * 1024); st_mmap.file_mmap = (char*)manager->allocate(st_mmap.size); + fr->self = fr; fr->fd = fd; fr->cpu = spe_cpu; fr->task_blocks = 16; @@ -146,13 +141,12 @@ fr->task_num = fr->filesize / (1024 * division); fr->task_num += ((fr->filesize % 1024 * division) != 0); - //HTaskPtr run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); - HTaskPtr run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); + run = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); run->spawn(); st_mmap.file_mmap = fr->read_text; - return 0; + return st_mmap; } static st_mmap_t @@ -314,13 +308,13 @@ FilereadPtr fr = (FilereadPtr)manager->allocate(sizeof(FilereadPtr)); //fr->self = fr; + fr->self = fr; fr->filename = filename; st_mmap_t st_mmap; + if (div_read != 0) { - //st_mmap = divide_read(manager,filename,fr); - read_run = manager->create_task(RUN_READ, (memaddr)&fr->self, sizeof(memaddr),0,0); - read_run->spawn(); + st_mmap = divide_read(manager,read_run,filename,fr); printf("in divide read\n"); @@ -386,7 +380,10 @@ HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, (memaddr)&w->self,sizeof(memaddr),0,0); - if (read_run != NULL) t_exec->wait_for(read_run); + if (read_run != NULL) { + t_exec->wait_for(read_run); + read_run->spawn(); + } t_print->wait_for(t_exec); t_exec->iterate(2);
--- a/example/regex_mas/ppe/Exec.cc Mon Dec 23 16:54:13 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Mon Dec 23 22:26:18 2013 +0900 @@ -46,7 +46,6 @@ unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf,0); - o_data[0] = 0; o_data[0] = BM_method(i_data,length,search_word,sw_len,skip_table);
--- a/example/regex_mas/ppe/Read.cc Mon Dec 23 16:54:13 2013 +0900 +++ b/example/regex_mas/ppe/Read.cc Mon Dec 23 22:26:18 2013 +0900 @@ -16,20 +16,19 @@ static int task_read(SchedTask *s, void *rbuf, void *wbuf) { - long fd = (long)s->get_input(rbuf,0); ///ファイルディスクリプタの受取 - long task_number = (long)s->get_param(0); //何番目のtaskか long division_size = (long)s->get_param(1); long read_size = (long)s->get_param(2); + long fd = (long)s->get_param(3); //fdの番号の受け取り char *readtext = (char*)s->get_output(wbuf,0); //char *text = (char*)s->allocate(sizeof(char)*read_size + 1); //char text[(long)read_size]; - //text[(long)read_size + 1] = '\0'; - s->printf("[print : %lld]\n",task_number+1); + //text[(long)read_size] = '\0'; + s->printf("[read No: %lld]\n",task_number+1); - pread(fd, readtext, (long)read_size , division_size*task_number); + pread(fd, readtext, read_size , division_size*task_number); //readtext = text;
--- a/example/regex_mas/task_init.cc Mon Dec 23 16:54:13 2013 +0900 +++ b/example/regex_mas/task_init.cc Mon Dec 23 22:26:18 2013 +0900 @@ -8,7 +8,6 @@ #endif SchedExternTask(Task_print); SchedExternTask(Task_read); -SchedExternTask(RUN_READ); SchedExternTask(RUN_READ_BLOCKS); SchedExternTask(RUN_TASK_BLOCKS); @@ -28,7 +27,6 @@ SchedRegister(Task_read); SchedRegister(Task_print); - SchedRegister(RUN_READ); SchedRegister(RUN_READ_BLOCKS); SchedRegister(RUN_TASK_BLOCKS); }