Mercurial > hg > Members > kono > Cerium
annotate example/word_count_test/ppe/Exec.cc @ 713:f725c6455d19
remove SIMPLE_TASK conditional
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 16 Dec 2009 15:27:46 +0900 |
parents | d753b4f6b129 |
children | 2708c4a7bade |
rev | line source |
---|---|
661 | 1 #include <stdio.h> |
2 #include <string.h> | |
3 #include "Exec.h" | |
4 #include "Func.h" | |
5 | |
6 /* これは必須 */ | |
7 SchedDefineTask(Exec); | |
8 | |
9 static int | |
10 run(SchedTask *s, void *rbuf, void *wbuf) | |
11 { | |
667
d753b4f6b129
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
665
diff
changeset
|
12 char *i_data = (char *)rbuf; |
d753b4f6b129
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
665
diff
changeset
|
13 unsigned long long *o_data = (unsigned long long*)wbuf; |
d753b4f6b129
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
665
diff
changeset
|
14 unsigned long long *head_tail_flag = o_data +2; |
d753b4f6b129
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
665
diff
changeset
|
15 int length = s->read_size(); |
713
f725c6455d19
remove SIMPLE_TASK conditional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
667
diff
changeset
|
16 |
661 | 17 int word_flag = 0; |
18 int word_num = 0; | |
19 int line_num = 0; | |
665 | 20 int i = 0; |
661 | 21 |
22 /*文字なら1,スペースか改行なら0*/ | |
23 head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); | |
667
d753b4f6b129
SimpeTask WordCount Worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
665
diff
changeset
|
24 word_num -= 1-head_tail_flag[0]; |
661 | 25 |
26 for (; i < length; i++) { | |
27 | |
28 //s->printf("[SPE%d]%c",id,i_data[i]); | |
29 | |
30 | |
31 if (i_data[i] == 0x20) { | |
32 //s->printf("スペース\n"); | |
33 word_flag = 1; | |
34 } | |
35 | |
36 else if (i_data[i] == 0x0A) { | |
37 //s->printf("改行\n"); | |
38 line_num += 1; | |
39 word_flag = 1; | |
40 } | |
41 | |
42 else { | |
43 word_num += word_flag; | |
44 word_flag = 0; | |
45 } | |
46 | |
47 } | |
48 | |
49 word_num += word_flag; | |
50 /*文字なら1,スペースか改行なら0*/ | |
51 //printf("last word %c",i_data[i-1]); | |
52 head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); | |
53 | |
664 | 54 // s->printf("PPE word %d line %d\n",word_num,line_num); |
661 | 55 |
56 o_data[0] = (unsigned long long)word_num; | |
57 o_data[1] = (unsigned long long)line_num; | |
58 | |
59 return 0; | |
60 } |