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

Expression: my_owner

michaelaeriksen
Beginner
249 Views

I get this strage error when I try to execute a parallel_for from a worker thread. And yes I didcall task_scheduler_init, but from the main thread.

The error is an assertion:

Expression: my_owner

Thread has not activated a task_scheduler_init object?

the assertion is thrown at

task_group_context ( kind_type relation_with_parent = bound )

: my_kind(relation_with_parent)

, my_version(0)

{

init();

}

0 Kudos
1 Reply
Andrey_Marochko
New Contributor III
249 Views
Hi, Michael

Was the worker thread created by you (using _beginthreadex, CreateThread, pthread_create or some other API)? If so, then you need to use task_scheduler_init there as well. The common rule is that you need to initialize TBB scheduler in every thread created by yourself (or by OS for you - like the main thread of your app).

Just so that it made more sence, TBB needs to have a separate instance of its scheduler in each thread that works with TBB tasks (or where TBB's parallel algorithms are used). Such a design drastically decreases the amount of costly inter-thread communication. Each thread maintains a local pool of task, and only when it gets empty tries to steal some work from other threads.

0 Kudos
Reply