Mercurial > hg > Game > Cerium
changeset 1863:3f058fee44d2 draft
fix read_run16 loops ( cannot running )
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Dec 2013 17:56:24 +0900 |
parents | 64c571a30bdb |
children | 7211816380bd |
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, 46 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/Func.h Mon Dec 23 22:26:18 2013 +0900 +++ b/example/regex_mas/Func.h Tue Dec 24 17:56:24 2013 +0900 @@ -3,8 +3,9 @@ Task_exec, Task_read, Task_print, + RUN_READ, + RUN_READ_BLOCKS, RUN_TASK_BLOCKS, - RUN_READ_BLOCKS, }; #define DATA_NUM 12
--- a/example/regex_mas/main.cc Mon Dec 23 22:26:18 2013 +0900 +++ b/example/regex_mas/main.cc Tue Dec 24 17:56:24 2013 +0900 @@ -61,6 +61,7 @@ long filesize; long left_size; int task_blocks; + int task_block_num; char *read_text; CPU_TYPE cpu; } Fileread, *FilereadPtr; @@ -82,39 +83,47 @@ FilereadPtr fr = (FilereadPtr)in; HTaskPtr wait; - for (int i = 0; (fr->left_size > 0) && (i < fr->task_blocks); i++) { - HTaskPtr read = manager->create_task(Task_read); - read->set_cpu(fr->cpu); + for (int j = 0; j < fr->task_block_num; j++) { - if (i == fr->task_blocks / 2) wait = read; + for (int i = 0; (fr->left_size > 0) && (i < fr->task_blocks); i++) { + HTaskPtr read = manager->create_task(Task_read); + read->set_cpu(fr->cpu); + + if (i == fr->task_blocks / 2) wait = read; - read->set_param(0,(long)fr->task_number); //生成するTaskが何番目か - read->set_param(1,(long)fr->division_size); //1つのタスクが読み込む量 - if(fr->left_size <= fr->division_size){ - read->set_param(2,(long)fr->left_size); - }else{ - read->set_param(2,(long)fr->division_size); + read->set_param(0,(long)fr->task_number); //生成するTaskが何番目か + read->set_param(1,(long)fr->division_size); //1つのタスクが読み込む量 + if(fr->left_size <= fr->division_size){ + read->set_param(2,(long)fr->left_size); + }else{ + read->set_param(2,(long)fr->division_size); + } + read->set_param(3,(long)fr->fd); //fdの番号の受け渡し + + read->set_outData(0,fr->read_text + fr->division_size*fr->task_number, fr->division_size); + read->spawn(); + + fr->left_size -= fr->division_size; + fr->task_number++; } - read->set_param(3,(long)fr->fd); //fdの番号の受け渡し - read->set_outData(0,fr->read_text + fr->division_size*fr->task_number, fr->division_size); - read->spawn(); - - fr->left_size -= fr->division_size; - fr->task_number++; - } - - if (fr->left_size > 0) { - HTaskPtr next = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); - next->wait_for(wait); - next->spawn(); + if (fr->left_size > 0) { + HTaskPtr next = manager->create_task(RUN_READ_BLOCKS, (memaddr)&fr->self, sizeof(memaddr),0,0); + next->wait_for(wait); + next->spawn(); + } } return 0; } -static st_mmap_t -divide_read(TaskManager *manager,HTaskPtr run,char *filename, FilereadPtr fr) +SchedDefineTask1(RUN_READ,divide_read); + +static int +divide_read(SchedTask *manager, void *in, void *out) { + FilereadPtr fr = (FilereadPtr)in; + char *filename = fr->filename; + st_mmap_t st_mmap; long fd = (long)manager->allocate(sizeof(long)); struct stat sb; @@ -140,13 +149,15 @@ fr->division_size = 1024 * division; fr->task_num = fr->filesize / (1024 * division); fr->task_num += ((fr->filesize % 1024 * division) != 0); + fr->task_block_num = fr->task_num / fr->task_blocks; + fr->task_block_num += ((fr->task_num % fr->task_blocks) != 0); - 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->spawn(); st_mmap.file_mmap = fr->read_text; - return st_mmap; + return 0; } static st_mmap_t @@ -314,7 +325,8 @@ st_mmap_t st_mmap; if (div_read != 0) { - st_mmap = divide_read(manager,read_run,filename,fr); + + read_run = manager->create_task(RUN_READ, (memaddr)&fr->self, sizeof(memaddr),0,0); printf("in divide read\n");
--- a/example/regex_mas/ppe/Exec.cc Mon Dec 23 22:26:18 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Tue Dec 24 17:56:24 2013 +0900 @@ -42,14 +42,14 @@ //get_param long task_count = (long)s->get_param(0); //何番目のtaskか - s->printf("[exec No: %lld]\n",task_count+1); + //s->printf("[exec No: %lld]\n",task_count+1); 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); - printf("match count : %llu\n",o_data[0]); + //printf("match count : %llu\n",o_data[0]); return 0; }
--- a/example/regex_mas/ppe/Read.cc Mon Dec 23 22:26:18 2013 +0900 +++ b/example/regex_mas/ppe/Read.cc Tue Dec 24 17:56:24 2013 +0900 @@ -26,7 +26,7 @@ //char *text = (char*)s->allocate(sizeof(char)*read_size + 1); //char text[(long)read_size]; //text[(long)read_size] = '\0'; - s->printf("[read No: %lld]\n",task_number+1); + //s->printf("[read No: %lld]\n",task_number+1); pread(fd, readtext, read_size , division_size*task_number);
--- a/example/regex_mas/task_init.cc Mon Dec 23 22:26:18 2013 +0900 +++ b/example/regex_mas/task_init.cc Tue Dec 24 17:56:24 2013 +0900 @@ -8,6 +8,7 @@ #endif SchedExternTask(Task_print); SchedExternTask(Task_read); +SchedExternTask(RUN_READ); SchedExternTask(RUN_READ_BLOCKS); SchedExternTask(RUN_TASK_BLOCKS); @@ -27,6 +28,7 @@ SchedRegister(Task_read); SchedRegister(Task_print); + SchedRegister(RUN_READ); SchedRegister(RUN_READ_BLOCKS); SchedRegister(RUN_TASK_BLOCKS); }