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

Reinitializing task_scheduler_init fails

jkomarov
Beginner
312 Views
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
312 Views
Which version of TBB do you use?
0 Kudos
jkomarov
Beginner
312 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.
0 Kudos
Andrey_Marochko
New Contributor III
312 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.
0 Kudos
jkomarov
Beginner
312 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.
0 Kudos
Reply