-
Notifications
You must be signed in to change notification settings - Fork 0
Reduce allocation #126
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
Reduce allocation #126
Changes from 80 commits
Commits
Show all changes
87 commits
Select commit
Hold shift + click to select a range
52560dc
Reduce allocations
ufechner7 5306b4b
Use normalize!
ufechner7 3cfff2f
Reduce allocations
ufechner7 858c036
Use \cdot
ufechner7 50254d5
Cleanup
ufechner7 7a72082
Replace cross with \times
ufechner7 2133d62
Add bench2.jl
ufechner7 210e13b
Update comments
ufechner7 3a3d7fa
Add P to VSMSolution and bench2.jl
ufechner7 1cba421
Make use of panel_width_array
ufechner7 4705658
Now 112, 600 allocations
ufechner7 706c21f
Now 596 allocations
ufechner7 429f5d3
Down to 590 allocations
ufechner7 b71846d
Cleanup
ufechner7 f06db22
Update comment
ufechner7 48e856e
Fix tests
ufechner7 a18b3b8
Fix examples
ufechner7 a247fa8
Cleanup
ufechner7 02cb714
Down to 586 allocations
ufechner7 1ee0731
Refactor update_effective_angle_of_attack_if_VSM()
ufechner7 92dca3e
Now 424 allocations
ufechner7 c9afaa1
Now 422 allocations
ufechner7 5f636be
Now 420 allocations
ufechner7 a9f4309
Change comment
ufechner7 709fae2
Cleanup
ufechner7 e529b19
Add PreallocationTools
ufechner7 361093d
Now 408 allocations
ufechner7 37a506f
Now 398 allocations
ufechner7 50ebc19
Refactoring
ufechner7 b426103
Refactoring
ufechner7 8909fce
Refactoring
ufechner7 0141122
Refactoring
ufechner7 4314378
Cleanup
ufechner7 36fc836
Refactoring
ufechner7 2d7b02d
Refactoring
ufechner7 a016eee
Update comment
ufechner7 f9d9531
Now 394 allocations
ufechner7 63c3bfa
Refactoring
ufechner7 31830a7
Add BaseResult
ufechner7 635ba3e
Improve LoopResult
ufechner7 d391ba5
Refactoring, use LoopResult
ufechner7 6675969
Refactoring
ufechner7 8cbcae9
Add comment
ufechner7 dc85609
Refactoring
ufechner7 4aefd86
Refactoring
ufechner7 52b8b45
Update docstring
ufechner7 40b225d
Refactoring
ufechner7 bdfb104
Cleanup
ufechner7 ef597d2
Refactoring
ufechner7 646fe11
Refactoring
ufechner7 04bc283
Refactoring
ufechner7 24f23b7
Refactoring
ufechner7 c415c9c
Update struct BaseResult
ufechner7 3cbc8f9
Add minimal working example
ufechner7 2035e24
Improve mwe_01.jl
ufechner7 70bdfd0
Now 390 allocations
ufechner7 3597ef9
Refactoring
ufechner7 05c733e
Add TODO
ufechner7 a1eb650
Now 350 allocations
ufechner7 66f9330
Now 348 allocations
ufechner7 4d6bd58
Now 346 allocations
ufechner7 ace85bf
Now 344 allocations
ufechner7 306527e
Now 342 allocations
ufechner7 98e2b2c
Add comment
ufechner7 e5e1452
Refactoring
ufechner7 26f2f1d
Refactoring
ufechner7 e733eb3
Update comment
ufechner7 8466643
Update comments
ufechner7 8c5ebbd
Refactoring
ufechner7 daa7f6d
Now 340 allocations
ufechner7 dec97ac
Add comment
ufechner7 e19461c
Now 337 allocations
ufechner7 98a7336
Update comments
ufechner7 e104242
Now 328 allocations
ufechner7 163d99d
Cleanup
ufechner7 54ce6a1
Update comment
ufechner7 c56e174
Update comment
ufechner7 b261c4e
Update comment
ufechner7 fdc7ed4
Add mwe_02.jl
ufechner7 831a85e
Cleanup
ufechner7 aa5c912
Add file to .gitignore
ufechner7 4fad8b4
Use Julia 1.10 to create bin files
ufechner7 548bf70
Merge branch 'main' into opt
1-Bart-1 d82d853
Address remarks
ufechner7 a1b5479
Merge branch 'main' into opt
1-Bart-1 df89b9d
Remove print statement
ufechner7 39333aa
Add comments
ufechner7 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
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
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,63 @@ | ||
| # replace va_norm_array = norm.(eachrow(solver.sol.va_array)) with a for loop | ||
|
|
||
| # testcase | ||
| using Test | ||
| using LinearAlgebra # for the norm function | ||
|
|
||
| # Define a mock Solver struct | ||
| struct MockSolver | ||
| sol::NamedTuple | ||
| end | ||
|
|
||
| function calc_norm_array!(va_norm_array, va_array) | ||
| for i in 1:size(va_array, 1) | ||
| va_norm_array[i] = norm(view(va_array, i, :)) | ||
| end | ||
| end | ||
|
|
||
| @testset "va_norm_array calculation" begin | ||
| global va_norm_array | ||
|
|
||
| # Create a sample 2D array | ||
| sample_va_array = [ | ||
| 1.0 2.0 3.0; | ||
| 4.0 5.0 6.0; | ||
| 7.0 8.0 9.0 | ||
| ] | ||
|
|
||
| # Create a mock solver with the sample array | ||
| mock_solver = MockSolver((va_array = sample_va_array,)) | ||
|
|
||
| # Calculate va_norm_array | ||
| n = @allocated va_norm_array = norm.(eachrow(mock_solver.sol.va_array)) | ||
| println(n) | ||
|
|
||
| va_norm_array2 = zeros(3) | ||
| m = @allocated calc_norm_array!(va_norm_array2, sample_va_array) | ||
| println(m) | ||
|
|
||
| # Expected results (calculated manually) | ||
| expected_norms = [ | ||
| sqrt(1^2 + 2^2 + 3^2), | ||
| sqrt(4^2 + 5^2 + 6^2), | ||
| sqrt(7^2 + 8^2 + 9^2) | ||
| ] | ||
|
|
||
| # Test the results | ||
| @test length(va_norm_array) == size(sample_va_array, 1) | ||
| @test va_norm_array ≈ expected_norms atol=1e-10 | ||
|
|
||
| # Test individual values | ||
| @test va_norm_array[1] ≈ norm(sample_va_array[1, :]) atol=1e-10 | ||
| @test va_norm_array[2] ≈ norm(sample_va_array[2, :]) atol=1e-10 | ||
| @test va_norm_array[3] ≈ norm(sample_va_array[3, :]) atol=1e-10 | ||
|
|
||
| @test length(va_norm_array2) == size(sample_va_array, 1) | ||
| @test va_norm_array2 ≈ expected_norms atol=1e-10 | ||
|
|
||
| # Test individual values | ||
| @test va_norm_array2[1] ≈ norm(sample_va_array[1, :]) atol=1e-10 | ||
| @test va_norm_array2[2] ≈ norm(sample_va_array[2, :]) atol=1e-10 | ||
| @test va_norm_array2[3] ≈ norm(sample_va_array[3, :]) atol=1e-10 | ||
| end | ||
| nothing |
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 @@ | ||
|
|
||
| using PreallocationTools, Parameters | ||
|
|
||
| Base.@kwdef mutable struct MockSolver | ||
| const ca::NTuple{11, LazyBufferCache{typeof(identity), typeof(identity)}} = ([LazyBufferCache() for _ in 1:11]) | ||
| end |
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
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.