@@ -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)
@@ -227,6 +234,7 @@ for (fname, elty, relty) in
227234 S:: StridedROCVector{$relty} = similar (A, $ relty, min (size (A)... )),
228235 U:: StridedROCMatrix{$elty} = similar (A, $ elty, size (A, 1 ), min (size (A)... )),
229236 Vᴴ:: StridedROCMatrix{$elty} = similar (A, $ elty, min (size (A)... ), size (A, 2 ));
237+ check:: Bool = CHECK_LIBRARY_CALLS[],
230238 kwargs...
231239 )
232240 chkstride1 (A, U, Vᴴ, S)
@@ -251,8 +259,10 @@ for (fname, elty, relty) in
251259 S, U, ldu, Vᴴ, ldv, ifail,
252260 dev_info
253261 )
254- info = @allowscalar dev_info[1 ]
255- rocSOLVER. chkargsok (BlasInt (info))
262+ if check
263+ info = @allowscalar dev_info[1 ]
264+ rocSOLVER. chkargsok (BlasInt (info))
265+ end
256266 # Zero the entries of `S` that `gesvdx` did not write.
257267 nv = @allowscalar Int (nsv[1 ])
258268 nv < length (S) && fill! (view (S, (nv + 1 ): length (S)), zero (eltype (S)))
275285# jobz::Char,
276286# uplo::Char,
277287# A::StridedROCMatrix{$elty},
278- # B::StridedROCMatrix{$elty})
288+ # B::StridedROCMatrix{$elty};
289+ # check::Bool = CHECK_LIBRARY_CALLS[],
290+ # )
279291# chkuplo(uplo)
280292# nA, nB = checksquare(A, B)
281293# if nB != nA
298310# buffer, sizeof(buffer) ÷ sizeof($elty), dh.info)
299311# end
300312
301- # info = @allowscalar dh.info[1]
302- # chkargsok(BlasInt(info))
303-
313+ # if check
314+ # info = @allowscalar dh.info[1]
315+ # chkargsok(BlasInt(info))
316+ # end
304317# if jobz == 'N'
305318# return W
306319# elseif jobz == 'V'
322335# A::StridedROCMatrix{$elty},
323336# B::StridedROCMatrix{$elty};
324337# tol::$relty=eps($relty),
325- # max_sweeps::Int=100)
338+ # max_sweeps::Int=100;
339+ # check::Bool = CHECK_LIBRARY_CALLS[],
340+ # )
326341# chkuplo(uplo)
327342# nA, nB = checksquare(A, B)
328343# if nB != nA
349364# return $fname(dh, itype, jobz, uplo, n, A, lda, B, ldb, W,
350365# buffer, sizeof(buffer) ÷ sizeof($elty), dh.info, params[])
351366# end
352-
353- # info = @allowscalar dh.info[1]
354- # chkargsok(BlasInt(info))
367+ # if check
368+ # info = @allowscalar dh.info[1]
369+ # chkargsok(BlasInt(info))
370+ # end
355371
356372# rocsolverDnDestroySyevjInfo(params[])
357373
378394# uplo::Char,
379395# A::StridedROCArray{$elty};
380396# tol::$relty=eps($relty),
381- # max_sweeps::Int=100)
397+ # max_sweeps::Int=100;
398+ # check::Bool = CHECK_LIBRARY_CALLS[],
399+ # )
382400
383401# # Set up information for the solver arguments
384402# chkuplo(uplo)
@@ -409,14 +427,15 @@ end
409427# sizeof(buffer) ÷ sizeof($elty), dh.info, params[], batchSize)
410428# end
411429
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-
430+ # if check
431+ # # Copy the solver info and delete the device memory
432+ # info = collect(dh.info)
433+ #
434+ # # Double check the solver's exit status
435+ # for i in 1:batchSize
436+ # chkargsok(BlasInt(info[i]))
437+ # end
438+ # end
420439# rocsolverDnDestroySyevjInfo(params[])
421440
422441# # Return eigenvalues (in W) and possibly eigenvectors (in A)
436455# @eval begin
437456# function potrsBatched!(uplo::Char,
438457# A::Vector{<:StridedROCMatrix{$elty}},
439- # B::Vector{<:StridedROCVecOrMat{$elty}})
458+ # B::Vector{<:StridedROCVecOrMat{$elty}};
459+ # check::Bool = CHECK_LIBRARY_CALLS[],
460+ # )
440461# if length(A) != length(B)
441462# throw(DimensionMismatch(""))
442463# end
@@ -462,11 +483,11 @@ end
462483
463484# # Run the solver
464485# $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-
486+ # if check
487+ # # Copy the solver info and delete the device memory
488+ # info = @allowscalar dh.info[1]
489+ # chklapackerror(BlasInt(info))
490+ # end
470491# return B
471492# end
472493# end
477498# (:rocsolverDnCpotrfBatched, :ComplexF32),
478499# (:rocsolverDnZpotrfBatched, :ComplexF64))
479500# @eval begin
480- # function potrfBatched!(uplo::Char, A::Vector{<:StridedROCMatrix{$elty}})
501+ # function potrfBatched!(uplo::Char, A::Vector{<:StridedROCMatrix{$elty}}; check::Bool = CHECK_LIBRARY_CALLS[], )
481502
482503# # Set up information for the solver arguments
483504# chkuplo(uplo)
@@ -493,14 +514,15 @@ end
493514# # Run the solver
494515# $fname(dh, uplo, n, Aptrs, lda, dh.info, batchSize)
495516
496- # # Copy the solver info and delete the device memory
497- # info = @allowscalar collect(dh.info)
517+ # if check
518+ # # Copy the solver info and delete the device memory
519+ # info = collect(dh.info)
498520
499- # # Double check the solver's exit status
500- # for i in 1:batchSize
501- # chkargsok(BlasInt(info[i]))
521+ # # Double check the solver's exit status
522+ # for i in 1:batchSize
523+ # chkargsok(BlasInt(info[i]))
524+ # end
502525# end
503-
504526# # info[i] > 0 means the leading minor of order info[i] is not positive definite
505527# # LinearAlgebra.LAPACK does not throw Exception here
506528# # to simplify calls to isposdef! and factorize
@@ -510,11 +532,13 @@ end
510532# end
511533
512534# # gesv
513- # function gesv!(X::CuVecOrMat {T}, A::CuMatrix {T}, B::CuVecOrMat {T}; fallback::Bool=true,
535+ # function gesv!(X::ROCVecOrMat {T}, A::ROCMatrix {T}, B::ROCVecOrMat {T}; fallback::Bool=true,
514536# residual_history::Bool=false, irs_precision::String="AUTO",
515537# refinement_solver::String="CLASSICAL",
516538# maxiters::Int=0, maxiters_inner::Int=0, tol::Float64=0.0,
517- # tol_inner=Float64 = 0.0) where {T<:BlasFloat}
539+ # tol_inner=Float64 = 0.0,
540+ # check::Bool = CHECK_LIBRARY_CALLS[],
541+ # ) where {T<:BlasFloat}
518542# params = CuSolverIRSParameters()
519543# info = CuSolverIRSInformation()
520544# n = checksquare(A)
@@ -583,7 +607,8 @@ for (heevd, heev, heevx, heevj, elty, relty) in
583607 A:: StridedROCMatrix{$elty} ,
584608 W:: StridedROCVector{$relty} ,
585609 V:: StridedROCMatrix{$elty} ;
586- uplo:: Char = ' U'
610+ uplo:: Char = ' U' ,
611+ check:: Bool = CHECK_LIBRARY_CALLS[],
587612 )
588613 chkuplo (uplo)
589614 n = checksquare (A)
@@ -601,8 +626,10 @@ for (heevd, heev, heevx, heevj, elty, relty) in
601626 roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
602627 $ heevd (dh, jobz, roc_uplo, n, A, lda, W, work, dev_info)
603628
604- info = @allowscalar dev_info[1 ]
605- chkargsok (BlasInt (info))
629+ if check
630+ info = @allowscalar dev_info[1 ]
631+ chkargsok (BlasInt (info))
632+ end
606633
607634 if jobz == rocSOLVER. rocblas_evect_original && V != = A
608635 copy! (V, A)
@@ -613,7 +640,8 @@ for (heevd, heev, heevx, heevj, elty, relty) in
613640 A:: StridedROCMatrix{$elty} ,
614641 W:: StridedROCVector{$relty} ,
615642 V:: StridedROCMatrix{$elty} ;
616- uplo:: Char = ' U'
643+ uplo:: Char = ' U' ,
644+ check:: Bool = CHECK_LIBRARY_CALLS[],
617645 )
618646 chkuplo (uplo)
619647 n = checksquare (A)
@@ -631,8 +659,10 @@ for (heevd, heev, heevx, heevj, elty, relty) in
631659 roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
632660 $ heev (dh, jobz, roc_uplo, n, A, lda, W, work, dev_info)
633661
634- info = @allowscalar dev_info[1 ]
635- chkargsok (BlasInt (info))
662+ if check
663+ info = @allowscalar dev_info[1 ]
664+ chkargsok (BlasInt (info))
665+ end
636666
637667 if jobz == rocSOLVER. rocblas_evect_original && V != = A
638668 copy! (V, A)
@@ -644,6 +674,7 @@ for (heevd, heev, heevx, heevj, elty, relty) in
644674 W:: StridedROCVector{$relty} ,
645675 V:: StridedROCMatrix{$elty} ;
646676 uplo:: Char = ' U' ,
677+ check:: Bool = CHECK_LIBRARY_CALLS[],
647678 kwargs...
648679 )
649680 chkuplo (uplo)
@@ -680,8 +711,10 @@ for (heevd, heev, heevx, heevj, elty, relty) in
680711 roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
681712 $ heevx (dh, jobz, range, roc_uplo, n, A, lda, vl, vu, il, iu, abstol, nev, W, V, ldv, ifail, dev_info)
682713
683- info = @allowscalar dev_info[1 ]
684- chkargsok (BlasInt (info))
714+ if check
715+ info = @allowscalar dev_info[1 ]
716+ chkargsok (BlasInt (info))
717+ end
685718 m = @allowscalar nev[1 ]
686719 return W, V, m
687720 end
@@ -692,7 +725,8 @@ for (heevd, heev, heevx, heevj, elty, relty) in
692725 uplo:: Char = ' U' ,
693726 tol:: $relty = eps ($ relty),
694727 max_sweeps:: Int = 100 ,
695- sort:: Char = ' N'
728+ sort:: Char = ' N' ,
729+ check:: Bool = CHECK_LIBRARY_CALLS[],
696730 )
697731 chkuplo (uplo)
698732 n = checksquare (A)
@@ -712,8 +746,10 @@ for (heevd, heev, heevx, heevj, elty, relty) in
712746 roc_sort = sort == ' N' ? rocSOLVER. rocblas_esort_none : rocSOLVER. rocblas_esort_ascending
713747 $ heevj (dh, roc_sort, jobz, roc_uplo, n, A, lda, tol, residual, max_sweeps, n_sweeps, W, dev_info)
714748
715- info = @allowscalar dev_info[1 ]
716- chkargsok (BlasInt (info))
749+ if check
750+ info = @allowscalar dev_info[1 ]
751+ chkargsok (BlasInt (info))
752+ end
717753
718754 if jobz == rocSOLVER. rocblas_evect_original && V != = A
719755 copy! (V, A)
0 commit comments