JuliaLinearAlgebra / Octavian.jl

Multi-threaded BLAS-like library that provides pure Julia matrix multiplication
https://julialinearalgebra.github.io/Octavian.jl/stable/
Other
232 stars 18 forks source link

Code coverage bug on line 6 of `src/macrokernel.jl` #15

Closed DilumAluthge closed 3 years ago

DilumAluthge commented 3 years ago

Here's coverage for src/macrokernel.jl. Observe the 0 on line 6:

- """
- The macrokernel. It iterates over our tiles, and applies the microkernel.
- """
17 function macrokernel!(C, A, B, α, β)
17     iszero(β) && return macrokernel!(C, A, B, α, StaticInt{0}())
0     LoopVectorization.@avx for n ∈ axes(C,2), m ∈ axes(C,1)
1         Cmn = zero(eltype(C))
1         for k ∈ axes(B,1)
1             Cmn += A[m,k] * B[k,n]
-         end
-         # C[m,n] may be `NaN`, but if `β == 0` we still want to zero it
1         C[m,n] = (α * Cmn) + β * C[m,n]
-     end
- end
16 function macrokernel!(C, A, B, α, ::StaticInt{0})
16     LoopVectorization.@avx for n ∈ axes(C,2), m ∈ axes(C,1)
16         Cmn = zero(eltype(C))
16         for k ∈ axes(B,1)
16             Cmn += A[m,k] * B[k,n]
-         end
-         # C[m,n] may be `NaN`, but if `β == 0` we still want to zero it
16         C[m,n] = (α * Cmn)
-     end
- end

Any idea what's going on? Why is the line with @avx not getting covered?

I thought maybe the issue was having both the for n and for m on the same line, so I moved the for m onto the next line. But that doesn't change anything. Here's the coverage from that experiment. As you can see, there is still a 0 on line 6:

- """
- The macrokernel. It iterates over our tiles, and applies the microkernel.
- """
17 function macrokernel!(C, A, B, α, β)
17     iszero(β) && return macrokernel!(C, A, B, α, StaticInt{0}())
0     LoopVectorization.@avx for n ∈ axes(C,2)
1         for m ∈ axes(C,1)
1             Cmn = zero(eltype(C))
1             for k ∈ axes(B,1)
1                 Cmn += A[m,k] * B[k,n]
-             end
-             # C[m,n] may be `NaN`, but if `β == 0` we still want to zero it
1             C[m,n] = (α * Cmn) + β * C[m,n]
-         end
-     end
- end
16 function macrokernel!(C, A, B, α, ::StaticInt{0})
16     LoopVectorization.@avx for n ∈ axes(C,2), m ∈ axes(C,1)
16         Cmn = zero(eltype(C))
16         for k ∈ axes(B,1)
16             Cmn += A[m,k] * B[k,n]
-         end
-         # C[m,n] may be `NaN`, but if `β == 0` we still want to zero it
16         C[m,n] = (α * Cmn)
-     end
- end
DilumAluthge commented 3 years ago

You can also view the coverage on the Codecov website, specifically here: https://codecov.io/gh/JuliaLinearAlgebra/Octavian.jl/src/master/src/macrokernels.jl

Observe that line 6 is red.

DilumAluthge commented 3 years ago

If I delete line 5 (the line that says iszero(β) && return macrokernel!(C, A, B, α, StaticInt{0}()), then it works just fine.

And I definitely have a test in the test suite with nonzero β.