Date: 2022-03-31T04:46:08+00:00

Actual source code: cupmblasinterface.cxx

      1: #include <petsc/private/cupmblasinterface.hpp>

      3: namespace Petsc
      4: {

      6: namespace Device
      7: {

      9: namespace CUPM
     10: {

     12: namespace Impl
     13: {

     15: #define PETSC_CUPMBLAS_STATIC_VARIABLE_DEFN(THEIRS,DEVICE,OURS)         \
     16:   const decltype(THEIRS) BlasInterface<DeviceType::DEVICE>::OURS;

     18: // in case either one or the other don't agree on a name, you can specify all three here:
     19: //
     20: // PETSC_CUPMBLAS_DEFINE_STATIC_VARIABLE_EXACT(CUBLAS_STATUS_SUCCESS, rocblas_status_success,
     21: // CUPMBLAS_STATUS_SUCCESS) ->
     22: // const decltype(CUBLAS_STATUS_SUCCESS)  BlasInterface<DeviceType::CUDA>::CUPMBLAS_STATUS_SUCCESS;
     23: // const decltype(rocblas_status_success) BlasInterface<DeviceType::HIP>::CUPMBLAS_STATUS_SUCCESS;
     24: #define PETSC_CUPMBLAS_DEFINE_STATIC_VARIABLE_EXACT(CUORIGINAL,HIPORIGINAL,OURS) \
     25:   PetscIfPetscDefined(HAVE_CUDA,PETSC_CUPMBLAS_STATIC_VARIABLE_DEFN,PetscExpandToNothing)(CUORIGINAL,CUDA,OURS) \
     26:   PetscIfPetscDefined(HAVE_HIP,PETSC_CUPMBLAS_STATIC_VARIABLE_DEFN,PetscExpandToNothing)(HIPORIGINAL,HIP,OURS)

     28: // if both cuda and hip agree on the same naming scheme i.e. CUBLAS_STATUS_SUCCESS and
     29: // HIPBLAS_STATUS_SUCCESS:
     30: //
     31: // PETSC_CUPMBLAS_DEFINE_STATIC_VARIABLE_MATCHING_PREFIX(STATUS_SUCCESS) ->
     32: // const decltype(CUBLAS_STATUS_SUCCESS)  BlasInterface<DeviceType::CUDA>::CUPMBLAS_STATUS_SUCCESS;
     33: // const decltype(HIPBLAS_STATUS_SUCCESS) BlasInterface<DeviceType::HIP>::CUPMBLAS_STATUS_SUCCESS;
     34: #define PETSC_CUPMBLAS_DEFINE_STATIC_VARIABLE_MATCHING_SCHEME(SUFFIX)   \
     35:   PETSC_CUPMBLAS_DEFINE_STATIC_VARIABLE_EXACT(PetscConcat(CUBLAS_,SUFFIX),PetscConcat(HIPBLAS_,SUFFIX),PetscConcat(CUPMBLAS_,SUFFIX))

     37: PETSC_CUPMBLAS_DEFINE_STATIC_VARIABLE_MATCHING_SCHEME(STATUS_SUCCESS)
     38: PETSC_CUPMBLAS_DEFINE_STATIC_VARIABLE_MATCHING_SCHEME(STATUS_NOT_INITIALIZED)
     39: PETSC_CUPMBLAS_DEFINE_STATIC_VARIABLE_MATCHING_SCHEME(STATUS_ALLOC_FAILED)

     41: } // namespace Impl

     43: } // namespace CUPM

     45: } // namespace Device

     47: } // namespace Petsc