Mercurial > hg > Members > kono > Cerium
annotate example/word_count/spe/Exec.cc @ 663:8a807e2f64f8
incremental task creation on word count_test
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 02 Dec 2009 22:20:32 +0900 |
parents | 6929d888fd69 |
children | 4615489c5faa |
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 | |
663
8a807e2f64f8
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
654
diff
changeset
|
9 // typedef char *cvector __attribute__ ((vector_size (16))); |
8a807e2f64f8
incremental task creation on word count_test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
654
diff
changeset
|
10 typedef char *cvector; |
653 | 11 |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
12 static int |
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
13 run(SchedTask *s, void *rbuf, void *wbuf) |
393 | 14 { |
653 | 15 cvector i_data ; |
16 i_data = (cvector)s->get_input(rbuf, 0); | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
17 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); |
626
ab866bc8a624
64bit mode compatibility on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
18 int length = (long)s->get_param(0); |
ab866bc8a624
64bit mode compatibility on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
19 int word_flag = (long)s->get_param(1); |
393 | 20 int word_num = 0; |
21 int line_num = 0; | |
22 int i; | |
653 | 23 static char spaces[] = {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20}; |
24 cvector space = (cvector)spaces; | |
25 static char newlines []= {0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a}; | |
26 cvector newline = (cvector)newlines; | |
27 | |
393 | 28 |
29 /*先頭の文字まで、飛ぶルーチン*/ | |
30 for(i = 0; i < length; i++) { | |
653 | 31 if ((i_data[i] != space[i%16]) && (i_data[i] != newline[i%16])) { |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
32 //s->printf("[SPE%d] break[%d] %d\n",id,i,i_data[i]); |
393 | 33 break; |
34 } | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
35 //s->printf("[SPE%d]%c",id,i_data[start_num]); |
393 | 36 word_num += word_flag; |
37 word_flag = 0; | |
653 | 38 line_num += (i_data[i] == newline[i%16]); |
393 | 39 } |
40 | |
41 word_flag = 0; | |
42 | |
653 | 43 for (; i < length; i++) { |
393 | 44 |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
45 //s->printf("[SPE%d]%c",id,i_data[i]); |
393 | 46 |
47 | |
653 | 48 if (i_data[i] == space[i%16]) { |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
49 //s->printf("スペース\n"); |
393 | 50 word_flag = 1; |
51 } | |
52 | |
653 | 53 else if (i_data[i] == newline[i%16]) { |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
54 //s->printf("改行\n"); |
393 | 55 line_num += 1; |
56 word_flag = 1; | |
57 } | |
58 | |
59 else { | |
60 word_num += word_flag; | |
61 word_flag = 0; | |
62 } | |
63 | |
64 } | |
65 | |
66 word_num += word_flag; | |
67 | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
68 //s->printf("%d %d\n",word_num,line_num); |
393 | 69 |
70 o_data[0] = (unsigned long long)word_num; | |
71 o_data[1] = (unsigned long long)line_num; | |
72 | |
73 return 0; | |
74 } |