**- Undocumented Matlab - https://undocumentedmatlab.com -**

Math libraries version info & upgrade

Posted By Yair Altman On July 17, 2013 | __7 Comments__

* version* is a well-known Matlab function, which displays and returns information about the installed release:

>> [v,d] = version v = 8.1.0.604 (R2013a) d = February 15, 2013 >> version('-java') ans = Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode

This is pretty boring stuff. But it starts to get interesting when we learn the undocumented fact that * version* can also report version information of the installed math libraries, starting in R2009b (Matlab 7.9):

% R2013a (Matlab 8.1) on Win7 64b >> version('-fftw') ans = FFTW-3.3.1-sse2-avx >> version('-blas') ans = Intel(R) Math Kernel Library Version 10.3.11 Product Build 20120606 for Intel(R) 64 architecture applications >> version('-lapack') ans = Intel(R) Math Kernel Library Version 10.3.11 Product Build 20120606 for Intel(R) 64 architecture applications Linear Algebra PACKage Version 3.4.1

This information is sometimes useful, and is sometimes asked ^{[3]} by users. Specific versions of BLAS ^{[4]}, LAPACK ^{[5]} and FFTW ^{[6]}, which Matlab uses under its hood for all linear algebra and FFW computations, may exhibit idiosyncrasies that may be important in certain cases.

In versions up to R2013a, this information could also be retrieved using the * internal.matlab.language.versionPlugins.** mex functions (e.g.,

Here is a summary of the math libraries version in recent Matlab releases (Windows only):

Matlab release | FFTW | MKL (BLAS) | LAPACK |
---|---|---|---|

R2009b SP1 (7.9.1) | 3.2.0-sse2 | 10.2.2 (2009-08-14) | 3.1.1 |

R2010a (7.10) | 3.2.2-sse2 | 10.2.2 (2009-08-14) | 3.2.1 |

R2010b (7.11) | 3.2.2-sse2 | 10.2.3 (2009-11-30) | 3.2.1 |

R2011a (7.12) | 3.2.2-sse2 | 10.2.6 (2010-07-28) | 3.2.2 |

R2011b (7.13) | 3.2.2-sse2 | 10.3.2 (2011-01-17) | 3.2.2 |

R2012a (7.14) | 3.2.2-sse2 | 10.3.5 (2011-07-20) | 3.3.1 |

R2012b (8.0) | 3.3.1-sse2 | 10.3.9 (2012-01-31) | 3.3.1 |

R2013a (8.1) | 3.3.1-sse2-avx | 10.3.11 (2012-06-06) | 3.4.1 |

Note that the LAPACK version is not always updated together with BLAS, although they are both part of Intel’s MKL (more on MKL below).

** Addendum 2013-10-9**: The undocumented

`-modules`

option of the >> version -modules C:\Program Files\Matlab\R2013b\bin\win64\libut.dll Version < unknown > C:\Program Files\Matlab\R2013b\bin\win64\libmwfl.dll Version < unknown > C:\Program Files\Matlab\R2013b\bin\win64\libmx.dll Version 8.2.0.627 C:\Program Files\Matlab\R2013b\bin\win64\zlib1.dll Version < unknown > ...

[/Addendum]

Do you know of any other hidden version info anywhere in Matlab? If so, please post a comment below.

It may well be possible for users to upgrade the internal libraries that Matlab uses to the latest version, assuming that backward compatibility is preserved in these libraries (which I suppose is the case). Naturally, you can only upgrade if you have a license for the upgraded library. For those interested, the libraries are located in *%matlabroot%/bin/%arch%*. For example: *C:\Program Files\Matlab\R2013b\bin\win64\mkl.dll* is Intel’s MKL ^{[7]} (Math Kernel Library), which contains BLAS and LAPACK. Using this example, the latest official version ^{[8]} of MKL is 11.0, which promises ^{[9]} several important improvements over R2013a’s bundled version (10.3.11):

- A fix for a bug
^{[10]}in theroutines**svd** - Improved performance
- Improved support for Intel’s AVX2
^{[11]}instruction set (see related comment^{[12]}by Eric Sampson recently) - Improved functionality of MKL’s FFT implementation — Matlab’s
functions use FFTW, but in some cases***fft**^{[13]}MKL’s FFT implementation outperforms FFTW’s. You may wish to use MKL’s FFTW wrapper^{[14]}in such cases rather than calling MKL’s FFT routines directly.

Similarly, FFTW’s latest stable release is 3.3.3, offers advantages ^{[15]} compared to R2013a’s bundled 3.3.1 version. Unfortunately, unlike MKL, FFTW is not bundled as a replaceable library file. I believe that FFTW is directly integrated in Matlab’s code. However, nothing prevents us from downloading ^{[16]} the latest library and using it directly.

Needless to say, upgrading specific DLLs in Matlab can be extremely dangerous, and is entirely unsupported by MathWorks. Don’t come crying if Matlab starts to crash, or even worse – to return incorrect numerical results. If you design a car with upgraded libs, just let me know please, so that I’d know not to buy that model… I don’t often place such warnings on this blog. After all, this is a blog about undocumented / unsupported stuff. So when I do explicitly warn like this, you should take extra note. Upgrading Matlab’s math libs is purely an exercise for adventurous engineers who like to blow things up (oh, the sheer pleasure of charting undocumented waters!).

** Addendum 2013-10-9**: Amro’s comment

`BLAS_VERSION`

environment variable or by updating the If you have the Image Processing Toolbox (IPT), then you will also find Intel’s IPP ^{[19]} (Integrated Performance Primitives) library (*ippl.dll*) in the same folder as *mkl.dll*. IPP is used by IPT for running some highly-optimized image-processing functions.

Unfortunately, I could not find a parameter of * version* that returns the IPP version used by Matlab. However, we can get IPP’s version info using the

% R2013a (Matlab 8.1) on Win7 64b >> [isIpplEnabled, ipplVersion] = ippl isIpplEnabled = 1 % == true ipplVersion = 'ippie9_t.lib 7.0 build 205.58 7.0.205.1054 e9 Apr 18 2011'

A few IPP-related aspects that you might find interesting in this regard:

- Matlab currently (R2013a) uses IPPL 7.0 dated April 2011 – the latest version
^{[20]}is 8.0 dated June 26, 2013 (only 3 weeks ago) includes^{[21]}significant performance boosts. Note that between 7.0 and 8.0 there was a 7.1 release that also had^{[22]}significant improvements, especially for modern CPUs. The 8.0 release changed some function names, so for compatibility with Matlab you might discover that you need to settle for the 7.1 DLL. This could still bring significant benefits. - Matlab currently limits IPP usage to uints, floats and (since R2012b) doubles, although (AFAIK) IPP also supports signed ints. For signed ints Matlab reverts to much slower functional processing, which seems a pity. I’m not 100% certain that these are indeed supported by IPP for the specific cases in which Matlab currently blocks them, but I think it’s worth a check – the performance boost could be worth the effort.
- Matlab currently uses IPP only for some of the image-processing functions. It would make sense to use IPP much more widely, e.g. math, stats, convolution, FFT/FIR (I’m not sure it’s faster than FFTW, but it may be worth a check) and many others – IPP is much more versatile than an image processing toolkit (read here
^{[20]}).

Even if we don’t upgrade the *ippl.dll* or *mkl.dll* version, we may still benefit by accessing them directly in Matlab and/or MEX code. They can be used in Matlab just like any other DLL. There are plenty of online resources that can help us program using the IPP/MKL functionalities, even on the Matlab CSSM newsgroup ^{[23]}. It seems that quite a few Matlab users try to work directly with these libraries, sometimes perhaps not realizing that they are already pre-bundled within Matlab.

If you have successfully used one of these libraries directly in Matlab, and/or successfully upgraded the libs for some use, please share your experience by posting a comment below.

Categories: High risk of breaking in future versions, Semi-documented function, Undocumented feature

7 Comments (Open | Close)

Article printed from Undocumented Matlab: **https://undocumentedmatlab.com**

URL to article: **https://undocumentedmatlab.com/blog/math-libraries-version-info-upgrade**

URLs in this post:

[1] Image: **http://undocumentedmatlab.com/feed/**

[2] **email feed**: **http://undocumentedmatlab.com/subscribe_email.html**

[3] sometimes asked: **https://www.mathworks.com/matlabcentral/newsreader/view_thread/327906**

[4] BLAS: **http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms**

[5] LAPACK: **http://en.wikipedia.org/wiki/LAPACK**

[6] FFTW: **http://en.wikipedia.org/wiki/FFTW**

[7] MKL: **http://en.wikipedia.org/wiki/Math_Kernel_Library**

[8] latest official version: **http://software.intel.com/en-us/intel-mkl/**

[9] promises: **http://software.intel.com/en-us/articles/intel-mkl-110-release-notes**

[10] fix for a bug: **http://software.intel.com/en-us/articles/svd-multithreading-bug-in-mkl**

[11] AVX2: **http://en.wikipedia.org/wiki/Advanced_Vector_Extensions**

[12] comment: **https://www.mathworks.com/matlabcentral/newsreader/view_thread/328084#901644**

[13] in some cases: **http://www.fftw.org/speed/**

[14] FFTW wrapper: **http://software.intel.com/sites/products/documentation/hpc/mkl/mklman/GUID-A23603DA-B6D1-48AA-90D2-A415302F27D9.htm**

[15] offers advantages: **http://www.fftw.org/release-notes.html**

[16] downloading: **http://www.fftw.org/download.html**

[17] comment: **https://undocumentedmatlab.com/blog/math-libraries-version-info-upgrade/#comment-226776**

[18] reported: **https://www.mathworks.com/matlabcentral/newsreader/view_thread/129077**

[19] IPP: **http://en.wikipedia.org/wiki/Integrated_Performance_Primitives**

[20] latest version: **http://software.intel.com/en-us/intel-ipp**

[21] includes: **http://software.intel.com/en-us/articles/intel-ipp-80-library-release-notes**

[22] also had: **http://software.intel.com/en-us/articles/intel-ipp-71-library-whats-new**

[23] Matlab CSSM newsgroup: **https://www.mathworks.com/matlabcentral/newsreader/search_results?dur=all&search_string=tag%3Amkl**

[24] Handle Graphics Behavior : **https://undocumentedmatlab.com/blog/handle-graphics-behavior**

[25] Types of undocumented Matlab aspects : **https://undocumentedmatlab.com/blog/types-of-undocumented-matlab-aspects**

[26] setPrompt – Setting the Matlab Desktop prompt : **https://undocumentedmatlab.com/blog/setprompt-setting-matlab-desktop-prompt**

[27] Matlab DDE support : **https://undocumentedmatlab.com/blog/matlab-dde-support**

[28] Matlab callbacks for Java events : **https://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events**

[29] Uitable sorting : **https://undocumentedmatlab.com/blog/uitable-sorting**

[30] : **http://www.mathworks.com/help/matlab/matlab_external/calling-lapack-and-blas-functions-from-mex-files.html**

[31] : **http://www.mathworks.com/matlabcentral/fileexchange/16777-lapack**

[32] : **https://en.wikipedia.org/wiki/Dynamic-link_library#Import_libraries**

[33] : **http://www.stanford.edu/~echu508/matlab.html**

[34] : **http://software.intel.com/en-us/articles/using-intel-mkl-with-matlab/**

[35] : **http://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-windows-using-intel-mkl-in-matlab-executable-mex-files/**

[36] : **http://www.mathworks.com/company/newsletters/articles/matlab-incorporates-lapack.html**

[37] : **http://www.walkingrandomly.com/**

Click here to print.

Copyright © Yair Altman - Undocumented Matlab. All rights reserved.

7 Comments To "Math libraries version info & upgrade"

#1 CommentByAmroOn July 18, 2013 @ 1:26 pmThere is a section in the docs explaining how to call BLAS/LAPACK routines in MEX functions (linking against the versions that ship with MATLAB):

^{[30]}Also here is an oldie but goodie submission on FEX to interface with LAPACK:

^{[31]}#2 CommentByYair AltmanOn July 18, 2013 @ 2:58 pmThe specified libs are static libs that are essentially MathWorks-generated wrappers for MKL’s internal BLAS, LAPACK functions. Instead of the libs, one could presumably link directly with

mkl.dll.Had MathWorks encapsulated BLAS and LAPACK in DLLs rather than libs, we could call them directly from m-code. Since MathWorks chose to use static libs, the libs can only be used in Matlab by linking them into a mex file. I’m not sure that I understand the logic of this decision. It doesn’t matter so much since we can directly use

mkl.dll, which presumably includes everything that the static libs have.#3 CommentByAmroOn July 18, 2013 @ 3:17 pmActually those *.lib files are considered import libraries [*], which are required in the case of MSVC compiler/linker. The actual implementation of the BLAS routines resides in the dynamically loaded library. On Linux/Mac, you can directly link against the shared library equivalent to DLLs (*.so files) without an import library.

[*]:

^{[32]}#4 CommentByAmroOn July 18, 2013 @ 2:35 pmSome people in the past have successfully managed to run MATLAB with customized implementations of BLAS/LAPACK (ATLAS, GotoBLAS, OpenBLAS, ..). Here are some references for those interested:

^{[18]}^{[33]}^{[34]}^{[35]}Back in v6 and earlier (I think), MATLAB used ATLAS as BLAS implementation, before switching to Intel MKL starting with v7:

^{[36]}It should be noted that MKL is highly optimized for Intel processors, and it’s hard to get large performance gains over the vendor’s own implementation..

#5 CommentByYair AltmanOn July 18, 2013 @ 2:48 pm@Amro – Thanks for the numerous references. It would be interesting to learn if anyone has successfully integrated a

newerversion of MKL or IPPL in Matlab, as opposed to an entirely different library which is naturally another story. My hope is that a simple in-place DLL replacement might provide important performance and stability benefits across Matlab, without requiring a single line of code to change.Unfortunately, I can’t test this as I do not have an independent license to MKL / IPPL. And I would probably wouldn’t know how to test it properly anyway if I did have a license. But there are plenty of smart linear-algebra experts out there who might just pick up the glove (

^{[37]}comes to mind, for one).I’ve offered the bait – now let’s see if anything interesting comes up in the net…

#6 CommentByAmroOn July 18, 2013 @ 3:03 pmI’m not sure if I’m allowed to discuss this in an open forum, but I just tried it in the R2013b prerelease, and they seem to be using the latest MKL 11.0.2 and FFT 3.3.3 versions. IPP is unchanged though.

Oh and you’ll be happy to know that MATLAB has finally upgraded to Java 7

#7 PingbackBySparse data math info | Undocumented MatlabOn July 31, 2013 @ 11:03 am[…] Two weeks ago, I posted about Matlab’s math libraries and their various versions across Matlab releases […]