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

Static Scheduling in TBB?

yoavhacohen
Beginner
517 Views
Hello,
I use TBB for parallelizing my code.
However, due to the dynamic scheduling, the result is not deterministic.
For testing, I do want the code to be parallel (to gain the speedup), but I would like to use static scheduling.
Is it possible to use static scheduling with TBB?
Thanks in advance,
Yoav
0 Kudos
2 Replies
Alexey-Kukanov
Employee
517 Views
If you mean something a-la OpenMP schedule(static), it does not exist. First, OpenMP fixes the number of threads in a parallel region, so schedule(static) can divide the work equally between the threads. In TBB, the number of threads handling parallel_for tasks can change dynamically.
Partitioning of the overall iteration space intowork chunksis deterministic with simple_partitioner, and non-deterministic with auto_ and affinity_partitioner. Mapping of work chunks to threads is always dynamic and nondeterministicin TBB, done by its work stealing scheduler.

Under the result not being deterministic, what exactly do you mean? Maybe we could suggest some ideas how to deal with the trouble.
0 Kudos
RafSchietekat
Valued Contributor III
517 Views
Just to cover the basics (although you would have read that in the documentation): the ultimate deterministic execution is where task_scheduler_init is used to specify single-threaded execution. TBB is about optional parallelism without required concurrency partly to allow such simple static scheduling. Did you try it yet?
0 Kudos
Reply