Mercurial > hg > Game > Cerium
changeset 1946:502521591d7c draft
remove RUN_READ_BLOCKS (cannot running)
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 05 Feb 2014 22:05:28 +0900 |
parents | 653c1caf1362 |
children | ef751840b388 |
files | example/regex_mas/Func.h example/regex_mas/WordCount.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 | 6 files changed, 42 insertions(+), 84 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/Func.h Wed Feb 05 20:09:44 2014 +0900 +++ b/example/regex_mas/Func.h Wed Feb 05 22:05:28 2014 +0900 @@ -1,7 +1,6 @@ enum { #include "SysTasks.h" READ_TASK, - RUN_READ_BLOCKS, MMAP, TASK_EXEC, RUN_TASK_BLOCKS,
--- a/example/regex_mas/WordCount.h Wed Feb 05 20:09:44 2014 +0900 +++ b/example/regex_mas/WordCount.h Wed Feb 05 22:05:28 2014 +0900 @@ -20,7 +20,7 @@ int task_num; // remaining task count int task_blocks; // spawn task one at a time int status_num; - int task_spwaned; + int task_spawned; unsigned long long *o_data; int out_task_num; char *file_mmap;
--- a/example/regex_mas/main.cc Wed Feb 05 20:09:44 2014 +0900 +++ b/example/regex_mas/main.cc Wed Feb 05 22:05:28 2014 +0900 @@ -63,56 +63,6 @@ return size; } -SchedDefineTask1(RUN_READ_BLOCKS,read_run); - -static int -read_run(SchedTask *manager, void *in, void *out) { - - WordCountPtr w = (WordCountPtr)in; - HTaskPtr wait; - - for (int i = 0; (w->read_left_size > 0) && (i < w->read_task_blocks); i++) { - HTaskPtr read = manager->create_task(READ_TASK); - read->set_cpu(w->read_cpu); - - if (i == w->read_task_blocks / 2) wait = read; - - read->set_param(0,(long)w->read_task_number); //生成するTaskが何番目か - read->set_param(1,(long)w->read_division_size); //1つのタスクが読み込む量 - if(w->read_left_size <= w->read_division_size){ - read->set_param(2,(long)w->read_left_size); - }else{ - read->set_param(2,(long)w->read_division_size); - } - read->set_param(3,(long)w->fd); //fdの番号の受け渡し - - read->set_outData(0,w->file_mmap + w->read_task_number*w->read_division_size, w->read_division_size); - //printf("----------------------\n"); - //printf("w->file_mmap : 0x%llx\n",w->file_mmap); - //printf("set_outData buf : 0x%llx\n",(memaddr)(w->file_mmap + w->read_task_number*w->read_division_size)); - //printf("w->read_task_number : %d\n",w->read_task_number); - //printf("w->read_division_size : %d\n",w->read_division_size); - //printf("----------------------\n"); - - w->t_exec->wait_for(read); - read->spawn(); - - w->read_left_size -= w->read_division_size; - w->read_task_number++; - } - - if (w->read_left_size > 0) { - - HTaskPtr next = manager->create_task(RUN_READ_BLOCKS, (memaddr)&w->self, sizeof(memaddr),0,0); - - w->t_print->wait_for(next); - w->t_exec->wait_for(next); - next->wait_for(wait); - next->spawn(); - } - return 0; -} - SchedDefineTask1(MMAP,my_mmap); static int @@ -162,7 +112,7 @@ Task *t_exec = 0; HTask *h_exec = 0; for (int j = 0; j < array_task_num; j++) { - long i = w->task_spwaned++; + long i = w->task_spawned++; if (w->size < size) size = w->size; if (size==0) break; if (use_task_array) { @@ -173,7 +123,7 @@ t_exec->set_param(0,(long)i); - t_exec->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); + t_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size); } else if (use_compat) { h_exec = manager->create_task(TASK_EXEC); h_exec->wait_for(t_read); @@ -221,26 +171,34 @@ if (w->task_num < w->task_blocks) { // last case while (w->size >= w->division_size) - run_tasks(manager,w,w->task_num, w->t_print, w->division_size + w->extra_len); + 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, w->t_print, w->size); + run_tasks(manager,w,1,0,w->t_print, w->size); // printf("run16 last %d\n",w->task_num); } else { HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS, (memaddr)&w->self,sizeof(memaddr),0,0); w->t_print->wait_for(t_next); - long task_spawned = w->task_spawned; - HTaskPtr t_read = manager->create_task(READ_TASK, - (memaddr)&w->self,sizeof(memaddr),0,0); + if (divide_read_flag != 0) { + long task_spawned = w->task_spawned; + HTaskPtr t_read = manager->create_task(READ_TASK, + (memaddr)&w->self,sizeof(memaddr),0,0); + + t_read->set_cpu(read_spe_cpu); + t_read->set_param(0,task_spawned*w->division_size); + + run_tasks(manager,w, w->task_blocks,t_read, t_next, w->division_size + w->extra_len); - t_read->set_cpu(read_cpu); - t_read->set_param(0,task_spawned*w->division_size); + task_spawned = w->task_spawned; + t_read->set_param(1,task_spawned*w->division_size); + t_read->set_param(2,(long)w->fd); - run_tasks(manager,w, w->task_blocks,t_read, t_next, w->division_size + w->extra_len); - t_read->set_param(1,task_spawned*w->division_size); + t_read->spawn(); - t_read->spawn(); + }else{ + run_tasks(manager,w, w->task_blocks,0, t_next, w->division_size + w->extra_len); + } t_next->spawn(); // printf("run16 next %d\n",w->task_num); } @@ -295,22 +253,21 @@ w->read_task_num = w->read_filesize / READ_DIVISION_SIZE; w->read_task_num += ((w->read_filesize % READ_DIVISION_SIZE) != 0); - printf("filesize : %lld\n",w->read_filesize); - printf("one_task_size: %ld\n",w->read_division_size); - printf("task_num : %d\n",w->read_task_num); + // printf("filesize : %lld\n",w->read_filesize); + // printf("one_task_size: %ld\n",w->read_division_size); + // printf("task_num : %d\n",w->read_task_num); HTaskPtr r_read = NULL; if (divide_read_flag != 0) { printf("[divide read mode]\n"); - w->file_mmap = (char*)manager->allocate(w->read_filesize); - r_read = manager->create_task(RUN_READ_BLOCKS, (memaddr)&w->self, sizeof(memaddr),0,0); + w->file_mmap = (char*)manager->allocate(sizeof(w->file_size)); }else { printf("[mmap mode]\n"); r_read = manager->create_task(MMAP , (memaddr)&w->self, sizeof(memaddr),0,0); + r_read->spawn(); } - r_read->spawn(); /* prepare BMSearch*/ int *skip = (int*)manager->allocate(256 * sizeof(int)); @@ -324,7 +281,7 @@ //w->task_blocks = blocks; w->self = w; - w->task_spwaned = 0; + w->task_spawned = 0; /*sizeはdivision_sizeの倍数にしている。*/ w->size = w->file_size = w->read_filesize; @@ -377,7 +334,6 @@ /* serialize されていると仮定する... */ t_exec = manager->create_task(RUN_TASK_BLOCKS, (memaddr)&w->self,sizeof(memaddr),0,0); - t_exec->wait_for(r_read); t_print->wait_for(t_exec); // t_exec->iterate(4); t_exec->spawn();
--- a/example/regex_mas/ppe/Exec.cc Wed Feb 05 20:09:44 2014 +0900 +++ b/example/regex_mas/ppe/Exec.cc Wed Feb 05 22:05:28 2014 +0900 @@ -40,15 +40,15 @@ int length = (int)s->get_inputSize(0); int sw_len = (int)s->get_inputSize(1); - //long task_count = (long)s->get_param(0); //何番目のtaskか - //s->printf("[start 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]); + long task_count = (long)s->get_param(0); //何番目のtaskか + s->printf("[start exec No: %lld]\n",task_count+1); + return 0; }
--- a/example/regex_mas/ppe/Read.cc Wed Feb 05 20:09:44 2014 +0900 +++ b/example/regex_mas/ppe/Read.cc Wed Feb 05 22:05:28 2014 +0900 @@ -9,6 +9,7 @@ #include "SchedTask.h" #include "Print.h" #include "Func.h" +#include "WordCount.h" /* これは必須 */ SchedDefineTask1(READ_TASK,read_task); @@ -16,15 +17,19 @@ static int read_task(SchedTask *s, void *rbuf, void *wbuf) { - 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); + WordCount *w = *(WordCount **)rbuf; + long start_read = (long)s->get_param(0); + long end_read = (long)s->get_param(1); + long fd = (long)s->get_param(2); - char *read_text = (char*)s->get_output(wbuf,0); + long read_size = start_read - end_read; + + //char *read_text = (char*)s->get_output(wbuf,0); + char *read_text = w->file_mmap + start_read; + //s->printf("[read No %d : wbuf addr 0x%llx]\n",task_number,read_text); //s->printf("[read No %d : wbuf addr 0x%llx]\n",task_number,read_text); - pread(fd, read_text, read_size , division_size*task_number); + pread(fd, read_text, read_size , start_read); //s->printf("[start read task No. %d]\n",task_number); //s->printf("%s\n",read_text);
--- a/example/regex_mas/task_init.cc Wed Feb 05 20:09:44 2014 +0900 +++ b/example/regex_mas/task_init.cc Wed Feb 05 22:05:28 2014 +0900 @@ -7,7 +7,6 @@ /* 必ずこの位置に書いて */ SchedExternTask(TASK_EXEC); SchedExternTask(READ_TASK); -SchedExternTask(RUN_READ_BLOCKS); SchedExternTask(MMAP); SchedExternTask(RUN_TASK_BLOCKS); SchedExternTask(PRINT_TASK); @@ -27,7 +26,6 @@ SchedRegister(TASK_EXEC); SchedRegister(READ_TASK); - SchedRegister(RUN_READ_BLOCKS); SchedRegister(MMAP); SchedRegister(RUN_TASK_BLOCKS); SchedRegister(PRINT_TASK);