Skip to content

Conversation

@adayton1
Copy link
Member

@adayton1 adayton1 commented Jan 21, 2026

ManagedArrayPointer is the experimental replacement for ManagedArray. All the logic for handling various memory types is delegated to a ManagerType template parameter.

This class provides a uniform interface for working with different types of memory across multiple backends. It has pointer semantics, meaning that copies are shallow, which allows this object to be passed by value to a CUDA or HIP kernel. When copy constructed, it queries the array manager to update the cached size and pointer from the array manager. The array must be explicitly freed from only one of the shallow copies.

@adayton1 adayton1 changed the title Add ManagedArrayPointer Add experimental ManagedArrayPointer Jan 21, 2026
Copy link
Contributor

@robinson96 robinson96 left a comment

Choose a reason for hiding this comment

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

LGTM

across multiple backends. It has pointer semantics, meaning that copies are shallow,
which allows this object to be passed by value to a CUDA or HIP kernel. When copy
constructed, it queries the array manager to update the cached size and pointer
from the array manager. The array must be explicitly freed from only one of the
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way for a user to check whether the data referenced by a ManagedArrayPointer has been freed; e.g., by another pointer object pointing to the same data? If not, it may be worth considering. I can see how that would be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not without a lot of extra tracking. My plan was to add another class called ManagedArraySharedPointer that would act like std::shared_ptr and avoid the need to explicitly free.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. I figured that would be the case. You solution sounds like it should do the trick.

Copy link
Member

@rhornung67 rhornung67 left a comment

Choose a reason for hiding this comment

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

Looks good to me. One comment to consider.

Also, you may want to rework the copyright statements in the files like I did in RAJA. Then, updating the copyright year only requires touching 2 files instead of all of them, which kinda pollutes the commit history of each file.

Here's the change: llnl/RAJA#1976

@adayton1 adayton1 merged commit da827e7 into develop Jan 21, 2026
5 of 9 checks passed
@adayton1 adayton1 deleted the expt/managed_array_pointer branch January 21, 2026 21:00
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.

6 participants