Skip to content
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

Proper handling of static arrays #444

Merged
merged 3 commits into from
Dec 13, 2023

Conversation

avik-pal
Copy link
Member

No description provided.

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (bda160c) 65.29% compared to head (a31f99f) 65.36%.

Files Patch % Lines
src/common.jl 89.28% 3 Missing ⚠️
src/default.jl 80.00% 1 Missing ⚠️
src/factorization.jl 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #444      +/-   ##
==========================================
+ Coverage   65.29%   65.36%   +0.06%     
==========================================
  Files          27       27              
  Lines        2072     2096      +24     
==========================================
+ Hits         1353     1370      +17     
- Misses        719      726       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChrisRackauckas
Copy link
Member

Could we add an inference and no alloc check on static array usage too?

@avik-pal
Copy link
Member Author

There is this 1 allocation while creating the LinearCache which I can't seem to track
image

@ChrisRackauckas
Copy link
Member

This is kind of the same thing as the SimpleNonlinearSolve/SimpleDiffEq case. If someone calls solve and not init, then with static things doing something simpler is advantageous. I would think that if someone calls solve on a StaticArray we should basically just do A\b and bypass the rest of LinearSolve.jl. I did a bunch of testing when making https://github.com/SciML/OrdinaryDiffEq.jl/blob/master/src/derivative_utils.jl#L1-L19 and for sufficiently small problems caching the LU with a static array (or the inv) is simply not helpful (track down the PR with the old benchmarks). This could be size dependent too.

Now if they do init I think this all makes sense though, just solve should have a fast path.

@avik-pal
Copy link
Member Author

Yeah that makes sense. Though I feel even for init with SArrays we shouldn't really cache anything, just pretend to cache it. I have found operations mixing MArrays and SArrays to be slower than just doing the uncached SArrays

@ChrisRackauckas
Copy link
Member

Agreed

@ChrisRackauckas ChrisRackauckas merged commit caaedab into SciML:main Dec 13, 2023
12 of 14 checks passed
@avik-pal avik-pal deleted the ap/static_arrays branch December 14, 2023 00:22
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.

2 participants