Actual source code: slepcmagma.h

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain

      6:    This file is part of SLEPc.
      7:    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
      8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      9: */
     10: /*
     11:    Macro definitions to use MAGMA functionality
     12: */

     14: #pragma once

     16: /* MANSEC = Sys */

     18: #if defined(PETSC_HAVE_MAGMA)

     20: #include <magma_v2.h>

     22: SLEPC_EXTERN PetscErrorCode SlepcMagmaInit(void);

     24: #define PetscCallMAGMA(func, ...) do { \
     25:     magma_int_t magma_ierr_; \
     26:     PetscStackPushExternal(PetscStringize(func)); \
     27:     func(__VA_ARGS__,&magma_ierr_); \
     28:     PetscStackPop; \
     29:     PetscCheck(magma_ierr_ == MAGMA_SUCCESS,PETSC_COMM_SELF,PETSC_ERR_LIB,"Error calling %s: error code %d",PetscStringize(func(__VA_ARGS__,&magma_ierr)),(int)magma_ierr_); \
     30:   } while (0)
     31: #define CHKERRMAGMA(...) PetscCall(__VA_ARGS__)

     33: #if defined(PETSC_USE_COMPLEX)
     34: #if defined(PETSC_USE_REAL_SINGLE)
     35: #define magma_xgeev(a,b,c,d,e,f,g,h,i,j,k,l,m,n) magma_cgeev((a),(b),(c),(magmaFloatComplex*)(d),(e),(magmaFloatComplex*)(f),(magmaFloatComplex*)(g),(h),(magmaFloatComplex*)(i),(j),(magmaFloatComplex*)(k),(l),(m),(n))
     36: #define magma_xgesv_gpu(a,b,c,d,e,f,g,h)         magma_cgesv_gpu((a),(b),(magmaFloatComplex_ptr)(c),(d),(e),(magmaFloatComplex_ptr)(f),(g),(h))
     37: #define magma_xgetrf_gpu(a,b,c,d,e,f)   magma_cgetrf_gpu((a),(b),(magmaFloatComplex_ptr)(c),(d),(e),(f))
     38: #define magma_xgetri_gpu(a,b,c,d,e,f,g) magma_cgetri_gpu((a),(magmaFloatComplex_ptr)(b),(c),(d),(magmaFloatComplex_ptr)(e),(f),(g))
     39: #define magma_get_xgetri_nb             magma_get_cgetri_nb
     40: #else
     41: #define magma_xgeev(a,b,c,d,e,f,g,h,i,j,k,l,m,n) magma_zgeev((a),(b),(c),(magmaDoubleComplex*)(d),(e),(magmaDoubleComplex*)(f),(magmaDoubleComplex*)(g),(h),(magmaDoubleComplex*)(i),(j),(magmaDoubleComplex*)(k),(l),(m),(n))
     42: #define magma_xgesv_gpu(a,b,c,d,e,f,g,h)         magma_zgesv_gpu((a),(b),(magmaDoubleComplex_ptr)(c),(d),(e),(magmaDoubleComplex_ptr)(f),(g),(h))
     43: #define magma_xgetrf_gpu(a,b,c,d,e,f)   magma_zgetrf_gpu((a),(b),(magmaDoubleComplex_ptr)(c),(d),(e),(f))
     44: #define magma_xgetri_gpu(a,b,c,d,e,f,g) magma_zgetri_gpu((a),(magmaDoubleComplex_ptr)(b),(c),(d),(magmaDoubleComplex_ptr)(e),(f),(g))
     45: #define magma_get_xgetri_nb             magma_get_zgetri_nb
     46: #endif
     47: #else
     48: #if defined(PETSC_USE_REAL_SINGLE)
     49: #define magma_xgeev                     magma_sgeev
     50: #define magma_xgesv_gpu                 magma_sgesv_gpu
     51: #define magma_xgetrf_gpu                magma_sgetrf_gpu
     52: #define magma_xgetri_gpu                magma_sgetri_gpu
     53: #define magma_get_xgetri_nb             magma_get_sgetri_nb
     54: #else
     55: #define magma_xgeev                     magma_dgeev
     56: #define magma_xgesv_gpu                 magma_dgesv_gpu
     57: #define magma_xgetrf_gpu                magma_dgetrf_gpu
     58: #define magma_xgetri_gpu                magma_dgetri_gpu
     59: #define magma_get_xgetri_nb             magma_get_dgetri_nb
     60: #endif
     61: #endif

     63: #if defined(PETSC_USE_REAL_SINGLE)
     64: #define magma_Cgesv_gpu(a,b,c,d,e,f,g,h)         magma_cgesv_gpu((a),(b),(magmaFloatComplex_ptr)(c),(d),(e),(magmaFloatComplex_ptr)(f),(g),(h))
     65: #else
     66: #define magma_Cgesv_gpu(a,b,c,d,e,f,g,h)         magma_zgesv_gpu((a),(b),(magmaDoubleComplex_ptr)(c),(d),(e),(magmaDoubleComplex_ptr)(f),(g),(h))
     67: #endif

     69: #endif