Skip to content

Consolidate in-place implementations for ConservativePDSProblems and PDSProblems#191

Merged
ranocha merged 5 commits intomainfrom
sk/unified_inplace_implementations
Mar 15, 2026
Merged

Consolidate in-place implementations for ConservativePDSProblems and PDSProblems#191
ranocha merged 5 commits intomainfrom
sk/unified_inplace_implementations

Conversation

@SKopecz
Copy link
Copy Markdown
Collaborator

@SKopecz SKopecz commented Mar 11, 2026

Problem: Currently, every algorithm requires two separate in-place implementations: one for ConservativePDSProblem and one for PDSProblem. Because the latter requires additional destruction vectors, they use different cache structures, leading to significant code duplication.

Solution: This PR consolidates these implementations by adopting the strategy used in the out-of-place version. By using Nothing for destruction vectors in ConservativePDSProblems and leveraging multiple dispatch, we can now use a single unified code path.

Impact:

  • Reduces code duplication significantly.

  • Simplifies maintenance and the implementation of future algorithms.

  • Consistent behavior between in-place and out-of-place APIs.

@SKopecz
Copy link
Copy Markdown
Collaborator Author

SKopecz commented Mar 11, 2026

The PR currently contains the consolidation for MPRK22.

prob = prob_pds_linmod_inplace
alg = MPRK22(1.0)

Before:

julia> @benchmark solve($prob, $alg; save_everystep = false)
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (min  max):  76.319 μs   26.239 ms  ┊ GC (min  max): 0.00%  99.53%
 Time  (median):     81.111 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   91.810 μs ± 325.420 μs  ┊ GC (mean ± σ):  5.61% ±  1.71%

  █▆▄▃▄▆▆▅▃▂▂▁▁▁▁                                              ▁
  ██████████████████▇▇█▇▇▇▆▆▇▆▆▆▅▆▆▆▆▆▆▆▇▆▆▆▆▆▅▆▆▆▅▅▅▄▄▆▅▅▆▅▅▅ █
  76.3 μs       Histogram: log(frequency) by time       173 μs <

 Memory estimate: 45.47 KiB, allocs estimate: 955.

After:

julia> @benchmark solve($prob, $alg; save_everystep = false)
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (min  max):  77.018 μs   33.066 ms  ┊ GC (min  max): 0.00%  99.57%
 Time  (median):     87.283 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   93.850 μs ± 373.274 μs  ┊ GC (mean ± σ):  5.36% ±  1.41%

  ▅▃▂▄█▅▄▃▂▆▇▆▅▄▂▂▁▁▁ ▁                                        ▂
  █████████████████████▇▇█▇▇▇▅▆▆▆▇▅▄▆▆▅▅▅▆▄▅▄▅▄▄▂▅▅▄▄▂▄▅▅▄▂▄▃▅ █
  77 μs         Histogram: log(frequency) by time       151 μs <

 Memory estimate: 45.47 KiB, allocs estimate: 955.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 11, 2026

Pull Request Test Coverage Report for Build 23067024649

Details

  • 34 of 34 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 97.305%

Totals Coverage Status
Change from base Build 22594658557: -0.2%
Covered Lines: 1661
Relevant Lines: 1707

💛 - Coveralls

@SKopecz
Copy link
Copy Markdown
Collaborator Author

SKopecz commented Mar 11, 2026

The in-place implementations of all MPRK and SSPMPRK algorithms have been consolidated. The implementation of MPDeC schemes is different, therefore I wouldn't change it.

Copy link
Copy Markdown
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks reasonable to me. I just have some minor suggestions.

SKopecz and others added 2 commits March 13, 2026 20:19
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Copy link
Copy Markdown
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ranocha ranocha merged commit 5b0b409 into main Mar 15, 2026
11 checks passed
@ranocha ranocha deleted the sk/unified_inplace_implementations branch March 15, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants