Date: 2024-12-02T08:56:43+00:00

Actual source code: slepccupmblas.h
slepc-3.22.2 2024-12-02
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 and hipBLAS functionality
     12: */

     14: #pragma once

     16: #include <petscdevice.h>
     17: #include <petsc/private/petsclegacycupmblas.h>

     19: #if defined(PETSC_HAVE_CUDA)

     21: /* complex single */
     22: #if defined(PETSC_USE_COMPLEX)
     23: #if defined(PETSC_USE_REAL_SINGLE)
     24: #define cublasXgetrfBatched(a,b,c,d,e,f,g) cublasCgetrfBatched((a),(b),(cuComplex**)(c),(d),(e),(f),(g))
     25: #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))
     26: #else /* complex double */
     27: #define cublasXgetrfBatched(a,b,c,d,e,f,g) cublasZgetrfBatched((a),(b),(cuDoubleComplex**)(c),(d),(e),(f),(g))
     28: #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))
     29: #endif
     30: #else /* real single */
     31: #if defined(PETSC_USE_REAL_SINGLE)
     32: #define cublasXgetrfBatched cublasSgetrfBatched
     33: #define cublasXgetrsBatched cublasSgetrsBatched
     34: #else /* real double */
     35: #define cublasXgetrfBatched cublasDgetrfBatched
     36: #define cublasXgetrsBatched cublasDgetrsBatched
     37: #endif
     38: #endif

     40: /* the following ones are used for PetscComplex in both real and complex scalars */
     41: #if defined(PETSC_USE_REAL_SINGLE)
     42: #define cublasXCaxpy(a,b,c,d,e,f,g)                cublasCaxpy((a),(b),(const cuComplex *)(c),(const cuComplex *)(d),(e),(cuComplex *)(f),(g))
     43: #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))
     44: #define cublasXCscal(a,b,c,d,e)                    cublasCscal((a),(b),(const cuComplex *)(c),(cuComplex *)(d),(e))
     45: #else
     46: #define cublasXCaxpy(a,b,c,d,e,f,g)                cublasZaxpy((a),(b),(const cuDoubleComplex *)(c),(const cuDoubleComplex *)(d),(e),(cuDoubleComplex *)(f),(g))
     47: #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))
     48: #define cublasXCscal(a,b,c,d,e)                    cublasZscal((a),(b),(const cuDoubleComplex *)(c),(cuDoubleComplex *)(d),(e))
     49: #endif

     51: #endif // PETSC_HAVE_CUDA

     53: #if defined(PETSC_HAVE_HIP)

     55: /* complex single */
     56: #if defined(PETSC_USE_COMPLEX)
     57: #if defined(PETSC_USE_REAL_SINGLE)
     58: #else /* complex double */
     59: #endif
     60: #else /* real single */
     61: #if defined(PETSC_USE_REAL_SINGLE)
     62: #else /* real double */
     63: #endif
     64: #endif

     66: #endif // PETSC_HAVE_HIP