-
Notifications
You must be signed in to change notification settings - Fork 10
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
Use MPI_BYTE for unknown types #81
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,7 @@ template <typename Scalar> | |
MPI_Datatype mpi_type() { | ||
using T = std::decay_t<Scalar>; | ||
|
||
if constexpr (std::is_same_v<T, std::byte>) | ||
return MPI_BYTE; | ||
|
||
else if constexpr (std::is_same_v<T, char>) | ||
if constexpr (std::is_same_v<T, char>) | ||
return MPI_CHAR; | ||
else if constexpr (std::is_same_v<T, unsigned char>) | ||
return MPI_UNSIGNED_CHAR; | ||
|
@@ -99,6 +96,9 @@ MPI_Datatype mpi_type() { | |
else if constexpr (std::is_same_v<T, Kokkos::complex<double>>) | ||
return MPI_DOUBLE_COMPLEX; | ||
|
||
else if constexpr (std::is_trivially_copyable_v<T>) | ||
return MPI_BYTE; | ||
|
||
else { | ||
static_assert(std::is_void_v<T>, "mpi_type not implemented"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might make sense to assert that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking ahead, I think trivially-copyable is a problem for Trilinos FAD types - they are actually trivially-copyable, but because of how they are implemented they have non-default ctors, etc that makes C++ think they're not trivially-copyable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe if we run into this problem (a problem of success), we can make a special configure-time toggle to remove this trivially-copyable check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing I'm not a fan of is that if you have type T with large There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now, maybe we can just send as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kokkos could offer a trait that overrides There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed that also in the context of |
||
return MPI_CHAR; // unreachable | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this fix alone solves your problem. I'm missing the part where we get the size of T. In https://github.com/kokkos/kokkos-comm/blob/develop/src/impl/KokkosComm_send.hpp#L72 we only get the type (
MPI_BYTE
here) and take the span, not thespan*sizeof(T)
. Maybempi_type()
should provide a count multiplier as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, @masterleinad identified this problem. I'm not sure what's the best way to proceed here. Your suggestion is one of the possible variants.