You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using FiniteHorizonGramians, BenchmarkTools
λ =1.0
n =20
t =1.0
A = λ * (I -2*tril(ones(n, n)))
B =sqrt(2λ) *ones(n, 1)
eA =similar(A)
U =similar(A)
qs = [3, 5, 7, 9, 13]
methods = [ExpAndGram{Float64,q}() for q in qs]
caches = [FiniteHorizonGramians.alloc_mem(A, B, method) for method in methods]
order(::ExpAndGram{T,Q}) where {T,Q} = Q
@info"Benchmark: cache creation"@info"low order"@btime FiniteHorizonGramians.alloc_mem($A, $B, ExpAndGram{Float64,3}())
@info"high order (q = 13)"@btime FiniteHorizonGramians.alloc_mem($A, $B, ExpAndGram{Float64,13}())
println("\n")
@info"Benchnmark: function exection no cache / cache"for (method, cache) inzip(methods, caches)
@info"order = $(order(method))"@btimeexp_and_gram_chol($A, $B, $t, $method)
@btimeexp_and_gram_chol!($eA, $U, $A, $B, $t, $method, $cache)
end
Conclusion
Around 99% of the memory consumption for methods 3, 5, 7, 9 is due to qr!. Around 94% for method 13.
There is also a significant speed-up but that is perhaps because the default block size of 36 in qr! is not an intelligent choice for the size of this particular test problem.
Definition of qrwoq!:
functionqrwoq!(A::AbstractMatrix{T}) where {T}
LinearAlgebra.require_one_based_indexing(A)
m, n =size(A)
for k =1:min(m -1+!(T<:Real), n)
x =view(A, k:m, k)
τk = LinearAlgebra.reflector!(x)
LinearAlgebra.reflectorApply!(x, τk, view(A, k:m, k +1:n))
end
Av =view(A, 1:min(m, n), 1:n)
triu!(Av)
triu2cholesky_factor!(Av)
end
The text was updated successfully, but these errors were encountered:
Results
Replace
qr!
withqrwoq!
(a non-allocating unblocked implementation) defined below reveals this:Benchmark results for
qr!
:Benchmark results for
qrwoq!
Benchmark script:
Conclusion
Around 99% of the memory consumption for methods 3, 5, 7, 9 is due to
qr!
. Around 94% for method 13.There is also a significant speed-up but that is perhaps because the default block size of 36 in
qr!
is not an intelligent choice for the size of this particular test problem.Definition of
qrwoq!
:The text was updated successfully, but these errors were encountered: