IPP and CPU-optimized Code on mulit-core

IPP and CPU-optimized Code on mulit-core

As everyone know, IPP is optimized for the broad range of Intel microprocessors:Intel CoreTM2 Quad processors, Intel CoreTM 2 Duo Processors, Intel Xeon processors, Intel Pentium 4 processor and the Intel Itanium 2 processors.Some quick questions may arise

1. how to make IPP function run with cpu_optimized code.
First, let's understand what is cpu_optimized code.

ippsCopy_8u ( ... )
{ switch ( detected_processor_feature )
{

case SSE4.1:

returnv8_ippsCopy_8u ( ... );

case SSE3:
return t7_ippsCopy_8u ( ... );
case SSE2:
return w7_ippsCopy_8u ( ... );
default: return px_ippsCopy_8u ( ... );
}

}
here the "v8","t7", "w7" are cpu-optimized Code. Please see more fromhttp://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-understanding-cpu-optimized-code-used-in-intel-ipp/

Thensomeof usmay consider the following question what cpu-optimized code should we use? Should we detect the cpu type first?

If youtake look at the code in detial, you willfindthe code "switch ( detected_processor_feature )" . It is cpu type detect code. Actually, IPP can automatically detect CPU type and dispatch the corresponding cpu_optimized codeat run-time. So from user of point of view, you don'tneedworry aboutwhat cpu-optimized codeyou should use. IPP will dothese for you automatically.

Please notes, if you are linking static IPP library, for exmaple, ippiemerged.lib ippimerged.lib, please callippStaticInit() at the begining of your code.

If you are linking Dynamic IPP library, then no thing need to do .

To know how to link IPP , please see

http://software.intel.com/en-us/articles/using-ipp-in-msvc2008/

http://software.intel.com/en-us/articles/how-to-build-ipp-application/

2. How to know the CPU type and which CPU-optimized code the IPP function will run

If you'd like to know what CPU type and which CPU-optimized code you machine are using.You can easily runany of exe fileunder \tools\perfsys, then you will see the message as below

+-----------------------------------------------------------------------------+
| CPU : Intel Core 2 Duo processor, 2x2 GHz, Max cache size 4096 K|
| OS : Microsoft Windows XP Service Pack 3 (Win32) |
| Computer : YHU5-MOBL |
| Library : ippacv8-6.1.dll, 6.1 build 137.15, Apr 10 2009 |
| Test : Timing |
| Mon Sep 14 15:06:25 2009|
+-----------------------------------------------------------------------------+

My machine is running IPP "v8" code and CPU type is Core 2 Duo Processor, 2x2GHZ.

3. How to use only one special CPU-optimized code for my machine

IPP provide one function ippInitCpu ()

Initializes the version of the library code for the specified processor type.

Call it if your exe will run on only one kind of processor.

Or

see the section : single processor static dispath at

http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-intel-ipp-linkage-models-quick-reference-guide/

4. how to run IPP function on Multi-core.

It is another big topic regarding IPP threading feature. We may talk it next time. If you are interested in these, please refer to

http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-threading-openmp-faq/

and

Limiting the Number of Cores of Execution on a Windows System

http://software.intel.com/en-us/articles/limiting-the-number-of-cores-of-execution-on-a-windows-system/

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.