Community
cancel
Showing results for 
Search instead for 
Did you mean: 
jkomarov
Beginner
54 Views

Reinitializing task_scheduler_init fails

Hello,

I try to reinitialize the globaltask_scheduler_init variable to use another number of working threads in my large MFC-based application. I do it this way:
[bash]stop_my_calc();//completely stop all calculation 
tsi.terminate();//tsi is the global task_scheduler_init variable
tsi.initialize(new_number_of_threads);
restart_my_calc();//restart calculation[/bash]
However the application keep using the previous number of working threads according to the Task Manager.
I can't reproduce this behavior in a small test application.
What can cause it? What is worth to check?
Best regards,
Ivan.
0 Kudos
4 Replies
Andrey_Marochko
New Contributor III
54 Views

Which version of TBB do you use?
jkomarov
Beginner
54 Views

Tried both 2.2 and 3.0.Couldn'tcompile them unfortunately.
The problem is related somehow to the fact that during "stopping" process not all resources are being freed correctly.
Andrey_Marochko
New Contributor III
54 Views

A possible reason could be that when you initialize/terminate scheduler, another instance already exists. E.g. this may happen because of auto-initialization that takes place when you work with tasks, task group contexts, or parallel algorithms without scheduler explicitly initialized via task_scheduler_init object.
jkomarov
Beginner
54 Views

The problem is solved.
There is a non-TBB working thread in that code that uses (but doesn't host) TBB ones. At the stop step it used to be just killed. Fixed it to allow it to get terminated correctly.
Reply