Mercurial > hg > Members > kono > Cerium
comparison example/word_count/main.cc @ 949:86aea6affe6c
word count size fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 02 Aug 2010 15:05:02 +0900 |
parents | 6a8941ee8294 |
children | e0908a8955cd |
comparison
equal
deleted
inserted
replaced
948:6a8941ee8294 | 949:86aea6affe6c |
---|---|
92 | 92 |
93 Task *t_exec = 0; | 93 Task *t_exec = 0; |
94 HTask *h_exec = 0; | 94 HTask *h_exec = 0; |
95 for (int j = 0; j < array_task_num; j++) { | 95 for (int j = 0; j < array_task_num; j++) { |
96 int i = w->task_spwaned++; | 96 int i = w->task_spwaned++; |
97 if (w->size < size) size = w->size; | |
98 if (size==0) break; | |
97 if (use_task_array) { | 99 if (use_task_array) { |
98 t_exec = task_array->next_task_array(TASK_EXEC,t_exec); | 100 t_exec = task_array->next_task_array(TASK_EXEC,t_exec); |
99 t_exec->set_inData(0,w->file_mmap + i*w->division_size, size); | 101 t_exec->set_inData(0,w->file_mmap + i*w->division_size, size); |
100 t_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size); | 102 t_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size); |
101 } else if (use_compat) { | 103 } else if (use_compat) { |
135 run16(SchedTask *manager, void *in, void *out) | 137 run16(SchedTask *manager, void *in, void *out) |
136 { | 138 { |
137 WordCount *w = *(WordCount **)in; | 139 WordCount *w = *(WordCount **)in; |
138 | 140 |
139 if (w->task_num < w->task_blocks) { | 141 if (w->task_num < w->task_blocks) { |
142 // last case | |
140 if (w->size >= w->division_size) | 143 if (w->size >= w->division_size) |
141 run_tasks(manager,w,w->task_num, w->t_print, w->division_size); | 144 run_tasks(manager,w,w->task_num, w->t_print, w->division_size); |
145 // remaining data | |
142 while (w->size>0) | 146 while (w->size>0) |
143 run_tasks(manager,w,1, w->t_print, w->size); | 147 run_tasks(manager,w,1, w->t_print, w->size); |
144 // printf("run16 last %d\n",w->task_num); | 148 // printf("run16 last %d\n",w->task_num); |
145 } else if (w->task_num > 0 ) { | 149 } else { |
146 HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS, | 150 HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS, |
147 (memaddr)&w->self,sizeof(memaddr),0,0); | 151 (memaddr)&w->self,sizeof(memaddr),0,0); |
148 w->t_print->wait_for(t_next); | 152 w->t_print->wait_for(t_next); |
149 | 153 |
150 run_tasks(manager,w, w->task_blocks, t_next, w->division_size); | 154 run_tasks(manager,w, w->task_blocks, t_next, w->division_size); |
172 w->self = w; | 176 w->self = w; |
173 w->task_blocks = blocks; | 177 w->task_blocks = blocks; |
174 w->task_spwaned = 0; | 178 w->task_spwaned = 0; |
175 | 179 |
176 /*sizeはdivision_sizeの倍数にしている。*/ | 180 /*sizeはdivision_sizeの倍数にしている。*/ |
177 w->size = st_mmap.size; | 181 w->size = w->file_size = st_mmap.size; |
178 w->file_mmap = st_mmap.file_mmap; | 182 w->file_mmap = st_mmap.file_mmap; |
183 printf("w %lx\n",(long)w); | |
179 | 184 |
180 /* 1task分のデータサイズ(byte) */ | 185 /* 1task分のデータサイズ(byte) */ |
181 if (w->size >= 1024*division) { | 186 if (w->size >= 1024*division) { |
182 w->division_size = 1024 * division;/*16kbyte*/ | 187 w->division_size = 1024 * division;/*16kbyte*/ |
183 } else { | 188 } else { |