Mercurial > hg > Game > Cerium
changeset 1991:82e6eb0fa692 draft
fix wordcount
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 19 Apr 2014 19:06:22 +0900 |
parents | e93e115b1903 |
children | 35dff9efffc2 727e896269e9 |
files | example/word_count/main.cc |
diffstat | 1 files changed, 31 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- 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<t_exec_num;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ if (read_type == BLOCKED_READ) { @@ -434,10 +438,7 @@ } else if (strcmp(argv[i], "-i") == 0) { use_iterate = 1; use_task_array = 0; - } else if (strcmp(argv[i], "-ia") == 0) { - use_iterate_all = 1; - use_iterate = 1; - use_task_array = 0; + t_exec_num = 1; } else if (strcmp(argv[i], "-br") == 0) { read_type = BLOCKED_READ; } else if (strcmp(argv[i], "-r") == 0) {