Intel® IPP for Mac OS* - How to link to the Intel® IPP for Mac OS* X in application?

Intel® Parallel Studio start to compatible with macOS Sierra since 2017 update 1 version. To install all version later than Intel® Parallel Studio 2017 update 1, please remember to upgrade operating system to macOS 10.12.* (Intel(R) 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 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 Mac OS* X are only available as components in Intel® Parallel Studio XE Composer Edition for C++ OS X* now. (The first integration was happened since Intel IPP version 7.0 in Intel® C++/Fortran Composer XE 2011 for Mac OS* X.) This documentation is using

  • Mac OS* X 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++ OS X*
  • Intel IPP Example

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

After install, Intel IPP provides sample code under 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 create an application called "IPP_FilterSobel". You could refer to open exist 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 to link with 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 Mac OS* commercial package, the Intel® IPP static and dynamic libraries are installed in the same directory $IPPROOT/lib. If link with -lipp*, the standard linker used by Xcode* first chooses a dynamic library over a static library. And 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 by Product » Build, please check with marked modified components in following image:

Intel C++ Compiler

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

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 Xcode IDE, create a new C++ console project.
  2. In 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 Intel compiler, all settings for compiler would appear.
  4. Then you could 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 then you 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 project need an image file as an input, you could add the customer working directory of input image in the Scheme Editor, 
1. From the Xcode menu click Product » Scheme » Edit Scheme…» Run 
2. Select the Options tab
3. Go working Directory, check the box Use custom working directory, add the directory of input image.

Command line

Here we discuss building and linking an IPP example project "ipp_resize_mt" with MKL. Users could 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 command-line

$ xcodebuild -project ipp_resize_mt.xcodeproj

$ build/Release/ipp_resize_mt

Or from 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*: Intel compiler link static Intel ipp library by default (may change in 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:

>Mac OS*

For more complete information about compiler optimizations, see our Optimization Notice.

1 comment

Top
Royi's picture

It doesn't seem to work if the output is "Bundle".

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.