cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Tasp
Journeyman III

atomic min to store id of tuple (value, id) with lowest value

I need a kernel that computes the id with minimal value from tuples (value, id).
How can I do that?

Only idea i have is combine the values:

32bit: 16bit = value, 16bit = id

and use the atomic_min function, first local, then global of course.
If value is equal lower id would win. 16bit precision would be enough for me.

Is there a better way?

0 Likes
1 Reply
himanshu_gautam
Grandmaster

hi tasp,

check out this link:

http://developer.amd.com/documentation/articles/Pages/OpenCL-Optimization-Case-Study-Simple-Reductions.aspx

This is much more efficient than using atomic operations.

0 Likes