Skip to content

Commit

Permalink
Don't allocate a new result buffer every time
Browse files Browse the repository at this point in the history
  • Loading branch information
lassepe committed Dec 16, 2024
1 parent 608800b commit bdcb3b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/AutoDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit bdcb3b3

Please sign in to comment.