                       double alpha, const double *A, int lda,
                                           double *B, int ldb,
                       cudaStream_t stream){
-
-  cublasHandle_t cublas_handle;
-  if( cublasCreate(&cublas_handle) != CUBLAS_STATUS_SUCCESS ) return;
-  if( cublasSetStream_v2(cublas_handle, stream) != CUBLAS_STATUS_SUCCESS ){
-    cublasDestroy_v2(cublas_handle);
-    return;
-  }
-  cublasSideMode_t  side_v2  = (side  == KBLAS_Left  ? CUBLAS_SIDE_LEFT : CUBLAS_SIDE_RIGHT);
-  cublasFillMode_t  uplo_v2  = (uplo  == KBLAS_Lower ? CUBLAS_FILL_MODE_LOWER : CUBLAS_FILL_MODE_UPPER);
-  cublasOperation_t trans_v2 = (trans == KBLAS_Trans ? CUBLAS_OP_T : CUBLAS_OP_N);
-  cublasDiagType_t  diag_v2  = (diag  == KBLAS_Unit  ? CUBLAS_DIAG_UNIT : CUBLAS_DIAG_NON_UNIT);
-
-  kblasXtrmm(cublas_handle,
-             side_v2, uplo_v2, trans_v2, diag_v2,
-             m, n,
-             &alpha, A, lda,
-                     B, ldb);
-
-  cublasDestroy_v2(cublas_handle);
+  kblasXtrmm_async_BODY
 }
 void kblasCtrmm_async(char side, char uplo, char trans, char diag,
                       int m, int n,
                       cuComplex alpha, const cuComplex *A, int lda,
                                              cuComplex *B, int ldb,
                       cudaStream_t stream){
-
-  cublasHandle_t cublas_handle;
-  if( cublasCreate(&cublas_handle) != CUBLAS_STATUS_SUCCESS ) return;
-  if( cublasSetStream_v2(cublas_handle, stream) != CUBLAS_STATUS_SUCCESS ){
-    cublasDestroy_v2(cublas_handle);
-    return;
-  }
-  cublasSideMode_t  side_v2  = (side  == KBLAS_Left  ? CUBLAS_SIDE_LEFT : CUBLAS_SIDE_RIGHT);
-  cublasFillMode_t  uplo_v2  = (uplo  == KBLAS_Lower ? CUBLAS_FILL_MODE_LOWER : CUBLAS_FILL_MODE_UPPER);
-  cublasOperation_t trans_v2 = (trans == KBLAS_Trans ? CUBLAS_OP_T : CUBLAS_OP_N);
-  cublasDiagType_t  diag_v2  = (diag  == KBLAS_Unit  ? CUBLAS_DIAG_UNIT : CUBLAS_DIAG_NON_UNIT);
-
-  kblasXtrmm(cublas_handle,
-             side_v2, uplo_v2, trans_v2, diag_v2,
-             m, n,
-             &alpha, A, lda,
-                     B, ldb);
-
-  cublasDestroy_v2(cublas_handle);
+  kblasXtrmm_async_BODY
 }
 void kblasZtrmm_async(char side, char uplo, char trans, char diag,
                       int m, int n,
                       cuDoubleComplex alpha, const cuDoubleComplex *A, int lda,
                                                    cuDoubleComplex *B, int ldb,
                       cudaStream_t stream){
-
-  cublasHandle_t cublas_handle;
-  if( cublasCreate(&cublas_handle) != CUBLAS_STATUS_SUCCESS ) return;
-  if( cublasSetStream_v2(cublas_handle, stream) != CUBLAS_STATUS_SUCCESS ){
-    cublasDestroy_v2(cublas_handle);
-    return;
-  }
-  cublasSideMode_t  side_v2  = (side  == KBLAS_Left  ? CUBLAS_SIDE_LEFT : CUBLAS_SIDE_RIGHT);
-  cublasFillMode_t  uplo_v2  = (uplo  == KBLAS_Lower ? CUBLAS_FILL_MODE_LOWER : CUBLAS_FILL_MODE_UPPER);
-  cublasOperation_t trans_v2 = (trans == KBLAS_Trans ? CUBLAS_OP_T : CUBLAS_OP_N);
-  cublasDiagType_t  diag_v2  = (diag  == KBLAS_Unit  ? CUBLAS_DIAG_UNIT : CUBLAS_DIAG_NON_UNIT);
-
-  kblasXtrmm(cublas_handle,
-             side_v2, uplo_v2, trans_v2, diag_v2,
-             m, n,
-             &alpha, A, lda,
-                     B, ldb);
-
-  cublasDestroy_v2(cublas_handle);
+  kblasXtrmm_async_BODY
 }
 //==============================================================================================
 

  return CUBLAS_STATUS_SUCCESS;
}


//==============================================================================================


}*/
  //==============================================================================================

#define kblasXtrmm_async_BODY {                                                                           \
  cublasHandle_t cublas_handle;                                                                           \
  if( cublasCreate(&cublas_handle) != CUBLAS_STATUS_SUCCESS ) return;                                     \
  if( cublasSetStream_v2(cublas_handle, stream) != CUBLAS_STATUS_SUCCESS ){                               \
    cublasDestroy_v2(cublas_handle);                                                                      \
    return;                                                                                               \
  }                                                                                                       \
  cublasSideMode_t  side_v2  = (side  == KBLAS_Left  ? CUBLAS_SIDE_LEFT : CUBLAS_SIDE_RIGHT);             \
  cublasFillMode_t  uplo_v2  = (uplo  == KBLAS_Lower ? CUBLAS_FILL_MODE_LOWER : CUBLAS_FILL_MODE_UPPER);  \
  cublasOperation_t trans_v2 = (trans == KBLAS_Trans ? CUBLAS_OP_T : CUBLAS_OP_N);                        \
  cublasDiagType_t  diag_v2  = (diag  == KBLAS_Unit  ? CUBLAS_DIAG_UNIT : CUBLAS_DIAG_NON_UNIT);          \
                                                                                                          \
  kblasXtrmm(cublas_handle,                                                                               \
             side_v2, uplo_v2, trans_v2, diag_v2,                                                         \
             m, n,                                                                                        \ 
             &alpha, A, lda,                                                                              \
                     B, ldb);                                                                             \
                                                                                                          \
  cublasDestroy_v2(cublas_handle);                                                                        \
}

void kblasStrmm_async(char side, char uplo, char trans, char diag,
                      int m, int n,
                      float alpha, const float *A, int lda,
                                         float *B, int ldb,
                      cudaStream_t stream){
  kblasXtrmm_async_BODY
}

void kblasDtrmm_async(char side, char uplo, char trans, char diag,
