Mercurial > hg > Members > kono > Cerium
comparison example/word_count/spe/Print.cc @ 393:72b73beb3325
add word_count
author | e065725@localhost.localdomain |
---|---|
date | Tue, 15 Sep 2009 16:30:46 +0900 |
parents | |
children | 44c0bce54dcf |
comparison
equal
deleted
inserted
replaced
392:690631340d58 | 393:72b73beb3325 |
---|---|
1 #include <stdio.h> | |
2 #include <string.h> | |
3 #include "Print.h" | |
4 #include "Func.h" | |
5 | |
6 /* これは必須 */ | |
7 SchedDefineTask(Print); | |
8 | |
9 int | |
10 Print::run(void *rbuf, void *wbuf) | |
11 { | |
12 unsigned long long *idata = (unsigned long long*)get_input(rbuf, 0); | |
13 int task_num = get_param(0); | |
14 int status_num = get_param(1); | |
15 unsigned long long word_data[task_num]; | |
16 | |
17 for (int i = 0; i < status_num; i++) { | |
18 word_data[i] = 0; | |
19 } | |
20 | |
21 for (int i = 0; i < task_num*status_num; i += status_num) { | |
22 for (int j = 0; j < status_num; j++) { | |
23 word_data[j] += idata[i+j]; | |
24 } | |
25 } | |
26 | |
27 for (int i = 0; i < status_num; i++) { | |
28 printf("%llu ",word_data[i]); | |
29 } | |
30 | |
31 printf("\n"); | |
32 | |
33 | |
34 return 0; | |
35 } |