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: /* macros to mangle BLAS/LAPACK names as needed for linking */

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

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

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

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

    119: /* definitions of BLAS and LAPACK symbols */

    121: /* Subroutine names that are the same for real/complex data: */
    122: /* no character-string arguments: */
    123: #define LAPACKgeqrf_     PETSCBLAS(geqrf, GEQRF)
    124: #define LAPACKgetrf_     PETSCBLAS(getrf, GETRF)
    125: #define LAPACKgetri_     PETSCBLAS(getri, GETRI)
    126: #define LAPACKREALgetrf_ PETSCBLASREAL(getrf, GETRF)
    127: #define LAPACKREALgetri_ PETSCBLASREAL(getri, GETRI)
    128: #define BLASnrm2_        PETSCBLASR(nrm2, NRM2)
    129: #define BLASscal_        PETSCBLAS(scal, SCAL)
    130: #define BLAScopy_        PETSCBLAS(copy, COPY)
    131: #define BLASswap_        PETSCBLAS(swap, SWAP)
    132: #define BLASaxpy_        PETSCBLAS(axpy, AXPY)
    133: #define BLASasum_        PETSCBLASR(asum, ASUM)
    134: #define LAPACKpttrf_     PETSCBLAS(pttrf, PTTRF) /* factorization of a spd tridiagonal matrix */
    135: #define LAPACKpttrs_     PETSCBLAS(pttrs, PTTRS) /* solve a spd tridiagonal matrix system */
    136: #if !defined(PETSC_MISSING_LAPACK_STEIN)
    137:   #define LAPACKstein_ PETSCBLAS(stein, STEIN) /* eigenvectors of real symm tridiagonal matrix */
    138: #endif
    139: #define LAPACKgesv_ PETSCBLAS(gesv, GESV)
    140: #if !defined(PETSC_MISSING_LAPACK_GELSS)
    141:   #define LAPACKgelss_ PETSCBLAS(gelss, GELSS)
    142: #endif
    143: #if !defined(PETSC_MISSING_LAPACK_GERFS)
    144:   #define LAPACKgerfs_ PETSCBLAS(gerfs, GERFS)
    145: #endif
    146: #if !defined(PETSC_MISSING_LAPACK_TGSEN)
    147:   #define LAPACKtgsen_ PETSCBLAS(tgsen, TGSEN)
    148: #endif
    149: /* character-string arguments: */
    150: #define LAPACKtrtri_ PETSCBLAS(trtri, TRTRI)
    151: #define LAPACKpotrf_ PETSCBLAS(potrf, POTRF)
    152: #define LAPACKpotri_ PETSCBLAS(potri, POTRI)
    153: #define LAPACKpotrs_ PETSCBLAS(potrs, POTRS)
    154: #define LAPACKsytrf_ PETSCBLAS(sytrf, SYTRF)
    155: #define LAPACKsytrs_ PETSCBLAS(sytrs, SYTRS)
    156: #if !defined(PETSC_MISSING_LAPACK_SYTRI)
    157:   #define LAPACKsytri_ PETSCBLAS(sytri, SYTRI)
    158: #endif
    159: #define BLASgemv_     PETSCBLAS(gemv, GEMV)
    160: #define LAPACKgetrs_  PETSCBLAS(getrs, GETRS)
    161: #define BLAStrmv_     PETSCBLAS(trmv, TRMV)
    162: #define BLAStrsv_     PETSCBLAS(trsv, TRSV)
    163: #define BLASgemm_     PETSCBLAS(gemm, GEMM)
    164: #define BLASsymm_     PETSCBLAS(symm, SYMM)
    165: #define BLASsyrk_     PETSCBLAS(syrk, SYRK)
    166: #define BLASsyr2k_    PETSCBLAS(syr2k, SYR2K)
    167: #define BLAStrsm_     PETSCBLAS(trsm, TRSM)
    168: #define BLASREALgemm_ PETSCBLASREAL(gemm, GEMM)
    169: #define LAPACKgesvd_  PETSCBLAS(gesvd, GESVD)
    170: #define LAPACKgeev_   PETSCBLAS(geev, GEEV)
    171: #define LAPACKgels_   PETSCBLAS(gels, GELS)
    172: #if !defined(PETSC_MISSING_LAPACK_STEGR)
    173:   #define LAPACKstegr_ PETSCBLAS(stegr, STEGR) /* eigenvalues and eigenvectors of symm tridiagonal */
    174: #endif
    175: #if !defined(PETSC_MISSING_LAPACK_STEQR)
    176:   #define LAPACKsteqr_     PETSCBLAS(steqr, STEQR) /* eigenvalues and eigenvectors of symm tridiagonal */
    177:   #define LAPACKREALsteqr_ PETSCBLASREAL(steqr, STEQR)
    178: #endif
    179: #if !defined(PETSC_MISSING_LAPACK_STEV)
    180:   #define LAPACKstev_     PETSCBLAS(stev, STEV) /* eigenvalues and eigenvectors of symm tridiagonal */
    181:   #define LAPACKREALstev_ PETSCBLASREAL(stev, STEV)
    182: #endif
    183: #if !defined(PETSC_MISSING_LAPACK_HSEQR)
    184:   #define LAPACKhseqr_ PETSCBLAS(hseqr, HSEQR)
    185: #endif
    186: #if !defined(PETSC_MISSING_LAPACK_GGES)
    187:   #define LAPACKgges_ PETSCBLAS(gges, GGES)
    188: #endif
    189: #if !defined(PETSC_MISSING_LAPACK_TRSEN)
    190:   #define LAPACKtrsen_ PETSCBLAS(trsen, TRSEN)
    191: #endif
    192: #if !defined(PETSC_MISSING_LAPACK_HGEQZ)
    193:   #define LAPACKhgeqz_ PETSCBLAS(hgeqz, HGEQZ)
    194: #endif
    195: #if !defined(PETSC_MISSING_LAPACK_TRTRS)
    196:   #define LAPACKtrtrs_ PETSCBLAS(trtrs, TRTRS)
    197: #endif

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

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

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

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