Mercurial > hg > Game > Cerium
changeset 2046:476fc75a5e17 draft
remove redundant task
author | masa |
---|---|
date | Wed, 27 Jan 2016 18:55:25 +0900 |
parents | 24113f4fa9b5 |
children | de89da997e07 |
files | example/word_count/Func.h example/word_count/main.cc example/word_count/ppe/Exec.cc example/word_count/ppe/Exec_Data_Parallel.cc example/word_count/task_init.cc |
diffstat | 5 files changed, 29 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/example/word_count/Func.h Thu Mar 26 18:36:07 2015 +0900 +++ b/example/word_count/Func.h Wed Jan 27 18:55:25 2016 +0900 @@ -3,7 +3,6 @@ BREAD_RUN_TASK_BLOCKS, READ_TASK, TASK_EXEC, - TASK_EXEC_DATA_PARALLEL, RUN_TASK_BLOCKS, TASK_PRINT, };
--- a/example/word_count/main.cc Thu Mar 26 18:36:07 2015 +0900 +++ b/example/word_count/main.cc Wed Jan 27 18:55:25 2016 +0900 @@ -148,11 +148,18 @@ if (size==0) break; if (use_task_array) { t_exec = task_array->next_task_array(TASK_EXEC,t_exec); + t_exec->set_param(0,(long)0); + t_exec->set_param(1,(long)0); + t_exec->set_param(2,(long)size); + t_exec->set_param(3,(long)w->division_out_size); 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); - t_exec->set_param(0,(long)size); } else if (use_compat) { h_exec = manager->create_task(TASK_EXEC); + t_exec->set_param(0,(long)0); + t_exec->set_param(1,(long)0); + t_exec->set_param(2,(long)size); + t_exec->set_param(3,(long)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); @@ -170,7 +177,7 @@ array_task_num -= 1; w->size += size; } - h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL); + h_exec = manager->create_task(TASK_EXEC); h_exec->flip(); h_exec->set_inData(0,w->file_mmap,w->file_size); h_exec->set_inData(1,w->o_data,w->out_size_); @@ -193,6 +200,10 @@ 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); + t_exec->set_param(0,(long)0); + t_exec->set_param(1,(long)0); + t_exec->set_param(2,(long)size); + t_exec->set_param(3,(long)w->division_out_size); t_next->wait_for(h_exec); h_exec->set_cpu(spe_cpu); h_exec->spawn();
--- a/example/word_count/ppe/Exec.cc Thu Mar 26 18:36:07 2015 +0900 +++ b/example/word_count/ppe/Exec.cc Wed Jan 27 18:55:25 2016 +0900 @@ -9,14 +9,26 @@ static int wordcount(SchedTask *s, void *rbuf, void *wbuf) { - char *i_data = (char *)s->get_input(0); - unsigned long long *o_data = (unsigned long long *)s->get_output(0); - unsigned long long *head_tail_flag = o_data + 2; - int length = (int)s->get_inputSize(0); + long task_spwaned = (long)s->get_param(0); + long division_size = (long)s->get_param(1); + long length = (long)s->get_param(2); + long out_size = (long)s->get_param(3); + long allocation = task_spwaned + (long)s->x; + char* i_data; + unsigned long long* o_data; + if (division_size) { + i_data = (char*)s->get_input(rbuf,0) + allocation*division_size; + o_data = (unsigned long long*)s->get_output(wbuf,1) + allocation*out_size; + } else { + i_data = (char*)s->get_input(0); + o_data = (unsigned long long*)s->get_output(0); + } + unsigned long long *head_tail_flag = o_data +2; int word_flag = 0; int word_num = 0; int line_num = 0; int i = 0; + head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); word_num -= 1-head_tail_flag[0];
--- a/example/word_count/ppe/Exec_Data_Parallel.cc Thu Mar 26 18:36:07 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include "Exec.h" -#include "Func.h" - -/* これは必須 */ -SchedDefineTask1(Exec_Data_Parallel,wordcount); - -static int -wordcount(SchedTask *s, void *rbuf, void *wbuf) -{ - long task_spwaned = (long)s->get_param(0); - long division_size = (long)s->get_param(1); - long length = (long)s->get_param(2); - long out_size = (long)s->get_param(3); - long allocation = task_spwaned + (long)s->x; - char* i_data = (char*)s->get_input(rbuf,0) + allocation*division_size; - unsigned long long* o_data = (unsigned long long*)s->get_output(wbuf,1) + allocation*out_size; - unsigned long long *head_tail_flag = o_data +2; - int word_flag = 0; - int word_num = 0; - int line_num = 0; - int i = 0; - - head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); - word_num -= 1-head_tail_flag[0]; - - for (; i < length; i++) { - if (i_data[i] == 0x20) { // 空白 - word_flag = 1; - } else if (i_data[i] == 0x0A) { // 改行 - line_num += 1; - word_flag = 1; - } else { - word_num += word_flag; - word_flag = 0; - } - } - - word_num += word_flag; - head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); - - // s->printf("SPE word %d line %d\n",word_num,line_num); - - o_data[0] = (unsigned long long)word_num; - o_data[1] = (unsigned long long)line_num; - - return 0; -}
--- a/example/word_count/task_init.cc Thu Mar 26 18:36:07 2015 +0900 +++ b/example/word_count/task_init.cc Wed Jan 27 18:55:25 2016 +0900 @@ -11,7 +11,6 @@ SchedExternTask(READ_TASK); SchedExternTask(BREAD_RUN_TASK_BLOCKS); SchedExternTask(Exec); -SchedExternTask(Exec_Data_Parallel); SchedExternTask(Print); SchedExternTask(RUN_TASK_BLOCKS); @@ -25,15 +24,12 @@ { #ifdef __CERIUM_GPU__ GpuSchedRegister(TASK_EXEC, "gpu/Exec.cl", "wordcount"); - GpuSchedRegister(TASK_EXEC_DATA_PARALLEL, "gpu/Exec_Data_Parallel.cl","wordcount_parallel"); #endif #ifdef __CERIUM_CUDA__ CudaSchedRegister(TASK_EXEC, "cuda/Exec.ptx", "wordcount"); - CudaSchedRegister(TASK_EXEC_DATA_PARALLEL, "cuda/Exec_Data_Parallel.ptx","wordcount_parallel"); #endif SchedRegisterTask(TASK_EXEC, Exec); - SchedRegisterTask(TASK_EXEC_DATA_PARALLEL, Exec_Data_Parallel); SchedRegister(READ_TASK); SchedRegister(BREAD_RUN_TASK_BLOCKS);