Skip to content

Adds cleanup functions for resources - #224

Merged
MrBurmark merged 49 commits into
mainfrom
bechols97/stream_cleanup
Sep 25, 2026
Merged

MrBurmark merged 49 commits into
mainfrom
bechols97/stream_cleanup

Conversation

@bechols97

@bechols97 bechols97 commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

This is a bugfix to add cleanup functions for resources.

The Hip and Cuda resources are non-owning and never destroy streams, which show up as leaks in memory checkers/sanitizers. In these cases, the streams would be destroyed in the new cleanup function. If there is no cleanup needed for a resource (such as Host, Omp_target, Sycl), then the cleanup function will be a no-op.

An open question for this PR is whether the cleanup functions should be thread-safe? Currently, these are not thread safe to be consistent with RAJA::release_unused_internal_memory().

Note: These changes were created by AI. I have reviewed the changes and they seemed reasonable.
At this point, this has been redesigned from the initial changes made by AI.

Related to: #223

@artv3

artv3 commented Aug 21, 2026

Copy link
Copy Markdown
Member

Will we need a patch release ? We use the wait_for functions in my application, wait_for(default_res) type of calls.

@bechols97

Copy link
Copy Markdown
Collaborator Author

No, we probably don't need a patch release for these changes. With these changes, applications will realistically be calling the cleanup function only once prior to exiting since the number of streams created within the lifetime of the program is constant and will only be reported as leak by memcheckers/sanitizers during exit. In the worse case, this includes camp's default stream and 16 additional streams if applications use more than the default stream.

Regarding the wait_for question, I believe events were made owning in #206, which was in the release.

rhornung67
rhornung67 previously approved these changes Aug 21, 2026

@rhornung67 rhornung67 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. However, someone else should review and approve to make sure.

Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/init_helpers.hpp Resolved
Comment thread include/camp/init_helpers.hpp Resolved
Comment thread include/camp/init_helpers.hpp Resolved
Comment thread test/resource.cpp Resolved
Comment thread test/resource.cpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/init_helpers.hpp Resolved
Comment thread include/camp/init_helpers.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/init_helpers.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
Comment thread include/camp/resource/cuda.hpp Resolved
MrBurmark
MrBurmark previously approved these changes Sep 24, 2026
Comment thread include/camp/resource/host.hpp Resolved
Comment thread include/camp/resource/omp_target.hpp Resolved
Comment thread include/camp/init_helpers.hpp Resolved
Comment thread include/camp/init_helpers.hpp Resolved
@rhornung67

Copy link
Copy Markdown
Member

@bechols97 @MrBurmark this branch of Camp passed all the CI checks in RAJA. Please feel free to merge it. After that, I will put up a PR for the Camp patch release.

@MrBurmark
MrBurmark merged commit dab2ba5 into main Sep 25, 2026
13 checks passed
@MrBurmark
MrBurmark deleted the bechols97/stream_cleanup branch September 25, 2026 16:34
@bechols97 bechols97 mentioned this pull request Sep 25, 2026
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.

5 participants