-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Description
Here is an example:
julia> using Pkg; Pkg.activate(temp=true); Pkg.add("BandedMatrices"); Pkg.add(name="BenchmarkTools", version=v"1.2.1")
[...]
[6e4b80f9] + BenchmarkTools v1.2.1
[...]
julia> using BandedMatrices, BenchmarkTools, LinearAlgebra
julia> u = randn(3); du = zero(u); A = brand(3, 3, 1, 1);
julia> @benchmark mul!(du, A, u)
BenchmarkTools.Trial: 10000 samples with 932 evaluations.
Range (min … max): 106.950 ns … 367.095 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 108.638 ns ┊ GC (median): 0.00%
Time (mean ± σ): 113.436 ns ± 17.081 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█▅▆▆▁ ▁ ▂
█████▇▆▃▄██▇▇▇▇▅▅▆▆██▇█▇▆▇▆▆▅▇█▇▇▇▇▅▅▅▆▆▅▆▆▄▄▄▄▅▅▆▅▆▅▄▁▄▅▄▅▅▅ █
107 ns Histogram: log(frequency) by time 206 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark mul!($du, $A, $u)
ERROR: MethodError: convert(::Type{AbstractArray{Float64}}, ::BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}) is ambiguous. Candidates:
convert(::Type{T}, a::T) where T<:AbstractArray in Base at abstractarray.jl:16
convert(::Type{AbstractArray{T}}, M::BandedMatrix) where T in BandedMatrices at /home/hendrik/.julia/packages/BandedMatrices/2lafE/src/banded/BandedMatrix.jl:99
Possible fix, define
convert(::Type{AbstractArray{T}}, ::BandedMatrix{T}) where T
Stacktrace:
[1] setindex!(A::Vector{AbstractArray{Float64}}, x::BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}, i1::Int64)
@ Base ./array.jl:903
[2] copyto!(dest::Vector{AbstractArray{Float64}}, src::Tuple{Vector{Float64}, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}, Vector{Float64}})
@ Base ./abstractarray.jl:893
[3] vect(::Vector{Float64}, ::Vararg{Any})
@ Base ./array.jl:147
[4] top-level scope
@ ~/.julia/packages/BenchmarkTools/3UOOD/src/execution.jl:442
The expected behavior is obtained on v1.2.0:
julia> using Pkg; Pkg.activate(temp=true); Pkg.add("BandedMatrices"); Pkg.add(name="BenchmarkTools", version=v"1.2.0")
Activating new project at `/tmp/jl_PVnuoc`
Updating registry at `~/.julia/registries/General.toml`
Resolving package versions...
Updating `/tmp/jl_PVnuoc/Project.toml`
[aae01518] + BandedMatrices v0.16.11
Updating `/tmp/jl_PVnuoc/Manifest.toml`
[4c555306] + ArrayLayouts v0.7.8
[aae01518] + BandedMatrices v0.16.11
[1a297f60] + FillArrays v0.12.7
[56f22d72] + Artifacts
[8f399da3] + Libdl
[37e2e46d] + LinearAlgebra
[9a3f8284] + Random
[ea8e919c] + SHA
[9e88b42a] + Serialization
[2f01184e] + SparseArrays
[10745b16] + Statistics
[e66e0078] + CompilerSupportLibraries_jll
[4536629a] + OpenBLAS_jll
[8e850b90] + libblastrampoline_jll
Resolving package versions...
Updating `/tmp/jl_PVnuoc/Project.toml`
[6e4b80f9] + BenchmarkTools v1.2.0
Updating `/tmp/jl_PVnuoc/Manifest.toml`
[6e4b80f9] + BenchmarkTools v1.2.0
[682c06a0] + JSON v0.21.2
[69de0a69] + Parsers v2.1.2
[ade2ca70] + Dates
[56ddb016] + Logging
[a63ad114] + Mmap
[de0858da] + Printf
[9abbd945] + Profile
[cf7118a7] + UUIDs
[4ec0a83e] + Unicode
julia> using BandedMatrices, BenchmarkTools, LinearAlgebra
julia> u = randn(3); du = zero(u); A = brand(3, 3, 1, 1);
julia> @benchmark mul!(du, A, u)
BenchmarkTools.Trial: 10000 samples with 930 evaluations.
Range (min … max): 116.087 ns … 232.405 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 119.637 ns ┊ GC (median): 0.00%
Time (mean ± σ): 120.453 ns ± 6.769 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▂▆▅▄▇█▆▃▁ ▂
▆█████████▇▄▄▃▃▄▃▁▁▁▁▃▁▁▁▃▄▆▄▅▆▇▆▆▇▆▄▄▃▄▁▁▃▁▁▁▃▄▁▃▁▁▅▃▅▅▇▇██▇ █
116 ns Histogram: log(frequency) by time 151 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark mul!($du, $A, $u)
BenchmarkTools.Trial: 10000 samples with 937 evaluations.
Range (min … max): 104.303 ns … 255.039 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 107.078 ns ┊ GC (median): 0.00%
Time (mean ± σ): 108.293 ns ± 9.135 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▇▇▄█▅▂▄ ▁ ▁ ▂
███████▇▇▇▆▅▄▄▄▃▁▅▅▆█▇▇█▇▇▆▅▄▃▁▁▁▃▁▄▁▇████▆▆▃▄▁▁▃▃▃▁▁▃▁▃▅▆▅▆▅ █
104 ns Histogram: log(frequency) by time 156 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
Metadata
Metadata
Assignees
Labels
No labels