bjang

reduction function which finds the index of max value in array

Discussion created by bjang on Sep 2, 2008
Latest reply on Oct 19, 2008 by zimoch

Hello,

I would like to write a reduction kernel which finds (or returns) the index of max value in array.

We have seen a beautiful reduction function which finds max value in array as follows by Ceq and by jski.

reduce void red(double a<>, reduce double b<>{
    if(b < a)   b = a;
}

reduce void red( float value<>, reduce float result<> ){
   result = max( value, value );
}

Now, I would like to find the index of that max value. Do you guys think it is possible with reduction kernel?

Outcomes