Actual source code: slepccublas.h
slepc-3.21.1 2024-04-26
Report Typos and Errors

      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 CUBLAS functionality
     12: */

     14: #pragma once

     16: #include <petscdevice.h>

     18: /* complex single */
     19: #if defined(PETSC_USE_COMPLEX)
     20: #if defined(PETSC_USE_REAL_SINGLE)
     21: #define cublasXgemm(a,b,c,d,e,f,g,h,i,j,k,l,m,n) cublasCgemm((a),(b),(c),(d),(e),(f),(const cuComplex*)(g),(const cuComplex*)(h),(i),(const cuComplex*)(j),(k),(const cuComplex*)(l),(cuComplex*)(m),(n))
     22: #define cublasXgemv(a,b,c,d,e,f,g,h,i,j,k,l) cublasCgemv((a),(b),(c),(d),(cuComplex*)(e),(cuComplex*)(f),(g),(cuComplex*)(h),(i),(cuComplex*)(j),(cuComplex*)(k),(l))
     23: #define cublasXgeam(a,b,c,d,e,f,g,h,i,j,k,l,m) cublasCgeam((a),(b),(c),(d),(e),(cuComplex*)(f),(cuComplex*)(g),(h),(cuComplex*)(i),(cuComplex*)(j),(k),(cuComplex*)(l),(m))
     24: #define cublasXscal(a,b,c,d,e) cublasCscal((a),(b),(const cuComplex*)(c),(cuComplex*)(d),(e))
     25: #define cublasXnrm2(a,b,c,d,e) cublasScnrm2((a),(b),(const cuComplex*)(c),(d),(e))
     26: #define cublasXaxpy(a,b,c,d,e,f,g) cublasCaxpy((a),(b),(const cuComplex*)(c),(const cuComplex*)(d),(e),(cuComplex*)(f),(g))
     27: #define cublasXdotc(a,b,c,d,e,f,g) cublasCdotc((a),(b),(const cuComplex *)(c),(d),(const cuComplex *)(e),(f),(cuComplex *)(g))
     28: #define cublasXgetrfBatched(a,b,c,d,e,f,g) cublasCgetrfBatched((a),(b),(cuComplex**)(c),(d),(e),(f),(g))
     29: #define cublasXgetrsBatched(a,b,c,d,e,f,g,h,i,j,k) cublasCgetrsBatched((a),(b),(c),(d),(const cuComplex**)(e),(f),(g),(cuComplex**)(h),(i),(j),(k))
     30: #else /* complex double */
     31: #define cublasXgemm(a,b,c,d,e,f,g,h,i,j,k,l,m,n) cublasZgemm((a),(b),(c),(d),(e),(f),(const cuDoubleComplex*)(g),(const cuDoubleComplex*)(h),(i),(const cuDoubleComplex*)(j),(k),(const cuDoubleComplex*)(l),(cuDoubleComplex *)(m),(n))
     32: #define cublasXgemv(a,b,c,d,e,f,g,h,i,j,k,l) cublasZgemv((a),(b),(c),(d),(cuDoubleComplex*)(e),(cuDoubleComplex*)(f),(g),(cuDoubleComplex*)(h),(i),(cuDoubleComplex*)(j),(cuDoubleComplex*)(k),(l))
     33: #define cublasXgeam(a,b,c,d,e,f,g,h,i,j,k,l,m) cublasZgeam((a),(b),(c),(d),(e),(cuDoubleComplex*)(f),(cuDoubleComplex*)(g),(h),(cuDoubleComplex*)(i),(cuDoubleComplex*)(j),(k),(cuDoubleComplex*)(l),(m))
     34: #define cublasXscal(a,b,c,d,e) cublasZscal((a),(b),(const cuDoubleComplex*)(c),(cuDoubleComplex*)(d),(e))
     35: #define cublasXnrm2(a,b,c,d,e) cublasDznrm2((a),(b),(const cuDoubleComplex*)(c),(d),(e))
     36: #define cublasXaxpy(a,b,c,d,e,f,g) cublasZaxpy((a),(b),(const cuDoubleComplex*)(c),(const cuDoubleComplex*)(d),(e),(cuDoubleComplex*)(f),(g))
     37: #define cublasXdotc(a,b,c,d,e,f,g) cublasZdotc((a),(b),(const cuDoubleComplex *)(c),(d),(const cuDoubleComplex *)(e),(f),(cuDoubleComplex *)(g))
     38: #define cublasXgetrfBatched(a,b,c,d,e,f,g) cublasZgetrfBatched((a),(b),(cuDoubleComplex**)(c),(d),(e),(f),(g))
     39: #define cublasXgetrsBatched(a,b,c,d,e,f,g,h,i,j,k) cublasZgetrsBatched((a),(b),(c),(d),(const cuDoubleComplex**)(e),(f),(g),(cuDoubleComplex**)(h),(i),(j),(k))
     40: #endif
     41: #else /* real single */
     42: #if defined(PETSC_USE_REAL_SINGLE)
     43: #define cublasXgemm cublasSgemm
     44: #define cublasXgemv cublasSgemv
     45: #define cublasXgeam cublasSgeam
     46: #define cublasXscal cublasSscal
     47: #define cublasXnrm2 cublasSnrm2
     48: #define cublasXaxpy cublasSaxpy
     49: #define cublasXdotc cublasSdot
     50: #define cublasXgetrfBatched cublasSgetrfBatched
     51: #define cublasXgetrsBatched cublasSgetrsBatched
     52: #else /* real double */
     53: #define cublasXgemm cublasDgemm
     54: #define cublasXgemv cublasDgemv
     55: #define cublasXgeam cublasDgeam
     56: #define cublasXscal cublasDscal
     57: #define cublasXnrm2 cublasDnrm2
     58: #define cublasXaxpy cublasDaxpy
     59: #define cublasXdotc cublasDdot
     60: #define cublasXgetrfBatched cublasDgetrfBatched
     61: #define cublasXgetrsBatched cublasDgetrsBatched
     62: #endif
     63: #endif

     65: #if defined(PETSC_USE_REAL_SINGLE)
     66: #define cublasXCaxpy(a,b,c,d,e,f,g)                cublasCaxpy((a),(b),(const cuComplex *)(c),(const cuComplex *)(d),(e),(cuComplex *)(f),(g))
     67: #define cublasXCgemm(a,b,c,d,e,f,g,h,i,j,k,l,m,n)  cublasCgemm((a),(b),(c),(d),(e),(f),(const cuComplex *)(g),(const cuComplex *)(h),(i),(const cuComplex *)(j),(k),(const cuComplex *)(l),(cuComplex *)(m),(n))
     68: #define cublasXCscal(a,b,c,d,e)                    cublasCscal((a),(b),(const cuComplex *)(c),(cuComplex *)(d),(e))
     69: #else
     70: #define cublasXCaxpy(a,b,c,d,e,f,g)                cublasZaxpy((a),(b),(const cuDoubleComplex *)(c),(const cuDoubleComplex *)(d),(e),(cuDoubleComplex *)(f),(g))
     71: #define cublasXCgemm(a,b,c,d,e,f,g,h,i,j,k,l,m,n)  cublasZgemm((a),(b),(c),(d),(e),(f),(const cuDoubleComplex *)(g),(const cuDoubleComplex *)(h),(i),(const cuDoubleComplex *)(j),(k),(const cuDoubleComplex *)(l),(cuDoubleComplex *)(m),(n))
     72: #define cublasXCscal(a,b,c,d,e)                    cublasZscal((a),(b),(const cuDoubleComplex *)(c),(cuDoubleComplex *)(d),(e))
     73: #endif /* COMPLEX */