Actual source code: aijmkl.h

      1: #pragma once
      2: /*
      3:   Wrappers for mkl_cspblas_ routines.
      4:   A more elegant way to do this would be to use an approach like that used in petsclbaslapack_mangle.h,
      5:   but since the MKL sparse BLAS routines are not going to be as widely used, and because
      6:   we don't have to worry about Fortran name mangling, this seems OK for now.
      7: */

      9: /* Have to redefine MKL_Complex16 and MKL_Complex8 as PetscScalar for the complex number cases.
     10:  * This works fine with a C99 compiler -- still need to verify that this works with C89.
     11:  * Note: These definitions need to occur BEFORE including MKL headers. */
     12: #define MKL_Complex16 PetscScalar
     13: #define MKL_Complex8  PetscScalar

     15: #if !defined(PETSC_USE_COMPLEX)
     16:   #if defined(PETSC_USE_REAL_SINGLE)
     17:     #define mkl_cspblas_xcsrgemv(transa, m, a, ia, ja, x, y) mkl_cspblas_scsrgemv(transa, m, a, ia, ja, x, y)
     18:   #elif defined(PETSC_USE_REAL_DOUBLE)
     19:     #define mkl_cspblas_xcsrgemv(transa, m, a, ia, ja, x, y) mkl_cspblas_dcsrgemv(transa, m, a, ia, ja, x, y)
     20:   #endif
     21: #else
     22:   #if defined(PETSC_USE_REAL_SINGLE)
     23:     #define mkl_cspblas_xcsrgemv(transa, m, a, ia, ja, x, y) mkl_cspblas_ccsrgemv(transa, m, a, ia, ja, x, y)
     24:   #elif defined(PETSC_USE_REAL_DOUBLE)
     25:     #define mkl_cspblas_xcsrgemv(transa, m, a, ia, ja, x, y) mkl_cspblas_zcsrgemv(transa, m, a, ia, ja, x, y)
     26:   #endif
     27: #endif

     29: /* Note: MKL releases prior to the end of 2014 do not have a const-correct interface -> ugly casts necessary.
     30:          Does not apply to mkl_sparse_x_*()-routines, because these have been introduced later. */
     31: #if !defined(PETSC_USE_COMPLEX)
     32:   #if defined(PETSC_USE_REAL_SINGLE)
     33:     #define mkl_xcsrmv(transa, m, k, alpha, matdescra, val, indx, pntrb, pntre, x, beta, y) mkl_scsrmv(transa, m, k, alpha, matdescra, (MatScalar *)val, (PetscInt *)indx, (PetscInt *)pntrb, (PetscInt *)pntre, (PetscScalar *)x, beta, y)
     34:   #elif defined(PETSC_USE_REAL_DOUBLE)
     35:     #define mkl_xcsrmv(transa, m, k, alpha, matdescra, val, indx, pntrb, pntre, x, beta, y) mkl_dcsrmv(transa, m, k, alpha, matdescra, (MatScalar *)val, (PetscInt *)indx, (PetscInt *)pntrb, (PetscInt *)pntre, (PetscScalar *)x, beta, y)
     36:   #endif
     37: #else
     38:   #if defined(PETSC_USE_REAL_SINGLE)
     39:     #define mkl_xcsrmv(transa, m, k, alpha, matdescra, val, indx, pntrb, pntre, x, beta, y) mkl_ccsrmv(transa, m, k, alpha, matdescra, (MatScalar *)val, (PetscInt *)indx, (PetscInt *)pntrb, (PetscInt *)pntre, (PetscScalar *)x, beta, y)
     40:   #elif defined(PETSC_USE_REAL_DOUBLE)
     41:     #define mkl_xcsrmv(transa, m, k, alpha, matdescra, val, indx, pntrb, pntre, x, beta, y) mkl_zcsrmv(transa, m, k, alpha, matdescra, (MatScalar *)val, (PetscInt *)indx, (PetscInt *)pntrb, (PetscInt *)pntre, (PetscScalar *)x, beta, y)
     42:   #endif
     43: #endif

     45: #if !defined(PETSC_USE_COMPLEX)
     46:   #if defined(PETSC_USE_REAL_SINGLE)
     47:     #define mkl_sparse_x_create_csr mkl_sparse_s_create_csr
     48:   #elif defined(PETSC_USE_REAL_DOUBLE)
     49:     #define mkl_sparse_x_create_csr mkl_sparse_d_create_csr
     50:   #endif
     51: #else
     52:   #if defined(PETSC_USE_REAL_SINGLE)
     53:     #define mkl_sparse_x_create_csr mkl_sparse_c_create_csr
     54:   #elif defined(PETSC_USE_REAL_DOUBLE)
     55:     #define mkl_sparse_x_create_csr mkl_sparse_z_create_csr
     56:   #endif
     57: #endif

     59: #if !defined(PETSC_USE_COMPLEX)
     60:   #if defined(PETSC_USE_REAL_SINGLE)
     61:     #define mkl_sparse_x_mv mkl_sparse_s_mv
     62:   #elif defined(PETSC_USE_REAL_DOUBLE)
     63:     #define mkl_sparse_x_mv mkl_sparse_d_mv
     64:   #endif
     65: #else
     66:   #if defined(PETSC_USE_REAL_SINGLE)
     67:     #define mkl_sparse_x_mv mkl_sparse_c_mv
     68:   #elif defined(PETSC_USE_REAL_DOUBLE)
     69:     #define mkl_sparse_x_mv mkl_sparse_z_mv
     70:   #endif
     71: #endif

     73: #if !defined(PETSC_USE_COMPLEX)
     74:   #if defined(PETSC_USE_REAL_SINGLE)
     75:     #define mkl_sparse_x_export_csr mkl_sparse_s_export_csr
     76:   #elif defined(PETSC_USE_REAL_DOUBLE)
     77:     #define mkl_sparse_x_export_csr mkl_sparse_d_export_csr
     78:   #endif
     79: #else
     80:   #if defined(PETSC_USE_REAL_SINGLE)
     81:     #define mkl_sparse_x_export_csr mkl_sparse_c_export_csr
     82:   #elif defined(PETSC_USE_REAL_DOUBLE)
     83:     #define mkl_sparse_x_export_csr mkl_sparse_z_export_csr
     84:   #endif
     85: #endif