cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

berathebrain
Journeyman III

max function

I was wondering how could I find a maximum of an array(stream) using AMD StreamSDK.

Thanks.

0 Likes
10 Replies
ryta1203
Journeyman III

There is a bitonic sort example that comes with the SDK.
0 Likes
Ceq
Journeyman III

Well, if he only needs the maximum value I think it's better to use a 'max reduction' than sorting the array.
You have an example in the documentation folder "brook/docs", section 5.2.

reduce void max_reduce(double a<>, reduce double b<> ) {
if (a > b) return a;
else return b;
}
0 Likes

Have you tried this out yet?

1. I wouldn't recommend going by anything in any of the documentation that you haven't directly coded and seen work. There are too many instances of poor documentation in the current SDK release. There are too many things they say "work" and then don't work.

2. Just looking at this kernel it has a return type of "void" but then "return"s a value. How does that work? For me, I get compiler errors when trying the kernel unmodified. The primary kernel must have a return type of "void" for the SDK but are reduction functions allowed a return type even though the kernel has a return type of "void"?

3. If you can get this working I would love for you to post the code. Right now, I can't find a sampe that came with the SDK that works AS IS that would do what he/she wants except Bitonic Sort.

Thanks. I know for sure the Bitonic Sort works though.

Maybe the AMD gods can shed some light on this.
0 Likes
Ceq
Journeyman III

Thanks Ryta, indeed its a mistake, I copied it from the documentation without checking.
However you can get it working easily this way:

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

I've tested this on my Radeon 4850 and seems to work properly.
0 Likes

Ceq,

Yes, you are correct. This does indeed work just fine.
0 Likes
Ceq
Journeyman III

0 Likes

Thanks, I coded my own example to test it using 4850, but it's nice for everyone to see the "whole" code in simple format, in case they have questions as to the size of the streams, passing what to the kernel and how, etc.
0 Likes

Thank you guys. Much appriciated. I too was encountered that max_reduce kernel problem from documentation and wasn't able to solve it.

Once again thank you.

0 Likes

I've notified the owner of the doc and will attempt to get it fixed in the release.
0 Likes
jski
Journeyman III

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

This seems to work just fine.  ---jski

0 Likes