I wrote a kernel which has to find the index of the minimum and maximum of a float array (parallel reduction). It works quite fine, but now I stumbled towards a problem for this input:
Problem is, whenever at least one value in the array is -1.#IND, the kernel returns wrong results. That’s because if one value is compared against -1.#IND, it’s neither less, equal, or greater…the partial min/max gets set to the first value, which produces unwanted output.
The -1.#IND probably is a result of a function computing something like exp(, ), I can’t avoid it.
Is there any elegant way to prefer the non-complex value in such a comparison? If not, what do you think would be the best way to make the kernel work the way one would expect it? (maybe checking each value when it’s loaded to shared mem, and setting -1.#IND to infinity?)
Thanks for answering. I use the normal < and > as reduction operators. I already read about fminf and fmaxf, unfortunately it doesn’t help me, since I am interested in finding the index of the greatest and smallest value, but not in the value itself.