Mercurial > hg > Members > kono > Cerium
comparison example/word_count_test/spe/Exec.cc @ 667:d753b4f6b129
SimpeTask WordCount Worked.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 03 Dec 2009 04:23:36 +0900 |
parents | 4470ff271c5a |
children | bde5f13adf10 |
comparison
equal
deleted
inserted
replaced
666:4615489c5faa | 667:d753b4f6b129 |
---|---|
7 SchedDefineTask(Exec); | 7 SchedDefineTask(Exec); |
8 | 8 |
9 static int | 9 static int |
10 run(SchedTask *s, void *rbuf, void *wbuf) | 10 run(SchedTask *s, void *rbuf, void *wbuf) |
11 { | 11 { |
12 #ifdef SIMPLE_TASK | |
13 char *i_data = (char *)rbuf; | |
14 unsigned long long *o_data = (unsigned long long*)wbuf; | |
15 unsigned long long *head_tail_flag = o_data +2; | |
16 int length = s->read_size(); | |
17 #else | |
12 char *i_data = (char*)s->get_input(rbuf, 0); | 18 char *i_data = (char*)s->get_input(rbuf, 0); |
13 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); | 19 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); |
14 /*担当範囲の先頭、末尾が「改行、スペース」か、「それ以外の文字」かのフラグ*/ | 20 /*担当範囲の先頭、末尾が「改行、スペース」か、「それ以外の文字」かのフラグ*/ |
15 unsigned long long *head_tail_flag = (unsigned long long*)s->get_output(wbuf,1); | 21 unsigned long long *head_tail_flag = (unsigned long long*)s->get_output(wbuf,1); |
16 int length = (long)s->get_param(0); | 22 int length = (long)s->get_param(0); |
23 #endif | |
17 int word_flag = 0; | 24 int word_flag = 0; |
18 int word_num = 0; | 25 int word_num = 0; |
19 int line_num = 0; | 26 int line_num = 0; |
20 int i = 0; | 27 int i = 0; |
21 | 28 |
49 word_num += word_flag; | 56 word_num += word_flag; |
50 /*文字なら1,スペースか改行なら0*/ | 57 /*文字なら1,スペースか改行なら0*/ |
51 //printf("last word %c",i_data[i-1]); | 58 //printf("last word %c",i_data[i-1]); |
52 head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); | 59 head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); |
53 | 60 |
54 // s->printf("PPE word %d line %d\n",word_num,line_num); | 61 // s->printf("SPE word %d line %d\n",word_num,line_num); |
55 | 62 |
56 o_data[0] = (unsigned long long)word_num; | 63 o_data[0] = (unsigned long long)word_num; |
57 o_data[1] = (unsigned long long)line_num; | 64 o_data[1] = (unsigned long long)line_num; |
58 | 65 |
59 return 0; | 66 return 0; |