Skip to content

Conversation

@gunney1
Copy link
Contributor

@gunney1 gunney1 commented Dec 18, 2025

Summary

  • This PR is a feature
  • It does the following:
    • Allows user to override the default allocator id when deep-copying a sidre::View to a conduit::Node.
    • Add a test for copying with allocator override.

This PR takes a bit out of #1736 to make that one smaller, as requested by the code review.

@gunney1 gunney1 self-assigned this Dec 18, 2025
@gunney1 gunney1 added the Sidre Issues related to Axom's 'sidre' component label Dec 18, 2025
Copy link
Member

@BradWhitlock BradWhitlock left a comment

Choose a reason for hiding this comment

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

Looks fine to me. Thanks.

@gunney1 gunney1 requested a review from BradWhitlock December 18, 2025 16:10
Copy link
Member

@kennyweiss kennyweiss left a comment

Choose a reason for hiding this comment

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

Thanks @gunney1.

I had one concern about checking that the data was actually copied. I'm not sure if this should hold up the PR, but having this check might help diagnose problems later (e.g. by ruling out some simple issues).

Comment on lines +2011 to +2059
TEST(sidre_view, deep_copy_to_conduit_with_allocid)
{
using axom::sidre::ConduitMemory;

std::vector<int> allocIds = getKnownAllocIds();
for(axom::IndexType si = 0; si < allocIds.size(); ++si)
{
auto aId = allocIds[si];
auto cId = ConduitMemory::axomAllocIdToConduit(aId);
std::cout << "si=" << si << " axomAllocId=" << aId << " conduitAllocId=" << cId << std::endl;
}
if(allocIds.size() < 2)
{
std::cout << "Skipping test deep_copy_to_conduit_with_allocid."
"At least 2 allocators are needed to test."
<< std::endl;
return;
}

DataStore ds;

Group* srcGrp = ds.getRoot()->createGroup("src");
View* srcView = srcGrp->createView("a");
srcView->setScalar(int(15));

// Copy srcView to conduit destinations, varying the allocator.
for(axom::IndexType si = 0; si < allocIds.size(); ++si)
{
// dst1 uses default Conduit allocator
conduit::Node dst1;
auto defaultConduitAllocId = dst1.allocator();
srcView->deepCopyToConduit(dst1);
EXPECT_EQ(dst1.allocator(), defaultConduitAllocId);

// dst2 sets and uses allocator allocIds[si]
conduit::Node dst2;
dst2.set_allocator(ConduitMemory::axomAllocIdToConduit(allocIds[si]));
srcView->deepCopyToConduit(dst2);
EXPECT_EQ(ConduitMemory::conduitAllocIdToAxom(dst2.allocator()), allocIds[si]);

// dst3 sets allocator allocIds[si] but overrides it in the copy
conduit::Node dst3;
dst3.set_allocator(ConduitMemory::axomAllocIdToConduit(allocIds[si]));
srcView->deepCopyToConduit(dst3, allocIds[0]);
EXPECT_EQ(ConduitMemory::conduitAllocIdToAxom(dst3.allocator()), allocIds[0]);
}

ds.getRoot()->destroyGroup("src");
}
Copy link
Member

Choose a reason for hiding this comment

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

This new test is checking that we can successfully call deepCopyToConduit in several ways, but it does not verify that the data was actually copied. Is there a way we can check the data?

One idea might be to copy using the data using the specified allocator and then to copy it back to a new buffer using the host allocator and then to check that the data is the same.
Another might be to to do some sort of checksum on the data, and then check that the checksums are the same after copying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have other tests that verify the copied data.

@gunney1 gunney1 merged commit 55e9df4 into develop Dec 18, 2025
15 checks passed
@gunney1 gunney1 deleted the feature/gunney/sidre-view-allocator-override branch December 18, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Sidre Issues related to Axom's 'sidre' component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants