Mercurial > hg > Game > Cerium
changeset 1802:e08f6133f5d7 draft
change iterator to spawn in fileread
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 08 Dec 2013 15:00:18 +0900 |
parents | e91bf033443a |
children | 8c79f9697179 |
files | example/fileread/main.cc example/fileread/ppe/Read.cc |
diffstat | 2 files changed, 27 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/example/fileread/main.cc Sun Dec 08 13:20:32 2013 +0900 +++ b/example/fileread/main.cc Sun Dec 08 15:00:18 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 Sun Dec 08 13:20:32 2013 +0900 +++ b/example/fileread/ppe/Read.cc Sun Dec 08 15:00:18 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; }