1 #ifndef AIJMKL_H 2 #define AIJMKL_H 3 /* 4 Wrappers for mkl_cspblas_ routines. 5 A more elegant way to do this would be to use an approach like that used in petsclbaslapack_mangle.h, 6 but since the MKL sparse BLAS routines are not going to be as widely used, and because 7 we don't have to worry about Fortran name mangling, this seems OK for now. 8 */ 9 10 /* Have to redefine MKL_Complex16 and MKL_Complex8 as PetscScalar for the complex number cases. 11 * This works fine with a C99 compiler -- still need to verify that this works with C89. 12 * Note: These definitions need to occur BEFORE including MKL headers. */ 13 #define MKL_Complex16 PetscScalar 14 #define MKL_Complex8 PetscScalar 15 16 #if !defined(PETSC_USE_COMPLEX) 17 #if defined(PETSC_USE_REAL_SINGLE) 18 #define mkl_cspblas_xcsrgemv(transa, m, a, ia, ja, x, y) mkl_cspblas_scsrgemv(transa, m, a, ia, ja, x, y) 19 #elif defined(PETSC_USE_REAL_DOUBLE) 20 #define mkl_cspblas_xcsrgemv(transa, m, a, ia, ja, x, y) mkl_cspblas_dcsrgemv(transa, m, a, ia, ja, x, y) 21 #endif 22 #else 23 #if defined(PETSC_USE_REAL_SINGLE) 24 #define mkl_cspblas_xcsrgemv(transa, m, a, ia, ja, x, y) mkl_cspblas_ccsrgemv(transa, m, a, ia, ja, x, y) 25 #elif defined(PETSC_USE_REAL_DOUBLE) 26 #define mkl_cspblas_xcsrgemv(transa, m, a, ia, ja, x, y) mkl_cspblas_zcsrgemv(transa, m, a, ia, ja, x, y) 27 #endif 28 #endif 29 30 /* Note: MKL releases prior to the end of 2014 do not have a const-correct interface -> ugly casts necessary. 31 Does not apply to mkl_sparse_x_*()-routines, because these have been introduced later. */ 32 #if !defined(PETSC_USE_COMPLEX) 33 #if defined(PETSC_USE_REAL_SINGLE) 34 #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) 35 #elif defined(PETSC_USE_REAL_DOUBLE) 36 #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) 37 #endif 38 #else 39 #if defined(PETSC_USE_REAL_SINGLE) 40 #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) 41 #elif defined(PETSC_USE_REAL_DOUBLE) 42 #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) 43 #endif 44 #endif 45 46 #if !defined(PETSC_USE_COMPLEX) 47 #if defined(PETSC_USE_REAL_SINGLE) 48 #define mkl_sparse_x_create_csr mkl_sparse_s_create_csr 49 #elif defined(PETSC_USE_REAL_DOUBLE) 50 #define mkl_sparse_x_create_csr mkl_sparse_d_create_csr 51 #endif 52 #else 53 #if defined(PETSC_USE_REAL_SINGLE) 54 #define mkl_sparse_x_create_csr mkl_sparse_c_create_csr 55 #elif defined(PETSC_USE_REAL_DOUBLE) 56 #define mkl_sparse_x_create_csr mkl_sparse_z_create_csr 57 #endif 58 #endif 59 60 #if !defined(PETSC_USE_COMPLEX) 61 #if defined(PETSC_USE_REAL_SINGLE) 62 #define mkl_sparse_x_mv mkl_sparse_s_mv 63 #elif defined(PETSC_USE_REAL_DOUBLE) 64 #define mkl_sparse_x_mv mkl_sparse_d_mv 65 #endif 66 #else 67 #if defined(PETSC_USE_REAL_SINGLE) 68 #define mkl_sparse_x_mv mkl_sparse_c_mv 69 #elif defined(PETSC_USE_REAL_DOUBLE) 70 #define mkl_sparse_x_mv mkl_sparse_z_mv 71 #endif 72 #endif 73 74 #if !defined(PETSC_USE_COMPLEX) 75 #if defined(PETSC_USE_REAL_SINGLE) 76 #define mkl_sparse_x_export_csr mkl_sparse_s_export_csr 77 #elif defined(PETSC_USE_REAL_DOUBLE) 78 #define mkl_sparse_x_export_csr mkl_sparse_d_export_csr 79 #endif 80 #else 81 #if defined(PETSC_USE_REAL_SINGLE) 82 #define mkl_sparse_x_export_csr mkl_sparse_c_export_csr 83 #elif defined(PETSC_USE_REAL_DOUBLE) 84 #define mkl_sparse_x_export_csr mkl_sparse_z_export_csr 85 #endif 86 #endif 87 88 #endif 89