View Full Version : can we use compare function in kernel?

01-05-2013, 11:44 PM
can we use compare(str1,str2) function in kernel?

01-11-2013, 01:34 PM
I don't know of an OpenCL built-in called "compare". Are you looking for a specific functionality? Are you trying to compare zero-terminated strings inside an OpenCL kernel?

01-11-2013, 11:38 PM
yes ,but how can i do it

01-12-2013, 10:53 AM
ocl c doesn't have string functions. you can write your own. the second example from this page might work as is :

http://www.programmingsimplified.com/c- ... wo-strings (http://www.programmingsimplified.com/c-program-compare-two-strings)

01-12-2013, 07:25 PM
ok ,do u know how to make array of string in kernel?

01-15-2013, 01:33 PM
well, if you know how long the longest one will be, and it's not too horribly huge, I'd just use a 2-d array. If you needed 20 strings of 100 length each:

char strang[20][100]

and then pass &strang[20][0] for the first one, &strang[20][1] for the second...

(I'm just guessing, as I don't have any arrays of strings in my kernel. But that kind of thing should work just fine, in my experience....)

... I don't think you can allocate dynamically-sized memory in a kernel (someone correct me if wrong). I haven't run into memory limitations on the GPU yet, but my task may not be like yours!