Mercurial > hg > Game > Cerium
annotate example/word_count/spe/Exec.cc @ 896:f3530a4100bf draft
minor fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 16 Jul 2010 17:37:31 +0900 |
parents | 97b75b9657a2 |
children | 852ed17d8af1 |
rev | line source |
---|---|
393 | 1 #include <stdio.h> |
2 #include <string.h> | |
3 #include "Exec.h" | |
4 #include "Func.h" | |
5 | |
6 /* これは必須 */ | |
7 SchedDefineTask(Exec); | |
8 | |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
9 static int |
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
10 run(SchedTask *s, void *rbuf, void *wbuf) |
393 | 11 { |
666 | 12 char *i_data = (char*)s->get_input(rbuf, 0); |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
13 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
666
diff
changeset
|
14 int length = (int)s->get_param(0); |
803 | 15 //int length = s->read_size(); |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
666
diff
changeset
|
16 int word_flag = 1-(int)s->get_param(1); |
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
666
diff
changeset
|
17 //int word_flag = (int)s->get_param(1); |
393 | 18 int word_num = 0; |
19 int line_num = 0; | |
666 | 20 int i ; |
393 | 21 |
666 | 22 word_num -= word_flag; |
393 | 23 |
666 | 24 for (i=0; i < length; i++) { |
393 | 25 |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
26 //s->printf("[SPE%d]%c",id,i_data[i]); |
393 | 27 |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
666
diff
changeset
|
28 if ((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { |
666 | 29 //s->printf("文字 数 = %d\n", word_num + word_flag); |
30 word_num += word_flag; | |
31 word_flag = 0; | |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
666
diff
changeset
|
32 } else if (i_data[i] == 0x20) { |
666 | 33 //printf("スペース\n"); |
393 | 34 word_flag = 1; |
786
043c98537bc5
fix early free of TaskArray, add SchedTaskArrayNop stage.
yutaka@localhost.localdomain
parents:
666
diff
changeset
|
35 } else if (i_data[i] == 0x0A) { |
666 | 36 //printf("改行\n"); |
393 | 37 line_num += 1; |
38 word_flag = 1; | |
39 } | |
40 | |
41 } | |
42 | |
43 word_num += word_flag; | |
44 | |
666 | 45 // printf("PPE word %d line %d\n",word_num,line_num); |
393 | 46 |
47 o_data[0] = (unsigned long long)word_num; | |
48 o_data[1] = (unsigned long long)line_num; | |
49 | |
50 return 0; | |
51 } |