Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/cublas/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ end
# BLAS 1
#

function LinearAlgebra.rmul!(x::CuArray{<:CublasFloat}, k::Bool)
# explicitly fill x with zero to comply with julias "false = strong zero"
!k && fill!(x, zero(eltype(x)))
return x
end

LinearAlgebra.rmul!(x::StridedCuArray{<:CublasFloat}, k::Number) =
scal!(length(x), k, x)

Expand Down Expand Up @@ -267,7 +273,7 @@ function LinearAlgebra.generic_matvecmul!(Y::StridedCuVector, tA::AbstractChar,
end

if nA == 0
return rmul!(Y, 0)
return rmul!(Y, beta)
end

T = eltype(Y)
Expand Down Expand Up @@ -356,7 +362,7 @@ function LinearAlgebra.generic_matmatmul!(C::StridedCuVecOrMat, tA, tB, A::Strid
if size(C) != (mA, nB)
throw(DimensionMismatch("C has dimensions $(size(C)), should have ($mA,$nB)"))
end
return LinearAlgebra.rmul!(C, 0)
return LinearAlgebra.rmul!(C, beta)
end

if all(in(('N', 'T', 'C')), (tA, tB))
Expand Down
6 changes: 6 additions & 0 deletions test/libraries/cublas/level1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ k = 13
@test dz ≈ z
end

@testset "rmul! strong zero" begin
@test testf(rmul!, fill(T(NaN), 3), false)
@test testf(rmul!, rand(T, 3), false)
@test testf(rmul!, rand(T, 3), true)
end

@testset "rotate!" begin
@test testf(rotate!, rand(T, m), rand(T, m), rand(real(T)), rand(real(T)))
@test testf(rotate!, rand(T, m), rand(T, m), rand(real(T)), rand(T))
Expand Down