I'm new to Opencl programming. To learn opencl better, after spending some time reading some tutorials, I started developing a simple pattern matching kernel function. But I have some doubts:
First, I have global variables declared inside the kernel function. Does it mean every work item shares a single copy of each variable?
Second, how can I use the standard C libraries, esp. "string.h".
__kernel void matchPatterns_V1(__global char *strings, __global char *patterns, __global int *matchCount,
int strCount, int strLength, int patCount, int patLength) {
int id = get_global_id(0);
int rowIndex = id*strLength;
int i, matches = 0;
__global char *pos = strings;
__global char *temp = strings;
__global char *pat = patterns;
for(i = 0; i < patCount; i++)
{
temp = &strings[rowIndex];
pat = &patterns[i*patLength];
while(pos != '\0') {
pos = StrStr(temp, pat);
if(pos != '\0') {
matches++;
temp = pos + patLength;
}
}
}
matchCount[id] = matches;
}
To summarize, does each work item has its own copy of the variables 'pos', 'temp', and 'pat'?
Any advice in learning Opencl is highly appreciated, including suggestion for best books/tutorial sites.