- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am rather new to TBB and this might be a silly problem, but here goes. I have a very simple application (see code bellow) that creates a task tree in a recursive manner. I can control the number of tasks to be created (the depth of the tree) and the amount of work the leaf nodes execute. My problem is that the number of tasks I know this application creates and the number of tasks TBB reports (in the statistics.txt file) don't match. For instance, when I run the application with a tree depth of 5 (resulting in 32 tasks), the statistics.txt file records 63 total tasks. I even added a counter in the scheduler.cpp/generic_scheduler::local_spawn method and for the above exeample, this method is called 31 times (an extra call is done for the generic_scheduler::local_spawn_root_and_wait). I tried to understand how the TBB statistics are counted, but I failed. Can anybody tell why the big difference between the 2 counters?
using namespace std;
using namespace tbb;
typedef long long value;
int loop( int n )
{
int i;
long int s=0;
for( i=0; i<n; i++ )
{
s += i;
}
return s;
}
struct StressTask: public task {
value n;
int d;
// task arguments
StressTask( value n_, int d_ ) :
n(n_), d(d_)
{}
//! Execute task
task* execute() {
if( d > 0 ) {
StressTask& a = *new( allocate_child() ) StressTask( n, d-1 );
StressTask& b = *new( allocate_child() ) StressTask( n, d-1 );
set_ref_count(3);
spawn( a );
spawn_and_wait_for_all( b );
}
else
loop( n );
return NULL;
}
};
void stress(value n, int depth, int itr)
{
int i;
for( i=0; i<itr; i++)
{
StressTask& a = *new(task::allocate_root()) StressTask(n, depth);
task::spawn_root_and_wait(a);
}
printf( "DONE\n" );
}
int main(int argc, char* argv[])
{
value n;
int depth,itr,nth;
static tick_count t0;
if (argc<4)
printf("\nUsage: ./stress.tbb <number_of_operations> <depth_of_tree> <number_of_iterations> <number_of_threads>\n");
else{
n = strtol(argv[1],0,0);
depth = (int)strtol(argv[2],0,0);
itr =(int)strtol(argv[3],0,0);
nth = (int)strtol(argv[4],0,0);
task_scheduler_init scheduler_init(nth);
t0 = tick_count::now();
stress(n,depth,itr);
printf("\nExecution time: %f sec\n",(tick_count::now() - t0).seconds());
}
return 0;
}
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
- 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
- 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
- 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
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page