PDA

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



prince
01-06-2013, 12:44 AM
can we use compare(str1,str2) function in kernel?
thanks

kunze
01-11-2013, 02: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?

prince
01-12-2013, 12:38 AM
yes ,but how can i do it

Photovore
01-12-2013, 11: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)

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

Photovore
01-15-2013, 02: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!