Finding the minimum value in an array with CUDA

I’m working on a program that involves an array full of floats, and I want to use CUDA to find the minimum value in this array. What’s a good way to go about it?

A reduction with the min operator would do this fine.

You could divide the sequence into sections, each thread block get min value of the section, then gather result and dispatch result sequence again to thread blocks, until you get the result you prefer.


Where can I find some good information about the min operator?

You write it yourself. If this is a ‘need’ (rather than a desire to learn how to do things in CUDA), then I’d look at the Thrust library, which has these sort of things already coded up.