Static Linking with Dispatching

Some applications use only a few Intel IPP functions and require a small memory footprint. Using the static link libraries offers both the benefits of a small footprint and optimization on multiple processors. The static libraries (such as libipps_l.a) provide an entry point for the non-decorated (with normal names) Intel IPP functions, and the jump table to each processor-specific implementation. When linked with your application, the function calls corresponding functions in accordance with the CPU setting detected by functions in libippcore_l.a.

If you want to use the threaded functions of Intel IPP, you need to link to the threaded versions of the static libraries (such as libipps_t.a), and threaded version libippcore_t.a.

You can choose one of the following functions to initialize the libraries:

One of these functions must be called before any other IPP functions. Otherwise, a C-optimized version of the IPP functions is called. This can decrease the performance of your application. The following example illustrates the performance difference. This example appears in the t2.cpp file.

Example: Performance difference with and without calling StaticInit

                #include <stdio.h>
                #include <ipp.h>
                
                int main() {
                   const int N = 20000, loops = 100;
                   Ipp32f src[N], dst[N];
                   unsigned int seed = 12345678, i;
                   Ipp64s t1,t2;
                   /// no StaticInit call, means PX code, not optimized
                   ippsRandUniform_Direct_32f(src,N,0.0,1.0,&seed);
                   t1=ippGetCpuClocks();
                   for(i=0; i<loops; i++)
                      ippsSqrt_32f(src,dst,N);
                   t2=ippGetCpuClocks();
                   printf("without StaticInit: %.1f clocks/element\n",
                         (float)(t2-t1)/loops/N);
                   ippStaticInit();
                   t1=ippGetCpuClocks();
                   for(i=0; i<loops; i++)
                      ippsSqrt_32f(src,dst,N);
                   t2=ippGetCpuClocks();
                   printf("with StaticInit: %.1f clocks/element\n",
                         (float)(t2-t1)/loops/N);
                   return 0;
                }
                
                
                
                t2.cpp
                cmdlinetest>t2
                without StaticInit: 61.3 clocks/element
                with StaticInit: 4.5 clocks/element

The following table summarizes the features of static linking to help you understand the benefits and drawbacks of this linking method.

Summary of features of the static linking (with dispatching)

Benefits

Drawbacks

  • Dispatches processor-specific optimizations during run-time

  • Creates a self-contained application executable

  • Generates a smaller footprint than the full set of Intel IPP SOs

  • Intel IPP code is duplicated for multiple Intel IPP-based applications because of static linking

  • An additional function call for dispatcher initialization is needed (once) during program initialization

Follow these steps to use static linking with dispatching:


  1. Includeipp.h in your application. This header includes the header files of all IPP domains.

  2. Initialize the static dispatcher using either function ippStaticInit() or ippInitCPU(), which are declared in the header file ippcore.h.

  3. Call IPP functions using normal, undecorated function names.

  4. Link corresponding static libraries, and then libippcore_l.a or libippcore_t.a. For example, if you use the function ippsCopy_8u(), the linked libraries are libipps_l.a and libippcore_l.a.

Optimization Notice

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804


Submit feedback on this help topic

Copyright © 2008 - 2011, Intel Corporation. All rights reserved.