@@ -8,6 +8,7 @@ using AMDGPU
88using AMDGPU: @allowscalar
99using AMDGPU. rocSOLVER
1010using AMDGPU. rocBLAS
11+ using .. MatrixAlgebraKit: CHECK_LIBRARY_CALLS
1112
1213# QR methods are implemented with full access to allocated arrays, so we do not need to redo this:
1314using AMDGPU. rocSOLVER: geqrf!, ormqr!, orgqr!
@@ -27,7 +28,8 @@ for (fname, elty, relty) in
2728 A:: StridedROCMatrix{$elty} ,
2829 S:: StridedROCVector{$relty} = similar (A, $ relty, min (size (A)... )),
2930 U:: StridedROCMatrix{$elty} = similar (A, $ elty, size (A, 1 ), min (size (A)... )),
30- Vᴴ:: StridedROCMatrix{$elty} = similar (A, $ elty, min (size (A)... ), size (A, 2 ))
31+ Vᴴ:: StridedROCMatrix{$elty} = similar (A, $ elty, min (size (A)... ), size (A, 2 ));
32+ check:: Bool = CHECK_LIBRARY_CALLS[],
3133 )
3234 chkstride1 (A, U, Vᴴ, S)
3335 m, n = size (A)
@@ -85,8 +87,10 @@ for (fname, elty, relty) in
8587 )
8688 AMDGPU. unsafe_free! (rwork)
8789
88- info = @allowscalar dev_info[1 ]
89- rocSOLVER. chkargsok (BlasInt (info))
90+ if check
91+ info = @allowscalar dev_info[1 ]
92+ rocSOLVER. chkargsok (BlasInt (info))
93+ end
9094
9195 return (S, U, Vᴴ)
9296 end
@@ -109,6 +113,7 @@ for (fname, elty, relty) in
109113 Vᴴ:: StridedROCMatrix{$elty} = similar (A, $ elty, min (size (A)... ), size (A, 2 ));
110114 tol:: $relty = eps ($ relty),
111115 max_sweeps:: Int = 100 ,
116+ check:: Bool = CHECK_LIBRARY_CALLS[],
112117 )
113118 chkstride1 (A, U, Vᴴ, S)
114119 m, n = size (A)
@@ -165,8 +170,10 @@ for (fname, elty, relty) in
165170 S, U, ldu, Vᴴ, ldv, dev_info,
166171 )
167172
168- info = @allowscalar dev_info[1 ]
169- rocSOLVER. chkargsok (BlasInt (info))
173+ if check
174+ info = @allowscalar dev_info[1 ]
175+ rocSOLVER. chkargsok (BlasInt (info))
176+ end
170177
171178 AMDGPU. unsafe_free! (dev_residual)
172179 AMDGPU. unsafe_free! (dev_n_sweeps)
275282# jobz::Char,
276283# uplo::Char,
277284# A::StridedROCMatrix{$elty},
278- # B::StridedROCMatrix{$elty})
285+ # B::StridedROCMatrix{$elty};
286+ # check::Bool = CHECK_LIBRARY_CALLS[],
287+ # )
279288# chkuplo(uplo)
280289# nA, nB = checksquare(A, B)
281290# if nB != nA
298307# buffer, sizeof(buffer) ÷ sizeof($elty), dh.info)
299308# end
300309
301- # info = @allowscalar dh.info[1]
302- # chkargsok(BlasInt(info))
303-
310+ # if check
311+ # info = @allowscalar dh.info[1]
312+ # chkargsok(BlasInt(info))
313+ # end
304314# if jobz == 'N'
305315# return W
306316# elseif jobz == 'V'
322332# A::StridedROCMatrix{$elty},
323333# B::StridedROCMatrix{$elty};
324334# tol::$relty=eps($relty),
325- # max_sweeps::Int=100)
335+ # max_sweeps::Int=100;
336+ # check::Bool = CHECK_LIBRARY_CALLS[],
337+ # )
326338# chkuplo(uplo)
327339# nA, nB = checksquare(A, B)
328340# if nB != nA
349361# return $fname(dh, itype, jobz, uplo, n, A, lda, B, ldb, W,
350362# buffer, sizeof(buffer) ÷ sizeof($elty), dh.info, params[])
351363# end
352-
353- # info = @allowscalar dh.info[1]
354- # chkargsok(BlasInt(info))
364+ # if check
365+ # info = @allowscalar dh.info[1]
366+ # chkargsok(BlasInt(info))
367+ # end
355368
356369# rocsolverDnDestroySyevjInfo(params[])
357370
378391# uplo::Char,
379392# A::StridedROCArray{$elty};
380393# tol::$relty=eps($relty),
381- # max_sweeps::Int=100)
394+ # max_sweeps::Int=100;
395+ # check::Bool = CHECK_LIBRARY_CALLS[],
396+ # )
382397
383398# # Set up information for the solver arguments
384399# chkuplo(uplo)
@@ -409,14 +424,15 @@ end
409424# sizeof(buffer) ÷ sizeof($elty), dh.info, params[], batchSize)
410425# end
411426
412- # # Copy the solver info and delete the device memory
413- # info = @allowscalar collect(dh.info)
414-
415- # # Double check the solver's exit status
416- # for i in 1:batchSize
417- # chkargsok(BlasInt(info[i]))
418- # end
419-
427+ # if check
428+ # # Copy the solver info and delete the device memory
429+ # info = collect(dh.info)
430+ #
431+ # # Double check the solver's exit status
432+ # for i in 1:batchSize
433+ # chkargsok(BlasInt(info[i]))
434+ # end
435+ # end
420436# rocsolverDnDestroySyevjInfo(params[])
421437
422438# # Return eigenvalues (in W) and possibly eigenvectors (in A)
436452# @eval begin
437453# function potrsBatched!(uplo::Char,
438454# A::Vector{<:StridedROCMatrix{$elty}},
439- # B::Vector{<:StridedROCVecOrMat{$elty}})
455+ # B::Vector{<:StridedROCVecOrMat{$elty}};
456+ # check::Bool = CHECK_LIBRARY_CALLS[],
457+ # )
440458# if length(A) != length(B)
441459# throw(DimensionMismatch(""))
442460# end
@@ -462,11 +480,11 @@ end
462480
463481# # Run the solver
464482# $fname(dh, uplo, n, nrhs, Aptrs, lda, Bptrs, ldb, dh.info, batchSize)
465-
466- # # Copy the solver info and delete the device memory
467- # info = @allowscalar dh.info[1]
468- # chklapackerror(BlasInt(info))
469-
483+ # if check
484+ # # Copy the solver info and delete the device memory
485+ # info = @allowscalar dh.info[1]
486+ # chklapackerror(BlasInt(info))
487+ # end
470488# return B
471489# end
472490# end
477495# (:rocsolverDnCpotrfBatched, :ComplexF32),
478496# (:rocsolverDnZpotrfBatched, :ComplexF64))
479497# @eval begin
480- # function potrfBatched!(uplo::Char, A::Vector{<:StridedROCMatrix{$elty}})
498+ # function potrfBatched!(uplo::Char, A::Vector{<:StridedROCMatrix{$elty}}; check::Bool = CHECK_LIBRARY_CALLS[], )
481499
482500# # Set up information for the solver arguments
483501# chkuplo(uplo)
@@ -493,14 +511,15 @@ end
493511# # Run the solver
494512# $fname(dh, uplo, n, Aptrs, lda, dh.info, batchSize)
495513
496- # # Copy the solver info and delete the device memory
497- # info = @allowscalar collect(dh.info)
514+ # if check
515+ # # Copy the solver info and delete the device memory
516+ # info = collect(dh.info)
498517
499- # # Double check the solver's exit status
500- # for i in 1:batchSize
501- # chkargsok(BlasInt(info[i]))
518+ # # Double check the solver's exit status
519+ # for i in 1:batchSize
520+ # chkargsok(BlasInt(info[i]))
521+ # end
502522# end
503-
504523# # info[i] > 0 means the leading minor of order info[i] is not positive definite
505524# # LinearAlgebra.LAPACK does not throw Exception here
506525# # to simplify calls to isposdef! and factorize
@@ -510,11 +529,13 @@ end
510529# end
511530
512531# # gesv
513- # function gesv!(X::CuVecOrMat {T}, A::CuMatrix {T}, B::CuVecOrMat {T}; fallback::Bool=true,
532+ # function gesv!(X::ROCVecOrMat {T}, A::ROCMatrix {T}, B::ROCVecOrMat {T}; fallback::Bool=true,
514533# residual_history::Bool=false, irs_precision::String="AUTO",
515534# refinement_solver::String="CLASSICAL",
516535# maxiters::Int=0, maxiters_inner::Int=0, tol::Float64=0.0,
517- # tol_inner=Float64 = 0.0) where {T<:BlasFloat}
536+ # tol_inner=Float64 = 0.0,
537+ # check::Bool = CHECK_LIBRARY_CALLS[],
538+ # ) where {T<:BlasFloat}
518539# params = CuSolverIRSParameters()
519540# info = CuSolverIRSInformation()
520541# n = checksquare(A)
@@ -583,7 +604,8 @@ for (heevd, heev, heevx, heevj, elty, relty) in
583604 A:: StridedROCMatrix{$elty} ,
584605 W:: StridedROCVector{$relty} ,
585606 V:: StridedROCMatrix{$elty} ;
586- uplo:: Char = ' U'
607+ uplo:: Char = ' U' ,
608+ check:: Bool = CHECK_LIBRARY_CALLS[],
587609 )
588610 chkuplo (uplo)
589611 n = checksquare (A)
@@ -601,8 +623,10 @@ for (heevd, heev, heevx, heevj, elty, relty) in
601623 roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
602624 $ heevd (dh, jobz, roc_uplo, n, A, lda, W, work, dev_info)
603625
604- info = @allowscalar dev_info[1 ]
605- chkargsok (BlasInt (info))
626+ if check
627+ info = @allowscalar dev_info[1 ]
628+ chkargsok (BlasInt (info))
629+ end
606630
607631 if jobz == rocSOLVER. rocblas_evect_original && V != = A
608632 copy! (V, A)
@@ -613,7 +637,8 @@ for (heevd, heev, heevx, heevj, elty, relty) in
613637 A:: StridedROCMatrix{$elty} ,
614638 W:: StridedROCVector{$relty} ,
615639 V:: StridedROCMatrix{$elty} ;
616- uplo:: Char = ' U'
640+ uplo:: Char = ' U' ,
641+ check:: Bool = CHECK_LIBRARY_CALLS[],
617642 )
618643 chkuplo (uplo)
619644 n = checksquare (A)
@@ -631,8 +656,10 @@ for (heevd, heev, heevx, heevj, elty, relty) in
631656 roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
632657 $ heev (dh, jobz, roc_uplo, n, A, lda, W, work, dev_info)
633658
634- info = @allowscalar dev_info[1 ]
635- chkargsok (BlasInt (info))
659+ if check
660+ info = @allowscalar dev_info[1 ]
661+ chkargsok (BlasInt (info))
662+ end
636663
637664 if jobz == rocSOLVER. rocblas_evect_original && V != = A
638665 copy! (V, A)
@@ -644,6 +671,7 @@ for (heevd, heev, heevx, heevj, elty, relty) in
644671 W:: StridedROCVector{$relty} ,
645672 V:: StridedROCMatrix{$elty} ;
646673 uplo:: Char = ' U' ,
674+ check:: Bool = CHECK_LIBRARY_CALLS[],
647675 kwargs...
648676 )
649677 chkuplo (uplo)
@@ -680,8 +708,10 @@ for (heevd, heev, heevx, heevj, elty, relty) in
680708 roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
681709 $ heevx (dh, jobz, range, roc_uplo, n, A, lda, vl, vu, il, iu, abstol, nev, W, V, ldv, ifail, dev_info)
682710
683- info = @allowscalar dev_info[1 ]
684- chkargsok (BlasInt (info))
711+ if check
712+ info = @allowscalar dev_info[1 ]
713+ chkargsok (BlasInt (info))
714+ end
685715 m = @allowscalar nev[1 ]
686716 return W, V, m
687717 end
@@ -692,7 +722,8 @@ for (heevd, heev, heevx, heevj, elty, relty) in
692722 uplo:: Char = ' U' ,
693723 tol:: $relty = eps ($ relty),
694724 max_sweeps:: Int = 100 ,
695- sort:: Char = ' N'
725+ sort:: Char = ' N' ,
726+ check:: Bool = CHECK_LIBRARY_CALLS[],
696727 )
697728 chkuplo (uplo)
698729 n = checksquare (A)
@@ -712,8 +743,10 @@ for (heevd, heev, heevx, heevj, elty, relty) in
712743 roc_sort = sort == ' N' ? rocSOLVER. rocblas_esort_none : rocSOLVER. rocblas_esort_ascending
713744 $ heevj (dh, roc_sort, jobz, roc_uplo, n, A, lda, tol, residual, max_sweeps, n_sweeps, W, dev_info)
714745
715- info = @allowscalar dev_info[1 ]
716- chkargsok (BlasInt (info))
746+ if check
747+ info = @allowscalar dev_info[1 ]
748+ chkargsok (BlasInt (info))
749+ end
717750
718751 if jobz == rocSOLVER. rocblas_evect_original && V != = A
719752 copy! (V, A)
0 commit comments