-
Notifications
You must be signed in to change notification settings - Fork 21
preallocated coordinate format vectors #473
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
Open
arnavk23
wants to merge
11
commits into
JuliaSmoothOptimizers:main
Choose a base branch
from
arnavk23:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
859c634
preallocated coordinate format vectors
arnavk23 050276c
do
arnavk23 db50341
Delete test/test_double_buffering.jl
arnavk23 696d17f
api reference documentation
arnavk23 321052a
make docs
arnavk23 154be07
Update julia_interface.jl
arnavk23 325b7a7
Update model.jl
arnavk23 044c787
Update julia_interface.jl
arnavk23 90f943d
Update model.jl
arnavk23 2c03812
Update print statements for consistency in tests
arnavk23 0066a3b
documentation changes
arnavk23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # API Reference | ||
|
|
||
| ```@docs | ||
arnavk23 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| CUTEst.prepare_input! | ||
| CUTEst.prepare_output! | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| using CUTEst | ||
| using BenchmarkTools | ||
| using LinearAlgebra | ||
| using NLPModels | ||
|
|
||
| # Test with an unconstrained problem first | ||
| println("Testing with unconstrained problem (ROSENBR):") | ||
| nlp1 = CUTEstModel{Float64}("ROSENBR") | ||
| x0 = nlp1.meta.x0 | ||
|
|
||
| # Test hess_coord allocations | ||
| println("✓ Problem loaded: $(nlp1.meta.name) ($(nlp1.meta.nvar) vars, $(nlp1.meta.ncon) cons)") | ||
| vals_h = Vector{Float64}(undef, nlp1.meta.nnzh) | ||
| hess_coord!(nlp1, x0, vals_h) | ||
|
|
||
| b_hess = @benchmark hess_coord!($nlp1, $x0, $vals_h) samples=100 evals=5 | ||
| println("✓ hess_coord!: $(b_hess.allocs) allocations, $(BenchmarkTools.prettytime(median(b_hess).time))") | ||
|
|
||
| finalize(nlp1) | ||
|
|
||
| # Test with a constrained problem | ||
| println("\nTesting with constrained problem (HS6):") | ||
| nlp2 = CUTEstModel{Float64}("HS6") | ||
| x0 = nlp2.meta.x0 | ||
|
|
||
| println("✓ Problem loaded: $(nlp2.meta.name) ($(nlp2.meta.nvar) vars, $(nlp2.meta.ncon) cons)") | ||
| println(" nnzj: $(nlp2.meta.nnzj), nnzh: $(nlp2.meta.nnzh)") | ||
|
|
||
| # Test basic functionality | ||
| f = obj(nlp2, x0) | ||
| g = similar(x0) | ||
| grad!(nlp2, x0, g) | ||
| println("✓ obj/grad: f = $(round(f, digits=6)), ||g|| = $(round(norm(g), digits=6))") | ||
|
|
||
| # Test constraint functions | ||
| c = Vector{Float64}(undef, nlp2.meta.ncon) | ||
| cons!(nlp2, x0, c) | ||
| println("✓ constraints: ||c|| = $(round(norm(c), digits=6))") | ||
|
|
||
| # Test cons_coord - this should show major allocation improvements | ||
| println("\nTesting cons_coord allocation improvements:") | ||
| c1, rows1, cols1, vals1 = cons_coord(nlp2, x0) | ||
|
|
||
| # Benchmark cons_coord | ||
| b_cons = @benchmark cons_coord($nlp2, $x0) samples=100 evals=5 | ||
| println("✓ cons_coord: $(b_cons.allocs) allocations, $(BenchmarkTools.prettytime(median(b_cons).time))") | ||
| println(" Memory: $(BenchmarkTools.prettymemory(median(b_cons).memory))") | ||
| println(" Returned $(length(vals1)) Jacobian elements") | ||
|
|
||
| # Test cons_coord! | ||
| rows = Vector{Cint}(undef, nlp2.meta.nnzj) | ||
| cols = Vector{Cint}(undef, nlp2.meta.nnzj) | ||
| vals = Vector{Float64}(undef, nlp2.meta.nnzj) | ||
| c_out = Vector{Float64}(undef, nlp2.meta.ncon) | ||
|
|
||
| b_cons_inplace = @benchmark cons_coord!($nlp2, $x0, $c_out, $rows, $cols, $vals) samples=100 evals=5 | ||
| println("✓ cons_coord!: $(b_cons_inplace.allocs) allocations, $(BenchmarkTools.prettytime(median(b_cons_inplace).time))") | ||
|
|
||
| # Test type conversion | ||
| println("\nTesting type conversion improvements:") | ||
| x0_f32 = Float32.(x0) | ||
| g_f32 = Vector{Float32}(undef, nlp2.meta.nvar) | ||
|
|
||
| b_grad_conv = @benchmark grad!($nlp2, $x0_f32, $g_f32) samples=100 evals=5 | ||
| println("✓ grad! with Float32->Float64 conversion: $(b_grad_conv.allocs) allocations") | ||
| println(" Time: $(BenchmarkTools.prettytime(median(b_grad_conv).time))") | ||
|
|
||
| # Test hess_coord with constraints | ||
| vals_h2 = Vector{Float64}(undef, nlp2.meta.nnzh) | ||
| y = zeros(nlp2.meta.ncon) | ||
| hess_coord!(nlp2, x0, y, vals_h2) | ||
|
|
||
| b_hess2 = @benchmark hess_coord!($nlp2, $x0, $y, $vals_h2) samples=100 evals=5 | ||
| println("✓ hess_coord! (constrained): $(b_hess2.allocs) allocations, $(BenchmarkTools.prettytime(median(b_hess2).time))") | ||
|
|
||
| finalize(nlp2) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.