Mercurial > hg > Game > Cerium
changeset 1688:705f09f646ac draft
remove spe_num roop
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Aug 2013 17:37:25 +0900 |
parents | 81bb9b2f35ca |
children | c595245aa59e |
files | example/word_count/main.cc example/word_count/ppe/Print.cc |
diffstat | 2 files changed, 46 insertions(+), 124 deletions(-) [+] |
line wrap: on
line diff
--- a/example/word_count/main.cc Tue Aug 13 01:57:13 2013 +0900 +++ b/example/word_count/main.cc Tue Aug 13 17:37:25 2013 +0900 @@ -88,148 +88,69 @@ } static void -run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) +run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) { - + if (task_count < array_task_num) { 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 (spl > w->task_num) { - if (w->task_num >= spe_num) { - array_task_num = w->task_num / spe_num; - } else { - - int task_num = w->task_num; - - for (int j = 0; j < task_num; j++) { - HTask *h_exec = 0; - int a = w->task_spwaned++; - - if (w->size < size) size = w->size; - - h_exec = manager->create_task(TASK_EXEC, - (memaddr)(w->file_mmap + a*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); - } - - h_exec->set_cpu(spe_cpu); - h_exec->spawn(); - - w->size -= size; - if (w->size == 0) break; - w->task_num--; - - } - - return; - } + + 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,0,1,1); + if (!all) { + t_next->wait_for(task_array); + } else { + w->t_print->wait_for(task_array); } - - // ここから - 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,1,1,1); - t_exec[k] = 0; - if (all) { - w->t_print->wait_for(task_array[k]); - } else { - t_next->wait_for(task_array[k]); - } - } - - for (int j = 0; j < array_task_num; j++) { - for (int k = 0; k < spe_num; k++) { - - int a = w->task_spwaned++; - - if (w->size < size) size = w->size; - int length = size/sizeof(char); - - t_exec[k] = task_array[k]->next_task_array(TASK_EXEC,t_exec[k]); - t_exec[k]->set_param(0,(memaddr)length); - t_exec[k]->set_inData(0,w->file_mmap + a*w->division_size, size); - 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(); - } - // free task_array and t_exec !!! - } - - 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 a = w->task_spwaned++; + int i = w->task_spwaned++; if (w->size < size) size = w->size; int length = size/sizeof(char); if (size==0) break; - - if (use_compat) { + if (use_task_array) { + t_exec = task_array->next_task_array(TASK_EXEC,t_exec); + t_exec->set_param(0,(memaddr)length); + t_exec->set_inData(0,w->file_mmap + i*w->division_size, 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->set_param(0,(memaddr)length); - h_exec->set_inData(0,w->file_mmap + a*w->division_size, size); - h_exec->set_outData(0,w->o_data + a*w->out_size, w->division_out_size); - + 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->set_cpu(SPE_ANY); h_exec->spawn(); - } else { h_exec = manager->create_task(TASK_EXEC, - (memaddr)(w->file_mmap + a*w->division_size), size, - (memaddr)(w->o_data + a*w->out_size), w->division_out_size); - - if (all) { - w->t_print->wait_for(h_exec); - } else { - t_next->wait_for(h_exec); - } - - h_exec->set_cpu(spe_cpu); + (memaddr)(w->file_mmap + i*w->division_size), size, + (memaddr)(w->o_data + i*w->out_size), w->division_out_size); + h_exec->set_param(0,(memaddr)length); + t_next->wait_for(h_exec); + h_exec->set_cpu(SPE_ANY); h_exec->spawn(); } w->size -= size; w->task_num--; } - - } - + if (use_task_array) { + task_array->spawn_task_array(t_exec->next()); + task_array->set_cpu(SPE_ANY); + task_array->spawn(); + } else { + //if (!all) t_next->wait_for(h_exec); + } + } } /** @@ -329,7 +250,7 @@ (memaddr)&w->self,sizeof(memaddr),0,0); w->t_print = t_print; - for(int i = 0;i<20;i++) { + for(int i = 0;i<4;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, @@ -372,16 +293,16 @@ } else if (strcmp(argv[i], "-anum") == 0) { array_task_num = atoi(argv[i+1]); i++; - } else if (strcmp(argv[i], "-g") == 0 ) { + } /*else if (strcmp(argv[i], "-g") == 0 ) { spe_cpu = GPU_0; - } else if (strcmp(argv[i], "-cpu") == 0) { + } else if (strcmp(argv[i], "-cpu") == 0) { spe_num = atoi(argv[i+1]); i++; if (spe_num==0) spe_num = 1; - } else { + } else { fprintf(stderr,"%s\n",usr_help_str); exit (0); - } + }*/ } if (filename==0) { puts(usr_help_str);
--- a/example/word_count/ppe/Print.cc Tue Aug 13 01:57:13 2013 +0900 +++ b/example/word_count/ppe/Print.cc Tue Aug 13 17:37:25 2013 +0900 @@ -68,6 +68,7 @@ for (int i = 0; i < out_task_num ; i++) { word_data[0] += idata[i*w->out_size+0]; + printf("idata[%d]=%lld\n",i*w->out_size+0,idata[i*w->out_size+0]); word_data[1] += idata[i*w->out_size+1]; unsigned long long *head_tail_flag = &idata[i*w->out_size+2];