Mercurial > hg > Game > Cerium
changeset 1956:b52fe4cceff3 draft
rename divide read to block read
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 07 Feb 2014 15:52:23 +0900 |
parents | 2573919e0d72 |
children | 59fc5bd0967f |
files | example/regex_mas/Func.h example/regex_mas/Makefile example/regex_mas/main.cc example/regex_mas/task_init.cc |
diffstat | 4 files changed, 50 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/Func.h Fri Feb 07 15:08:03 2014 +0900 +++ b/example/regex_mas/Func.h Fri Feb 07 15:52:23 2014 +0900 @@ -1,8 +1,9 @@ enum { #include "SysTasks.h" + TASK_EXEC, + BREAD_RUN_TASK_BLOCKS, + MMAP_RUN_TASK_BLOCKS, READ_TASK, - TASK_EXEC, - RUN_TASK_BLOCKS, PRINT_TASK, };
--- a/example/regex_mas/Makefile Fri Feb 07 15:08:03 2014 +0900 +++ b/example/regex_mas/Makefile Fri Feb 07 15:52:23 2014 +0900 @@ -17,7 +17,7 @@ @$(MAKE) -f Makefile.gpu test: - ./regex -file c.txt -cpu 4 -sw doing -dr + ./regex -file c.txt -cpu 4 -sw doing -br FORCE:
--- a/example/regex_mas/main.cc Fri Feb 07 15:08:03 2014 +0900 +++ b/example/regex_mas/main.cc Fri Feb 07 15:52:23 2014 +0900 @@ -29,7 +29,7 @@ int div_read = 0; int array_task_num = 8; int spe_num = 1; -int divide_read_flag = 0; +int block_read_flag = 0; int DIVISION_SIZE = 4*4096; int READ_DIVISION_SIZE = 4*4096 * 1024; @@ -57,7 +57,6 @@ static void my_mmap(char *filename, WordCount *w) { - /*マッピングだよ!*/ int map = MAP_PRIVATE; st_mmap_t st_mmap; @@ -159,10 +158,10 @@ * 二つ実行されていて、Task が足りなくなることがないようにしている。 */ -SchedDefineTask1(RUN_TASK_BLOCKS,task_run16); +SchedDefineTask1(BREAD_RUN_TASK_BLOCKS,bread_run16); static int -task_run16(SchedTask *manager, void *in, void *out) +bread_run16(SchedTask *manager, void *in, void *out) { WordCount *w = *(WordCount **)in; @@ -184,9 +183,8 @@ t_read->set_param(2,w->task_spawned*w->division_size); t_read->spawn(); - // printf("run16 last %d\n",w->task_num); } else { - HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS, + HTaskPtr t_next = manager->create_task(BREAD_RUN_TASK_BLOCKS, (memaddr)&w->self,sizeof(memaddr),0,0); w->t_print->wait_for(t_next); @@ -199,7 +197,32 @@ t_read->spawn(); t_next->spawn(); - // printf("run16 next %d\n",w->task_num); + } + return 0; +} + +SchedDefineTask1(MMAP_RUN_TASK_BLOCKS,mmap_run16); + +static int +mmap_run16(SchedTask *manager, void *in, void *out) +{ + WordCount *w = *(WordCount **)in; + + if (w->task_num < w->task_blocks) { + // last case + while (w->size >= w->division_size) + run_tasks(manager,w,w->task_num,0, w->t_print, w->division_size + w->extra_len); + // remaining data + while (w->size>0) + run_tasks(manager,w,1,0,w->t_print, w->size); + } else { + HTaskPtr t_next = manager->create_task(MMAP_RUN_TASK_BLOCKS, + (memaddr)&w->self,sizeof(memaddr),0,0); + w->t_print->wait_for(t_next); + + run_tasks(manager,w, w->task_blocks,0, t_next, w->division_size + w->extra_len); + + t_next->spawn(); } return 0; } @@ -247,8 +270,8 @@ w->read_filesize = sb->st_size; - if (divide_read_flag != 0) { - printf("[divide read mode]\n"); + if (block_read_flag == 1) { + printf("[block read mode]\n"); w->file_mmap = (char*)manager->allocate(w->read_filesize); }else { printf("[mmap mode]\n"); @@ -270,9 +293,7 @@ w->self = w; w->task_spawned = 0; - /*sizeはdivision_sizeの倍数にしている。*/ w->size = w->file_size = w->read_filesize; - //w->file_mmap = st_mmap.file_mmap; printf("w %lx\n",(long)w); /* 1task分のデータサイズ(byte) */ @@ -319,8 +340,14 @@ for(int i=0;i<1;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ - t_exec = manager->create_task(RUN_TASK_BLOCKS, - (memaddr)&w->self,sizeof(memaddr),0,0); + if (block_read_flag == 1) { + t_exec = manager->create_task(BREAD_RUN_TASK_BLOCKS, + (memaddr)&w->self,sizeof(memaddr),0,0); + }else { + t_exec = manager->create_task(MMAP_RUN_TASK_BLOCKS, + (memaddr)&w->self,sizeof(memaddr),0,0); + } + t_print->wait_for(t_exec); // t_exec->iterate(4); t_exec->spawn(); @@ -365,8 +392,8 @@ if (spe_num==0) spe_num = 1; } else if (strcmp(argv[i], "-sw") == 0) { sword = (unsigned char*)argv[i+1]; - } else if (strcmp(argv[i], "-dr") == 0) { - divide_read_flag = 1; + } else if (strcmp(argv[i], "-br") == 0) { + block_read_flag = 1; } } if ((filename==0) || (sword==0)) {
--- a/example/regex_mas/task_init.cc Fri Feb 07 15:08:03 2014 +0900 +++ b/example/regex_mas/task_init.cc Fri Feb 07 15:52:23 2014 +0900 @@ -7,7 +7,8 @@ /* 必ずこの位置に書いて */ SchedExternTask(TASK_EXEC); SchedExternTask(READ_TASK); -SchedExternTask(RUN_TASK_BLOCKS); +SchedExternTask(BREAD_RUN_TASK_BLOCKS); +SchedExternTask(MMAP_RUN_TASK_BLOCKS); SchedExternTask(PRINT_TASK); /** @@ -25,6 +26,7 @@ SchedRegister(TASK_EXEC); SchedRegister(READ_TASK); - SchedRegister(RUN_TASK_BLOCKS); + SchedRegister(MMAP_RUN_TASK_BLOCKS); + SchedRegister(BREAD_RUN_TASK_BLOCKS); SchedRegister(PRINT_TASK); }