Mercurial > hg > Members > kono > Cerium
diff example/word_count3/ppe/Print.cc @ 527:7d9d209bdc82
add word_count3
author | yutaka@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 20 Oct 2009 16:28:16 +0900 |
parents | |
children | 60aa3f241b10 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/word_count3/ppe/Print.cc Tue Oct 20 16:28:16 2009 +0900 @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <string.h> +#include "Print.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(Print); + +static int +run(SchedTask *s, void *rbuf, void *wbuf) +{ + unsigned long long *idata = (unsigned long long*)s->get_input(rbuf, 0); + int task_num = s->get_param(0); + int status_num = s->get_param(1); + unsigned long long word_data[task_num]; + + 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) { + for (int j = 0; j < status_num; j++) { + word_data[j] += idata[i+j]; + } + } + + for (int i = 0; i < status_num; i++) { + s->printf("%llu ",word_data[i]); + } + + s->printf("\n"); + + + return 0; +}