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: /* MANSEC = Sys */

     10: /* macros to mangle BLAS/LAPACK names as needed for linking */

     12: /* token pasting, with an extra level of indirection so that we
     13:    can paste the contents of other preprocessor #definitions */
     14: #define PETSC_PASTE2_(a, b)    a##b
     15: #define PETSC_PASTE2(a, b)     PETSC_PASTE2_(a, b)
     16: #define PETSC_PASTE3_(a, b, c) a##b##c
     17: #define PETSC_PASTE3(a, b, c)  PETSC_PASTE3_(a, b, c)

     19: #if !defined(PETSC_BLASLAPACK_SUFFIX)
     20:   #if defined(PETSC_BLASLAPACK_UNDERSCORE)
     21:     #define PETSC_BLASLAPACK_SUFFIX_ _
     22:   #else
     23:     #define PETSC_BLASLAPACK_SUFFIX_
     24:   #endif
     25: #else
     26:   #if defined(PETSC_BLASLAPACK_UNDERSCORE)
     27:     #define PETSC_BLASLAPACK_SUFFIX_ PETSC_PASTE2(PETSC_BLASLAPACK_SUFFIX, _)
     28:   #else
     29:     #define PETSC_BLASLAPACK_SUFFIX_ PETSC_BLASLAPACK_SUFFIX
     30:   #endif
     31: #endif

     33: /* complex/real and single/double/quad/half precision prefixes: */
     34: #if !defined(PETSC_USE_COMPLEX)
     35:   #if defined(PETSC_BLASLAPACK_CAPS)
     36:     #if defined(PETSC_USE_REAL_SINGLE)
     37:       #define PETSC_BLASLAPACK_PREFIX_        S
     38:       #define PETSC_BLASLAPACK_PREFIX_COMPLEX C
     39:     #elif defined(PETSC_USE_REAL_DOUBLE)
     40:       #define PETSC_BLASLAPACK_PREFIX_        D
     41:       #define PETSC_BLASLAPACK_PREFIX_COMPLEX Z
     42:     #elif defined(PETSC_USE_REAL___FLOAT128)
     43:       #define PETSC_BLASLAPACK_PREFIX_        Q
     44:       #define PETSC_BLASLAPACK_PREFIX_COMPLEX W
     45:     #else
     46:       #define PETSC_BLASLAPACK_PREFIX_        H
     47:       #define PETSC_BLASLAPACK_PREFIX_COMPLEX K
     48:     #endif
     49:   #else
     50:     #if defined(PETSC_USE_REAL_SINGLE)
     51:       #define PETSC_BLASLAPACK_PREFIX_        s
     52:       #define PETSC_BLASLAPACK_PREFIX_COMPLEX c
     53:     #elif defined(PETSC_USE_REAL_DOUBLE)
     54:       #define PETSC_BLASLAPACK_PREFIX_        d
     55:       #define PETSC_BLASLAPACK_PREFIX_COMPLEX z
     56:     #elif defined(PETSC_USE_REAL___FLOAT128)
     57:       #define PETSC_BLASLAPACK_PREFIX_        q
     58:       #define PETSC_BLASLAPACK_PREFIX_COMPLEX w
     59:     #else
     60:       #define PETSC_BLASLAPACK_PREFIX_        h
     61:       #define PETSC_BLASLAPACK_PREFIX_COMPLEX k
     62:     #endif
     63:   #endif
     64:   #define PETSC_BLASLAPACK_RPREFIX_    PETSC_BLASLAPACK_PREFIX_
     65:   #define PETSC_BLASLAPACK_PREFIX_REAL PETSC_BLASLAPACK_PREFIX_
     66: #else
     67:   #if defined(PETSC_BLASLAPACK_CAPS)
     68:     #if defined(PETSC_USE_REAL_SINGLE)
     69:       #define PETSC_BLASLAPACK_PREFIX_     C
     70:       #define PETSC_BLASLAPACK_PREFIX_REAL S
     71:       #define PETSC_BLASLAPACK_RPREFIX_    SC
     72:     #elif defined(PETSC_USE_REAL_DOUBLE)
     73:       #define PETSC_BLASLAPACK_PREFIX_     Z
     74:       #define PETSC_BLASLAPACK_PREFIX_REAL D
     75:       #define PETSC_BLASLAPACK_RPREFIX_    DZ
     76:     #elif defined(PETSC_USE_REAL___FLOAT128)
     77:       #define PETSC_BLASLAPACK_PREFIX_     W
     78:       #define PETSC_BLASLAPACK_PREFIX_REAL Q
     79:       #define PETSC_BLASLAPACK_RPREFIX_    QW
     80:     #else
     81:       #define PETSC_BLASLAPACK_PREFIX_     K
     82:       #define PETSC_BLASLAPACK_PREFIX_REAL H
     83:       #define PETSC_BLASLAPACK_RPREFIX_    HK
     84:     #endif
     85:   #else
     86:     #if defined(PETSC_USE_REAL_SINGLE)
     87:       #define PETSC_BLASLAPACK_PREFIX_     c
     88:       #define PETSC_BLASLAPACK_PREFIX_REAL s
     89:       #define PETSC_BLASLAPACK_RPREFIX_    sc
     90:     #elif defined(PETSC_USE_REAL_DOUBLE)
     91:       #define PETSC_BLASLAPACK_PREFIX_     z
     92:       #define PETSC_BLASLAPACK_PREFIX_REAL d
     93:       #define PETSC_BLASLAPACK_RPREFIX_    dz
     94:     #elif defined(PETSC_USE_REAL___FLOAT128)
     95:       #define PETSC_BLASLAPACK_PREFIX_     w
     96:       #define PETSC_BLASLAPACK_PREFIX_REAL q
     97:       #define PETSC_BLASLAPACK_RPREFIX_    qw
     98:     #else
     99:       #define PETSC_BLASLAPACK_PREFIX_     k
    100:       #define PETSC_BLASLAPACK_PREFIX_REAL h
    101:       #define PETSC_BLASLAPACK_RPREFIX_    hk
    102:     #endif
    103:   #endif
    104:   #define PETSC_BLASLAPACK_PREFIX_COMPLEX PETSC_BLASLAPACK_PREFIX_
    105: #endif

    107: /* define macros PETSCBLAS to mangle BLAS/LAPACK subroutine names, and
    108:    PETSCBLASR for functions returning real values */
    109: #if defined(PETSC_BLASLAPACK_CAPS)
    110:   #define PETSCBLAS(x, X)        PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_, X, PETSC_BLASLAPACK_SUFFIX_)
    111:   #define PETSCBLASREAL(x, X)    PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_REAL, X, PETSC_BLASLAPACK_SUFFIX_)
    112:   #define PETSCBLASCOMPLEX(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_COMPLEX, X, PETSC_BLASLAPACK_SUFFIX_)
    113:   #define PETSCBLASR(x, X)       PETSC_PASTE3(PETSC_BLASLAPACK_RPREFIX_, X, PETSC_BLASLAPACK_SUFFIX_)
    114: #else
    115:   #define PETSCBLAS(x, X)        PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_, x, PETSC_BLASLAPACK_SUFFIX_)
    116:   #define PETSCBLASREAL(x, X)    PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_REAL, x, PETSC_BLASLAPACK_SUFFIX_)
    117:   #define PETSCBLASCOMPLEX(x, X) PETSC_PASTE3(PETSC_BLASLAPACK_PREFIX_COMPLEX, x, PETSC_BLASLAPACK_SUFFIX_)
    118:   #define PETSCBLASR(x, X)       PETSC_PASTE3(PETSC_BLASLAPACK_RPREFIX_, x, PETSC_BLASLAPACK_SUFFIX_)
    119: #endif

    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:   #define LAPACKgerc_ PETSCBLAS(ger, GER)
    222:   #define BLAShemv_   PETSCBLAS(symv, SYMV)
    223: #else
    224:   #define LAPACKhetrf_ PETSCBLAS(hetrf, HETRF)
    225:   #define LAPACKhetrs_ PETSCBLAS(hetrs, HETRS)
    226:   #define LAPACKhetri_ PETSCBLAS(hetri, HETRI)
    227:   #define LAPACKheev_  PETSCBLAS(heev, HEEV)
    228:   #if !defined(PETSC_MISSING_LAPACK_ORGQR)
    229:     #define LAPACKorgqr_ PETSCBLAS(ungqr, UNGQR)
    230:   #endif
    231:   #if !defined(PETSC_MISSING_LAPACK_ORMQR)
    232:     #define LAPACKormqr_ PETSCBLAS(unmqr, UNMQR)
    233:   #endif
    234: /* note: dot and dotu are handled separately for complex data */

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

    241:   #define LAPACKgerc_ PETSCBLAS(gerc, GERC)
    242:   #define BLAShemv_   PETSCBLAS(hemv, HEMV)
    243: #endif