27#ifndef math_cublasHandle_hpp
28#define math_cublasHandle_hpp
36#include <cuda_runtime.h>
60 cublasHandle_t m_handle{ NULL };
71 explicit cublasHandle(
bool create )
75 cublasStatus_t cbec = this->create();
77 if( cbec != CUBLAS_STATUS_SUCCESS )
79 std::string msg = std::format(
"cublasHandle::cublasHandle error from create: [{}] {}\n",
80 cublasGetStatusName( cbec ),
81 cublasGetStatusString( cbec ) );
91 cublasStatus_t cbec = destroy();
92 if( cbec != CUBLAS_STATUS_SUCCESS )
94 std::cerr << std::format(
"cublasHandle::~cublasHandle error from destroy: [{}] {}\n",
95 cublasGetStatusName( cbec ),
96 cublasGetStatusString( cbec ) );
104 cublasStatus_t create()
107 cublasStatus_t cbec = destroy();
108 if( cbec != CUBLAS_STATUS_SUCCESS )
113 cbec = cublasCreate( &m_handle );
115 if( cbec != CUBLAS_STATUS_SUCCESS )
128 cublasStatus_t destroy()
130 cublasStatus_t cbec = CUBLAS_STATUS_SUCCESS;
133 cublasStatus_t cbec = cublasDestroy( m_handle );
145 cublasHandle_t operator()()
154 operator cublasHandle_t()
The mxlib exception class.
@ exception
An exception was thrown.
@ liberr
An error was returned by a library.