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

Discussion created by Tasp on Sep 29, 2010
Latest reply on Sep 30, 2010 by himanshu.gautam

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?