Ceriumによる
正規表現マッチャの実装
Masataka Kohagura
7th May , 2013
Masataka Kohagura
7th May , 2013
本研究室では、Cell用に作られたCeriumにて並列プログラミングを行なっている。 近年、マルチコアCPUが主流となっているが、それをフルに使用させるためにはプログラムの並列度を上げる必要がある。(続く)
現在は正規表現を並列実装している段階である。
C言語ポインタ完全制覇でポインタの勉強(半分ほど)
for (; i < length; i++) { if (i_data[i] == 0x0A) { if (match_flag == true) { line_print(line_num,line_length,line_data); } match_flag = false; line_length = 0; line_num++; } else { line_data[line_length] = i_data[i]; line_length++; if (i_data[i] == 0x61) { a_flag = true; }else if ((i_data[i] == 0x62) && (a_flag == true)) { match_flag = true; }else if (i_data[i] == 0x20) { a_flag = false; } } }
void line_print(int _line_num,int _line_length,char *input_data){ printf("%d : ",_line_num); for (int k = 0; k < _line_length; k++) { printf("%c",input_data[k]); } printf("\n"); }
[Masa]~% ./regex -file b.txt [~/hg/Cerium/example/regex_mas] 1 : ab aaa dddd ssss abab 2 : ab bbbbbbbbbb aaaaaaa 4 : ab aaaab
[Masa]~% ./regex -file c.txt [~/hg/Cerium/example/regex_mas] 1 : Pakistan who've volunteered to join private militias, called lashkars. These groups have vowed to help Pakistan's military in fighting the Taliban. 5 : Pakistani military officials credit the lashkars with helping chase the Taliban out of Swat Valley and neighboring districts once infested with the militants. 6 : Pakistan who've volunteered to join private militias, called lashkars. These groups have vowed to help Pakistan's military in fighting the Taliban. [中略] 196 : Pakistan who've volunteered to join private militias, called lashkars. These groups have vowed to help Pakistan's military in fighting the Taliban. 200 : Pakistani military officials credit the lashkars with helping chase the Taliban out of Swat Valley and neighboring districts once infested with the militants. 1 : red to join private militias, called lashkars. These groups have vowed to help Pakistan's military in fighting the Taliban. 5 : Pakistani military officials credit the lashkars with helping chase the Taliban out of Swat Valley and neighboring districts once infested with the militants.