Repository navigation
TRMM when B contains Inf values #1469
Replies: 6 comments
|
The Reference BLAS is "only" an inofficial standard, but a well-established one. Looking at the documentation part of its TRMM source, it actually defines that the other triangle "is not referenced". So it looks like you've found a bug in at least some cpu-specific kernel(s) of OpenBLAS and possibly others |
|
Cool :-) |
|
🐸😩 |
|
BTW, I also reported this issue to the BLIS developers: flame/blis#967 |
|
I like your example: Thanks for providing it. Yes, I think we want the result to be The zero entry in A(1,2) should be treated as a hard zero. This is a structural zero (since we say that A is lower triangular) and the operation Inf * 0 should not happen. I think reference BLAS and MKL are all good on that one. Thanks for letting the BLIS and AOCL folks know about this. |
|
Apparently, this hasn't been a particularly pressing issue for the BLIS developers so far 😆 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assume B contains Inf values, and A is, for simplicity, the identity matrix. When I compute B <- A B with the Ref-BLAS implementation of TRMM, I get the expected result: B is unchanged.
When I use optimized implementations like MKL, AOCL, or OpenBLAS, however, then Inf entries in B can turn into NaNs.
I understand the reason. Ref-BLAS only uses the elements of the actual triangular part of A, whereas the other implementations treat the remaining elements as zeros and also use them in the computation. So we get 0 * Inf = NaN.
I also understand that BLAS is rather a de facto standard than an ISO standard. So if this discrepancy is considered OK, that's fine with me.
I'm just wondering if there might be a ticking time bomb in the LAPACK layer above, where some algorithms implicitly rely on the Ref-BLAS behavior.
If one wanted to reproduce the Ref-BLAS behavior, one possible solution would be to use dedicated TRMM micro-kernels. These could be essentially identical to the GEMM micro-kernels, except that SIMD lanes corresponding to elements outside the triangular part of A would be masked out, so those multiplications are never performed.
Has this been discussed before? (could not find anything)
Edit: I was actually wrong about MKL. It reproduces the Ref-BLAS behavior, even for Inf values. I tested this with oneMKL 2025.0.1 on Ice Lake and Zen 4.
All reactions