Mercurial > hg > Game > Cerium
annotate example/word_count/ppe/Print.cc @ 786:043c98537bc5 draft
fix early free of TaskArray, add SchedTaskArrayNop stage.
author | yutaka@localhost.localdomain |
---|---|
date | Sat, 24 Apr 2010 15:24:33 +0900 |
parents | f02b3338b91b |
children | 852ed17d8af1 |
rev | line source |
---|---|
393 | 1 #include <stdio.h> |
2 #include <string.h> | |
3 #include "Print.h" | |
4 #include "Func.h" | |
5 | |
6 /* これは必須 */ | |
7 SchedDefineTask(Print); | |
8 | |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
9 static int |
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
10 run(SchedTask *s, void *rbuf, void *wbuf) |
393 | 11 { |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
12 unsigned long long *idata = (unsigned long long*)s->get_input(rbuf, 0); |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
13 long task_num = (long)s->get_param(0); |
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
14 long status_num = (long)s->get_param(1); |
393 | 15 unsigned long long word_data[task_num]; |
16 | |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
17 s->printf("start sum\n"); |
393 | 18 |
19 for (int i = 0; i < status_num; i++) { | |
20 word_data[i] = 0; | |
21 } | |
22 | |
23 for (int i = 0; i < task_num*status_num; i += status_num) { | |
24 for (int j = 0; j < status_num; j++) { | |
25 word_data[j] += idata[i+j]; | |
26 } | |
27 } | |
28 | |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
666
diff
changeset
|
29 for (int i = 0; i < status_num; i++) { |
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
666
diff
changeset
|
30 s->printf("%llu ",word_data[status_num - i - 1]); |
393 | 31 } |
32 | |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
33 s->printf("\n"); |
393 | 34 |
35 | |
36 return 0; | |
37 } |