Mercurial > hg > Members > kono > Cerium
changeset 783:fc9c3b23d875
wordcount fix?
author | yutaka@localhost.localdomain |
---|---|
date | Tue, 20 Apr 2010 15:37:42 +0900 |
parents | d46dea8399e4 |
children | d5065fef0f6d |
files | example/word_count/main.cc |
diffstat | 1 files changed, 26 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/example/word_count/main.cc Fri Mar 05 13:24:38 2010 +0900 +++ b/example/word_count/main.cc Tue Apr 20 15:37:42 2010 +0900 @@ -82,8 +82,8 @@ /* 1task分のデータサイズ(byte) */ int division_size; - if (size >= 4096*4) { - division_size = 4096 * 4;/*16kbyte*/ + if (size >= 1024*16) { + division_size = 1024 * 16;/*16kbyte*/ } else { division_size = size; @@ -119,46 +119,57 @@ /*渡すデータの最後が文字かどうか。(スペース、改行以外)*/ int word_flag = 0; - int i; - int task_size = 32; - for (i = 0; i < task_num; i+=task_size) { - HTask *task_main = manager->create_task_array(TASK_EXEC,task_size,2,1,1); + int index = 1; + int array_task_num = 1; + for (int i = 0; i < task_num; i += array_task_num) { + HTask *task_main = manager->create_task_array(TASK_EXEC,array_task_num,2,1,1); int j ; Task *t_exec = 0; - for(j = 0; j < task_size; j++) { + for(j = 0; j < array_task_num; j++) { t_exec = task_main->next_task_array(TASK_EXEC,t_exec); - task_main->set_cpu(SPE_ANY); t_print->wait_for(task_main); // t_exec = manager->create_task(TASK_EXEC); t_exec->set_param(0,division_size); t_exec->set_param(1,word_flag); - t_exec->set_inData(0,file_mmap + i*division_size, division_size); - t_exec->set_outData(0,o_data + i*status_num, division_out_size); + + //t_exec->set_inData(0,file_mmap + index*division_size, division_size); + //t_exec->set_outData(0,o_data + index*status_num, division_out_size); - word_flag = ((file_mmap[(i+1)*division_size-1] != 0x20) && (file_mmap[(i+1)*division_size-1] != 0x0A)); + printf("%c",file_mmap[index*division_size]); + + t_exec->set_inData(0,&file_mmap[index*division_size], division_size); + t_exec->set_outData(0,&o_data[index*status_num], division_out_size); + + word_flag = ((file_mmap[(index+1)*division_size-1] != 0x20) && (file_mmap[(index+1)*division_size-1] != 0x0A)); size -= division_size; + index++; + } + task_main->spawn_task_array(t_exec->next()); + task_main->set_cpu(SPE_ANY); + task_main->spawn(); } + + while (size>0) { t_exec = manager->create_task(TASK_EXEC); t_exec->set_param(0,size); t_exec->set_param(1,word_flag); - t_exec->set_inData(0,file_mmap + i*division_size, size); - t_exec->set_outData(0,o_data + i*status_num, division_out_size); + t_exec->set_inData(0,file_mmap + index*division_size, size); + t_exec->set_outData(0,o_data + index*status_num, division_out_size); t_exec->set_cpu(SPE_ANY); t_print->wait_for(t_exec); t_exec->spawn(); - i++; + index++; size -= division_size; } - t_print->spawn(); }