Mercurial > hg > Members > kono > Cerium
changeset 653:94c6b7ea87c2
vectorize word_count.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 01 Dec 2009 10:39:04 +0900 |
parents | dbe137505f2e |
children | 6929d888fd69 |
files | TaskManager/kernel/ppe/MailManager.cc example/word_count/spe/Exec.cc |
diffstat | 2 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/MailManager.cc Mon Nov 23 12:01:45 2009 +0900 +++ b/TaskManager/kernel/ppe/MailManager.cc Tue Dec 01 10:39:04 2009 +0900 @@ -29,7 +29,7 @@ MailManager::extend() { memaddr *newq = New(memaddr,size*2); - int i = 0; + unsigned int i = 0; while(i<size) { newq[i++] = queue[read++]; read &= mask; @@ -46,7 +46,7 @@ queue[write++] = data; write &= mask; if (write==read) { - externd(); + extend(); } }
--- a/example/word_count/spe/Exec.cc Mon Nov 23 12:01:45 2009 +0900 +++ b/example/word_count/spe/Exec.cc Tue Dec 01 10:39:04 2009 +0900 @@ -6,42 +6,52 @@ /* これは必須 */ SchedDefineTask(Exec); +// typedef char *cvector __attribute__ ((vector_size (16))); +// +typedef char *cvector; + static int run(SchedTask *s, void *rbuf, void *wbuf) { - char *i_data = (char*)s->get_input(rbuf, 0); + cvector i_data ; + i_data = (cvector)s->get_input(rbuf, 0); unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); int length = (long)s->get_param(0); int word_flag = (long)s->get_param(1); int word_num = 0; int line_num = 0; int i; + static char spaces[] = {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20}; + cvector space = (cvector)spaces; + static char newlines []= {0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a}; + cvector newline = (cvector)newlines; + /*先頭の文字まで、飛ぶルーチン*/ for(i = 0; i < length; i++) { - if ((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { + if ((i_data[i] != space[i%16]) && (i_data[i] != newline[i%16])) { //s->printf("[SPE%d] break[%d] %d\n",id,i,i_data[i]); break; } //s->printf("[SPE%d]%c",id,i_data[start_num]); word_num += word_flag; word_flag = 0; - line_num += (i_data[i] == 0x0A); + line_num += (i_data[i] == newline[i%16]); } word_flag = 0; - for (; i < length; i++) { + for (; i < length; i++) { //s->printf("[SPE%d]%c",id,i_data[i]); - if (i_data[i] == 0x20) { + if (i_data[i] == space[i%16]) { //s->printf("スペース\n"); word_flag = 1; } - else if (i_data[i] == 0x0A) { + else if (i_data[i] == newline[i%16]) { //s->printf("改行\n"); line_num += 1; word_flag = 1;