cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

rolandman99
Journeyman III

modulo (mod) function in opencl kernel

is there any builtin mod function can be used inside a kernel? I need mod to implement hash function. If not, any suggestion?

0 Likes
2 Replies
dravisher
Journeyman III

It's the same as in C, %: 3 % 2 == 1.

It's not a fast operation, so keep in mind that the modulo of powers of two can be computed much more efficiently as:

x % 2^n == x & (2^n - 1)

From the wikipedia article.

0 Likes

there is also float function floatN fmod(floatN a, floatN b)

0 Likes