-
Notifications
You must be signed in to change notification settings - Fork 427
Reserve space in particle redistribution #4731
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
base: development
Are you sure you want to change the base?
Conversation
When redistributing particles, we need to resize a number of vectors. This sometimes causes out-of-memory issues for GPU runs, because the vector resize may fragment the memory arena. To address the issue, we try to minimize the number of memory reallocation calls by reserving space before we unpack local and remote communication buffers. Previously, resize may cause memory reallocation in both unpacking operations. We have also collected all the vectors that need to be resized into one place. This will allows to explore different strategies for how to resize a number of vectors.
Src/Particle/AMReX_ParticleTile.H
Outdated
| } | ||
| } | ||
|
|
||
| // xxxxx TODO: Can we come up a better strategy? |
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.
Maybe we can try to shrink the size first if a vector has say 2x capacity than needed. Then we can order the vectors by their future capacity, and reserve big vectors first.
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.
If a reserve fails, maybe we should try to defragment these vectors that are under our control. We can order them by their pointer address, and then try to move the vectors to lower addresses.
When redistributing particles, we need to resize a number of vectors. This sometimes causes out-of-memory issues for GPU runs, because the vector resize may fragment the memory arena. To address the issue, we try to minimize the number of memory reallocation calls by reserving space before we unpack local and remote communication buffers. Previously, resize may cause memory reallocation in both unpacking operations.
We have also collected all the vectors that need to be resized into one place. This will allows to explore different strategies for how to resize a number of vectors.