I have an application that has several threads. We are using IPP 7.0.
I want certain functions to run IPP in multi threaded model and some in single threaded model
So I switch between ippSetNumThreads(1) to ippSetNumThreads(N) where N is the number of cores in the machine.
Please answer these questions
1) Thread1 sets ippSetNumThreads(1) and makes a call. Is that guaranteed to run with only one thread ? What if there was a context switch and the other thread also made a call to ippSetNumThreads(N) ?
2) What is the best practice to assure that certain IPP functions run with desired number of threads when we have many threads that make IPP calls ?
Thanks for your help in advance.
ippSetNumThreads() will set the "max" number of the threading the library can run. If the problem size is too small, or the threading is not efficient, the library may not create that number of threadings.
It looks that you are working on the nested threading. Both the application and IPP function may have the threadings. For this case, we are recommend to use the high level application threading, other than internal IPP threading, check this article for some info on this:
Thanks a lot for your answer Chao.
We are using an older version of IPP. And our code base is pretty big. Moving to newer IPP is currently not an option. We have to stick to version 7.0.
Given we will still use 7.0, you recommend us to use ippSetNumThreads(1) everywhere to avoid nested thread issues ?