Skip to content

dot could be faster for SArrays #629

Closed
@simeonschaub

Description

@simeonschaub

This just came up on discourse:

julia> a1 = rand(9, 9)
9×9 Array{Float64,2}:

julia> a2 = rand(9, 9)
9×9 Array{Float64,2}:

julia> s1 = SArray{Tuple{9,9}}(a1)
9×9 SArray{Tuple{9,9},Float64,2,81}:

julia> s2 = SArray{Tuple{9,9}}(a2)
9×9 SArray{Tuple{9,9},Float64,2,81}:

julia> @btime dot($a1, $a2)
  22.762 ns (0 allocations: 0 bytes)
18.782035065611815

julia> @btime dot($s1, $s2)
  70.213 ns (0 allocations: 0 bytes)
18.782035065611826

julia> @btime dot($(vec(a1)), $(vec(a2)))
  23.527 ns (0 allocations: 0 bytes)
18.782035065611815

julia> @btime dot($(vec(s1)), $(vec(s2)))
  15.570 ns (0 allocations: 0 bytes)
18.782035065611815

Is there any reason that dot is special-cased for multi-dimensional SArrays and not just implemented as dot(vec(s1), vec(s2))?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions