27#ifndef math_cublasHandle_hpp
28#define math_cublasHandle_hpp
32#include <cuda_runtime.h>
54 cublasHandle_t m_handle{ NULL };
65 explicit cublasHandle(
bool create )
69 cublasStatus_t cbec = this->create();
71 if( cbec != CUBLAS_STATUS_SUCCESS )
73 std::string msg = std::format(
"cublasHandle::cublasHandle error from create: [{}] {}\n",
74 cublasGetStatusName( cbec ),
75 cublasGetStatusString( cbec ) );
85 cublasStatus_t cbec = destroy();
86 if( cbec != CUBLAS_STATUS_SUCCESS )
88 std::cerr << std::format(
"cublasHandle::~cublasHandle error from destroy: [{}] {}\n",
89 cublasGetStatusName( cbec ),
90 cublasGetStatusString( cbec ) );
98 cublasStatus_t create()
101 cublasStatus_t cbec = destroy();
102 if( cbec != CUBLAS_STATUS_SUCCESS )
107 cbec = cublasCreate( &m_handle );
109 if( cbec != CUBLAS_STATUS_SUCCESS )
122 cublasStatus_t destroy()
124 cublasStatus_t cbec = CUBLAS_STATUS_SUCCESS;
127 cublasStatus_t cbec = cublasDestroy( m_handle );
139 cublasHandle_t operator()()
148 operator cublasHandle_t()
Augments an exception with the source file and line.
@ liberr
An error was returned by a library.