We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
copyto!
I notice that copyto! sometimes allocates. I guess this could be avoided by simply adding @inline in front of the copyto!s?
@inline
Here is an example with BlockArrays:
using BenchmarkTools using BlockArrays dest = rand(4, 4) src = BlockMatrix(rand(4, 4), [2, 2], [2, 2]) @btime copyto!($dest, $src)
Staring from a fresh Julia session, the above results in one allocation:
julia> @btime copyto!($dest, $src) 87.933 ns (1 allocation: 48 bytes)
There is no allocation if I do the following, which is exactly what copyto! does:
using ArrayLayouts: MemoryLayout, _copyto! @btime _copyto!(MemoryLayout($dest), MemoryLayout($src), $dest, $src)
julia> @btime _copyto!(MemoryLayout($dest), MemoryLayout($src), $dest, $src) 73.099 ns (0 allocations: 0 bytes)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I notice that
copyto!
sometimes allocates. I guess this could be avoided by simply adding@inline
in front of thecopyto!
s?Here is an example with BlockArrays:
Staring from a fresh Julia session, the above results in one allocation:
There is no allocation if I do the following, which is exactly what
copyto!
does:The text was updated successfully, but these errors were encountered: