Closed Omar-Elrefaei closed 1 year ago
YES! We need to do similar changes in QuasiUpperTriangular.jl, I had forgotten about it. We can't use the methods in ExtendedMul.jl for QuasiUpperTriangular.jl: we need specialized code. To be consistent with the idea that direct multiplications with sub-arrays are only done in KroneckerProductTools.jl, we need to move and transform all the A_mul_B methods with offset... and so on from QuasiUpperTriangular.jl to ExtendedMul.jl. Then, change the names A_mul_B to mul! for the remaining methods (without offset... and so on) in QuasiUpperTriangular.jl In QuasiUpperTriangular.jl, we also use alpha and beta (that are always 1.0 and 0.0 in ExtendedMul.jl). This makes me think that we should add methods for alpha and beta in ExtendedMul.jl
We can't use the methods in ExtendedMul.jl for QuasiUpperTriangular.jl: we need specialized code.
Turns out we can! QuasiTriangular just was not implementing the necessary interface to be compatible with BLAS operations.
Once I defined the functions in DynareJulia/QuasiTriangular.jl#1, all the tests passed flawlessly without needing any of the A_mul_B
functions from QuasiTriangular. Of course we can still port them as appropriate becase they might have a more specialized or efficient algorithm, but now the generic _mul!/Ccall OpenBLAS
and LinearAlgebra.BLAS
work as they should.
ie. The DynareJulia/QuasiTriangular.jl/#1 PR should make this current PR ready to merge and makes our job with QuasiTriangular much easier.
source: https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-strided-arrays more context:
This is because the tests in test_quasi_upper_triangular.jl
only use matrices whose storage (X.data) is quasi upper triangular as they are created by a Schur decomposition. In the tests we should use matrices that have garbage in their lower triangular but not contiguous nonzero on the first sub-diagonal
I've added tests for a few branches and deleted the corresponding #FIXME: UNTESTED
labels.
I was not able to quickly construct valid tests for a_mul_b_kron_c!
and at_mul_b_kron_c!
though.
I added the missing test cases for a_mul_b_kron_c!
I opened the PR as a draft because one test does not pass yet, the
QuasiUpperTriangular
one.Everything else works delightfully.
originating from the
kron_mul_elem!
call in runtests.jl:273, it errors when it gets from the second (abbreviated)A*B'
method, to the full one, to the BLAS Ccall with the following:I can confirm from a REPL: