Skip to content

Removes allocations with get_tmp that occur in some cases #125

New issue

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

Merged
merged 3 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name = "LabelledArrays"
uuid = "2ee39098-c373-598a-b85f-a56591580800"
authors = ["Chris Rackauckas <[email protected]>"]
version = "1.11.1"
version = "1.11.2"

[deps]
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
ArrayInterfaceStaticArrays = "b0d46f97-bff5-4637-a19a-dd75974142cd"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Expand All @@ -17,6 +18,7 @@ RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
ArrayInterfaceCore = "0.1.13"
ArrayInterfaceStaticArrays = "0.1"
ChainRulesCore = "1"
ForwardDiff = "0.10.3"
MacroTools = "0.5"
PreallocationTools = "0.4"
RecursiveArrayTools = "2"
Expand Down
5 changes: 3 additions & 2 deletions src/LabelledArrays.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module LabelledArrays

using LinearAlgebra, StaticArrays, ArrayInterfaceCore
import RecursiveArrayTools, PreallocationTools
import RecursiveArrayTools, PreallocationTools, ForwardDiff

include("slarray.jl")
include("larray.jl")
Expand Down Expand Up @@ -65,7 +65,8 @@ end
ArrayInterfaceCore.can_setindex(::Type{<:SLArray}) = false

function PreallocationTools.get_tmp(dc::PreallocationTools.DiffCache,
u::LArray{T, N, D, Syms}) where {T, N, D, Syms}
u::LArray{T, N, D, Syms}) where {T <: ForwardDiff.Dual,
N, D, Syms}
nelem = div(sizeof(T), sizeof(eltype(dc.dual_du))) * length(dc.du)
if nelem > length(dc.dual_du)
PreallocationTools.enlargedualcache!(dc, nelem)
Expand Down