Skip to content
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

Set default allocator id to device instead of unified for CUDA and HIP execution policies #1316

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

Conversation

bmhan12
Copy link
Contributor

@bmhan12 bmhan12 commented Apr 10, 2024

This PR:

  • Makes device the default Umpire allocator id instead of unified for CUDA and HIP execution policies.
  • Adjusts unit tests and examples to reflect device memory as the new default.
    • For tests and examples where device id for memory allocation did not work, unified id is used instead.

Follow-up work is required to revisit tests and examples that still require unified memory, and adjust the source implementation.
These include:

  • quest DistributedClosestPoint
  • quest SignedDistance
  • quest MeshTester
  • quest IntersectionShaper
  • spin ImplicitGrid (getCandidates() function call)
  • mint for_all_cells/ for_all_nodes/ for_all_faces (???)

@bmhan12 bmhan12 added Core Issues related to Axom's 'core' component Quest Issues related to Axom's 'quest' component Primal Issues related to Axom's 'primal component GPU Issues related to GPU development labels Apr 10, 2024
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 @bmhan12 !

src/axom/core/tests/core_execution_for_all.hpp Outdated Show resolved Hide resolved
src/axom/mint/tests/mint_execution_cell_traversals.cpp Outdated Show resolved Hide resolved
@@ -40,7 +40,10 @@ void check_bb_policy()
box[i].isValid();
});

EXPECT_EQ(box[0], BoundingBoxType(PointType(0.0), PointType(10.0)));
BoundingBoxType box_host;
Copy link
Member

Choose a reason for hiding this comment

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

Minor: Would this code be simpler if box used a StackArray instead of allocating and deallocating one bounding box?

@@ -329,6 +329,12 @@ void unit_check_poly_clip()
// |
// In addition, vertices 0 and 3 should be marked as clipped.

const int current_allocator = axom::getDefaultAllocatorID();
Copy link
Member

Choose a reason for hiding this comment

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

Similarly here:
Do we have a better pattern for allocating/deallocating moving a single object between host and device, e.g. using a StackArray ?

(Not required for this PR, but if we have a cleaner way of doing this, we should prefer to use it in the unit tests)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have a better pattern for allocating/deallocating moving a single object between host and device, e.g. using a StackArray ?

Not that I am aware of. The best I have found is either using axom::allocate & axom::copy, or using axom::Array constructors to move between host and device.

Comment on lines +450 to +462
tet[0] = TetrahedronType(PointType {1, 0, 0},
PointType {1, 1, 0},
PointType {0, 1, 0},
PointType {1, 0, 1});

hex[0] = HexahedronType(PointType {0, 0, 0},
PointType {1, 0, 0},
PointType {1, 1, 0},
PointType {0, 1, 0},
PointType {0, 0, 1},
PointType {1, 0, 1},
PointType {1, 1, 1},
PointType {0, 1, 1});
Copy link
Member

Choose a reason for hiding this comment

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

Does this change require setDefaultAllocatorID() to have been set above? Or does it work because its constructed within the appropriate ExecPolicy ?

If it's the former, is there a way to make this work without setting the default allocator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this change require setDefaultAllocatorID() to have been set above? Or does it work because its constructed within the appropriate ExecPolicy ?

The latter, and it works because the hexahedron constructor is host-device decorated.

Comment on lines +528 to +531
// Shapes on host
TetrahedronType tet_host;
OctahedronType oct_host;
PolyhedronType res_host;
Copy link
Member

Choose a reason for hiding this comment

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

Likely outside the scope of this PR, but we should probably have a standardized convention for labeling variables as host, device and views and use them consistently within axom and its tests and examples.

Perhaps we should create a separate issue to track this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue #1333 opened to track this issue.

src/axom/primal/tests/primal_polyhedron.cpp Outdated Show resolved Hide resolved
src/axom/quest/IntersectionShaper.hpp Outdated Show resolved Hide resolved
src/axom/spin/tests/spin_implicit_grid.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issues related to Axom's 'core' component GPU Issues related to GPU development Primal Issues related to Axom's 'primal component Quest Issues related to Axom's 'quest' component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants