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 BLASgemm_     PETSCBLAS(gemm, GEMM)
165: #define BLASsymm_     PETSCBLAS(symm, SYMM)
166: #define BLASsyrk_     PETSCBLAS(syrk, SYRK)
167: #define BLASsyr2k_    PETSCBLAS(syr2k, SYR2K)
168: #define BLAStrsm_     PETSCBLAS(trsm, TRSM)
169: #define BLASREALgemm_ PETSCBLASREAL(gemm, GEMM)
170: #define LAPACKgesvd_  PETSCBLAS(gesvd, GESVD)
171: #define LAPACKgeev_   PETSCBLAS(geev, GEEV)
172: #define LAPACKgels_   PETSCBLAS(gels, GELS)
173: #if !defined(PETSC_MISSING_LAPACK_STEGR)
174:   #define LAPACKstegr_ PETSCBLAS(stegr, STEGR) /* eigenvalues and eigenvectors of symm tridiagonal */
175: #endif
176: #if !defined(PETSC_MISSING_LAPACK_STEQR)
177:   #define LAPACKsteqr_     PETSCBLAS(steqr, STEQR) /* eigenvalues and eigenvectors of symm tridiagonal */
178:   #define LAPACKREALsteqr_ PETSCBLASREAL(steqr, STEQR)
179: #endif
180: #if !defined(PETSC_MISSING_LAPACK_STEV)
181:   #define LAPACKstev_     PETSCBLAS(stev, STEV) /* eigenvalues and eigenvectors of symm tridiagonal */
182:   #define LAPACKREALstev_ PETSCBLASREAL(stev, STEV)
183: #endif
184: #if !defined(PETSC_MISSING_LAPACK_HSEQR)
185:   #define LAPACKhseqr_ PETSCBLAS(hseqr, HSEQR)
186: #endif
187: #if !defined(PETSC_MISSING_LAPACK_GGES)
188:   #define LAPACKgges_ PETSCBLAS(gges, GGES)
189: #endif
190: #if !defined(PETSC_MISSING_LAPACK_TRSEN)
191:   #define LAPACKtrsen_ PETSCBLAS(trsen, TRSEN)
192: #endif
193: #if !defined(PETSC_MISSING_LAPACK_HGEQZ)
194:   #define LAPACKhgeqz_ PETSCBLAS(hgeqz, HGEQZ)
195: #endif
196: #if !defined(PETSC_MISSING_LAPACK_TRTRS)
197:   #define LAPACKtrtrs_ PETSCBLAS(trtrs, TRTRS)
198: #endif

200: /* Subroutine names that differ for real/complex data: */
201: #if !defined(PETSC_USE_COMPLEX)
202:   #if !defined(PETSC_MISSING_LAPACK_ORGQR)
203:     #define LAPACKorgqr_ PETSCBLAS(orgqr, ORGQR)
204:   #endif
205:   #if !defined(PETSC_MISSING_LAPACK_ORMQR)
206:     #define LAPACKormqr_ PETSCBLAS(ormqr, ORMQR)
207:   #endif
208:   #define BLASdot_  PETSCBLAS(dot, DOT)
209:   #define BLASdotu_ PETSCBLAS(dot, DOT)

211:   #define LAPACKsyev_  PETSCBLAS(syev, SYEV)   /* eigenvalues and eigenvectors of a symm matrix */
212:   #define LAPACKsyevx_ PETSCBLAS(syevx, SYEVX) /* selected eigenvalues and eigenvectors of a symm matrix */
213:   #define LAPACKsygv_  PETSCBLAS(sygv, SYGV)
214:   #define LAPACKsygvx_ PETSCBLAS(sygvx, SYGVX)

216:   /* stebz does not exist for complex data */
217:   #if !defined(PETSC_MISSING_LAPACK_STEBZ)
218:     #define LAPACKstebz_ PETSCBLAS(stebz, STEBZ) /* eigenvalues of symm tridiagonal matrix */
219:   #endif
220: #else
221:   #define LAPACKhetrf_ PETSCBLAS(hetrf, HETRF)
222:   #define LAPACKhetrs_ PETSCBLAS(hetrs, HETRS)
223:   #define LAPACKhetri_ PETSCBLAS(hetri, HETRI)
224:   #define LAPACKheev_  PETSCBLAS(heev, HEEV)
225:   #if !defined(PETSC_MISSING_LAPACK_ORGQR)
226:     #define LAPACKorgqr_ PETSCBLAS(ungqr, UNGQR)
227:   #endif
228:   #if !defined(PETSC_MISSING_LAPACK_ORMQR)
229:     #define LAPACKormqr_ PETSCBLAS(unmqr, UNMQR)
230:   #endif
231: /* note: dot and dotu are handled separately for complex data */

233:   #define LAPACKsyev_  PETSCBLAS(heev, HEEV)   /* eigenvalues and eigenvectors of a symm matrix */
234:   #define LAPACKsyevx_ PETSCBLAS(heevx, HEEVX) /* selected eigenvalues and eigenvectors of a symm matrix */
235:   #define LAPACKsygv_  PETSCBLAS(hegv, HEGV)
236:   #define LAPACKsygvx_ PETSCBLAS(hegvx, HEGVX)
237: #endif