This guide is intended to help the current Octave users to potentialy improve performance by utilizing Intel® Math Kernel Library (Intel® MKL). It explains how to build 64-bit Octave with Intel MKL for Intel64 based applications.
GNU Octave is a high-level language, primarily intended for numerical computations. It provides a convenient command line interface for solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with Matlab*. It may also be used as a batch-oriented language.
Octave has extensive tools for solving common numerical linear algebra problems, finding the roots of nonlinear equations, integrating ordinary functions, manipulating polynomials, and integrating ordinary differential and differential-algebraic equations. It is easily extensible and customizable via user-defined functions written in Octave's own language, or using dynamically loaded modules written in C++, C, Fortran, or other languages.
This application note was created to help users who use Octave to also incorporate the latest versions of Intel MKL 10.3.2 or higher on Linux* platforms on Intel® Xeon® *processor-based systems. Specifically, we'll address Intel MKL version 10.3.2.
This application note applies to Intel Composer XE 2011 and Octave 3.2.4
Note: One can use Intel MKL FFTW3 wrappers in Octave only with Intel MKL 10.3.2 or higher. For using the previous versions please contact the Intel MKL team.
Downloading Intel tools & Octave source code
- Intel® MKL contains highly optimized BLAS, LAPACK, and FFT and also the wrappers for FFTW, which can be obtained at: Intel® Math Kernel Library Product Page.
- Obtain Intel® C++ and Fortran compilers (Intel MKL and Intel Compilers are now available in a single package - Intel Composer XE 2011).
- To get Octave - http://www.gnu.org/software/octave/
Note: This application note is written specifically for use with the Intel® compilers. Though using Intel MKL with Octave built with other compilers is also possible.
- Use the following commands to extract the Octave files:
tar -xf octave-x.x.x.tar.gz
This will create a directory called octave-x.x.x.
- Change configure.in. Please find in the file the lines below and change them from
1. if test "$with_fftw" = yes; then 2. have_fftw3_header=no 3. with_fftw3=no 4. AC_CHECK_HEADER(fftw3.h, [have_fftw3_header=yes]) 5. if test "$have_fftw3_header" = yes; then 6. AC_CHECK_LIB(fftw3, fftw_plan_dft_1d, [ 7. AC_CHECK_LIB(fftw3f, fftwf_plan_dft_1d, [FFTW_LIBS="-lfftw3 -lfftw3f"; with_fftw3=yes])]) 8. fi 9. fi
1. if test "$with_fftw" = yes; then 2. have_fftw3_header=no 3. with_fftw3=no 4. AC_CHECK_HEADER(fftw3.h, [have_fftw3_header=yes]) 5. if test "$have_fftw3_header" = yes; then 6. AC_CHECK_LIB(fftw3, fftw_plan_dft_1d, [ 7. AC_CHECK_LIB(fftw3f, fftwf_plan_dft_1d, [FFTW_LIBS="-lfftw3 -lfftw3f"; with_fftw3=yes])]) 8. # Add MKL check 9. AC_CHECK_LIB(mkl_intel_lp64, fftw_plan_dft_1d, [FFTW_LIBS="-Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -WI, --end-group -liomp5 -lpthread"; with_fftw3=yes],AC_MSG_RESULT("MKL library not found. Octave will use the FFTW3 instead."),[-Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread]) 10. fi 11. fi
- Run autoreconf without any parameters. Autoconf (that includes autoreconf) could be found here http://www.gnu.org/software/autoconf/
- Make sure that C/C++ and Fortran compilers are installed and in the PATH. Set LD_LIBRARY_PATH to your compiler (C/C++ and Fortran), and Intel MKL libraries. Also set MKLROOT to you MKL directory.
There are environment setters in both Intel MKL and Intel CCompiler installation directories: source .../mkl/bin/mklvars.sh intel64 or like that
- Set next environment variable: CC, CXX, F77, CFLAGS, CPPFLAGS, LDFLAGS as follow
1. export CC=icc 2. export CXX=icc 3. export F77=ifort 4. export CFLAGS="-O3 -ipo- -std=c99 -fPIC -DMKL_LP64 -DM_PI=3.1415926535897932384" 5. export CPPFLAGS="-I$MKLROOT/include -I$MKLROOT/include/fftw" 6. export LDFLAGS="-L$MKLROOT/lib/intel64 -L$MKLROOT/../compiler/lib/intel64" 7. export LD_LIBRARY_PATH="$MKLROOT/lib/intel64:$MKLROOT/../compiler/lib/intel64:$LD_LIBRARY_PATH"
Configure and make
Build Octave and install it in the standard place
1. configure --with-blas="-Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread" --with-lapack="-Wl,--start-group -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -Wl,--end-group -liomp5 -lpthread" 2. make 3. make install
Add Octave path to environment variable PATH
Then, you should be able to run Octave