How to Link Your C++ Applications with Intel® DAAL?

签署人: Zhang Zhang

已发布:07/23/2015   最后更新时间:07/23/2015

Intel® Data Analytics Acceleration Library (Intel® DAAL) provides pre-built binary libraries ready to be linked into C++ applications. Linking is supported by all C++ compilers. This article shows linking examples using the Intel C/C++ compiler and GCC. For information on how to use Intel DAAL with Microsoft Visual Studio, refer to the online article Getting Started with Intel Data Analytics Acceleration Library for Windows

We assume the following environment variables are defined:

DAALROOT=<installation location of DAAL>
DAALINCLUDE=$DAALROOT/include

For Intel64 architectures
DAALLIB=$DAALROOT/lib/intel64
For IA-32 architectures
DAALLIB=$DAALROOT/lib/ia32

Linking with Intel C/C++ Compiler

Dynamic linking

The easiest way of linking is to use the -daal (Linux and OS X) or the /Qdaal (Windows) switch. This by default tells the compiler to use threaded (parallel) DAAL, which is equivalent to -daal=parallel (Linux and OS X) or /Qdaal=parallel (Windows). To specify using the sequential (single-threaded) DAAL, use -daal=sequential (Linux and OS X) or /Qdaal=sequential (Windows). For example,

  • On Linux or OS X

    icc -I$DAALINCLUDE daal_test.cpp -daal 
    icc -I$DAALINCLUDE daal_test.cpp -daal=parallel
    icc -I$DAALINCLUDE daal_test.cpp -daal=sequential
  • On Windows

    icc /I%DAALINCLUDE% daal_test.cpp /Qdaal
    icc /I%DAALINCLUDE% daal_test.cpp /Qdaal=parallel
    icc /I%DAALINCLUDE% daal_test.cpp /Qdaal=sequential

Static linking

On Linux or OS X, Intel DAAL static library files include libdaal_core.a, libdaal_thread.a, and libdaal_sequential.a. On Windows, Intel DAAL static library files include daal_core.lib, daal_thread.lib, and daal_sequential.lib. When linking with parallel Intel DAAL, the runtime libraries of OpenMP (libiomp5) and Intel Threading Building Blocks (libtbb) are also needed

  • On Linux or OS X

    icc -I$DAALINCLUDE daal_test.cpp $DAALLIB/libdaal_core.a $DAALLIB/libdaal_thread.a -liomp5 -ltbb -lpthread -lm
    icc -I$DAALINCLUDE daal_test.cpp $DAALLIB/libdaal_core.a $DAALLIB/libdaal_sequential.a -lpthread -lm
  • On Windows

    icc /I%DAALINCLUDE% daal_test.cpp /Qopenmp /Qtbb %DAALLIB%\daal_core.lib %DAALLIB%\daal_thread.lib 
    icc /I%DAALINCLUDE% daal_test.cpp %DAALLIB%\daal_core.lib %DAALLIB%\daal_sequential.lib

​Linking with GCC 

Dynamic linking

  • On Linux or OS X

    g++ -I$DAALINCLUDE daal_test.cpp -L$DAALLIB -ldaal_core -ldaal_thread -liomp5 -ltbb -lpthread -lm
    g++ -I$DAALINCLUDE daal_test.cpp -L$DAALLIB -ldaal_core -ldaal_sequential -lpthread -lm

​Static linking

  • On Linux or OS X

    g++ -I$DAALINCLUDE daal_test.cpp $DAALLIB/libdaal_core.a $DAALLIB/libdaal_thread.a -liomp5 -ltbb -lpthread -lm
    g++ -I$DAALINCLUDE daal_test.cpp $DAALLIB/libdaal_core.a $DAALLIB/libdaal_sequential.a -lpthread -lm

Running applications built with Intel DAAL

Regardless of linking method, applications linked with Intel DAAL require threading runtime libraries to run. On Linux or OS X systems, make sure the environment variable LD_LIBRARY_PATH contains architecture specific directories with libiomp5.so and libtbb.so. On Windows systems, make sure the environment variable PATH contains architecture specific directories with libiomp5md.dll and tbb.dll

If your application links with dynamic Intel DAAL, then LD_LIBRARY_PATH (Linux and OS X) and PATH (Windows) also need to contain architecture specific directories with DAAL runtime libraries. 

The easiest way of setting up environment properly is to use the scripts provided by Intel DAAL:

  • On Linux or OS X:

    source $DAALROOT/bin/daalvars.sh ia32 (for IA-32 architectures)
    source $DAALROOT/bin/daalvars.sh intel64 (for Intel64 architectures)
  • On Windows:
    %DAALROOT%\bin\daalvars.bat ia32 (for IA-32 architectures)
    %DAALROOT%\bin\daalvars.bat intel64 (for Intel64 architectures)

产品和性能信息

1

英特尔的编译器针对非英特尔微处理器的优化程度可能与英特尔微处理器相同(或不同)。这些优化包括 SSE2、SSE3 和 SSSE3 指令集和其他优化。对于在非英特尔制造的微处理器上进行的优化,英特尔不对相应的可用性、功能或有效性提供担保。该产品中依赖于微处理器的优化仅适用于英特尔微处理器。某些非特定于英特尔微架构的优化保留用于英特尔微处理器。关于此通知涵盖的特定指令集的更多信息,请参阅适用产品的用户指南和参考指南。

通知版本 #20110804