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

queue_node is slow

Hi
I am new to Intel TBB, and am trying to write some code which uses a flow graph.
I have a reader class to read data from a file which I want to queue using a buffer (there are other classes which read data from this buffer and process it). Here is what I tried:
[cpp]graph g; data_source the_source(g, reader(p, db, iter, cont), false); data_pool the_data_pool(g); try { task_scheduler_init init(p.num_threads); make_edge(the_source, the_data_pool); tick_count begin=tick_count::now(); the_source.activate(); g.wait_for_all(); tick_count end=tick_count::now(); cout << (end-begin).seconds() << "seconds " << endl; } catch(std::exception& e) { cerr<<"error occurred. error text is :"" <
data_pool is a queue_node. This takes about 7 seconds to read a file with 100,000 lines.
The reader only takes around 3 - 3.5 seconds. I verified this by using the following code:
[cpp]graph g; data_pool the_data_pool(g); reader r(p, db, iter, cont); size_t idx; while(r(idx)){ } [/cpp]
To confirm that it is the queing that is taking up more time I used the following code:
[cpp]
[/cpp][cpp]graph g; data_pool the_data_pool(g); reader r(p, db, iter, cont); size_t idx; while(r(idx)){ the_data_pool.try_put(idx); the_data_pool.try_consume(); }[/cpp]
and sure enough the time doubles. I am wondering why merely queing up data takes up so much time.
Please ask if you need any other information. I am using the tbb installed by macports
tbb @4.0-20120201 (devel)
thanks
vishy
0 Kudos
0 Replies