-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Calling BLAS and negative step views #813
Comments
What is the BLAS story on negative strides? Is there a consistent one? A quick search hit this SO question which I had apparently already seen and upvoted at some point in the past. |
Good point! I have edited the description to focus on this specific case. (However, my impression from a quick look at the report linked above is that vectors with negative stride might be fine for some other BLAS functions, too. I don't know how closely various implementations comply to the report.) |
(Made while looking at #39836, which is matrix x vector. Matrix x matrix with negative stride is fine as it is, because it uses the Julia implementation of matrix multiplication.)
…aLang#39849) (Made while looking at #39836, which is matrix x vector. Matrix x matrix with negative stride is fine as it is, because it uses the Julia implementation of matrix multiplication.)
…aLang#39849) (Made while looking at #39836, which is matrix x vector. Matrix x matrix with negative stride is fine as it is, because it uses the Julia implementation of matrix multiplication.)
Another example of this problem with negative stride (using Julia 1.6.3):
but
If at least one of the vectors has only integer elements, the result is correct. The problem also happens if you use |
Should be fixed after JuliaLang/julia#42957. |
should pass but fails
Evaluated: [9.0, 0.0] ≈ [12.0, 0.0]
Found while looking at #768, present on a recent 1.7.0-DEV, and 1.4.1.
Looking at LinearAlgebra/blas.jl, it seems there might be more functions which do not correctly handle negative stride yet, that is, the case of a StridedVector being a SubArray.
For the above example, there should be a fix similar to PR JuliaLang/julia#39751. If so, one should probably add an inline function computing the pointer to the first element (in the sense of having the lowest address in memory) of a StridedVector, and use this function when BLAS.dgemv is called for StridedVectors (and make the change from JuliaLang/julia#39751 use this function, too/take the code from there).
Warning: This is based on the assumption that the step size can be negative in the BLAS function.
Reading dgemv.f, I got the impression that negative strides are supported for dgemv in OpenBLAS StridedVector's.
Also page 40 of blas-report.pdf sounds like other BLAS functions should support negative stride for vectors.
The text was updated successfully, but these errors were encountered: