Debian Codegraph @

vendored-meson/meson/test cases/frameworks/38 blas-lapack/cblas_lapack.h

raw
1 // Unified CBLAS and LAPACK header to account for the various name mangling
2 // schemes used by Accelerate, OpenBLAS, MKL & co. As well as for the names of
3 // header files varying (e.g. cblas.h, Accelerate/Accelerate.h, mkl_cblas.h)
4 //
5 // Accelerate.h (via cblas_new.h) contains non-suffixed names, and the suffixed
6 // symbols are added via aliases inserted with __asm.
7 // OpenBLAS headers do contain suffixed names (e.g., `cblas_dgemm64_`)
8 // The end result after the standardization discussion in
9 // https://github.com/Reference-LAPACK/lapack/issues/666 should be
10 // `cblas_dgemm_64`, however that isn't yet final or implemented.
11 //
12 // # Actual symbols present in MKL:
13
14 // 00000000003e4970 T cblas_dgemm
15 // 00000000003e4970 T cblas_dgemm_
16 // 00000000003e34e0 T cblas_dgemm_64
17 // 00000000003e34e0 T cblas_dgemm_64_
18 //
19 // 00000000004e9f80 T dgesv
20 // 00000000004e9f80 T dgesv_
21 // 00000000004ea050 T dgesv_64
22 // 00000000004ea050 T dgesv_64_
23 //
24 //
25 // # Actual symbols present in OpenBLAS (in `libopenblas64`):
26 //
27 // 00000000000a3430 T cblas_dgemm64_
28 //
29 // 00000000000a6e50 T dgesv_64_
30
31 // Name mangling adapted/extended from NumPy's npy_cblas.h
32 #include <math.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35
36 #ifdef ACCELERATE_NEW_LAPACK
37 #if __MAC_OS_X_VERSION_MAX_ALLOWED < 130300
38 #ifdef HAVE_BLAS_ILP64
39 #error "Accelerate ILP64 support is only available with macOS 13.3 SDK or later"
40 #endif
41 #else
42 #define NO_APPEND_FORTRAN
43 #ifdef HAVE_BLAS_ILP64
44 #define BLAS_SYMBOL_SUFFIX $NEWLAPACK$ILP64
45 #else
46 #define BLAS_SYMBOL_SUFFIX $NEWLAPACK
47 #endif
48 #endif
49 #endif
50
51 #ifdef NO_APPEND_FORTRAN
52 #define BLAS_FORTRAN_SUFFIX
53 #else
54 #define BLAS_FORTRAN_SUFFIX _
55 #endif
56
57 #ifndef BLAS_SYMBOL_SUFFIX
58 #define BLAS_SYMBOL_SUFFIX
59 #endif
60
61 #define BLAS_FUNC_CONCAT(name, suffix, suffix2) name##suffix##suffix2
62 #define BLAS_FUNC_EXPAND(name, suffix, suffix2) \
63 BLAS_FUNC_CONCAT(name, suffix, suffix2)
64
65 #define CBLAS_FUNC(name) BLAS_FUNC_EXPAND(name, , BLAS_SYMBOL_SUFFIX)
66 #ifdef OPENBLAS_ILP64_NAMING_SCHEME
67 #define BLAS_FUNC(name) \
68 BLAS_FUNC_EXPAND(name, BLAS_FORTRAN_SUFFIX, BLAS_SYMBOL_SUFFIX)
69 #define LAPACK_FUNC(name) BLAS_FUNC(name)
70 #else
71 #define BLAS_FUNC(name) \
72 BLAS_FUNC_EXPAND(name, BLAS_SYMBOL_SUFFIX, BLAS_FORTRAN_SUFFIX)
73 #define LAPACK_FUNC(name) BLAS_FUNC(name)
74 #endif
75
76 #ifdef HAVE_BLAS_ILP64
77 #define blas_int long
78 #define lapack_int long
79 #else
80 #define blas_int int
81 #define lapack_int int
82 #endif
83
84 enum CBLAS_ORDER { CblasRowMajor = 101, CblasColMajor = 102 };
85 enum CBLAS_TRANSPOSE {
86 CblasNoTrans = 111,
87 CblasTrans = 112,
88 CblasConjTrans = 113
89 };
90
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94
95 void CBLAS_FUNC(cblas_dgemm)(const enum CBLAS_ORDER Order,
96 const enum CBLAS_TRANSPOSE TransA,
97 const enum CBLAS_TRANSPOSE TransB,
98 const blas_int M, const blas_int N,
99 const blas_int K, const double alpha,
100 const double *A, const blas_int lda,
101 const double *B, const blas_int ldb,
102 const double beta, double *C, const blas_int ldc);
103
104 double CBLAS_FUNC(cblas_dnrm2)(const blas_int N, const double *X,
105 const blas_int incX);
106
107 void LAPACK_FUNC(dgesv)(lapack_int *n, lapack_int *nrhs, double *a,
108 lapack_int *lda, lapack_int *ipivot, double *b,
109 lapack_int *ldb, lapack_int *info);
110
111 #ifdef __cplusplus
112 }
113 #endif