Skip to content

Conversation

@aplavin
Copy link
Collaborator

@aplavin aplavin commented Jul 3, 2022

No description provided.

Copy link
Member

@andyferris andyferris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks.

Out of curiousity is there some benchmark (or general advice or observations) that indicate this performs better? What does out[I..., :] .= a[j] do? I had previously assumed the three would generate similar code.

@andyferris
Copy link
Member

(Also sorry for the lack of attention - I've been overseas, had Covid in the house, general chaos).

@aplavin
Copy link
Collaborator Author

aplavin commented Jul 31, 2022

There's significant overhead associated with : handling, even in the simplest cases:

julia> @btime (A[1, 2, :] = $([5])) setup=(A=rand(2, 3))
  13.988 ns (0 allocations: 0 bytes)

julia> @btime (view(A, 1, 2) .= $([5])) setup=(A=rand(2, 3))
  7.006 ns (0 allocations: 0 bytes)

This line in combinedims just stood out in profiling my code once, and explicit view performs better. I don't really have a deeper explanation of why exactly this difference is present.

Btw, unrelated to this PR - an eager version of combinedims may soon appear in Base: JuliaLang/julia#43334.

@andyferris andyferris merged commit 8534d12 into JuliaData:main Jul 31, 2022
@aplavin aplavin deleted the patch-1 branch September 23, 2022 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants