Mercurial > hg > Game > Cerium
changeset 1868:14225fec047c draft
implements mmap read & divide read(pread) in fileread
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 26 Dec 2013 15:30:15 +0900 |
parents | 7b3aa1a31c3a |
children | 5e06a8089625 |
files | example/fileread/main.cc example/fileread/ppe/Print.cc example/fileread/ppe/Read.cc example/fileread/spe/test.txt |
diffstat | 3 files changed, 19 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/example/fileread/main.cc Wed Dec 25 02:13:28 2013 +0900 +++ b/example/fileread/main.cc Thu Dec 26 15:30:15 2013 +0900 @@ -17,7 +17,7 @@ static int spe_num = 1; int divide_read_flag = 0; static CPU_TYPE spe_cpu = SPE_ANY; -static int DIVISION_SIZE = 4096 * 4; +static int DIVISION_SIZE = 4096*4; extern TaskManager *manager; const char *usr_help_str = "Usage: ./fileread [-cpu cpu_num] [-file filename]\n\ @@ -35,6 +35,7 @@ run16(SchedTask *manager, void *in, void *out) { FileReadPtr fr = (FileReadPtr)in; + char* read_text = (char*)out; HTaskPtr wait; for (int i = 0; (fr->left_size > 0) && (i < fr->task_blocks); i++) { @@ -51,6 +52,10 @@ read->set_param(2,(long)fr->division_size); } read->set_param(3,(long)fr->fd); //fdの番号の受け渡し + + read->set_outData(0,read_text + fr->task_number*fr->division_size, fr->division_size); + + fr->t_print->wait_for(read); read->spawn(); fr->left_size -= fr->division_size; @@ -58,7 +63,8 @@ } if (fr->left_size > 0) { - HTaskPtr next = manager->create_task(RUN_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); + HTaskPtr next = manager->create_task(RUN_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),read_text,fr->filesize); + fr->t_print->wait_for(next); next->wait_for(wait); next->spawn(); } @@ -164,13 +170,17 @@ HTaskPtr run = NULL; HTaskPtr t_print = manager->create_task(Print_task, (memaddr)&fr->self, sizeof(memaddr),0,0); + fr->t_print = t_print; if (divide_read_flag != 0) { - run = manager->create_task(RUN_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),fr->read_text,fr->filesize); + char *read_text = (char*)manager->allocate(fr->filesize); + run = manager->create_task(RUN_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),read_text,fr->filesize); + fr->read_text = read_text; }else { //my_mmap(filename, fd, fr); run = manager->create_task(MMAP , (memaddr)&fr->self, sizeof(memaddr),0,0); } + t_print->wait_for(run); run->spawn();
--- a/example/fileread/ppe/Print.cc Wed Dec 25 02:13:28 2013 +0900 +++ b/example/fileread/ppe/Print.cc Thu Dec 26 15:30:15 2013 +0900 @@ -10,9 +10,8 @@ static int print_task(SchedTask *s, void *rbuf, void *wbuf) { - FileReadPtr fr = (FileReadPtr)rbuf; - - s->printf("%s\n in Print\n", fr->read_text); + //FileReadPtr fr = (FileReadPtr)rbuf; + //s->printf("%s\n in Print\n", fr->read_text); return 0; }
--- a/example/fileread/ppe/Read.cc Wed Dec 25 02:13:28 2013 +0900 +++ b/example/fileread/ppe/Read.cc Thu Dec 26 15:30:15 2013 +0900 @@ -21,13 +21,12 @@ long read_size = (long)s->get_param(2); long fd = (long)s->get_param(3); - char text[(long)read_size]; - text[(long)read_size] = '\0'; + char *read_text = (char*)s->get_output(wbuf,0); - pread(fd, text, (long)read_size , division_size*task_number); + pread(fd, read_text, (long)read_size , division_size*task_number); //s->printf("[start task No. %d]\n",task_number); - //s->printf("%s\n",text); - s->printf("in divide_read\n"); + //s->printf("%s\n",read_text); + //s->printf("in divide_read\n"); return 0; }