-
Notifications
You must be signed in to change notification settings - Fork 89
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
feat: MpiWrapper::allReduce overload for arrays. #3446
base: develop
Are you sure you want to change the base?
Conversation
…OS-DEV/GEOS into feature/cusini/addMpiWrapperForArrays
@rrsettgast , @corbett5 , @wrtobin this is ready for review. |
namespace geos | ||
{ | ||
|
||
namespace internal | ||
{ | ||
|
||
template< typename T, typename = void > | ||
struct has_value_type : std::false_type {}; | ||
|
||
template< typename T > | ||
struct has_value_type< T, std::void_t< typename T::value_type > > : std::true_type {}; | ||
|
||
template< typename T, typename = void > | ||
struct has_ValueType : std::false_type {}; | ||
|
||
template< typename T > | ||
struct has_ValueType< T, std::void_t< typename T::ValueType > > : std::true_type {}; | ||
|
||
} // namespace internal | ||
|
||
template< typename T, typename Enable = void > | ||
struct get_value_type | ||
{ | ||
static_assert( sizeof(T) == 0, "T must define either value_type or ValueType." ); | ||
}; | ||
|
||
template< typename T > | ||
struct get_value_type< T, std::enable_if_t< internal::has_value_type< T >::value > > | ||
{ | ||
using type = typename T::value_type; | ||
}; | ||
|
||
template< typename T > | ||
struct get_value_type< T, std::enable_if_t< !internal::has_value_type< T >::value && internal::has_ValueType< T >::value > > | ||
{ | ||
using type = typename T::ValueType; | ||
}; | ||
|
||
} // namespace geos | ||
|
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.
doxygen
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.
At this point, can we drop or at least set to private the following signature?
template< typename T >
static int allReduce( T const * sendbuf, T * recvbuf, int count, MPI_Op op, MPI_Comm comm = MPI_COMM_GEOS );
All external calls seem to be able to be translated to Span<T[]>
.
yes, you are right, let me try to do this. |
We had a bug because two arrays of different size were exchanged by grabbing the buffers directly. This overload will prevent it from happening.
I had to add a small helper coz
LvArray
hasValueType
instead ofvalue_type
likestd
objects.