Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Reinitializing task_scheduler_init fails

jkomarov
Beginner
125 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
125 Views
Which version of TBB do you use?
jkomarov
Beginner
125 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
125 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
125 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