- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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();
}
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.

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