Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

IPP static libs make huge CPU load

Roman_T_
New Contributor I
877 Views

Hi all,

I use IPP 7.1 to process uncompressed images from IP-cam.

So, I have to init my custom DLL, call IPP functions via my own functions inside my DLL and, finally, shut down my DLL.

And of course I have to call IPP functions in accordance with IP-cam FPS. If IP-cam gives me 25 FPS, I have to call IPP-functions 25 times per second.

Everything was fine, when I used dynamic-linkage DLL (as I know, they are multithreaded, so I use ippSetNumThreads(1) to avoid problems in OpenMP). 

But when I tried static linkage, I got huge CPU load. ippStaticInit() call doesn't change anything.

Have I make any additional settings to make CPU load with static and dynamic linkage equal?

 

Best Regards,

Roman

0 Kudos
15 Replies
Naveen_G_Intel
Employee
877 Views

Hi,

You should use the ippInit() function, ippStaticInit() is deprecated.

Regards,

Naveen Gv

0 Kudos
Roman_T_
New Contributor I
877 Views

Naveen Gv (Intel) wrote:

Hi,

You should use the ippInit() function, ippStaticInit() is deprecated.

Regards,

Naveen Gv

 

Hi Naveen,

I replaced ippStaticInit with ippInit, 

nothing has been changed, all 4 cores of my Core i5 are loaded about 100%.

 

Regards,

Roman Tarasov

0 Kudos
Naveen_G_Intel
Employee
877 Views

Hi Roman Tarasov,

You are linking with threaded version of static libraries? If yes, can you disable threading as you have done for dynamic linking?

There could be several reasons to increase the CPU usage because of internal threading as explained in the article.

https://software.intel.com/en-us/articles/high-cpu-usage-and-intel-ipp-threaded-function

I am highly recommending to use IPP 8.2(latest version) and use explicit threading model to parallelize the application.

 

Regards,

Naveen Gv

0 Kudos
Roman_T_
New Contributor I
877 Views

Naveen Gv (Intel) wrote:

Hi Roman Tarasov,

You are linking with threaded version of static libraries? If yes, can you disable threading as you have done for dynamic linking?

There could be several reasons to increase the CPU usage because of internal threading as explained in the article.

https://software.intel.com/en-us/articles/high-cpu-usage-and-intel-ipp-threaded-function

I am highly recommending to use IPP 8.2(latest version) and use explicit threading model to parallelize the application.

 

Regards,

Naveen Gv

 

Hi Naveen,

As I know static libraries for IPP 7.1  exist in single-threaded version only. Is my information correct?

 

Best Regards,
Roman

0 Kudos
Igor_A_Intel
Employee
877 Views

Hi Roman,

IPP 7.1 also contained threaded static libraries. As single threaded IPP doesn't depend on system runtime (only malloc/free were used in 7.1) - it can't load 4 CPUs. Something is wrong at the application side, or you've linked with threaded version and 100% load for all your CPUs may be OMP (libguide) issue - there were some issues with kmp_block_time in some old versions of libguide (by default it was set to 0 that leaded to full CPUs load). An output from ippGetLibVersion will put a light on your problem and set all points above "i"...

regards, Igor

0 Kudos
Roman_T_
New Contributor I
877 Views

Igor Astakhov (Intel) wrote:

Hi Roman,

IPP 7.1 also contained threaded static libraries. As single threaded IPP doesn't depend on system runtime (only malloc/free were used in 7.1) - it can't load 4 CPUs. Something is wrong at the application side, or you've linked with threaded version and 100% load for all your CPUs may be OMP (libguide) issue - there were some issues with kmp_block_time in some old versions of libguide (by default it was set to 0 that leaded to full CPUs load). An output from ippGetLibVersion will put a light on your problem and set all points above "i"...

regards, Igor

Hi Igor,

All LIB files, I'm using now have "_l" at the end. For example ippi_l.lib

Here I put ippGetLibVersion statistics.

Does it all look like multi-threaded IPP version?

Best Regards,
Roman

0 Kudos
Igor_A_Intel
Employee
877 Views

Ok,

I asked for:

void libinfo(void) {
const IppLibraryVersion*
lib = ippsGetLibVersion();
printf(“%s %s %d.%d.%d.%d\n”, lib->Name, lib->Version, lib->major, lib->minor, lib->majorBuild, lib->build);
}
Output:
ippsv8_1.lib 7.0 build 205.68

but if your lib has _l suffixs - it means it's single-threaded (multi-threaded has "_t" suffix).

I don't have any more ideas and can't help without having any reproducer of your issue. The best and most efficient way is to submit your issue to IPS (Intel Premier support). Anyway it also requires a reproducer. The last attempt to help via forum - could you provide your linker cmd line?

regards, Igor

0 Kudos
Roman_T_
New Contributor I
877 Views

Igor Astakhov (Intel) wrote:

Ok,

I asked for:

void libinfo(void) {
const IppLibraryVersion*
lib = ippsGetLibVersion();
printf(“%s %s %d.%d.%d.%d\n”, lib->Name, lib->Version, lib->major, lib->minor, lib->majorBuild, lib->build);
}
Output:
ippsv8_1.lib 7.0 build 205.68

but if your lib has _l suffixs - it means it's single-threaded (multi-threaded has "_t" suffix).

I don't have any more ideas and can't help without having any reproducer of your issue. The best and most efficient way is to submit your issue to IPS (Intel Premier support). Anyway it also requires a reproducer. The last attempt to help via forum - could you provide your linker cmd line?

regards, Igor

Hi Igor,

Here I put the results of your version  ippsGetLibVersion() statistics:

Here I put a linker cmd line from VS2010 project (DLL):

/OUT:"D:\color_test\Release\color_detection.dll" /INCREMENTAL:NO /NOLOGO /LIBPATH:"D:\color_test\Release\" /LIBPATH:"C:\ipp_lib" /DLL "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "ippcc_l.lib" "ippi_l.lib" "ipps_l.lib" "ippcore_l.lib" "ippcv_l.lib" /MANIFEST /ManifestFile:"Release\color_detection.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\color_test\Release\color_detection.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /PGD:"D:\color_test\Release\color_detection.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE 

And  a linker cmd line from VS2010 project (window test tool):

/OUT:"D:\color_test\Release\HiSpeedViewer.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"D:\color_test\Release\" /LIBPATH:"c:\JPEGConverter\Debug" /LIBPATH:"C:\Program Files\Intel\Composer XE 2013\ipp\lib\ia32" /LIBPATH:"..\lib_release" "vfw32.lib" "m_detection.lib" "m_static.lib" "JpegConverter.lib" "HighSpeedDecoder.lib" "color_detection.lib" "ippcc_l.lib" "ippi_l.lib" "ipps_l.lib" "ippcore_l.lib" "ippcv_l.lib" /MANIFEST /ManifestFile:"Release\HiSpeedViewer.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\color_test\Release\HiSpeedViewer.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /PGD:"D:\color_test\Release\HiSpeedViewer.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

And one more question.

I have to call a sequence of IPP functions 25 times per second (I call IPP inside one of functions of my DLL). Does it mean that I have to call ippInit or ippSetNumThreads(1) (in dynamic linkage case) every time I call a sequence of IPP functions?

Best Regards,
Roman

0 Kudos
Pavel_B_Intel1
Employee
877 Views

Hi Roman,

first of all you should call such functions like ippInit(), ippSetNumThreads() only once at the start of your application.

Regarding your issue with multi-threading mode: your linkage lines seems ok, I can't suggest anything... To make sure that IPP works in one thread mode please call ippGetNumThreads() and please share the result with us.

Pavel

0 Kudos
Roman_T_
New Contributor I
877 Views

Pavel Berdnikov (Intel) wrote:

Hi Roman,

first of all you should call such functions like ippInit(), ippSetNumThreads() only once at the start of your application.

Regarding your issue with multi-threading mode: your linkage lines seems ok, I can't suggest anything... To make sure that IPP works in one thread mode please call ippGetNumThreads() and please share the result with us.

Pavel

Hi Pavel,

I discovered some unexpected results.

My VS2010 solution has more than one project. First project is DLL for data processing, second project is window-based application (UI). Both projects use IPP.

But I found, that I use one additional DLL (a result of my very old project). This DLL is just to decompress JPEG to uncompressed DIB...and it uses dynamically linked IPP.

So my window based UI, with statically linked IPP uses JPEG decoder with dynamically linked IPP (it is not a part of VS2010 solution because I  use it as a compiled DLL).

Everything is fine when all parts of project use dynamically linked IPP, But when I switch solution to static link to IPP CPU load becomes huge.

Today I enabled non-IPP JPEG decoder. Situation became not very good (this decoder is very slow) but understandable.

One of cores of Core i5 has a load about 80% and other 3 cores have a load less than 10% with no dependence on kind of IPP linkage.

But now I have the next question...If UI application and DLL for JPEG decoding use the same version of IPP, is it necessary to use the same method of linkage? What will be if this DLL is a commercial project and I don't have its source code?

 

Best regards,
Roman

0 Kudos
Igor_A_Intel
Employee
877 Views

ok, now something has become clear. Please try to substitute libiomp dll that is used with your jpeg-devoted dll with the libiomp from the IPP package you use - as I've already mentioned above - some rather old libiomp dlls has a bug with kmp_block_time variable and because of that load all cpus on 100%.

regards, Igor

0 Kudos
Pavel_B_Intel1
Employee
877 Views

Hi Roman,

regarding your question:

But now I have the next question...If UI application and DLL for JPEG decoding use the same version of IPP, is it necessary to use the same method of linkage? What will be if this DLL is a commercial project and I don't have its source code?

You can use any linkage methods as you wish, IPP doesn't have any requirements regarding it. You only should satisfy OS requirements, for example: DLL is self-sufficient module, it can be linked with IPP DLLs and ippInit() function should be called inside the DLL to initialize IPP dispatcher for these functions that are used inside the DLL. An application can use the DLL and the application can be additionally linked with IPP static or dynamic versions. The application know nothing about IPP inside the DLL and the application should call ippInit() function to initialize IPP dispatcher for the functionality which are used in the application. It is possible to have +1 or +2 or more and more DLLs which are used by the application and each DLL can be linked with IPP static or dynamic versions.

When we are talking about linkage - we should think about self-sufficient modules and we should talk about how each module is linked with IPP separately.

I hope I described the example clearly :-)

Pavel

0 Kudos
Ying_H_Intel
Employee
876 Views

Hi Roman T. and all, 

Just recalled one issue related JPEG codec, just for your reference. 

Please search your whole code and see if there is ippGetCpu*  code.    I recalled, one auxiliary function like get  Cpu frequency, which is only for computing the performance. It was called in a loop   and  cost much cpu workloads.  Please remove it if possible. 

Best Regards,

Ying

 

0 Kudos
Sergey_K_Intel
Employee
876 Views

Hi, I would say, that ippGetCpuFreqMHz doesn't cause high CPU load. It waits for long to collect clock data, so its usage is not recommended in the loops, but not 100% CPU load.

0 Kudos
Roman_T_
New Contributor I
876 Views

Dear Sirs,

I integrated my IPP-based data processing DLL to our video surveillance system.  I think this branch can be closed.

Best regards,

Roman 

0 Kudos
Reply