Skip to content

Don't zero out destination in generic_matvecmul #1242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
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: 4 additions & 6 deletions src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1063,17 +1063,15 @@ function __generic_matvecmul!(::typeof(identity), C::AbstractVector, A::Abstract
alpha::Number, beta::Number)
Astride = size(A, 1)
@inbounds begin
for i = eachindex(C)
if !iszero(beta)
C[i] *= beta
elseif length(B) == 0
for i in eachindex(C)
if length(B) == 0
C[i] = zero(eltype(C))
else
C[i] = zero(A[i]*B[1] + A[i]*B[1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really see how to get this working, without modifying the corresponding test case, which fails for all commits on this branch. We need this sum here to be able to promote to the eltype of C, but we don't have zero available for neither A nor B. If this doesn't affect performance too much, maybe it's not worth it after all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, probably not worth it

C[i] = A[i]*B[1]*alpha + C[i]*beta
end
end
if !iszero(alpha)
for k = eachindex(B)
for k in @view eachindex(B)[2:end]
aoffs = (k-1)*Astride
b = @stable_muladdmul MulAddMul(alpha,false)(B[k])
for i = eachindex(C)
Expand Down