How to link to Intel® IPP for macOS* Libraries in an Application

Intel® Parallel Studio started to be compatible with macOS* Sierra* with the 2017 update 1 version. To install all versions later than Intel® Parallel Studio 2017 update 1, please remember to upgrade your operating system to macOS 10.12 (Intel® 64). This document provides information on using Intel® Integrated Performance Primitives (Intel® IPP) 2017 update 3 with Intel® C++ Compiler and Apple LLVM* 8.1 in the Xcode* 8.3.3 integration development environment (IDE) and on the command line. In each case, the path to the Intel IPP header files and libraries is added to the project settings or command line.

Prerequisite
Build in Xcode IDE
With default Xcode Compiler
With Intel® C/C++ Compiler

Command line
With Clang* Compiler
With Intel® C/C++ Compiler

Prerequisite:

Intel IPP and Intel® Math Kernel Library (Intel MKL) for macOS* are only available as components in Intel Parallel Studio XE Composer Edition for C++ macOS now. (The first integration happened in Intel IPP version 7.0 in Intel® C++/Fortran Composer XE 2011 for macOS.) This documentation is using:

  • macOS Sierra Version 10.12.5, Xcode Version 8.3.3, Default C/C++ compiler (Apple LLVM 8.1)
  • Intel Parallel Studio XE Composer Edition for C++ macOS
  • Intel IPP Example

If you plan to work in the Xcode integration environment, please check the option “Both command line and Xcode integration environment” when installing Intel Parallel Studio XE.

After installation, Intel IPP provides sample code under the default directory. Copy the ipp-examples.tgz to a folder ~/Desktop and untar it.

$cd /opt/intel/composer_xe_2015.0.071/ipp/examples/ ipp-examples.tgz

$cp ipp-examples.tgz  ~/Desktop/.

$tar –xzvf ipp-examples.tgz

We use the sample project ipp_resize_mt/ ipp_resize_mt.xcodeproj and src/ ipp_resize_mt.cpp in the directory examples.  

Xcode IDE

Step 1. Start Xcode and create a new project with OS X » Application » Command Line Tool. 

I created an application called "IPP_FilterSobel". You could refer to existing Xcode IPP project "ipp_resize_mt.xcodeproj" from <IPPROOT>/examples/components/examples_core/ipp_resize_mt/ . The <IPPROOT> would be defined as /opt/intel/compilers_and_libraries_2017.4.181/mac/ipp by default.

Step 2. Setting link to Intel IPP headers and libraries

  1. Click Build Settings tag to modify settings.
  2. Select the Header Search Paths field and type.
    /opt/intel/ipp/include
  3. Select the Library Search Paths field and type.
    /opt/intel/ipp/lib
  4. Select the Other Linker Flags field and type in the linker flags for the libraries you wish to link to.
    For dynamic linking:
    ·         -lippi –lipps -lippvm –lippcore
    For static linking:
    ·         /opt/intel/ipp/lib/libippi.a  /opt/intel/ipp/lib/libipps.a /opt/intel/ipp/lib/libippvm.a /opt/intel/ipp/lib/libippcore.a

Note: For the Intel IPP for macOS commercial package, the Intel IPP static and dynamic libraries are installed in the same directory $IPPROOT/lib. If linking with -lipp*, the standard linker used by Xcode first chooses a dynamic library over a static library. If you need to use static, please link to the static libraries by using the full path and library name as shown in the examples above.

Step 3. Build project in Xcode

Build using Product » Build. Please check with marked modified components in the following image:

Intel C++ Compiler

If you plan to use the Intel® compiler, please read the Intel C/C++ Compiler user and reference guide.

The Intel C++ Compiler comes bundled with several Intel® Performance Libraries. To access these libraries in Xcode, use the following Target Info properties, located in the Intel C++ Compiler Performance Library Build Components category:

·         Use Intel® Integrated Performance Primitives Libraries (Intel® IPP)
·         Use Intel® Math Kernel Library (Intel® MKL)
·         Use Intel® Threading Building Blocks Library (Intel® TBB)
·         Use Intel® Data Analytics Acceleration Library (Intel® DAAL)

The Use Intel Integrated Performance Primitives Libraries property provides the following options in a drop-down menu:

·         None: Disable use of Intel® IPP.
·         Use main libraries set (-ipp=common): Use all libraries except Cryptography libraries.
·         Use main libraries and cryptography library (-ipp=crypto): Use Cryptography libraries and main libraries.

  1. In the Xcode IDE, create a new C++ console project.
  2. In the Build Settings page, select the All tab.
  3. Select the Compiler for C/C++/Objective-C filed, select ICC Intel® C++ Compiler 17.0. While using the Intel Compiler, all settings for the compiler will appear.
  4. Then you will find a filed called ICC Intel® C++ Compiler XE 17.0 – Performance Library Build Components. Set the value of Use Intel® Integrated Performance Primitives Libraries to Use main Library set (-ipp=common) 
  5. Build the project from Xcode menu Product >> Build​.

Note 1: If you are using dynamic linking, you will need to add the path to the dynamic libraries to the system environment so that they are invoked at runtime.

Here is one way to add the run-time environment in Scheme Editor:
1.     From the Xcode menu, click Product » Scheme » Edit Scheme…» Run
2.     Select the Arguments tab.
3.     Under Environment Variables, click the [ + ] button.
4.     Under the Name field, type DYLD_LIBRARY_PATH.
5.     Under the Value field, type /opt/intel/ipp/lib.

Note 2: For some projects which need an image file as an input, you can add the working directory of the input image in the Scheme Editor:
1. From the Xcode menu click Product » Scheme » Edit Scheme…» Run.
2. Select the Options tab.
3. Go to the working Directory, check the box Use custom working directory, then add the directory of the input image.

Command line

Here we discuss building and linking an IPP example project "ipp_resize_mt" with MKL. Users can access the example from $IPPROOT/examples/components_and_examples_mac_ps/components/examples_core/

Set environment variable as below
$ source /opt/intel/ipp/bin/ippvars.sh

Build the project from the command line:

$ xcodebuild -project ipp_resize_mt.xcodeproj

$ build/Release/ipp_resize_mt

Or from the command line:
Suppose the libcommon.a is built by $xcodebuild -project common.xcodeproj

For dynamic linking

$clang++ src/ipp_resize_mt.cpp -I/opt/intel/composer_xe_2017.4.181/ipp/include -I../common/include -L/opt/intel/ipp/lib -lippi -lipps -lippvm -lippcore -stdlib=libc++ /Users/yhu5/Desktop/examples/common/build/Release/libcommon.a

$./a.out

For static linking

$clang++ src/ipp_resize_mt.cpp -I/opt/intel/composer_xe_2017.4.181/ipp/include -I../common/include /opt/intel/ipp/lib/libippi.a  /opt/intel/ipp/lib/libipps.a  /opt/intel/ipp/lib/libippvm.a /opt/intel/ipp/lib/libippcore.a -stdlib=libc++ /Users/yhu5/Desktop/examples/common/build/Release/libcommon.a

Intel C++ Compiler

$source /opt/intel/composer_xe_2017.4.181/bin/iccvars.sh intel64
$icc src/ipp_resize_mt.cpp -I../common/include -ipp /Users/yhu5/Desktop/examples/common/build/Release/libcommon.a

Note*: The Intel Compiler links the static Intel ipp library by default (that may change in a different version).  If you plan to use dynamic linking, then use the common line:

$icc src/ipp_resize_mt.cpp -I../common/include –ipp-link=dynamic –ipp /Users/yhu5/Desktop/examples/common/build/Release/libcommon.a

Operating System:

>macOS

Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.