Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Shashi_K_
Beginner
92 Views

Switching ippSetNumThreads in threads

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.

Shashi

 


 

 

 

 

0 Kudos
3 Replies
Chao_Y_Intel
Employee
92 Views

Hi Shashi,

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:
https://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-threadin...

Thanks,
Chao

Shashi_K_
Beginner
92 Views

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 ?

Shashi

 

 

 

 

Chao_Y_Intel
Employee
92 Views

Shashi, For nest threading, yes, it is better to disable internal IPP threading, and use the external high level threading. ippSetNumThreads(1) will make IPP choose one threading. but IPP functions will still use OpenMP runtime libraries. If you do not plan to use IPP internal threading, the code can link with non-threaded IPP function, which will not use OpenMP runtime libraries any more. Thanks, chao
Reply