Eigen  5.0.1
 
Loading...
Searching...
No Matches
MKL_support.h
1/*
2 Copyright (c) 2011, Intel Corporation. All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice, this
8 list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 this list of conditions and the following disclaimer in the documentation
11 and/or other materials provided with the distribution.
12 * Neither the name of Intel Corporation nor the names of its contributors may
13 be used to endorse or promote products derived from this software without
14 specific prior written permission.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 ********************************************************************************
28 * Content : Eigen bindings to Intel(R) MKL
29 * Include file with common MKL declarations
30 ********************************************************************************
31*/
32// SPDX-License-Identifier: BSD-3-Clause
33
34#ifndef EIGEN_MKL_SUPPORT_H
35#define EIGEN_MKL_SUPPORT_H
36
37/* Eigen/Core includes this header well before Meta.h, so <cstdint> is not yet available for EIGEN_BLAS_INT. */
38#include <cstdint>
39
40#ifdef EIGEN_USE_MKL_ALL
41#ifndef EIGEN_USE_BLAS
42#define EIGEN_USE_BLAS
43#endif
44#ifndef EIGEN_USE_LAPACKE
45#define EIGEN_USE_LAPACKE
46#endif
47#ifndef EIGEN_USE_MKL_VML
48#define EIGEN_USE_MKL_VML
49#endif
50#endif
51
52#ifdef EIGEN_USE_LAPACKE_STRICT
53#define EIGEN_USE_LAPACKE
54#endif
55
56#if defined(EIGEN_USE_MKL_VML) && !defined(EIGEN_USE_MKL)
57#define EIGEN_USE_MKL
58#endif
59
60#if defined EIGEN_USE_MKL
61#if (!defined MKL_DIRECT_CALL) && (!defined EIGEN_MKL_NO_DIRECT_CALL)
62#define MKL_DIRECT_CALL
63#define MKL_DIRECT_CALL_JUST_SET
64#endif
65#include <mkl.h>
66/*Check IMKL version for compatibility: < 10.3 is not usable with Eigen*/
67#ifndef INTEL_MKL_VERSION
68#undef EIGEN_USE_MKL /* INTEL_MKL_VERSION is not even defined on older versions */
69#elif INTEL_MKL_VERSION < \
70 100305 /* the intel-mkl-103-release-notes say this was when the lapacke.h interface was added*/
71#undef EIGEN_USE_MKL
72#endif
73#ifndef EIGEN_USE_MKL
74/*If the MKL version is too old, undef everything*/
75#undef EIGEN_USE_MKL_ALL
76#undef EIGEN_USE_LAPACKE
77#undef EIGEN_USE_MKL_VML
78#undef EIGEN_USE_LAPACKE_STRICT
79#ifdef MKL_DIRECT_CALL_JUST_SET
80#undef MKL_DIRECT_CALL
81#endif
82#endif
83#endif
84
85#if defined EIGEN_USE_MKL
86
87#define EIGEN_MKL_VML_THRESHOLD 128
88
89/* MKL_DOMAIN_BLAS, etc are defined only in 10.3 update 7 */
90/* MKL_BLAS, etc are not defined in 11.2 */
91#ifdef MKL_DOMAIN_ALL
92#define EIGEN_MKL_DOMAIN_ALL MKL_DOMAIN_ALL
93#else
94#define EIGEN_MKL_DOMAIN_ALL MKL_ALL
95#endif
96
97#ifdef MKL_DOMAIN_BLAS
98#define EIGEN_MKL_DOMAIN_BLAS MKL_DOMAIN_BLAS
99#else
100#define EIGEN_MKL_DOMAIN_BLAS MKL_BLAS
101#endif
102
103#ifdef MKL_DOMAIN_FFT
104#define EIGEN_MKL_DOMAIN_FFT MKL_DOMAIN_FFT
105#else
106#define EIGEN_MKL_DOMAIN_FFT MKL_FFT
107#endif
108
109#ifdef MKL_DOMAIN_VML
110#define EIGEN_MKL_DOMAIN_VML MKL_DOMAIN_VML
111#else
112#define EIGEN_MKL_DOMAIN_VML MKL_VML
113#endif
114
115#ifdef MKL_DOMAIN_PARDISO
116#define EIGEN_MKL_DOMAIN_PARDISO MKL_DOMAIN_PARDISO
117#else
118#define EIGEN_MKL_DOMAIN_PARDISO MKL_PARDISO
119#endif
120#endif
121
122/* Integer width of the external BLAS interface.
123 *
124 * Fortran BLAS passes every dimension and stride by pointer, so a width mismatch between Eigen and the linked library
125 * is invisible to both the compiler and the linker and silently corrupts arguments at run time. Define
126 * EIGEN_64BIT_BLAS to select the 64-bit-integer ("ILP64") interface. It is an ABI-affecting macro and must be
127 * consistent across all translation units.
128 */
129#ifndef EIGEN_BLAS_INT
130#if defined(EIGEN_64BIT_BLAS)
131#define EIGEN_BLAS_INT std::int64_t
132#else
133#define EIGEN_BLAS_INT int
134#endif
135#endif
136
137/* Suffix appended to external BLAS symbol names, for libraries that expose the 64-bit interface under decorated names
138 * rather than in a separate library: reference LAPACK built with BUILD_INDEX64_EXT_API and oneMKL >= 2025 use _64
139 * (dgemm_64_), as does OpenBLAS built with SYMBOLSUFFIX=64_. Libraries that keep the undecorated names in a separate
140 * ILP64 build (oneMKL *_ilp64, plain OpenBLAS INTERFACE64=1) need only EIGEN_64BIT_BLAS.
141 */
142#ifndef EIGEN_BLAS_SYMBOL_SUFFIX
143#define EIGEN_BLAS_SYMBOL_SUFFIX
144#endif
145/* EIGEN_BLAS_POSTFIX is the suffix plus the Fortran trailing underscore (_ by default, _64_ for a _64 build).
146 * Both go through EIGEN_CAT rather than bare ##, which would suppress expansion of the argument.
147 */
148#define EIGEN_BLAS_POSTFIX EIGEN_CAT(EIGEN_BLAS_SYMBOL_SUFFIX, _)
149#define EIGEN_BLAS_SYM(NAME) EIGEN_CAT(NAME, EIGEN_BLAS_POSTFIX)
150
151#if defined(EIGEN_USE_BLAS) && !defined(EIGEN_USE_MKL)
152#include "blas.h"
153#endif
154
155// IWYU pragma: private
156#include "../InternalHeaderCheck.h"
157
158/* dcomplex, scomplex, and BlasIndex are used by both the BLAS and LAPACKE backends, so they live in a
159 * backend-neutral header. It is included here, after the integer-width macros above are set, because BlasIndex
160 * depends on them.
161 */
162#include "BlasTypes.h"
163
164#endif // EIGEN_MKL_SUPPORT_H