-
-
Couldn't load subscription status.
- Fork 5.7k
LAPACK wrappers: use resize!(a) instead of a = Vector{T}() #21938
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
Conversation
|
Dunno how visible this will be to the Base benchmarks, but... @nanosoldier |
| iwork = Vector{BlasInt}(1) | ||
| liwork = BlasInt(-1) | ||
| rwork = Array{$relty,0}() | ||
| rwork = Vector{$relty}(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change from a zero-dimensional Ah, I see Array to a single-element one-dimensional Array?rwork was formerly bound to a fresh Vector below, and you now resize instead. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this commit should probably be squashed, on merge if not before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alyst! :) (Absent objections, requests for time, or someone beating me to it, I plan to merge this tomorrow morning.)
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
|
Those benchmarks are a little surprising given that the intent of the PR is to reduce memory usage. |
|
Oh, well. Maybe |
|
It looks, though, that time-wise these linalg benchmarks are much more precise than their tolerance values: all changes are within 3%. |
|
@nanosoldier |
|
@fredrikekre Absolutely. Just a wild guess. OTOH it shouldn't be as disruptive as the change of the growth rate. |
|
Funnily, Travis failed in the QR test, but the problem is not in the linalg. Most likely the last commit exposed something in string interpolation. lstring = sprint(show,l)
qstring = sprint(show,q)
@test sprint(show,lqa) == "$(typeof(lqa)) with factors L and Q:\n$lstring\n$qstring"The difference between LHS and RHS is the last |
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
|
Surprisingly, the benchmarks had not regressed memory-wise except |
|
@nanosoldier |
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
src/array.c
Outdated
| size_t nbinc = inc * elsz; | ||
| size_t newlen = a->maxsize == 0 ? (inc < 4 ? 4 : inc) : a->maxsize * 2; | ||
| while ((n + inc) > newlen - a->offset) | ||
| // if the requested size is much larger than the current maxsize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this heuristic doesn't sound absurd to me, maybe it would make sense (as in more robust) to add an exact=false argument to resize!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think giving the user more control over memory allocation, resize!() in particular, would make a lot of sense. Unfortunately, I didn't expect that trivial LAPACK fixes would require that sort of things: the last commit was just a quick check. I'd rather way until the memory allocation problem is addressed by a separate PR and update this one accordingly.
|
I think we should just merge the lapack wrapper part of this PR. The wrappers will use slightly more memory for now but it still looked like it gave a speedup. Probably because the wrapper then interacts less with the GC. We might be able to make |
|
@andreasnoack I've moved the last commit into the new issue for discussions. |
- replace a = Vector{T}(n) with resize!(a, n)
- add comments when BLAS API method is called twice
|
#22038 is merged, so this one should not introduce regressions when merged into master. |
|
@nanosoldier |
|
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
Following up the discussion at #21564, replace
a = Vector{T}(n)withresize!(a, n).Hopefully should decrease resources usage by a tiny bit.
Also add comments clarifying why BLAS routine is called twice.