2
병렬 문자열 검색을 수행 할 커널을 빌드하려고합니다. 이를 위해 필자는 유한 상태 시스템을 사용하는 경향이 있습니다. fsm의 전이 테이블은 커널 인수 상태에 있습니다. 코드 : 나는 iocgui를 사용하여이 커널을 컴파일하는 경우OpenCL 커널이 벡터화되지 않았습니다.
__kernel void Find (__constant char *text,
const int offset,
const int tlenght,
__constant char *characters,
const int clength,
const int maxlength,
__constant int *states,
const int statesdim){
private char c;
private int state;
private const int id = get_global_id(0);
if (id<(tlenght-maxlength)) {
private int cIndex,sd,s,k;
for (int i=0; i<maxlength; i++) {
c = text[i+offset];
cIndex = -1;
for (int j=0; j<clength; j++) {
if (characters[j]==c) {
cIndex = j;
}
}
if (cIndex==-1) {
state = 0;
break;
} else {
s = states[state+cIndex*statesdim];
}
if (state<=0) break;
}
}
}
, 나는 결과를 얻을 :
state = states[state+cIndex*statesdim];
: 나는 새로운 상태가 결정되는 줄을 변경
Using default instruction set architecture.
Intel OpenCL CPU device was found!
Device name: Pentium(R) Dual-Core CPU T4400 @ 2.20GHz
Device version: OpenCL 1.1 (Build 31360.31426)
Device vendor: Intel(R) Corporation
Device profile: FULL_PROFILE
Build started
Kernel <Find> was successfully vectorized
Done.
Build succeeded!
결과는 다음과 같습니다.
Using default instruction set architecture.
Intel OpenCL CPU device was found!
Device name: Pentium(R) Dual-Core CPU T4400 @ 2.20GHz
Device version: OpenCL 1.1 (Build 31360.31426)
Device vendor: Intel(R) Corporation
Device profile: FULL_PROFILE
Build started
Kernel <Find> was not vectorized
Done.
Build succeeded!