[petsc-users] Limiting the number of vectors allocated at a time by fgmres etc.

Matthew Knepley knepley at gmail.com
Tue Feb 10 17:28:09 CST 2026


On Tue, Feb 10, 2026 at 5:32 PM Wells, David via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hello,
>
> I've been profiling the memory usage of my solver and it looks like a huge
> number (roughly half) of allocations are from KSPFGMRESGetNewVectors(). I
> read through the source code and it looks like these vectors are allocated
> ten at a time (FGMRES_DELTA_DIRECTIONS) in a couple of places inside that
> KSP. Is there a way to change this value?
>

We could add an option to change this delta. Actually theory suggests that
a constant is not optimal, but rather we should double the number each
time. I would also be willing to code that.


> If not - how hard would it be to add an API to set a different initial
> value for that? These vectors take up a lot of memory and I would rather
> just one at a time.
>

I cannot understand precisely what is happening here. You specify a restart
size when you setup the KSP. It allocates that many vecs (roughly). Why are
there reallocations? Do you increase the restart size during the iteration?

  Thanks,

     Matt


> Best,
> David Wells
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!bSUDVgOBX_MDxTjSivXOuXsYl5KKCBhJDYseaa3Gb4DMURCyG3nv1cAESszMf_OsNZRuR6JWB7VFthuvYWD6$  <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!bSUDVgOBX_MDxTjSivXOuXsYl5KKCBhJDYseaa3Gb4DMURCyG3nv1cAESszMf_OsNZRuR6JWB7VFtp20RqZe$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260210/58cc30bb/attachment.html>


More information about the petsc-users mailing list