blob: 6de14afad9bb09db5d2fd3e37414f3a82ec171d8 [file] [log] [blame]
Brian Silverman72890c22015-09-19 14:37:37 -04001/*
2 Copyright (c) 2011, Intel Corporation. All rights reserved.
3 Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its contributors may
14 be used to endorse or promote products derived from this software without
15 specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 ********************************************************************************
29 * Content : Documentation on the use of Intel MKL through Eigen
30 ********************************************************************************
31*/
32
33namespace Eigen {
34
Austin Schuh189376f2018-12-20 22:11:15 +110035/** \page TopicUsingIntelMKL Using Intel® MKL from %Eigen
Brian Silverman72890c22015-09-19 14:37:37 -040036
Austin Schuh189376f2018-12-20 22:11:15 +110037<!-- \section TopicUsingIntelMKL_Intro Eigen and Intel® Math Kernel Library (Intel® MKL) -->
Brian Silverman72890c22015-09-19 14:37:37 -040038
Austin Schuh189376f2018-12-20 22:11:15 +110039Since %Eigen version 3.1 and later, users can benefit from built-in Intel® Math Kernel Library (MKL) optimizations with an installed copy of Intel MKL 10.3 (or later).
40
Brian Silverman72890c22015-09-19 14:37:37 -040041<a href="http://eigen.tuxfamily.org/Counter/redirect_to_mkl.php"> Intel MKL </a> provides highly optimized multi-threaded mathematical routines for x86-compatible architectures.
42Intel MKL is available on Linux, Mac and Windows for both Intel64 and IA32 architectures.
43
Austin Schuh189376f2018-12-20 22:11:15 +110044\note
45Intel® MKL is a proprietary software and it is the responsibility of users to buy or register for community (free) Intel MKL licenses for their products. Moreover, the license of the user product has to allow linking to proprietary software that excludes any unmodified versions of the GPL.
Brian Silverman72890c22015-09-19 14:37:37 -040046
Austin Schuh189376f2018-12-20 22:11:15 +110047Using Intel MKL through %Eigen is easy:
48-# define the \c EIGEN_USE_MKL_ALL macro before including any %Eigen's header
Brian Silverman72890c22015-09-19 14:37:37 -040049-# link your program to MKL libraries (see the <a href="http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/">MKL linking advisor</a>)
50-# on a 64bits system, you must use the LP64 interface (not the ILP64 one)
51
Austin Schuh189376f2018-12-20 22:11:15 +110052When doing so, a number of %Eigen's algorithms are silently substituted with calls to Intel MKL routines.
Brian Silverman72890c22015-09-19 14:37:37 -040053These substitutions apply only for \b Dynamic \b or \b large enough objects with one of the following four standard scalar types: \c float, \c double, \c complex<float>, and \c complex<double>.
54Operations on other scalar types or mixing reals and complexes will continue to use the built-in algorithms.
55
Austin Schuh189376f2018-12-20 22:11:15 +110056In addition you can choose which parts will be substituted by defining one or multiple of the following macros:
Brian Silverman72890c22015-09-19 14:37:37 -040057
58<table class="manual">
Austin Schuh189376f2018-12-20 22:11:15 +110059<tr><td>\c EIGEN_USE_BLAS </td><td>Enables the use of external BLAS level 2 and 3 routines</td></tr>
60<tr class="alt"><td>\c EIGEN_USE_LAPACKE </td><td>Enables the use of external Lapack routines via the <a href="http://www.netlib.org/lapack/lapacke.html">Lapacke</a> C interface to Lapack</td></tr>
61<tr><td>\c EIGEN_USE_LAPACKE_STRICT </td><td>Same as \c EIGEN_USE_LAPACKE but algorithm of lower robustness are disabled. \n This currently concerns only JacobiSVD which otherwise would be replaced by \c gesvd that is less robust than Jacobi rotations.</td></tr>
Brian Silverman72890c22015-09-19 14:37:37 -040062<tr class="alt"><td>\c EIGEN_USE_MKL_VML </td><td>Enables the use of Intel VML (vector operations)</td></tr>
63<tr><td>\c EIGEN_USE_MKL_ALL </td><td>Defines \c EIGEN_USE_BLAS, \c EIGEN_USE_LAPACKE, and \c EIGEN_USE_MKL_VML </td></tr>
64</table>
65
Austin Schuh189376f2018-12-20 22:11:15 +110066The options can be combined with \b MKL_DIRECT_CALL to enable MKL direct call feature. This may help to increase performance of some MKL BLAS (?GEMM, ?GEMV, ?TRSM, ?AXPY and ?DOT) and LAPACK (LU, Cholesky and QR) routines for very small matrices. To make it work properly, the macro \c EIGEN_USE_MKL must also be defined in the case none of the other \c EIGEN_USE_MKL_* macros has been defined.
67
68Note that the BLAS and LAPACKE backends can be enabled for any F77 compatible BLAS and LAPACK libraries. See this \link TopicUsingBlasLapack page \endlink for the details.
69
Brian Silverman72890c22015-09-19 14:37:37 -040070Finally, the PARDISO sparse solver shipped with Intel MKL can be used through the \ref PardisoLU, \ref PardisoLLT and \ref PardisoLDLT classes of the \ref PardisoSupport_Module.
71
Austin Schuh189376f2018-12-20 22:11:15 +110072The following table summarizes the list of functions covered by \c EIGEN_USE_MKL_VML:
Brian Silverman72890c22015-09-19 14:37:37 -040073<table class="manual">
Austin Schuh189376f2018-12-20 22:11:15 +110074<tr><th>Code example</th><th>MKL routines</th></tr>
75<tr><td>\code
Brian Silverman72890c22015-09-19 14:37:37 -040076v2=v1.array().sin();
77v2=v1.array().asin();
78v2=v1.array().cos();
79v2=v1.array().acos();
80v2=v1.array().tan();
81v2=v1.array().exp();
82v2=v1.array().log();
83v2=v1.array().sqrt();
84v2=v1.array().square();
85v2=v1.array().pow(1.5);
86\endcode</td><td>\code
87v?Sin
88v?Asin
89v?Cos
90v?Acos
91v?Tan
92v?Exp
93v?Ln
94v?Sqrt
95v?Sqr
96v?Powx
97\endcode</td></tr>
98</table>
Austin Schuh189376f2018-12-20 22:11:15 +110099In the examples, v1 and v2 are dense vectors.
Brian Silverman72890c22015-09-19 14:37:37 -0400100
101
102\section TopicUsingIntelMKL_Links Links
103- Intel MKL can be purchased and downloaded <a href="http://eigen.tuxfamily.org/Counter/redirect_to_mkl.php">here</a>.
104- Intel MKL is also bundled with <a href="http://software.intel.com/en-us/articles/intel-composer-xe/">Intel Composer XE</a>.
105
106
107*/
108
109}