Mercurial > hg > Game > Cerium
changeset 1789:82f8250f23d5 draft
minor fix
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 03 Dec 2013 18:14:24 +0900 |
parents | 06f5a4b09396 |
children | 6790d1d83bb7 |
files | example/regex_mas/main.cc example/regex_mas/ppe/Exec.cc |
diffstat | 2 files changed, 49 insertions(+), 95 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/main.cc Mon Dec 02 19:59:59 2013 +0900 +++ b/example/regex_mas/main.cc Tue Dec 03 18:14:24 2013 +0900 @@ -88,6 +88,7 @@ } /*sizeをページングサイズの倍数にあわせる*/ + //st_mmap.size = fix_byte(sb.st_size,4096); st_mmap.size = fix_byte(sb.st_size,division * 1024); st_mmap.file_mmap = (char*)manager->allocate(st_mmap.size); @@ -110,112 +111,63 @@ array_task_num = task_count; if (task_count<=0) return; } - - if (use_task_array) { - - int spl = spe_num * array_task_num; - int loop = (task_count + spl - 1) / spl; - - for (int i = 0; i < loop; i += 1) { - - if (w->task_num < spe_num) spe_num = w->task_num; - - // ここから - HTask **task_array = (HTask**)manager->allocate(sizeof(HTask*)*spe_num); - Task **t_exec = (Task**)manager->allocate(sizeof(Task*)*spe_num); - - for (int k = 0; k < spe_num; k++) { - task_array[k] = manager->create_task_array(TASK_EXEC,array_task_num,set_param_num,set_inData_num,set_out_num); - t_exec[k] = 0; - if (all) { - w->t_print->wait_for(task_array[k]); - } else { - t_next->wait_for(task_array[k]); - } + for (int i = 0; i < task_count; i += array_task_num) { + HTask *task_array; + if (use_task_array) { + int task_num = (w->size+size-1)/size; + if (task_num>array_task_num) task_num = array_task_num; + task_array = manager->create_task_array(TASK_EXEC,task_num,4,1,1); + if (!all) { + t_next->wait_for(task_array); + } else { + w->t_print->wait_for(task_array); } - - for (int j = 0; j < array_task_num; j++) { - for (int k = 0; k < spe_num; k++) { - - task_count++; - int a = w->task_spwaned++; - - if (w->size < size) size = w->size; - //if (size == w->size) break; - - t_exec[k] = task_array[k]->next_task_array(TASK_EXEC,t_exec[k]); - - if(size != w->size){ //最後のタスクかどうかの判定 - t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, w->division_size + w->extra_len); - }else{ - t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, w->division_size); - } - t_exec[k]->set_inData(1,w->search_word, w->search_word_len); - t_exec[k]->set_inData(2,w->BMskip_table, 256); - t_exec[k]->set_param(0,(unsigned long long)a); - - t_exec[k]->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); - w->size -= size; - w->task_num--; - } - } - for (int k = 0; k < spe_num; k++) { - task_array[k]->spawn_task_array(t_exec[k]->next()); - task_array[k]->set_cpu(spe_cpu); - task_array[k]->spawn(); - } - } - return; - - } - - for (int i = 0; i < task_count; i += array_task_num) { - + Task *t_exec = 0; HTask *h_exec = 0; for (int j = 0; j < array_task_num; j++) { - int i = w->task_spwaned++; + int a = w->task_spwaned++; if (w->size < size) size = w->size; - int length = size/sizeof(char); if (size==0) break; + if (use_task_array) { + t_exec = task_array->next_task_array(TASK_EXEC,t_exec); + t_exec->set_inData(0,w->file_mmap + a*w->division_size, size); - if (use_compat) { + t_exec->set_param(0,(long)a); + t_exec->set_param(1,w->search_word); + t_exec->set_param(2,(long)w->search_word_len); + t_exec->set_param(3,w->BMskip_table); + + t_exec->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); + } else if (use_compat) { h_exec = manager->create_task(TASK_EXEC); - h_exec->set_param(0,&length); h_exec->set_inData(0,w->file_mmap + i*w->division_size, size); h_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size); - - if (all) { - w->t_print->wait_for(h_exec); - } else { - t_next->wait_for(h_exec); - } + t_next->wait_for(h_exec); h_exec->set_cpu(spe_cpu); h_exec->spawn(); - } else { h_exec = manager->create_task(TASK_EXEC, (memaddr)(w->file_mmap + i*w->division_size), size, (memaddr)(w->o_data + i*w->out_size), w->division_out_size); - - if (all) { - w->t_print->wait_for(h_exec); - } else { - t_next->wait_for(h_exec); - } - + t_next->wait_for(h_exec); h_exec->set_cpu(spe_cpu); h_exec->spawn(); } w->size -= size; - w->task_num--; + w->task_num--; } - + if (use_task_array) { + task_array->spawn_task_array(t_exec->next()); + task_array->set_cpu(spe_cpu); + task_array->spawn(); + } else { + //if (!all) t_next->wait_for(h_exec); + } } - } /** @@ -233,7 +185,7 @@ 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); + run_tasks(manager,w,w->task_num, 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); @@ -306,6 +258,7 @@ w->status_num = 1; /* taskの数 */ w->task_num = w->size / w->division_size; + printf("task num: %d\n", w->task_num); w->task_num = w->task_num + (w->division_size*w->task_num < w->size); int out_task_num = w->task_num; @@ -330,7 +283,7 @@ (memaddr)&w->self,sizeof(memaddr),0,0); w->t_print = t_print; - for(int i = 0;i<2;i++) { + for(int i = 0;i<1;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS,
--- a/example/regex_mas/ppe/Exec.cc Mon Dec 02 19:59:59 2013 +0900 +++ b/example/regex_mas/ppe/Exec.cc Tue Dec 03 18:14:24 2013 +0900 @@ -24,7 +24,7 @@ --i; --j; } - i = i + max((int)skip[(int)text[i]],sw_len - j); + i = i + max(skip[text[i]],sw_len - j); } return match_counter; } @@ -32,24 +32,25 @@ static int run(SchedTask *s, void *rbuf, void *wbuf) { - //set_inData + //get_inData unsigned char *i_data = (unsigned char *)s->get_input(rbuf,0); - unsigned char *search_word = (unsigned char*)s->get_input(rbuf,1); - //unsigned char search_word[] = "doing"; - int *skip_table = (int *)s->get_input(rbuf,2); int length = (int)s->get_inputSize(0); - int sw_len = (int)s->get_inputSize(1); - unsigned long long task_count = (unsigned long long)s->get_param(0); - //s->printf("length %d\n",length); - //s->printf("sw_len %d\n",sw_len); + //get_param + long task_count = (long)s->get_param(0); + unsigned char *search_word = (unsigned char*)s->get_param(1); + long sw_len = (long)s->get_param(2); + int *skip_table = (int*)s->get_param(3); + s->printf("[task count: %lld]\n",task_count); + s->printf("[search word: %s]\n",search_word); + s->printf("[search word len : %d]\n",sw_len); - unsigned long long *o_data = (unsigned long long*)wbuf; + + 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); + return 0; //s->printf("in Exec.cc\n"); - return 0; }