Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
9 Views

Faulty maximum search...

Hi,
I'm a beginner with intel TBB and to understand the principles of parallel_reduce a tried a simple maximum search on a ten-elements vector. Strangely the results I get are sometimes false (on the same entry I can have either the max or the second with about the same probability) I don't get what I messed up and I think that I missed an important point.
Could you please take a look.
Thank you in advance
Alex
0 Kudos
2 Replies
Highlighted
Black Belt
9 Views

Have you studied the examples in the Tutorial? In both constructors, initialise the member variables to neutral values. You must also not assume that operator() is called exactly once for Max: assume it already contains an intermediate result from any number of previous calls. Note that I have not verified the rest of the code, but this should already make a difference.
0 Kudos
Highlighted
Beginner
9 Views

Quoting - Raf Schietekat
You must also not assume that operator() is called exactly once for Max: assume it already contains an intermediate result from any number of previous calls.
That was my mistake... Thank you
0 Kudos