-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add a BLAS wrapper for axpby #23291
Add a BLAS wrapper for axpby #23291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice first PR 👍
base/linalg/blas.jl
Outdated
@@ -463,6 +463,55 @@ function axpy!(alpha::Number, x::Array{T}, rx::Union{UnitRange{Ti},Range{Ti}}, | |||
y | |||
end | |||
|
|||
""" | |||
axpby!(a, X, b, Y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 space indent for the signature.
base/linalg/blas.jl
Outdated
""" | ||
axpby!(a, X, b, Y) | ||
|
||
Overwrite `Y` with `a*X + b*Y`, where `a` and `b` are scalars. Returns `Y`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns
-> Return
base/linalg/blas.jl
Outdated
|
||
Overwrite `Y` with `a*X + b*Y`, where `a` and `b` are scalars. Returns `Y`. | ||
|
||
# Example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Example:
-> # Examples
base/linalg/blas.jl
Outdated
|
||
# Example: | ||
```jldoctest | ||
julia> x = [1.; 2; 3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps change to commas in the vector, i.e. [1., 2, 3]
and likewise for y
?
base/linalg/blas.jl
Outdated
# INTEGER INCX,INCY,N | ||
#* .. Array Arguments .. | ||
# DOUBLE PRECISION DX(*),DY(*) | ||
function axpby!(n::Integer, alpha::($elty), dx::Union{Ptr{$elty}, DenseArray{$elty}}, incx::Integer, beta::($elty), dy::Union{Ptr{$elty}, DenseArray{$elty}}, incy::Integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting a bit beyond the line length recommendation
would also be more conventional to indent the whole @eval
block since it's inside a for loop (or do @eval function
since the begin
is somewhat superfluous)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :) don't know why the indenting got messed up
I discussed #13640 with @andreasnoack and I think it makes sense indeed to add a generic Also the ccall should probably not use |
Bump |
# INTEGER INCX,INCY,N | ||
#* .. Array Arguments .. | ||
# DOUBLE PRECISION DX(*),DY(*) | ||
function axpby!(n::Integer, alpha::($elty), dx::Union{Ptr{$elty}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this exist in every blas implementation? if it isn't in netlib I don't think we can unconditionally have a wrapper for it here
The
axpby!
routine computesy = a * x + b * y
and is an extension of BLAS. The current BLAS-style alternative is to doscale!(b, y); axpy!(a, x, y)
, which does the same amount of computational work, but requires going through memory twice.I have not added generic fallbacks for this method because I'm unsure about #13640 which made
axpy!
basicallyxapy!
. It also does not come withaxpby!(a, x, indices_x, b, y, indices_y)
because I think that's superfluous when when there are views.