- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
class SumFoo {
float* my_a;
public:
float my_sum;
void operator()( const blocked_range
float *a = my_a;
float sum = my_sum;
size_t end = r.end();
for ( size_t i=r.begin(); i!=end; ++i )
sum += a;
my_sum = sum;
}
SumFoo( SumFoo& x, split ) : my_a(x.my_a), my_sum(0.0f) {}
void join( const SumFoo& y ) {
std::cout<
my_sum+=y.my_sum/2;
}
SumFoo(float* a ) :
my_a(a), my_sum(0)
{}
};
float ParallelSumFoo( float* a, size_t n ) {
SumFoo sf(a);
parallel_reduce( blocked_range
return sf.my_sum;
}
As you can see, I put a cout line in join function. I also tried to play with the my_sum. But when I run this program, the cout line never shows up. And no matter what I play with the my_sum+=y.my_sum/2; or even commend it out, the result is still the same.
So when, how is join function used here?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I put a cout in the operator() function, I can see the different range gets executed. But it seems the join is never called, which is very strange to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(Edited 07:15Z.)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page