Fix issue #1327 - #1328
Conversation
…ther than doing ZY(I) = ZB*ZY(I) + ZA*ZX(I)
|
Reviewing the Level 1 BLAS:
I am a little confused as to why someone decided that SCAL, ASUM and IAMAX should not handle INCX ≤ 0. It seems that if we look at
the original codes for SCAL, ASUM and IAMAX were handling INCX ≤ 0 just fine. |
|
Hmm. I do remember that NRM2 only (re?)gained that capability with its "recent" rewrite around three years ago. But if there was any discussion about this aspect back then, I don't recall it |
|
That was #514, citing an Edward Anderson paper from 2017. |
|
Thanks @martin-frbg, the reference to Ed's paper is great and useful. This is page 12:2 (top left corner of PDF) and reference for the record is:
Thanks! |
|
I would be in favor of having the code for SCAL, ASUM and IAMAX to handle INCX ≤ 0. |
|
We need to speak about the current implementation of AXPBY and IF (α .EQ. 0) THEN
CALL SCAL(N, β, Y, INCY)For AXPBY( α, X, β, Y ), the call to SCAL( β, Y ) when α = 0 means that,
I do not think we have been thinking at exception handling for AXPBY. Current behavior for AXPBY( α, X, β, Y ), Y ← α X + β Y, is that
Is that we want? For GEMM( α, A, B, β, C ), ( C ← α AB + β C ), the behavior is
For AXPY( α, X, Y ), ( Y ← α X + Y ), the behavior is
For SCAL( α, X ), ( X ← α X ), the behavior is
I think what we want is Desired behavior for AXPBY( α, X, β, Y ), Y ← α X + β Y,
(Which is the reverse of what we have.) Opinions welcome. |
It would seem to make sense (though OpenBLAS would probably have to fix assembly implementations across all architectures). I haven't checked what MKL does here but its documentation does not mention any constraints on the increment |
Fix issue #1327
AXPBY(N, α, X, INCX, β, Y, INCY) calls SCAL(N, β, Y, INCY) in the case ( α.EQ.0 )
However, as pointed by @venovako in Iisue #1327, SCAL does not handle INCX ≤ 0 so the fix is that we only call SCAL when INCY > 0.
I also fixed the two typos pointed by @venovako
Also, for some reasons, AXPBY(N, α, X, INCX, β, Y, INCY) was not calling SCAL(N, β, Y, INCY) in the case ( α.EQ.0 ) .AND. ( β.EQ.0 ), but I think it is good to call SCAL in this case too so I removed the ( β.NE.0 ) condition.
I do not know why SCAL does not handle INCX ≤ 0. This is weird and maybe a better fix is to change the behavior of SCAL so that SCAL handles INCX ≤ 0. However the behavior seemed to be intentional as mentioned in the comment:
lapack/BLAS/SRC/cscal.f
Line 72 in c1c5b72
Anyone knows why?