Mercurial > hg > Members > kono > Cerium
diff example/word_count_test/main.cc @ 664:7405d92733a8
word count
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 03 Dec 2009 00:20:28 +0900 |
parents | 8a807e2f64f8 |
children | 4470ff271c5a |
line wrap: on
line diff
--- a/example/word_count_test/main.cc Wed Dec 02 22:20:32 2009 +0900 +++ b/example/word_count_test/main.cc Thu Dec 03 00:20:28 2009 +0900 @@ -26,6 +26,7 @@ int task_num; // remaining task count int task_blocks; // spawn task one at a time int status_num; + int task_spwaned; unsigned long long *o_data; unsigned long long *head_tail_flag; int pad; @@ -83,8 +84,10 @@ static void run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) { - for (int i = 0; i < task_count && w->size >= w->division_size; i++) { + for (int j = 0; j < task_count && w->size>0; j++) { + int i = w->task_spwaned++; HTaskPtr t_exec = manager->create_task(TASK_EXEC); + if (size>w->size) size = w->size; t_exec->add_inData(w->file_mmap + i*w->division_size, size); t_exec->add_outData(w->o_data + i*w->status_num, w->division_out_size); t_exec->add_outData(w->head_tail_flag + i*w->pad, w->division_out_size); @@ -97,18 +100,19 @@ } } -SchedDefineTask1(RUN_TASK_16,run16); +SchedDefineTask1(RUN_TASK_BLOCKS,run16); static int run16(SchedTask *manager, void *in, void *out) { - WordCount *w = (WordCount *)manager->get_param(1); + WordCount *w = (WordCount *)manager->get_param(0); if (w->task_num < w->task_blocks) { - if (w->size > w->division_size) + if (w->size >= w->division_size) run_tasks(manager,w,w->task_blocks, w->t_print, w->division_size); - if (w->size>0 && w->size < w->division_size) + while (w->size>0) run_tasks(manager,w,1, w->t_print, w->size); + // printf("run16 last %d\n",w->task_num); } else { HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS); @@ -118,6 +122,7 @@ run_tasks(manager,w, w->task_blocks, t_next, w->division_size); t_next->spawn(); + // printf("run16 next %d\n",w->task_num); } return 0; } @@ -133,8 +138,10 @@ st_mmap_t st_mmap; st_mmap = my_mmap(filename); WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount)); + // bzero(w,sizeof(WordCount)); w->task_blocks = blocks; + w->task_spwaned = 0; /*sizeはdivision_sizeの倍数にしている。*/ w->size = st_mmap.size; @@ -163,9 +170,11 @@ /* out用のデータのサイズ。*/ int out_size = w->division_out_size*out_task_num; w->o_data = (unsigned long long*)manager->allocate(out_size); + //bzero(w->o_data,out_size); w-> pad = 2; w->head_tail_flag = (unsigned long long*)manager->allocate(out_size); + // bzero(w->head_tail_flag,out_size); printf("out size %d\n",out_size);