String matching/searching kernel Kernel implementation

Dear all,

I need help. Sorry if I missed any, as I can not find any thread discussing string manipulation. This source is from supercomputingblog.

__global__ void searchWordGPU(char *pszData, int dataLength, char *pszTarget, int targetLen, int *pFound) {

	int startIndex = blockDim.x*blockIdx.x + threadIdx.x;

	if(*pFound > startIndex)


		// only continue if an earlier instance hasn't already been found

		int fMatch = 1;

		for (int i=0; i < targetLen; i++)


			if (pszData[startIndex+i] != pszTarget[i]) fMatch = 0;


		if (fMatch) atomicMin(pFound, startIndex);

		//if (fMatch) *pFound = startIndex;



My questions:


[*]startIndex will be increased (i.e. startIndex++). Is there any way to increased based on e.g. targetLen=8 size (i.e. startIndex+=8)?

[*]atomicMin still has a compilation error? Any idea how to resolve this?

[*]any performance issue if there are too many if/else statement?

Thanks, in advance.

atomicMin does not support sm10, you need to compile by option -arch=sm_11,

-arch=sm_12, -arch=sm_13 or -arch=sm_20

if you want to find starting position of matched pattern, then you can try our library, PFAC,

Thanks for the prompt reply, LSChien.