@@ -27,22 +27,22 @@ struct GetTypeThrust<std::complex<double>> {
2727static cublasHandle_t cublas_handle = nullptr ;
2828
2929void xdot_wrapper (const int &n, const float * x, const int &incx, const float * y, const int &incy, float &result) {
30- cublasErrcheck (cublasSdot (cublas_handle, n, x, incx, y, incy, &result));
30+ CHECK_CUBLAS (cublasSdot (cublas_handle, n, x, incx, y, incy, &result));
3131}
3232
3333void xdot_wrapper (const int &n, const double * x, const int &incx, const double * y, const int &incy, double &result) {
34- cublasErrcheck (cublasDdot (cublas_handle, n, x, incx, y, incy, &result));
34+ CHECK_CUBLAS (cublasDdot (cublas_handle, n, x, incx, y, incy, &result));
3535}
3636
3737void createGpuBlasHandle (){
3838 if (cublas_handle == nullptr ) {
39- cublasErrcheck (cublasCreate (&cublas_handle));
39+ CHECK_CUBLAS (cublasCreate (&cublas_handle));
4040 }
4141}
4242
4343void destoryBLAShandle (){
4444 if (cublas_handle != nullptr ) {
45- cublasErrcheck (cublasDestroy (cublas_handle));
45+ CHECK_CUBLAS (cublasDestroy (cublas_handle));
4646 cublas_handle = nullptr ;
4747 }
4848}
@@ -58,7 +58,7 @@ void scal_op<float, base_device::DEVICE_GPU>::operator()(const int& N,
5858 std::complex <float >* X,
5959 const int & incx)
6060{
61- cublasErrcheck (cublasCscal (cublas_handle, N, (float2 *)alpha, (float2 *)X, incx));
61+ CHECK_CUBLAS (cublasCscal (cublas_handle, N, (float2 *)alpha, (float2 *)X, incx));
6262}
6363
6464template <>
@@ -67,7 +67,7 @@ void scal_op<double, base_device::DEVICE_GPU>::operator()(const int& N,
6767 std::complex <double >* X,
6868 const int & incx)
6969{
70- cublasErrcheck (cublasZscal (cublas_handle, N, (double2 *)alpha, (double2 *)X, incx));
70+ CHECK_CUBLAS (cublasZscal (cublas_handle, N, (double2 *)alpha, (double2 *)X, incx));
7171}
7272
7373template <>
@@ -78,7 +78,7 @@ void axpy_op<double, base_device::DEVICE_GPU>::operator()(const int& N,
7878 double * Y,
7979 const int & incY)
8080{
81- cublasErrcheck (cublasDaxpy (cublas_handle, N, alpha, X, incX, Y, incY));
81+ CHECK_CUBLAS (cublasDaxpy (cublas_handle, N, alpha, X, incX, Y, incY));
8282}
8383
8484template <>
@@ -89,7 +89,7 @@ void axpy_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const int
8989 std::complex <float >* Y,
9090 const int & incY)
9191{
92- cublasErrcheck (cublasCaxpy (cublas_handle, N, (float2 *)alpha, (float2 *)X, incX, (float2 *)Y, incY));
92+ CHECK_CUBLAS (cublasCaxpy (cublas_handle, N, (float2 *)alpha, (float2 *)X, incX, (float2 *)Y, incY));
9393}
9494
9595template <>
@@ -100,7 +100,7 @@ void axpy_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(const in
100100 std::complex <double >* Y,
101101 const int & incY)
102102{
103- cublasErrcheck (cublasZaxpy (cublas_handle, N, (double2 *)alpha, (double2 *)X, incX, (double2 *)Y, incY));
103+ CHECK_CUBLAS (cublasZaxpy (cublas_handle, N, (double2 *)alpha, (double2 *)X, incX, (double2 *)Y, incY));
104104}
105105
106106
@@ -175,7 +175,7 @@ void gemv_op<double, base_device::DEVICE_GPU>::operator()(const char& trans,
175175 const int & incy)
176176{
177177 cublasOperation_t cutrans = judge_trans_op (false , trans, " gemv_op" );
178- cublasErrcheck (cublasDgemv (cublas_handle, cutrans, m, n, alpha, A, lda, X, incx, beta, Y, incx));
178+ CHECK_CUBLAS (cublasDgemv (cublas_handle, cutrans, m, n, alpha, A, lda, X, incx, beta, Y, incx));
179179}
180180
181181template <>
@@ -194,7 +194,7 @@ void gemv_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const cha
194194 cublasOperation_t cutrans = judge_trans_op (true , trans, " gemv_op" );
195195 cuFloatComplex alpha = make_cuFloatComplex (alpha_in->real (), alpha_in->imag ());
196196 cuFloatComplex beta = make_cuFloatComplex (beta_in->real (), beta_in->imag ());
197- cublasErrcheck (cublasCgemv (cublas_handle, cutrans, m, n, &alpha, (cuFloatComplex*)A, lda, (cuFloatComplex*)X, incx, &beta, (cuFloatComplex*)Y, incx));
197+ CHECK_CUBLAS (cublasCgemv (cublas_handle, cutrans, m, n, &alpha, (cuFloatComplex*)A, lda, (cuFloatComplex*)X, incx, &beta, (cuFloatComplex*)Y, incx));
198198}
199199
200200template <>
@@ -215,7 +215,7 @@ void gemv_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(const ch
215215 cuDoubleComplex beta = make_cuDoubleComplex (beta_in->real (), beta_in->imag ());
216216 // icpc and nvcc have some compatible problems
217217 // We must use cuDoubleComplex instead of converting std::complex<double>* to cuDoubleComplex*
218- cublasErrcheck (cublasZgemv (cublas_handle, cutrans, m, n, &alpha, (cuDoubleComplex*)A, lda, (cuDoubleComplex*)X, incx, &beta, (cuDoubleComplex*)Y, incx));
218+ CHECK_CUBLAS (cublasZgemv (cublas_handle, cutrans, m, n, &alpha, (cuDoubleComplex*)A, lda, (cuDoubleComplex*)X, incx, &beta, (cuDoubleComplex*)Y, incx));
219219}
220220
221221template <>
@@ -235,7 +235,7 @@ void gemm_op<float, base_device::DEVICE_GPU>::operator()(const char& transa,
235235{
236236 cublasOperation_t cutransA = judge_trans_op (false , transa, " gemm_op" );
237237 cublasOperation_t cutransB = judge_trans_op (false , transb, " gemm_op" );
238- cublasErrcheck (cublasSgemm (cublas_handle, cutransA, cutransB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc));
238+ CHECK_CUBLAS (cublasSgemm (cublas_handle, cutransA, cutransB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc));
239239}
240240
241241template <>
@@ -255,7 +255,7 @@ void gemm_op<double, base_device::DEVICE_GPU>::operator()(const char& transa,
255255{
256256 cublasOperation_t cutransA = judge_trans_op (false , transa, " gemm_op" );
257257 cublasOperation_t cutransB = judge_trans_op (false , transb, " gemm_op" );
258- cublasErrcheck (cublasDgemm (cublas_handle, cutransA, cutransB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc));
258+ CHECK_CUBLAS (cublasDgemm (cublas_handle, cutransA, cutransB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc));
259259}
260260template <>
261261void gemm_op<std::complex <float >, base_device::DEVICE_GPU >::operator ()(const char & transa,
@@ -274,7 +274,7 @@ void gemm_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const cha
274274{
275275 cublasOperation_t cutransA = judge_trans_op (true , transa, " gemm_op" );
276276 cublasOperation_t cutransB = judge_trans_op (true , transb, " gemm_op" );
277- cublasErrcheck (cublasCgemm (cublas_handle, cutransA, cutransB, m, n ,k, (float2 *)alpha, (float2 *)a , lda, (float2 *)b, ldb, (float2 *)beta, (float2 *)c, ldc));
277+ CHECK_CUBLAS (cublasCgemm (cublas_handle, cutransA, cutransB, m, n ,k, (float2 *)alpha, (float2 *)a , lda, (float2 *)b, ldb, (float2 *)beta, (float2 *)c, ldc));
278278}
279279
280280template <>
@@ -294,7 +294,7 @@ void gemm_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(const ch
294294{
295295 cublasOperation_t cutransA = judge_trans_op (true , transa, " gemm_op" );
296296 cublasOperation_t cutransB = judge_trans_op (true , transb, " gemm_op" );
297- cublasErrcheck (cublasZgemm (cublas_handle, cutransA, cutransB, m, n ,k, (double2 *)alpha, (double2 *)a , lda, (double2 *)b, ldb, (double2 *)beta, (double2 *)c, ldc));
297+ CHECK_CUBLAS (cublasZgemm (cublas_handle, cutransA, cutransB, m, n ,k, (double2 *)alpha, (double2 *)a , lda, (double2 *)b, ldb, (double2 *)beta, (double2 *)c, ldc));
298298}
299299
300300template <>
@@ -311,15 +311,15 @@ void matrixTranspose_op<double, base_device::DEVICE_GPU>::operator()(const int&
311311 double ONE = 1.0 , ZERO = 0.0 ;
312312
313313 // use 'geam' API todo transpose.
314- cublasErrcheck (cublasDgeam (cublas_handle, CUBLAS_OP_T , CUBLAS_OP_N , col, row, &ONE , input_matrix, col, &ZERO , input_matrix, col, device_temp, col));
314+ CHECK_CUBLAS (cublasDgeam (cublas_handle, CUBLAS_OP_T , CUBLAS_OP_N , col, row, &ONE , input_matrix, col, &ZERO , input_matrix, col, device_temp, col));
315315 }
316316 else
317317 {
318318 int thread = 1024 ;
319319 int block = (row + col + thread - 1 ) / thread;
320320 matrix_transpose_kernel<double > <<<block, thread >>> (row, col, input_matrix, device_temp);
321321
322- cudaCheckOnDebug ();
322+ CHECK_CUDA_SYNC ();
323323 }
324324
325325 base_device::memory::synchronize_memory_op<double , base_device::DEVICE_GPU , base_device::DEVICE_GPU >()(
@@ -348,7 +348,7 @@ void matrixTranspose_op<std::complex<float>, base_device::DEVICE_GPU>::operator(
348348 ZERO .x = ZERO .y = 0.0 ;
349349
350350 // use 'geam' API todo transpose.
351- cublasErrcheck (cublasCgeam (cublas_handle, CUBLAS_OP_T , CUBLAS_OP_N , col, row,
351+ CHECK_CUBLAS (cublasCgeam (cublas_handle, CUBLAS_OP_T , CUBLAS_OP_N , col, row,
352352 reinterpret_cast <const float2 *>(&ONE ), (float2 *)input_matrix, col,
353353 reinterpret_cast <const float2 *>(&ZERO ), (float2 *)input_matrix, col, (float2 *)device_temp, col));
354354 } else
@@ -357,7 +357,7 @@ void matrixTranspose_op<std::complex<float>, base_device::DEVICE_GPU>::operator(
357357 int block = (row + col + thread - 1 ) / thread;
358358 matrix_transpose_kernel<thrust::complex <float >> <<<block, thread >>> (row, col, (thrust::complex <float >*)input_matrix, (thrust::complex <float >*)device_temp);
359359
360- cudaCheckOnDebug ();
360+ CHECK_CUDA_SYNC ();
361361 }
362362
363363 base_device::memory::synchronize_memory_op<std::complex <float >, base_device::DEVICE_GPU , base_device::DEVICE_GPU >()(
@@ -367,7 +367,7 @@ void matrixTranspose_op<std::complex<float>, base_device::DEVICE_GPU>::operator(
367367
368368 base_device::memory::delete_memory_op<std::complex <float >, base_device::DEVICE_GPU >()(device_temp);
369369
370- cudaCheckOnDebug ();
370+ CHECK_CUDA_SYNC ();
371371
372372}
373373
@@ -389,13 +389,13 @@ void matrixTranspose_op<std::complex<double>, base_device::DEVICE_GPU>::operator
389389 ZERO .x = ZERO .y = 0.0 ;
390390
391391 // use 'geam' API todo transpose.
392- cublasErrcheck (cublasZgeam (cublas_handle, CUBLAS_OP_T , CUBLAS_OP_N , col, row, &ONE , (double2 *)input_matrix, col, &ZERO , (double2 *)input_matrix, col, (double2 *)device_temp, col));
392+ CHECK_CUBLAS (cublasZgeam (cublas_handle, CUBLAS_OP_T , CUBLAS_OP_N , col, row, &ONE , (double2 *)input_matrix, col, &ZERO , (double2 *)input_matrix, col, (double2 *)device_temp, col));
393393 } else
394394 {
395395 int thread = 1024 ;
396396 int block = (row + col + thread - 1 ) / thread;
397397 matrix_transpose_kernel<thrust::complex <double >> <<<block, thread >>> (row, col, (thrust::complex <double >*)input_matrix, (thrust::complex <double >*)device_temp);
398- cudaCheckOnDebug ();
398+ CHECK_CUDA_SYNC ();
399399 }
400400
401401 base_device::memory::synchronize_memory_op<std::complex <double >,
@@ -416,7 +416,7 @@ void matrixCopy<double, base_device::DEVICE_GPU>::operator()(const int& n1,
416416 const dim3 blockSize (16 , 16 );
417417 const dim3 gridSize ((n1 + blockSize.x - 1 ) / blockSize.x , (n2 + blockSize.y - 1 ) / blockSize.y );
418418 matrix_copy_kernel<double > <<<gridSize, blockSize >>> (n1, n2, A, LDA , B, LDB );
419- cudaCheckOnDebug ();
419+ CHECK_CUDA_SYNC ();
420420}
421421template <>
422422void matrixCopy<std::complex <float >, base_device::DEVICE_GPU >::operator ()(const int & n1,
@@ -429,7 +429,7 @@ void matrixCopy<std::complex<float>, base_device::DEVICE_GPU>::operator()(const
429429 const dim3 blockSize (16 , 16 );
430430 const dim3 gridSize ((n1 + blockSize.x - 1 ) / blockSize.x , (n2 + blockSize.y - 1 ) / blockSize.y );
431431 matrix_copy_kernel<thrust::complex <float >> <<<gridSize, blockSize >>> (n1, n2, reinterpret_cast <const thrust::complex <float >*>(A), LDA , reinterpret_cast <thrust::complex <float >*>(B), LDB );
432- cudaCheckOnDebug ();
432+ CHECK_CUDA_SYNC ();
433433
434434}
435435template <>
@@ -443,7 +443,7 @@ void matrixCopy<std::complex<double>, base_device::DEVICE_GPU>::operator()(const
443443 const dim3 blockSize (16 , 16 );
444444 const dim3 gridSize ((n1 + blockSize.x - 1 ) / blockSize.x , (n2 + blockSize.y - 1 ) / blockSize.y );
445445 matrix_copy_kernel<thrust::complex <double >> <<<gridSize, blockSize >>> (n1, n2, reinterpret_cast <const thrust::complex <double >*>(A), LDA , reinterpret_cast <thrust::complex <double >*>(B), LDB );
446- cudaCheckOnDebug ();
446+ CHECK_CUDA_SYNC ();
447447}
448448
449449template <>
@@ -453,7 +453,7 @@ void matrix_mul_vector_op<double, base_device::DEVICE_GPU>::operator()(const int
453453 dim3 block ((m + thread.x - 1 ) / thread.x , (n + thread.y - 1 ) / thread.y , 1 );
454454 matrix_multiply_vector_kernel<double , double > <<<block, thread >>> (m, n, a, lda,
455455 b, alpha, c, ldc);
456- cudaCheckOnDebug ();
456+ CHECK_CUDA_SYNC ();
457457}
458458
459459template <>
@@ -463,7 +463,7 @@ void matrix_mul_vector_op<std::complex<float>, base_device::DEVICE_GPU>::operato
463463 dim3 block ((m + thread.x - 1 ) / thread.x , (n + thread.y - 1 ) / thread.y , 1 );
464464 matrix_multiply_vector_kernel<thrust::complex <float >, float > <<<block, thread >>> (m, n, reinterpret_cast <thrust::complex <float >*>(a), lda,
465465 b, alpha, reinterpret_cast <thrust::complex <float >*>(c), ldc);
466- cudaCheckOnDebug ();
466+ CHECK_CUDA_SYNC ();
467467}
468468
469469template <>
@@ -474,7 +474,7 @@ void matrix_mul_vector_op<std::complex<double>, base_device::DEVICE_GPU>::operat
474474 dim3 block ((m + thread.x - 1 ) / thread.x , (n + thread.y - 1 ) / thread.y , 1 );
475475 matrix_multiply_vector_kernel<thrust::complex <double >, double > <<<block, thread >>> (m, n, reinterpret_cast <thrust::complex <double >*>(a), lda,
476476 b, alpha, reinterpret_cast <thrust::complex <double >*>(c), ldc);
477- cudaCheckOnDebug ();
477+ CHECK_CUDA_SYNC ();
478478}
479479
480480// Explicitly instantiate functors for the types of functor registered.
0 commit comments