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

Changes supporting GEOSX Trilinos/Tpetra wrapper #189

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

klevzoff
Copy link
Contributor

@klevzoff klevzoff commented Aug 3, 2020

This PR adds a simple function in ArrayView (and NewChaiBuffer) to get the data pointer in a specific MemorySpace, whether most current or not.

While this should not be needed/used by most developers, Tpetra implements dual memory space semantics, meaning that Tpetra::Vector for example contains pointers in both host and device memory spaces, and can potentially move data between them as needed. Therefore, in order to support the zero-copy creation of parallel vectors from ArrayView of local values, we have to be able to deliver pointers in both memory spaces.

Related to GEOS-DEV/GEOS#1086

@klevzoff klevzoff self-assigned this Aug 3, 2020
@klevzoff klevzoff mentioned this pull request Aug 3, 2020
3 tasks
@klevzoff klevzoff marked this pull request as ready for review August 8, 2020 06:15
@klevzoff klevzoff requested review from corbett5 and rrsettgast August 8, 2020 06:15
@klevzoff
Copy link
Contributor Author

klevzoff commented Aug 8, 2020

Note: code in GEOSX that uses this is currently disabled behind an #if 0, because I found out some Tpetra-based solvers only work reliably with Unified Memory, and so the zero-copy dual-view semantics cannot be implemented. So this PR could in principle be abandoned, however I though it might be useful in future.

*/
LVARRAY_HOST_DEVICE inline constexpr
T * data( MemorySpace const space ) const
{ return static_cast< T * >( m_pointer_record->m_pointers[ internal::toChaiExecutionSpace( space ) ] ); }
Copy link
Member

Choose a reason for hiding this comment

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

Is this sort of error prone? by this I mean that it seems likely that we can get a pointer that is not current? It there an underlying check/move?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code that uses this in GEOSX calls a move before. Would you rather have a call to move embedded in here? This sort of makes synchronization unavoidable, and I'm not sure we always want it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with this for the use case you describe above you don't want to move the data before getting the pointers our. Obviously you could really shoot yourself but this should only be used in a few places.

Could you

  1. Add a check to error out if the array wasn't allocated in that space m_pointer_record->m_pointers[ space ] == nullptr?
  2. Add the following the MallocBuffer and StackBuffer?
T * data( MemorySpace const space ) const
{
  LVARRAY_ERROR_IF_NE( space, MemorySpace::CPU );
  return data();
}
  1. Add a simple test to testArrayView.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@corbett5 done

@rrsettgast
Copy link
Member

Note: code in GEOSX that uses this is currently disabled behind an #if 0, because I found out some Tpetra-based solvers only work reliably with Unified Memory, and so the zero-copy dual-view semantics cannot be implemented. So this PR could in principle be abandoned, however I though it might be useful in future.

Do we need to update Trilinos?

@klevzoff
Copy link
Contributor Author

Do we need to update Trilinos?

No, there's no new version available. And it's not something they seem to have fixed yet. All Tpetra build instructions, FAQs, etc. explicitly require configuring Kokkos to use UM as default memory space for CUDA.

@rrsettgast
Copy link
Member

Do we need to update Trilinos?

No, there's no new version available. And it's not something they seem to have fixed yet. All Tpetra build instructions, FAQs, etc. explicitly require configuring Kokkos to use UM as default memory space for CUDA.

🤦

@corbett5
Copy link
Collaborator

No, there's no new version available. And it's not something they seem to have fixed yet. All Tpetra build instructions, FAQs, etc. explicitly require configuring Kokkos to use UM as default memory space for CUDA.

🤦

We can always just allocate the matrix with unified memory, it would be pretty easy to add that support.

@klevzoff klevzoff force-pushed the feature/klevzoff/tpetra branch 2 times, most recently from 72c0f88 to f142b04 Compare August 11, 2020 02:28
Copy link
Collaborator

@corbett5 corbett5 left a comment

Choose a reason for hiding this comment

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

Thanks!

@klevzoff klevzoff force-pushed the feature/klevzoff/tpetra branch from f142b04 to deb79fb Compare August 20, 2020 21:13
@klevzoff klevzoff force-pushed the feature/klevzoff/tpetra branch 3 times, most recently from 9c98e61 to 5daf329 Compare September 11, 2020 08:50
@klevzoff klevzoff force-pushed the feature/klevzoff/tpetra branch from 5daf329 to 95db802 Compare September 21, 2020 06:38
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.

3 participants