Mercurial > hg > Members > kono > Cerium
diff example/word_count_test/ppe/Print.cc @ 667:d753b4f6b129
SimpeTask WordCount Worked.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 03 Dec 2009 04:23:36 +0900 |
parents | 4615489c5faa |
children | 4af9d20cf3af |
line wrap: on
line diff
--- a/example/word_count_test/ppe/Print.cc Thu Dec 03 02:11:31 2009 +0900 +++ b/example/word_count_test/ppe/Print.cc Thu Dec 03 04:23:36 2009 +0900 @@ -2,20 +2,36 @@ #include <string.h> #include "Print.h" #include "Func.h" +#include "WordCount.h" /* これは必須 */ -SchedDefineTask(Print); +SchedDefineTask1(Print,run_print); static int -run(SchedTask *s, void *rbuf, void *wbuf) +run_print(SchedTask *s, void *rbuf, void *wbuf) { +#ifdef SIMPLE_TASK + WordCount *w = *(WordCount**)rbuf; + unsigned long long *idata = w->o_data; + // long task_num = w->task_num; + long status_num = w->status_num; + int out_task_num = w->out_task_num; + + /* + * head_flag + * o_data[0] + * o_data[1] + * + */ +#else + int pad = w->pad; unsigned long long *idata = (unsigned long long*)s->get_input(rbuf, 0); - unsigned long long *head_tail_flag= (unsigned long long*)s->get_input(rbuf,1); long task_num = (long)s->get_param(0); long status_num = (long)s->get_param(1); - int out_task_num = (int)s->get_param(2); + // int out_task_num = (int)s->get_param(2); int pad = (int)s->get_param(3); - unsigned long long word_data[task_num]; +#endif + unsigned long long word_data[2]; int flag_cal_sum = 0; //printf("pad %d\n",pad); @@ -53,32 +69,42 @@ * */ - - for (int i = 1; i < out_task_num * pad - pad; i += pad) { - //printf("%llu ",head_tail_flag[i]); - //printf("%llu\n",head_tail_flag[i+1]); - - if((head_tail_flag[i] == 1) && (head_tail_flag[i+1] == 0)) { - flag_cal_sum++; - } - - } - s->printf("start sum\n"); for (int i = 0; i < status_num; i++) { word_data[i] = 0; } - for (int i = 0; i < task_num*status_num; i += status_num) { +#ifdef SIMPLE_TASK + for (int i = 0; i < out_task_num ; i++) { + word_data[0] += idata[i*w->out_size+0]; + word_data[1] += idata[i*w->out_size+1]; + unsigned long long *head_tail_flag = + &idata[i*w->out_size+2]; + if((i!=out_task_num-1)&& + (head_tail_flag[1] == 1) && (head_tail_flag[4] == 0)) { + flag_cal_sum++; + } + } +#else + for (int i = 1; i < out_task_num * pad - pad; i += pad) { + //printf("%llu ",head_tail_flag[i]); + //printf("%llu\n",head_tail_flag[i+1]); + if((head_tail_flag[i] == 1) && (head_tail_flag[i+1] == 0)) { + flag_cal_sum++; + } + } + + for (int i = 0; i < out_task_num*status_num; i += status_num) { for (int j = 0; j < status_num; j++) { word_data[j] += idata[i+j]; } } +#endif word_data[0] += flag_cal_sum; - for (int i = status_num-1; i >= 0; i--) { + for (int i = status_num-1; i >=0; i--) { s->printf("%llu ",word_data[i]); }