Skip to content

Deep copy from Sidre to Conduit #1510

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

Open
wants to merge 67 commits into
base: develop
Choose a base branch
from

Conversation

gunney1
Copy link
Contributor

@gunney1 gunney1 commented Mar 3, 2025

Summary

  • This PR is a feature
  • It does the following:
    • Implement Group::deepCopyToConduit and View::deepCopyToConduit
    • Secondarily, but critically, provide a mechanism for allocating Views with different allocators based on the View type (string, scalar or array). The mechanism generalizes scalars so they can be array-like but treated as scalars for the purpose of data allocation and copying. In use, this can transparently place big computational data on device and metadata on host.
    • Support copying from one allocator id to another. The allocator ids are set before the copy, and the copy assures destination memory uses the right id.
    • Support Conduit memory allocation using any Axom or Umpire allocator id. This functionality partially overlaps the one recently added to the bump component. We will combine the two after this merge.
    • Fix bug that always allocates string and scalar View data on host. They now allocate in the default allocator of the Group that owns the View. (We have discussed this in the project meetings, reaching the concensus was that all data should use the default allocator unless individually overridden, despite the fact that many parts of a hierarchy would only be used on the host.) Preserves the unintended but useful behavior of scalars and strings always being allocated on the host. Scalars and strings now have their own allocator, with the option of being placed on device if the user wants.
    • Manually tell a bunch of Views to allocate data on the host, where they are used and expected to be.
    • Add tests for the new methods.

The generalized scalar type is called a "tuple", which is treated like a scalar but may have more than one element. This change:

  • is backward compatible
  • preserves the current unintended but useful sidre behavior placing strings and scalars on hosts
  • continues to support the previously intended behavior of putting strings, scalars and arrays in the same memory space, if that's what the user wants
  • adds a small set of critical methods: View::setTuple, View::isTuple, Group::setDefaultArrayAllocator and Group::setDefaultTupleAllocator
  • changes Group::setDefaultAllocator and Group::getDefaultAllocator to call the array versions of those methods

The use of tuples greatly simplifies working with sidre hierarchies. Using the same allocator for all data and manually overriding individual leaves, was not workable.

The goal of this change is toward supporting transparent switching between sidre and conduit. With the addition of Group::deepCopyToConduit, the state of conduit-sidre hierarchy copies is:
Screenshot_2025-04-22_06-02-48
* I labeled importConduitTreeExternal as the shallow conduit-to-sidre copy, but it's not exactly analogous to createNativeLayout (the shallow sidre-to-conduit copy).

@gunney1 gunney1 added the Sidre Issues related to Axom's 'sidre' component label Mar 3, 2025
@gunney1 gunney1 self-assigned this Mar 3, 2025
gunney1 added 20 commits March 6, 2025 09:17
The actual fix is on another branch, but I can't wait for it to
be merged.
It's failing.  Maybe because non-Umpire allocators are not
working right or Group isn't using it right.
Also disable test copying in/out of Umpire.
This check needs to wait for proper support for
that kind of copy, which is being performed on
another branch.
change transfer_allocator method name to transferTo.
Also use call-back to return View-specific allocator.
@gunney1 gunney1 force-pushed the feature/gunney/copy-sidre-to-conduit branch from 6764c24 to 41c15d7 Compare March 28, 2025 18:08
@gunney1 gunney1 force-pushed the feature/gunney/copy-sidre-to-conduit branch from 582bbad to 46bb8a7 Compare April 1, 2025 01:06
*
* \return pointer to this Group object.
*
* This method is recursive.
Copy link
Member

@rhornung67 rhornung67 Jul 30, 2025

Choose a reason for hiding this comment

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

Does recursive mean that the operation is applied to the entire group hierarchy rooted at the group?
If so, maybe it's clearer to say something like that since that is what I see in other comments that do similar hierarchy traversals. If not, I would have to look at the implementation to see what it means...

@@ -1872,7 +2100,7 @@ const char* View::getAttributeString(const Attribute* attr) const
*
*************************************************************************
*/
int View::getValidAllocatorID(int allocID)
int View::getValidAxomAllocatorID(int allocID)
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment/question as earlier about why the Axom qualifier is needed and what it means.

* If the state is EMPTY or allocId is the current
* allocator or is axom::INVALID_ALLOCATOR_ID, this is a no-op.
* Reallocating an EXTERNAL View means allocating it internally.
* (This could be revisited, but it is the behavior for now.)
Copy link
Member

Choose a reason for hiding this comment

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

I may be missing something, but that seems like the only reasonable choice.

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.

A variety of comments and questions to consider.

gunney1 added 5 commits July 30, 2025 16:22
Back out work-arounds that were in place to get View
data into the right memory space.
The specification is now done transparently by the hierarchy.
These are obsolete because the hierarchy can now allocate memory
in the right allocator id.
@gunney1 gunney1 force-pushed the feature/gunney/copy-sidre-to-conduit branch from 8e97b84 to 1b67d97 Compare August 1, 2025 16:47
@gunney1 gunney1 force-pushed the feature/gunney/copy-sidre-to-conduit branch from 1b67d97 to 634cbaf Compare August 1, 2025 19:18
@gunney1
Copy link
Contributor Author

gunney1 commented Aug 5, 2025

It looks like there are several changes unrelated to the Sidre updates in this PR, are those intended or do we need further cleanup?

Yes, they are intended even though they're unrelated. With the number of times I had to merge this branch with an active branch that depends on it, it got to be too much work keeping that code separated.

@gunney1 gunney1 requested a review from kennyweiss August 7, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GPU Issues related to GPU development Reviewed Sidre Issues related to Axom's 'sidre' component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants