@@ -786,6 +786,26 @@ function _gesvdx_jobs(U, Vᴴ, m::Integer, n::Integer, maxnsv::Integer)
786786 return jobu, jobvt
787787end
788788
789+ """
790+ _gesvdx_zero_unconverged!(S, nsv)
791+
792+ Zero the entries of `S` that `gesvdx` did not write.
793+ """
794+ function _gesvdx_zero_unconverged! (S:: StridedROCVector , nsv:: ROCVector{Cint} )
795+ nv = @allowscalar Int (nsv[1 ])
796+ nv < length (S) && fill! (view (S, (nv + 1 ): length (S)), zero (eltype (S)))
797+ return S
798+ end
799+ function _gesvdx_zero_unconverged! (S:: StridedROCMatrix , nsv:: ROCVector{Cint} )
800+ minmn = size (S, 1 )
801+ nvs = Array (nsv)
802+ all (== (minmn), nvs) && return S # nothing omitted, skip the per-batch fills
803+ for (b, nv) in pairs (nvs)
804+ nv < minmn && fill! (view (S, (nv + 1 ): minmn, b), zero (eltype (S)))
805+ end
806+ return S
807+ end
808+
789809# Wrapper for SVD via Bisection
790810for (fname, elty, relty) in
791811 (
@@ -826,9 +846,7 @@ for (fname, elty, relty) in
826846 )
827847 info = @allowscalar dev_info[1 ]
828848 rocSOLVER. chkargsok (BlasInt (info))
829- # Zero the entries of `S` that `gesvdx` did not write.
830- nv = @allowscalar Int (nsv[1 ])
831- nv < length (S) && fill! (view (S, (nv + 1 ): length (S)), zero (eltype (S)))
849+ _gesvdx_zero_unconverged! (S, nsv)
832850
833851 AMDGPU. unsafe_free! (nsv)
834852 AMDGPU. unsafe_free! (ifail)
@@ -888,6 +906,7 @@ for (fname, elty, relty) in
888906 AMDGPU. unsafe_free! (pA)
889907
890908 rocSOLVER. chkargsok .(BlasInt .(collect (dev_info)))
909+ _gesvdx_zero_unconverged! (S, nsv)
891910
892911 AMDGPU. unsafe_free! (nsv)
893912 AMDGPU. unsafe_free! (ifail)
@@ -942,6 +961,7 @@ for (fname, elty, relty) in
942961 )
943962
944963 rocSOLVER. chkargsok .(BlasInt .(collect (dev_info)))
964+ _gesvdx_zero_unconverged! (S, nsv)
945965
946966 AMDGPU. unsafe_free! (nsv)
947967 AMDGPU. unsafe_free! (ifail)
0 commit comments