Mercurial > hg > Game > Cerium
changeset 1590:c44fd3708d89 draft
fix
author | Masa <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 01 Apr 2013 17:48:30 +0900 |
parents | 345139e65ef1 |
children | 619cbf3a0297 |
files | example/regex_masa/ppe/Exec.cc example/regex_masa/spe/Exec.cc.vector |
diffstat | 2 files changed, 2 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_masa/ppe/Exec.cc Sun Mar 31 20:33:26 2013 +0900 +++ b/example/regex_masa/ppe/Exec.cc Mon Apr 01 17:48:30 2013 +0900 @@ -22,8 +22,7 @@ //head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A); //word_num -= 1-head_tail_flag[0]; - - //i_data[length - 1] = 0x61; //分割されたファイルのラストがaのときに固まってしまう + head_tail_flag[0] = (i_data[0] == 0x62); for (; i < length; i++) { if (i_data[i] == 0x61) { @@ -32,7 +31,6 @@ word_flag = true; line_flag = true; word_head_a_flag = true; - printf("num:%d\n", (int)word_head_a_flag); } else if (i_data[i] == 0x20) { //空白 word_num += word_flag; word_flag = false; @@ -47,7 +45,7 @@ } //head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A); - head_tail_flag[1] = (i_data[i-1] != 0x61); + head_tail_flag[1] = (i_data[i-1] == 0x61); s->printf("SPE include 'ab' %d lines. %d words. \n",line_num,word_num);
--- a/example/regex_masa/spe/Exec.cc.vector Sun Mar 31 20:33:26 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include "Exec.h" -#include "Func.h" - -/* これは必須 */ -SchedDefineTask(Exec); - -typedef char *cvector __attribute__ ((vector_size (16))); -// vectorize だと結果がよろしくない... -// -// typedef char *cvector; - -static int -run(SchedTask *s, void *rbuf, void *wbuf) -{ -#ifdef SIMPLE_TASK - cvector i_data = (cvector)rbuf; - char* i_data0 = (char*)rbuf; - unsigned long long *o_data = (unsigned long long*)wbuf; - unsigned long long *head_tail_flag = o_data +2; - int length = s->read_size(); -#else - cvector i_data = (cvector)s->get_input(rbuf, 0); - char* i_data0 = (char*)s->get_input(rbuf, 0); - unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); - /*担当範囲の先頭、末尾が「改行、スペース」か、「それ以外の文字」かのフラグ*/ - unsigned long long *head_tail_flag = (unsigned long long*)s->get_output(wbuf,1); - int length = (long)s->get_param(0); -#endif - - static const char spaces[] = {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20} ; - cvector const space = (cvector)spaces; - static const char newlines[] = {0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a}; - cvector const newline = (cvector)newlines; - - int word_flag = 0; - int word_num = 0; - int line_num = 0; - int i = 0; - - /*文字なら1,スペースか改行なら0*/ - char top = i_data0[0]; - head_tail_flag[0] = ((top != 0x20) && (top != 0x0a)); - word_num -= 1-head_tail_flag[0]; - - for (; i < length; i++) { - if (i_data[i] == space[i%16]) { - //s->printf("スペース\n"); - word_flag = 1; - } else if (i_data[i] == newline[i%16]) { - //s->printf("改行\n"); - line_num += 1; - word_flag = 1; - } else { - word_num += word_flag; - word_flag = 0; - } - } - - word_num += word_flag; - /*文字なら1,スペースか改行なら0*/ - //printf("last word %c",i_data[i-1]); - char end = i_data0[i-1]; - head_tail_flag[1] = ((end != 0x20) && (end != 0x0a)); - - // s->printf("SPU word %d line %d\n",word_num,line_num); - - o_data[0] = (unsigned long long)word_num; - o_data[1] = (unsigned long long)line_num; - - return 0; -}