From bdcb3b3b652518d66ddce8cd6c83017961db7efe Mon Sep 17 00:00:00 2001 From: lassepe Date: Mon, 16 Dec 2024 17:37:15 +0100 Subject: [PATCH] Don't allocate a new result buffer every time --- src/AutoDiff.jl | 4 ++-- src/solver.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AutoDiff.jl b/src/AutoDiff.jl index a29ff6c..49ec381 100644 --- a/src/AutoDiff.jl +++ b/src/AutoDiff.jl @@ -25,13 +25,13 @@ function _solve_jacobian_θ(mcp::MixedComplementarityProblems.PrimalDualMCP, sol (; x, y, s, ϵ) = solution ∇F_z = let - ∇F = SymbolicTracingUtils.get_result_buffer(mcp.∇F_z!) + ∇F = mcp.∇F_z!.result_buffer mcp.∇F_z!(∇F, x, y, s; θ, ϵ) ∇F end ∇F_θ = let - ∇F = SymbolicTracingUtils.get_result_buffer(mcp.∇F_θ!) + ∇F = mcp.∇F_θ!.result_buffer mcp.∇F_θ!(∇F, x, y, s; θ, ϵ) ∇F end diff --git a/src/solver.jl b/src/solver.jl index d9de223..eb2be75 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -27,7 +27,7 @@ function solve( max_outer_iters = 50, ) # Set up common memory. - ∇F = SymbolicTracingUtils.get_result_buffer(mcp.∇F_z!) + ∇F = mcp.∇F_z!.result_buffer F = zeros(mcp.unconstrained_dimension + 2mcp.constrained_dimension) δz = zeros(mcp.unconstrained_dimension + 2mcp.constrained_dimension) δx = @view δz[1:(mcp.unconstrained_dimension)]