The code example below represents a short application to help you get started with Intel® IPP. It illustrates several key concepts:
#include "ipp.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
const IppLibraryVersion *lib;
Ipp64u fm;
ippInit(); //Automatic best static dispatch
//ippInitCpu(ippCpuSSSE3); //Select a specific static library level
//Can be useful for debugging/profiling
//Get version info
lib = ippiGetLibVersion();
printf("%s %s\n", lib->Name, lib->Version);
//Get CPU features enabled with selected library level
fm=ippGetEnabledCpuFeatures();
printf("SSE2 %c\n",(fm>>2)&1?'Y':'N');
printf("SSE3 %c\n",(fm>>3)&1?'Y':'N');
printf("SSSE3 %c\n",(fm>>4)&1?'Y':'N');
printf("SSE41 %c\n",(fm>>6)&1?'Y':'N');
printf("SSE42 %c\n",(fm>>7)&1?'Y':'N');
printf("AVX %c OS Enabled %c\n", (fm>>8)&1 ?'Y':'N', (fm>>9)&1 ?'Y':'N');
printf("AES %c CLMUL %c\n", (fm>>10)&1?'Y':'N', (fm>>11)&1?'Y':'N');
return 0;
}
This application consists of the three sections:
IPP initialization. This stage is required to take advantage of full IPP optimization. While an IPP program will run without ippInit(), by default the least optimized implementation will be chosen. With ippInit() the best optimization layer will be dispatched at runtime. Occasionally, such as certain debugging scenarios, it is helpful to force a specific implementation layer instead of the best as chosen by the dispatcher - in this case ippInitCpu can be used.
Get the library layer name and version. You can also get the version information using the ippversion.h file located in the /include directory.
Show the hardware optimizations used by this library layer.
To build the code example above on Linux, follow the steps:
Paste the code into the editor of your choice.
Make sure the compiler variables are set in your shell. To set the variables, run the compilervars.h.
Compile with icc ipptest.cpp -o ipptest -I$IPPROOT/include -L$IPPROOT/lib/intel4 -lippi - lipps - lippcore.
Run with ./ipptest.