- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the best method to increase speed up for a loop?
I have parallelize loop but speed up is < 1 infact the serial version is better than parallel version.
Someone can do an example where i can see the efficient of parallel_for ?
This is my code:
task_scheduler_init ( 5 ); -> maybe the error is here?
num_thread = 5;
chunk_inner=int((nel+Ndelay)/num_threads); -> maybe the error is here?
parallel_for (blocked_range(0,Ndelay+nel,chunk_inner), First_Loop (i,nel,direct_i,direct_q),simple_partitioner());
Thanks a lot
I have parallelize loop but speed up is < 1 infact the serial version is better than parallel version.
Someone can do an example where i can see the efficient of parallel_for ?
This is my code:
task_scheduler_init ( 5 ); -> maybe the error is here?
num_thread = 5;
chunk_inner=int((nel+Ndelay)/num_threads); -> maybe the error is here?
parallel_for (blocked_range
Thanks a lot
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The first line creates a task_scheduler_init instance and immediately destroys it; maybe TBB forgets the 5 but I'm not sure. Instead, give the object a name (task_scheduler_init is a type, not a function), and no argument (let TBB figure out the number of threads by itself). Or simply omit the line and rely on implicit initialisation.
chunk_inner is a misnomer, because it is used as a grainsize. Letting it depend on number of worker threads is also bad practice (more small tasks leads to more parallel overhead); instead, make it a constant size.
chunk_inner is a misnomer, because it is used as a grainsize. Letting it depend on number of worker threads is also bad practice (more small tasks leads to more parallel overhead); instead, make it a constant size.

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