Gpu mem leak with init invoked multiple times #1735
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR is to address the issue #1678 with the GPU package where host memory allocation increases when the run command is called multiple times.
Related Issues
Fixes #1678
Author(s)
Trung Nguyen (Northwestern)
Licensing
By submitting this pull request, I agree, that my contribution will be included in LAMMPS and redistributed under either the GNU General Public License version 2 (GPL v2) or the GNU Lesser General Public License version 2.1 (LGPL v2.1).
Backward Compatibility
Yes
Implementation Notes
The issue disappears if "pre no" is used, suggesting that the problem comes from init_style() in the /gpu pair styles, which go into the init function of the corresponding pair styles and pppm in the GPU library. The host memory increase is not reported as memory leaks by valgrind, but massif does show the memory allocation increase associated with libcuda.so for CUDA builds and libopencl.so with OpenCL builds. The changes in this PR are made to the base classes, which 1) remove a call to device->clear() in the clear_atomic() function, 2) move the section where the kernel and program deallocation to the destructor (assuming that the kernels and program are needed to be compiled once), and 3) initialize pair_program with NULL in the constructor, and delete the pointer if it is not NULL (that is, already allocated).
Post Submission Checklist
Please check the fields below as they are completed after the pull request has been submitted. Delete lines that don't apply