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

feat: MpiWrapper::allReduce overload for arrays. #3446

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

Conversation

CusiniM
Copy link
Collaborator

@CusiniM CusiniM commented Nov 15, 2024

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 has ValueType instead of value_type like std objects.

@CusiniM CusiniM self-assigned this Nov 15, 2024
@CusiniM CusiniM added the flag: no rebaseline Does not require rebaseline label Nov 15, 2024
@CusiniM
Copy link
Collaborator Author

CusiniM commented Dec 5, 2024

@rrsettgast , @corbett5 , @wrtobin this is ready for review.

Comment on lines +26 to +65
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

Copy link
Member

Choose a reason for hiding this comment

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

doxygen

Copy link
Contributor

@MelReyCG MelReyCG left a 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[]>.

@CusiniM
Copy link
Collaborator Author

CusiniM commented Dec 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: no rebaseline Does not require rebaseline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants