Mercurial > hg > Game > Cerium
annotate example/word_count/gpu/Exec.cl @ 2054:2e7a6f40672f draft
add param(4) in FileMapReduce.cc
author | masa |
---|---|
date | Fri, 29 Jan 2016 15:56:28 +0900 |
parents | 44fa0f1320a9 |
children |
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, |
1842 | 4 __global unsigned long *o_data) |
1539 | 5 { |
1842 | 6 __global unsigned 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]; |
1838 | 8 long word_flag = 0; |
9 long word_num = 0; | |
10 long line_num = 0; | |
11 long i = 0; | |
1539 | 12 |
13 head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); | |
14 word_num -= 1-head_tail_flag[0]; | |
15 for (; i < length; i++) { | |
16 if (i_data[i] == 0x20) { | |
17 word_flag = 1; | |
18 } else if (i_data[i] == 0x0A) { | |
19 line_num += 1; | |
20 word_flag = 1; | |
21 } else { | |
22 word_num += word_flag; | |
23 word_flag = 0; | |
24 } | |
25 } | |
26 | |
27 word_num += word_flag; | |
28 head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); | |
29 | |
30 // s->printf("SPE word %d line %d\n",word_num,line_num); | |
31 | |
1842 | 32 o_data[0] = (unsigned long)word_num; |
33 o_data[1] = (unsigned long)line_num; | |
1539 | 34 |
35 } |