Actual source code: petscblaslapack_mangle.h
1: /*
2: This file deals with the BLAS/LAPACK naming convention on
3: non-Microsoft Windows systems, which may append an underscore, use
4: upper or lower case, and/or use a configurable symbol suffix.
5: */
6: #pragma once
8: /****************************************************************************/
9: /* macros to mangle BLAS/LAPACK names as needed for linking */
11: /* token pasting, with an extra level of indirection so that we
12: can paste the contents of other preprocessor #definitions */
13: #define PETSC_PASTE2_(a, b) a##b
14: #define PETSC_PASTE2(a, b) PETSC_PASTE2_(a, b)
15: #define PETSC_PASTE3_(a, b, c) a##b##c
16: #define PETSC_PASTE3(a, b, c) PETSC_PASTE3_(a, b, c)
18: #if !defined(PETSC_BLASLAPACK_SUFFIX)
19: #if defined(PETSC_BLASLAPACK_UNDERSCORE)
20: #define PETSC_BLASLAPACK_SUFFIX_ _
21: #else
22: #define PETSC_BLASLAPACK_SUFFIX_
23: #endif
24: #else
25: #if defined(PETSC_BLASLAPACK_UNDERSCORE)
26: #define PETSC_BLASLAPACK_SUFFIX_ PETSC_PASTE2(PETSC_BLASLAPACK_SUFFIX, _)
27: #else
28: #define PETSC_BLASLAPACK_SUFFIX_ PETSC_BLASLAPACK_SUFFIX
29: #endif
30: #endif
32: /* complex/real and single/double/quad/half precision prefixes: */
33: #if !defined(PETSC_USE_COMPLEX)
34: #if defined(PETSC_BLASLAPACK_CAPS)
35: #if defined(PETSC_USE_REAL_SINGLE)
36: #define PETSC_BLASLAPACK_PREFIX_ S
37: #define PETSC_BLASLAPACK_PREFIX_COMPLEX C
38: #elif defined(PETSC_USE_REAL_DOUBLE)
39: #define PETSC_BLASLAPACK_PREFIX_ D
40: #define PETSC_BLASLAPACK_PREFIX_COMPLEX Z
41: #elif defined(PETSC_USE_REAL___FLOAT128)
42: #define PETSC_BLASLAPACK_PREFIX_ Q
43: #define PETSC_BLASLAPACK_PREFIX_COMPLEX W
44: #else
45: #define PETSC_BLASLAPACK_PREFIX_ H
46: #define PETSC_BLASLAPACK_PREFIX_COMPLEX K
47: #endif
48: #else
49: #if defined(PETSC_USE_REAL_SINGLE)
50: #define PETSC_BLASLAPACK_PREFIX_ s
51: #define PETSC_BLASLAPACK_PREFIX_COMPLEX c
52: #elif defined(PETSC_USE_REAL_DOUBLE)
53: #define PETSC_BLASLAPACK_PREFIX_ d
54: #define PETSC_BLASLAPACK_PREFIX_COMPLEX z
55: #elif defined(PETSC_USE_REAL___FLOAT128)
56: #define PETSC_BLASLAPACK_PREFIX_ q
57: #define PETSC_BLASLAPACK_PREFIX_COMPLEX w
58: #else
59: #define PETSC_BLASLAPACK_PREFIX_ h
60: #define PETSC_BLASLAPACK_PREFIX_COMPLEX k
61: #endif
62: #endif
63: #define PETSC_BLASLAPACK_RPREFIX_ PETSC_BLASLAPACK_PREFIX_
64: #define PETSC_BLASLAPACK_PREFIX_REAL PETSC_BLASLAPACK_PREFIX_
65: #else
66: #if defined(PETSC_BLASLAPACK_CAPS)
67: #if defined(PETSC_USE_REAL_SINGLE)
68: #define PETSC_BLASLAPACK_PREFIX_ C
69: #define PETSC_BLASLAPACK_PREFIX_REAL S
70: #define PETSC_BLASLAPACK_RPREFIX_ SC
71: #elif defined(PETSC_USE_REAL_DOUBLE)
72: #define PETSC_BLASLAPACK_PREFIX_ Z
73: #define PETSC_BLASLAPACK_PREFIX_REAL D
74: #define PETSC_BLASLAPACK_RPREFIX_ DZ
75: #elif defined(PETSC_USE_REAL___FLOAT128)
76: #define PETSC_BLASLAPACK_PREFIX_ W
77: #define PETSC_BLASLAPACK_PREFIX_REAL Q
78: #define PETSC_BLASLAPACK_RPREFIX_ QW
79: #else
80: #define PETSC_BLASLAPACK_PREFIX_ K
81: #define PETSC_BLASLAPACK_PREFIX_REAL H
82: #define PETSC_BLASLAPACK_RPREFIX_ HK
83: #endif
84: #else
85: #if defined(PETSC_USE_REAL_SINGLE)
86: #define PETSC_BLASLAPACK_PREFIX_ c
87: #define PETSC_BLASLAPACK_PREFIX_REAL s
88: #define PETSC_BLASLAPACK_RPREFIX_ sc
89: #elif defined(PETSC_USE_REAL_DOUBLE)
90: #define PETSC_BLASLAPACK_PREFIX_ z
91: #define PETSC_BLASLAPACK_PREFIX_REAL d
92: #define PETSC_BLASLAPACK_RPREFIX_ dz
93: #elif defined(PETSC_USE_REAL___FLOAT128)
94: #define PETSC_BLASLAPACK_PREFIX_ w
95: #define PETSC_BLASLAPACK_PREFIX_REAL q
96: #define PETSC_BLASLAPACK_RPREFIX_ qw
97: #else
98: #define PETSC_BLASLAPACK_PREFIX_ k
99: #define PETSC_BLASLAPACK_PREFIX_REAL h
100: #define PETSC_BLASLAPACK_RPREFIX_ hk
101: #endif
102: #endif
103: #define PETSC_BLASLAPACK_PREFIX_COMPLEX PETSC_BLASLAPACK_PREFIX_
104: #endif
106: /* define macros PETSCBLAS to mangle BLAS/LAPACK subroutine names, and
107: PETSCBLASR for functions returning real values */
108: #if defined(PETSC_BLASLAPACK_CAPS)
109: #define PETSCBLAS(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_, X, PETSC_BLASLAPACK_SUFFIX_)
110: #define PETSCBLASREAL(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_REAL, X, PETSC_BLASLAPACK_SUFFIX_)
111: #define PETSCBLASCOMPLEX(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_COMPLEX, X, PETSC_BLASLAPACK_SUFFIX_)
112: #define PETSCBLASR(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_RPREFIX_, X, PETSC_BLASLAPACK_SUFFIX_)
113: #else
114: #define PETSCBLAS(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_, x, PETSC_BLASLAPACK_SUFFIX_)
115: #define PETSCBLASREAL(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_REAL, x, PETSC_BLASLAPACK_SUFFIX_)
116: #define PETSCBLASCOMPLEX(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_COMPLEX, x, PETSC_BLASLAPACK_SUFFIX_)
117: #define PETSCBLASR(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_RPREFIX_, x, PETSC_BLASLAPACK_SUFFIX_)
118: #endif
120: /****************************************************************************/
121: /* definitions of BLAS and LAPACK symbols */
123: /* Subroutine names that are the same for real/complex data: */
124: /* no character-string arguments: */
125: #define LAPACKgeqrf_ PETSCBLAS(geqrf, GEQRF)
126: #define LAPACKgetrf_ PETSCBLAS(getrf, GETRF)
127: #define LAPACKgetri_ PETSCBLAS(getri, GETRI)
128: #define LAPACKREALgetrf_ PETSCBLASREAL(getrf, GETRF)
129: #define LAPACKREALgetri_ PETSCBLASREAL(getri, GETRI)
130: #define BLASnrm2_ PETSCBLASR(nrm2, NRM2)
131: #define BLASscal_ PETSCBLAS(scal, SCAL)
132: #define BLAScopy_ PETSCBLAS(copy, COPY)
133: #define BLASswap_ PETSCBLAS(swap, SWAP)
134: #define BLASaxpy_ PETSCBLAS(axpy, AXPY)
135: #define BLASasum_ PETSCBLASR(asum, ASUM)
136: #define LAPACKpttrf_ PETSCBLAS(pttrf, PTTRF) /* factorization of a spd tridiagonal matrix */
137: #define LAPACKpttrs_ PETSCBLAS(pttrs, PTTRS) /* solve a spd tridiagonal matrix system */
138: #if !defined(PETSC_MISSING_LAPACK_STEIN)
139: #define LAPACKstein_ PETSCBLAS(stein, STEIN) /* eigenvectors of real symm tridiagonal matrix */
140: #endif
141: #define LAPACKgesv_ PETSCBLAS(gesv, GESV)
142: #if !defined(PETSC_MISSING_LAPACK_GELSS)
143: #define LAPACKgelss_ PETSCBLAS(gelss, GELSS)
144: #endif
145: #if !defined(PETSC_MISSING_LAPACK_GERFS)
146: #define LAPACKgerfs_ PETSCBLAS(gerfs, GERFS)
147: #endif
148: #if !defined(PETSC_MISSING_LAPACK_TGSEN)
149: #define LAPACKtgsen_ PETSCBLAS(tgsen, TGSEN)
150: #endif
151: /* character-string arguments: */
152: #define LAPACKtrtri_ PETSCBLAS(trtri, TRTRI)
153: #define LAPACKpotrf_ PETSCBLAS(potrf, POTRF)
154: #define LAPACKpotri_ PETSCBLAS(potri, POTRI)
155: #define LAPACKpotrs_ PETSCBLAS(potrs, POTRS)
156: #define LAPACKsytrf_ PETSCBLAS(sytrf, SYTRF)
157: #define LAPACKsytrs_ PETSCBLAS(sytrs, SYTRS)
158: #if !defined(PETSC_MISSING_LAPACK_SYTRI)
159: #define LAPACKsytri_ PETSCBLAS(sytri, SYTRI)
160: #endif
161: #define BLASgemv_ PETSCBLAS(gemv, GEMV)
162: #define LAPACKgetrs_ PETSCBLAS(getrs, GETRS)
163: #define BLAStrmv_ PETSCBLAS(trmv, TRMV)
164: #define BLAStrsv_ PETSCBLAS(trsv, TRSV)
165: #define BLASgemm_ PETSCBLAS(gemm, GEMM)
166: #define BLASsymm_ PETSCBLAS(symm, SYMM)
167: #define BLASsyrk_ PETSCBLAS(syrk, SYRK)
168: #define BLASsyr2k_ PETSCBLAS(syr2k, SYR2K)
169: #define BLAStrsm_ PETSCBLAS(trsm, TRSM)
170: #define BLASREALgemm_ PETSCBLASREAL(gemm, GEMM)
171: #define LAPACKgesvd_ PETSCBLAS(gesvd, GESVD)
172: #define LAPACKgeev_ PETSCBLAS(geev, GEEV)
173: #define LAPACKgels_ PETSCBLAS(gels, GELS)
174: #if !defined(PETSC_MISSING_LAPACK_STEGR)
175: #define LAPACKstegr_ PETSCBLAS(stegr, STEGR) /* eigenvalues and eigenvectors of symm tridiagonal */
176: #endif
177: #if !defined(PETSC_MISSING_LAPACK_STEQR)
178: #define LAPACKsteqr_ PETSCBLAS(steqr, STEQR) /* eigenvalues and eigenvectors of symm tridiagonal */
179: #define LAPACKREALsteqr_ PETSCBLASREAL(steqr, STEQR)
180: #endif
181: #if !defined(PETSC_MISSING_LAPACK_STEV)
182: #define LAPACKstev_ PETSCBLAS(stev, STEV) /* eigenvalues and eigenvectors of symm tridiagonal */
183: #define LAPACKREALstev_ PETSCBLASREAL(stev, STEV)
184: #endif
185: #if !defined(PETSC_MISSING_LAPACK_HSEQR)
186: #define LAPACKhseqr_ PETSCBLAS(hseqr, HSEQR)
187: #endif
188: #if !defined(PETSC_MISSING_LAPACK_GGES)
189: #define LAPACKgges_ PETSCBLAS(gges, GGES)
190: #endif
191: #if !defined(PETSC_MISSING_LAPACK_TRSEN)
192: #define LAPACKtrsen_ PETSCBLAS(trsen, TRSEN)
193: #endif
194: #if !defined(PETSC_MISSING_LAPACK_HGEQZ)
195: #define LAPACKhgeqz_ PETSCBLAS(hgeqz, HGEQZ)
196: #endif
197: #if !defined(PETSC_MISSING_LAPACK_TRTRS)
198: #define LAPACKtrtrs_ PETSCBLAS(trtrs, TRTRS)
199: #endif
201: /* Subroutine names that differ for real/complex data: */
202: #if !defined(PETSC_USE_COMPLEX)
203: #if !defined(PETSC_MISSING_LAPACK_ORGQR)
204: #define LAPACKorgqr_ PETSCBLAS(orgqr, ORGQR)
205: #endif
206: #if !defined(PETSC_MISSING_LAPACK_ORMQR)
207: #define LAPACKormqr_ PETSCBLAS(ormqr, ORMQR)
208: #endif
209: #define BLASdot_ PETSCBLAS(dot, DOT)
210: #define BLASdotu_ PETSCBLAS(dot, DOT)
212: #define LAPACKsyev_ PETSCBLAS(syev, SYEV) /* eigenvalues and eigenvectors of a symm matrix */
213: #define LAPACKsyevx_ PETSCBLAS(syevx, SYEVX) /* selected eigenvalues and eigenvectors of a symm matrix */
214: #define LAPACKsygv_ PETSCBLAS(sygv, SYGV)
215: #define LAPACKsygvx_ PETSCBLAS(sygvx, SYGVX)
217: /* stebz does not exist for complex data */
218: #if !defined(PETSC_MISSING_LAPACK_STEBZ)
219: #define LAPACKstebz_ PETSCBLAS(stebz, STEBZ) /* eigenvalues of symm tridiagonal matrix */
220: #endif
221: #else
222: #define LAPACKhetrf_ PETSCBLAS(hetrf, HETRF)
223: #define LAPACKhetrs_ PETSCBLAS(hetrs, HETRS)
224: #define LAPACKhetri_ PETSCBLAS(hetri, HETRI)
225: #define LAPACKheev_ PETSCBLAS(heev, HEEV)
226: #if !defined(PETSC_MISSING_LAPACK_ORGQR)
227: #define LAPACKorgqr_ PETSCBLAS(ungqr, UNGQR)
228: #endif
229: #if !defined(PETSC_MISSING_LAPACK_ORMQR)
230: #define LAPACKormqr_ PETSCBLAS(unmqr, UNMQR)
231: #endif
232: /* note: dot and dotu are handled separately for complex data */
234: #define LAPACKsyev_ PETSCBLAS(heev, HEEV) /* eigenvalues and eigenvectors of a symm matrix */
235: #define LAPACKsyevx_ PETSCBLAS(heevx, HEEVX) /* selected eigenvalues and eigenvectors of a symm matrix */
236: #define LAPACKsygv_ PETSCBLAS(hegv, HEGV)
237: #define LAPACKsygvx_ PETSCBLAS(hegvx, HEGVX)
238: #endif