Skip to content

Multi-level broadcast of ArrayPartition allocates #95

@ChrisRackauckas

Description

@ChrisRackauckas

But single-level is fine:

using RecursiveArrayTools, Test

xce0 = ArrayPartition(zeros(2),[0.])
xcde0 = copy(xce0)
function foo(y, x)
	y .= y .+ x
	nothing
end
foo(xcde0, xce0)
@test 0 == @allocated foo(xcde0, xce0)
function foo(y, x)
	y .= y .+ 2 .* x
	nothing
end
foo(xcde0, xce0)
@test 0 == @allocated foo(xcde0, xce0)

using BenchmarkTools
@btime foo(xcde0, xce0)

ap = ArrayPartition([100], [4, 1.3], ArrayPartition(ArrayPartition([1], [1, 4.4]), [0.4, 2, 1, 45]));
ap2 = recursivecopy(ap)
@btime foo(ap, ap2)

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