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?

This is where the vector properties of the graphic card come in very handy. This can actually be handled with very minimal changes to the code.

reduce void red(float a<>, reduce float4 b<> )

{

if(b.x < a)

{

b.x = a;

b.y = indexof(a).x;

b.z = indexof(a).y;

}

}