Overview
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.
[Reference: http://www.gnu.org/software/octave/about.html*]
Version Information
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
Prerequisites:
- 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.
Unpack:
- 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.
Building Octave
Update configure:
- 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
to
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/
Set environment:
- 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_sequential -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
Running Octave
Add Octave path to environment variable PATH
Then, you should be able to run Octave

Comments
I need to build octave 3.4.2 as the latest io package require >3.4. In the 3.4.2 there is no configure.in (only configure.ac which is used with autoconf) so I can't implement the changes above. For a green belt like me it is a bit difficult to figure out all the nuances so I'll appreiate some guidance.
Thanks in advance.
Hi
You can skip "update configure" and "run autoreconf" steps. It affects only DFT performance.
Victor
I would also like to get 3.4.2 working, but in the meantime am trying to compile 3.2.4 with the instructions above. Problem seems to be that the FFTW3 wrappers seem to not be working fully. I get the following in the configure output. I'm using Intel 12 compilers and 10.3 MKLs. I've also run "make libintel64" in the FFTW wrapper directories. Do I need to do something else? Thanks.
checking fftw3.h usability... yes
checking fftw3.h presence... yes
checking for fftw3.h... yes
checking for fftw_plan_dft_1d in -lfftw3... no
FFTW library not found. Octave will use the (slower) FFTPACK library instead.
Hi,
I managed to get the MKL libraries (v10.3.5) fully linked in today, so I thought I'd put a comment here.
I actually started from this page (most useful, thanks!) and digged into the new configure script to find out how to explicitely specify the libraries.
I am using local versions of gcc/gfortran v4.6.1 and Octave 3.4.2.
Here is my config:
// FLAGS
export F77=gfortran
export CFLAGS="-O2 -fPIC -DMKL_LP64 -DM_PI=3.1415926535897932384"
export FFLAGS="-O2 -fPIC"
export CPPFLAGS="-I/home/rpayan/intel/mkl/include -I/home/rpayan/intel/mkl/include/fftw"
export LDFLAGS="-L/home/rpayan/intel/mkl/lib/intel64 -L/home/rpayan/intel/lib/intel64"
export LD_LIBRARY_PATH="/home/rpayan/local/gcc-4.6.1/lib:/home/rpayan/local/gcc-4.6.1/lib64:/home/rpayan/intel/lib/intel64:/home/rpayan/intel/mkl/lib/intel64:$LD_LIBRARY_PATH"
// Configure command
./configure --prefix=/home/rpayan/local/octave-3.4.2 --enable-docs=no --without-curl --with-blas="-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -liomp5 -lpthread" --with-lapack="-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -liomp5 -lpthread" --with-fftw3="-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -liomp5 -lpthread -lm" --with-fftw3f="-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -liomp5 -lpthread -lm"
Once configure is completed, you can check it has reported correctly the linked libraries for BLAS, LAPACK, FFTW3 and FFTW3F.
When this is done, build your Octave with a simple "make" (multi-thread works fine with -j X where X is the number of parallel threads you want).
Then you can try "make check" to make sure your build is functional, and finally, "make install".
Hope this helps!
Hi Remi,
Thank you very much sharing valuable information, this is useful.
Regards,
Naveen Gv
Hi,
I have tried the above procedure and consistently failed to build...
i got the following error:
oct-alloc.h(33): error: identifier "size_t" is undefined
octave_allocator (size_t item_sz, int grow_sz = 256)
^
oct-alloc.h(40): error: identifier "size_t" is undefined
void *alloc (size_t size);
^
oct-alloc.h(43): error: identifier "size_t" is undefined
void free (void *p, size_t size);
^
oct-alloc.h(58): error: identifier "size_t" is undefined
size_t item_size;
^
oct-alloc.cc(33): error: identifier "size_t" is undefined
octave_allocator::alloc (size_t size)
^
oct-alloc.cc(53): error: identifier "size_t" is undefined
octave_allocator::free (void *p, size_t size)
^
Has anyone had any similar problems ?
Please HELP..
Cheers
laszlo
I'm sorry, but could someone please help. I have followed the steps given and advice given later, but configure still aborts with " error: A BLAS library was detected but found incompatible with your Fortran 77 compiler settings."
Hi
Which C and FORTRAN compiler did you use?
Victor
I tried to compile octave-3.6.3 whit intel composer xe 2013. But in the ./configure step produce this error message:
configure: error: A BLAS library was detected but found incompatible with your Fortran 77 compiler settings