Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

TBB and Raytracing

pkei
Beginner
268 Views
Hi guys!
I'm new to Intel's TBB and I would like to optimize my raytracing engine.
The problem is, that I don't get any performance boost by using TBB,
which is somehow weird, because it should run faster in a multi-threaded
environment.
What I did so far:
[cpp]tbb::task_scheduler_init init;
init.initialize(4);

...

tbb::blocked_range2d range(0u, SCREENH, GRAN, 0u, SCREENW, GRAN);
tbb::parallel_for(range, tRenderParallel(renderer));[/cpp]
I initialized the task scheduler to use 4 threads and SCREENH, SCREENW and GRAN are the screen resolution and the granularity (I tried values between 1 and 10000 - no effect).
The tRenderParallel calls my renderer with the appropriate clip region.
I understand it in that the way, that the above code is enough to parallelize the system. Can anyone tell me, what's wrong with my approach?
Thanks in advance,
pkei
0 Kudos
2 Replies
TimP
Honored Contributor III
268 Views
You ought to be able to see information on this subject already posted in the TBB section of the forum.
0 Kudos
robert-reed
Valued Contributor II
268 Views
There are no obvious issues with the code you've shared, but as always, the devil is in the details. Need to see tRenderParallel.operator() and perhaps further details to understand what may be preventing your desired scaling, but one sanity question: you are running four threads on a machine that has at least four HW threads, right?
0 Kudos
Reply