Intel Math Kernel Library (MKL)

Stata 17 provides deeply optimized LAPACK routines by using the Intel Math Kernel Library (MKL) on compatible hardware (all Intel- and AMD-based 64-bit computers).

LAPACK (Linear Algebra PACKage) is a freely available set of routines for solving systems of simultaneous equations, eigenvalue problems, and singular value problems, among others. Mata operators and functions qrd(), lud(), cholesky(), etc., leverage LAPACK where possible for many numerical operations.

LAPACK backed by the Intel MKL provides the latest LAPACK routines heavily optimized for the 64-bit Intel x86-64 instruction set used by both modern Intel and modern AMD processors. Mata functions and operators using MKL benefit greatly in terms of performance.

For example:

Timing of multiplication of two real matrices in seconds:

Edition Size MKL non-MKL
MP8 5,000 by 5,000 2.55 10.26
MP8 10,000 by 10,000 17.28 85.60
MP4 5,000 by 5,000 3.62 15.95
MP4 10,000 by 10,000 28.22 127.24
SE 5,000 by 5,000 13.64 70.61
SE 10,000 by 10,000 108.33 566.99
Timings run in Windows 10 on a computer with an i9-9900KS processor at 4.00GHz and 64GB RAM

 

Timing of cholesky() in seconds:

Edition Size MKL non-MKL
MP8 5,000 by 5,000 0.42 16.69
MP8 10,000 by 10,000 2.91 133.60
MP4 5,000 by 5,000 0.69 16.69
MP4 10,000 by 10,000 5.03 133.70
SE 5,000 by 5,000 2.41 18.62
SE 10,000 by 10,000 16.66 133.63
Timings run in Windows 10 on a computer with an i9-9900KS processor at 4.00GHz and 64GB RAM

 

And most importantly, you don’t need to do anything to take advantage of the speed gains. Stata commands using these Mata functions and operators, and the Mata functions and operators themselves, will automatically use the Intel MKL on compatible hardware.