Expression: my_owner

Expression: my_owner

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();

}

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.

Leave a Comment

Please sign in to add a comment. Not a member? Join today