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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
393
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
1 #include <stdio.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
2 #include <string.h>
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
3 #include "Print.h"
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
4 #include "Func.h"
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
5
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
6 /* これは必須 */
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
7 SchedDefineTask(Print);
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
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
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
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
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
15 unsigned long long word_data[task_num];
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
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
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
18
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
19 for (int i = 0; i < status_num; i++) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
20 word_data[i] = 0;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
21 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
22
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
23 for (int i = 0; i < task_num*status_num; i += status_num) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
24 for (int j = 0; j < status_num; j++) {
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
25 word_data[j] += idata[i+j];
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
26 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
27 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
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
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
31 }
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
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
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
34
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
35
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
36 return 0;
cb06748ba6cf add word_count
e065725@localhost.localdomain
parents:
diff changeset
37 }