- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm reading ITBB and there is something I cant get about the "load-balanced execution".
Supose one want to apply a function wich complexity depends upon the index of the array, e.g.,
class ApplyFoo {
float *const my_a;
public:
void operator() ( const blocked_range& r ) const {
float *a = my_a;
for( size_t i=r.begin();i!=r.end();i++){
for(size_t j=0;j!=i*i;j++)//complexity n^2
a += j;
}
}
ApplyFoo( float a[] ) :
my_a(a)
{}
};
The cuestion is how this will be "load-balanced" if one have enough cores to make all the task run indepently?
thanks,
sebastian
I'm reading ITBB and there is something I cant get about the "load-balanced execution".
Supose one want to apply a function wich complexity depends upon the index of the array, e.g.,
class ApplyFoo {
float *const my_a;
public:
void operator() ( const blocked_range
float *a = my_a;
for( size_t i=r.begin();i!=r.end();i++){
for(size_t j=0;j!=i*i;j++)//complexity n^2
a += j;
}
}
ApplyFoo( float a[] ) :
my_a(a)
{}
};
The cuestion is how this will be "load-balanced" if one have enough cores to make all the task run indepently?
thanks,
sebastian
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The blocked_range used above is a "splittable" range. Some thread is going to get stuck with the upper end of i and be bogged down added j to a[something] but the other threads will be working on the other end of the range and finish their work more quickly. Then they will come looking for work and start stealing parts of the high-range task's assignment range. Thus the work will be balanced among the available threads.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page