# HG changeset patch # User Shohei KOKUBO # Date 1397901982 -32400 # Node ID 82e6eb0fa6928ba4746c86dbad4376c2c175e160 # Parent e93e115b1903378316ab06c62329870836739843 fix wordcount diff -r e93e115b1903 -r 82e6eb0fa692 example/word_count/main.cc --- a/example/word_count/main.cc Sat Apr 19 14:10:27 2014 +0900 +++ b/example/word_count/main.cc Sat Apr 19 19:06:22 2014 +0900 @@ -25,11 +25,10 @@ int use_task_creater = 0; int use_compat = 0; int use_iterate = 0; -int use_iterate_all = 0; int array_task_num = 11; int spe_num = 1; int read_type = MY_MMAP; - +int t_exec_num = 4; CPU_TYPE spe_cpu = SPE_ANY; CPU_TYPE read_spe_cpu = IO_0; @@ -94,7 +93,7 @@ } //madvise(w->file_mmap, w->read_filesize, POSIX_MADV_NORMAL); - w->file_mmap = (char*)mmap(NULL,w->read_filesize,PROT_READ,map,fd,(off_t)0); + w->file_mmap = (char*)mmap(NULL,w->read_filesize,PROT_WRITE|PROT_READ,map,fd,(off_t)0); if (st_mmap.file_mmap == (caddr_t)-1) { fprintf(stderr,"Can't mmap file\n"); @@ -148,10 +147,15 @@ h_exec->set_cpu(spe_cpu); h_exec->spawn(); } else if (use_iterate) { - if(use_iterate_all) - array_task_num = w->task_num; + array_task_num = w->task_num; + use_iterate = 0; + use_compat = 1; + w->size -= size*array_task_num; - if(w->size < 0) array_task_num -= 1; + if(w->size < 0) { + array_task_num -= 1; + w->size += size; + } h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL); h_exec->flip(); h_exec->set_inData(0,w->file_mmap,w->file_size); @@ -170,26 +174,26 @@ w->task_num -= array_task_num; w->task_spawned += array_task_num-1; - if(w->size < 0) { - h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL); - 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_); - h_exec->set_outData(0,w->file_mmap,w->file_size); - h_exec->set_outData(1,w->o_data,w->out_size_); - h_exec->set_param(0,(long)w->task_spawned); - h_exec->set_param(1,(long)w->division_size); - h_exec->set_param(2,(long)(size+w->size)); - h_exec->set_param(3,(long)w->out_size); + // if(w->size < 0) { + // h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL); + // 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_); + // h_exec->set_outData(0,w->file_mmap,w->file_size); + // h_exec->set_outData(1,w->o_data,w->out_size_); + // h_exec->set_param(0,(long)w->task_spawned); + // h_exec->set_param(1,(long)w->division_size); + // h_exec->set_param(2,(long)(size+w->size)); + // h_exec->set_param(3,(long)w->out_size); - t_next->wait_for(h_exec); - h_exec->set_cpu(spe_cpu); - h_exec->iterate(1); + // t_next->wait_for(h_exec); + // h_exec->set_cpu(spe_cpu); + // h_exec->iterate(1); - w->task_num -= 1; - w->task_spawned += 1; - array_task_num += 1; - } + // w->task_num -= 1; + // w->task_spawned += 1; + // array_task_num += 1; + // } break; } else { h_exec = manager->create_task(TASK_EXEC, @@ -267,7 +271,7 @@ { WordCount *w = *(WordCount **)in; - if(use_iterate_all) { + if(use_iterate) { run_tasks(manager, w, w->task_num, 0, w->t_print, w->division_size); } else if (w->task_num < w->task_blocks) { // last case @@ -378,7 +382,7 @@ t_print = manager->create_task(TASK_PRINT, (memaddr)&w->self,sizeof(memaddr),0,0); w->t_print = t_print; - for(int i=0;i<4;i++) { + for(int i=0;i