diff 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
line wrap: on
line diff
--- a/example/word_count/main.cc	Mon Aug 02 09:36:02 2010 +0900
+++ b/example/word_count/main.cc	Mon Aug 02 15:05:02 2010 +0900
@@ -94,6 +94,8 @@
     HTask *h_exec = 0;
     for (int j = 0; j < array_task_num; j++) {
 	int i = w->task_spwaned++;
+	if (w->size < size) size = w->size;
+	if (size==0) break;
 	if (use_task_array) {
 	    t_exec = task_array->next_task_array(TASK_EXEC,t_exec);
 	    t_exec->set_inData(0,w->file_mmap + i*w->division_size, size);
@@ -137,12 +139,14 @@
     WordCount *w = *(WordCount **)in;
    
     if (w->task_num < w->task_blocks) {
+	// last case
 	if (w->size >= w->division_size) 
 	    run_tasks(manager,w,w->task_num, w->t_print, w->division_size);
+	// remaining data 
 	while (w->size>0) 
 	    run_tasks(manager,w,1, w->t_print, w->size);
 	// printf("run16 last %d\n",w->task_num);
-    } else if (w->task_num > 0 ) {
+    } else {
 	HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS,
 	    (memaddr)&w->self,sizeof(memaddr),0,0);
 	w->t_print->wait_for(t_next);
@@ -174,8 +178,9 @@
     w->task_spwaned = 0;
 
     /*sizeはdivision_sizeの倍数にしている。*/
-    w->size = st_mmap.size;
+    w->size = w->file_size = st_mmap.size;
     w->file_mmap = st_mmap.file_mmap;
+    printf("w %lx\n",(long)w);
 
     /* 1task分のデータサイズ(byte) */
     if (w->size >= 1024*division) {