Mercurial > hg > Game > Cerium
annotate example/word_count/gpu/Exec.cl @ 1837:093bdd5e940e draft
add file
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 20 Dec 2013 12:00:15 +0900 |
parents | 56692133c5fb |
children | 759587e37bc7 |
rev | line source |
---|---|
1539 | 1 __kernel void |
1836
56692133c5fb
success run wordcount with gpu, but result is wrong
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1677
diff
changeset
|
2 wordcount(__constant long *param, |
56692133c5fb
success run wordcount with gpu, but result is wrong
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1677
diff
changeset
|
3 __global char *i_data, |
56692133c5fb
success run wordcount with gpu, but result is wrong
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1677
diff
changeset
|
4 __global unsigned long long *o_data) |
1539 | 5 { |
1837 | 6 __global unsigned long long *head_tail_flag = o_data+2; |
1836
56692133c5fb
success run wordcount with gpu, but result is wrong
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1677
diff
changeset
|
7 long length = param[0]; |
1539 | 8 int word_flag = 0; |
9 int word_num = 0; | |
10 int line_num = 0; | |
11 int i = 0; | |
12 | |
13 head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); | |
14 word_num -= 1-head_tail_flag[0]; | |
15 | |
16 for (; i < length; i++) { | |
17 if (i_data[i] == 0x20) { | |
18 word_flag = 1; | |
19 } else if (i_data[i] == 0x0A) { | |
20 line_num += 1; | |
21 word_flag = 1; | |
22 } else { | |
23 word_num += word_flag; | |
24 word_flag = 0; | |
25 } | |
26 } | |
27 | |
28 word_num += word_flag; | |
29 head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); | |
30 | |
31 // s->printf("SPE word %d line %d\n",word_num,line_num); | |
32 | |
33 o_data[0] = (unsigned long long)word_num; | |
34 o_data[1] = (unsigned long long)line_num; | |
35 | |
36 } |