20 #ifndef GEOS_COMMON_MPIWRAPPER_HPP_
21 #define GEOS_COMMON_MPIWRAPPER_HPP_
27 #if defined(GEOS_USE_MPI)
29 #define MPI_PARAM( x ) x
31 #define MPI_PARAM( x )
34 #define MPI_COMM_NULL ((MPI_Comm)0x04000000)
35 #define MPI_COMM_WORLD ((MPI_Comm)0x44000000)
36 #define MPI_COMM_SELF ((MPI_Comm)0x40000000)
39 typedef int MPI_Datatype;
40 #define MPI_CHAR ((MPI_Datatype)0x4c000101)
41 #define MPI_SIGNED_CHAR ((MPI_Datatype)0x4c000118)
42 #define MPI_UNSIGNED_CHAR ((MPI_Datatype)0x4c000102)
43 #define MPI_BYTE ((MPI_Datatype)0x4c00010d)
44 #define MPI_WCHAR ((MPI_Datatype)0x4c00040e)
45 #define MPI_SHORT ((MPI_Datatype)0x4c000203)
46 #define MPI_UNSIGNED_SHORT ((MPI_Datatype)0x4c000204)
47 #define MPI_INT ((MPI_Datatype)0x4c000405)
48 #define MPI_UNSIGNED ((MPI_Datatype)0x4c000406)
49 #define MPI_LONG ((MPI_Datatype)0x4c000807)
50 #define MPI_UNSIGNED_LONG ((MPI_Datatype)0x4c000808)
51 #define MPI_FLOAT ((MPI_Datatype)0x4c00040a)
52 #define MPI_DOUBLE ((MPI_Datatype)0x4c00080b)
53 #define MPI_LONG_DOUBLE ((MPI_Datatype)0x4c00100c)
54 #define MPI_LONG_LONG_INT ((MPI_Datatype)0x4c000809)
55 #define MPI_UNSIGNED_LONG_LONG ((MPI_Datatype)0x4c000819)
56 #define MPI_LONG_LONG MPI_LONG_LONG_INT
60 #define MPI_MAX (MPI_Op)(0x58000001)
61 #define MPI_MIN (MPI_Op)(0x58000002)
62 #define MPI_SUM (MPI_Op)(0x58000003)
63 #define MPI_PROD (MPI_Op)(0x58000004)
64 #define MPI_LAND (MPI_Op)(0x58000005)
65 #define MPI_BAND (MPI_Op)(0x58000006)
66 #define MPI_LOR (MPI_Op)(0x58000007)
67 #define MPI_BOR (MPI_Op)(0x58000008)
68 #define MPI_LXOR (MPI_Op)(0x58000009)
69 #define MPI_BXOR (MPI_Op)(0x5800000a)
70 #define MPI_MINLOC (MPI_Op)(0x5800000b)
71 #define MPI_MAXLOC (MPI_Op)(0x5800000c)
72 #define MPI_REPLACE (MPI_Op)(0x5800000d)
73 #define MPI_NO_OP (MPI_Op)(0x5800000e)
76 #define MPI_UNDEFINED (-32766)
77 #define MPI_STATUS_IGNORE (MPI_Status *)1
78 #define MPI_STATUSES_IGNORE (MPI_Status *)1
79 #define MPI_REQUEST_NULL ((MPI_Request)0x2c000000)
80 typedef int MPI_Request;
83 #define MPI_INFO_NULL (MPI_Info)(0x60000000)
93 #define MPI_CHECK_ERROR( error ) ((void) error)
95 #define MPI_CHECK_ERROR( error ) GEOS_ERROR_IF_NE( error, MPI_SUCCESS );
152 static void barrier( MPI_Comm
const & MPI_PARAM( comm )=
MPI_COMM_GEOS );
154 static int cartCoords( MPI_Comm comm,
int rank,
int maxdims,
int coords[] );
156 static int cartCreate( MPI_Comm comm_old,
int ndims,
const int dims[],
const int periods[],
157 int reorder, MPI_Comm * comm_cart );
159 static int cartRank( MPI_Comm comm,
const int coords[] );
161 static void commFree( MPI_Comm & comm );
163 static int commRank( MPI_Comm
const & MPI_PARAM( comm )=
MPI_COMM_GEOS );
165 static int commSize( MPI_Comm
const & MPI_PARAM( comm )=
MPI_COMM_GEOS );
167 static bool commCompare( MPI_Comm
const & comm1, MPI_Comm
const & comm2 );
169 static bool initialized();
171 static int init(
int * argc,
char * * * argv );
173 static void finalize();
175 static MPI_Comm commDup( MPI_Comm
const comm );
177 static MPI_Comm commSplit( MPI_Comm
const comm,
int color,
int key );
179 static int test( MPI_Request * request,
int * flag,
MPI_Status * status );
181 static int testAny(
int count, MPI_Request array_of_requests[],
int * idx,
int * flags,
MPI_Status array_of_statuses[] );
183 static int testSome(
int count, MPI_Request array_of_requests[],
int * outcount,
int array_of_indices[],
MPI_Status array_of_statuses[] );
185 static int testAll(
int count, MPI_Request array_of_requests[],
int * flags,
MPI_Status array_of_statuses[] );
207 static int checkAny(
int count, MPI_Request array_of_requests[],
int * idx,
int * flag,
MPI_Status array_of_statuses[] );
218 static int checkAll(
int count, MPI_Request array_of_requests[],
int * flag,
MPI_Status array_of_statuses[] );
220 static int wait( MPI_Request * request,
MPI_Status * status );
222 static int waitAny(
int count, MPI_Request array_of_requests[],
int * indx,
MPI_Status array_of_statuses[] );
224 static int waitSome(
int count, MPI_Request array_of_requests[],
int * outcount,
int array_of_indices[],
MPI_Status array_of_statuses[] );
226 static int waitAll(
int count, MPI_Request array_of_requests[],
MPI_Status array_of_statuses[] );
228 static double wtime(
void );
241 MPI_Request array_of_requests[],
243 std::function< MPI_Request (
int ) > func );
255 MPI_Request array_of_requests[],
257 std::function< MPI_Request (
int ) > func );
272 std::vector< std::tuple< MPI_Request *,
MPI_Status *, std::function< MPI_Request (
int ) > > >
const & phases );
288 std::vector< std::tuple< MPI_Request *,
MPI_Status *, std::function< MPI_Request (
int ) > > >
const & phases );
291 #if !defined(GEOS_USE_MPI)
292 static std::map< int, std::pair< int, void * > > & getTagToPointersMap()
294 static std::map< int, std::pair< int, void * > > tagToPointers;
295 return tagToPointers;
316 template<
typename T_SEND,
typename T_RECV >
335 template<
typename T_SEND,
typename T_RECV >
349 template<
typename T >
352 template<
typename T >
365 template<
typename T >
376 template<
typename T >
387 template<
typename SRC_CONTAINER_TYPE,
typename DST_CONTAINER_TYPE >
399 template<
typename SRC_CONTAINER_TYPE,
typename DST_CONTAINER_TYPE >
400 static void allReduce( SRC_CONTAINER_TYPE
const & src, DST_CONTAINER_TYPE & dst,
int const count,
Reduction const op, MPI_Comm
const comm );
412 template<
typename T >
413 static int reduce( T
const * sendbuf, T * recvbuf,
int count, MPI_Op op,
int root, MPI_Comm comm =
MPI_COMM_GEOS );
423 template<
typename T >
434 template<
typename T >
438 template<
typename T >
439 static int scan( T
const * sendbuf, T * recvbuf,
int count, MPI_Op op, MPI_Comm comm =
MPI_COMM_GEOS );
441 template<
typename T >
442 static int exscan( T
const * sendbuf, T * recvbuf,
int count, MPI_Op op, MPI_Comm comm =
MPI_COMM_GEOS );
452 template<
typename T >
462 template<
typename T >
477 template<
typename TS,
typename TR >
478 static int gather( TS
const *
const sendbuf,
496 template<
typename T,
typename DST_CONTAINER,
497 typename = std::enable_if_t<
498 std::is_trivially_copyable_v< T > &&
499 std::is_same_v< decltype(std::declval< DST_CONTAINER >().size()),
std::size_t > &&
500 std::is_same_v< decltype(std::declval< DST_CONTAINER >().data()), T * > > >
502 DST_CONTAINER & destValuesBuffer,
520 template<
typename TS,
typename TR >
524 const int * recvcounts,
536 template<
typename T >
538 int MPI_PARAM( source ),
540 MPI_Comm MPI_PARAM( comm ),
543 template<
typename T >
545 int MPI_PARAM( dest ),
547 MPI_Comm MPI_PARAM( comm ),
548 MPI_Request * MPI_PARAM( request ) );
560 template<
typename T >
566 MPI_Request * request );
578 template<
typename T >
579 static int iSend( T
const *
const buf,
584 MPI_Request * request );
593 template<
typename U,
typename T >
601 template<
typename T >
610 template<
typename T >
618 template<
typename T >
627 template<
typename T >
635 template<
typename T >
644 template<
typename T >
667 template<
typename T >
668 static int allReduce( T
const * sendbuf, T * recvbuf,
int count, MPI_Op op, MPI_Comm comm =
MPI_COMM_GEOS );
674 template<
typename T,
typename ENABLE =
void >
675 struct MpiTypeImpl {};
677 #define ADD_MPI_TYPE_MAP( T, MPI_T ) \
678 template<> struct MpiTypeImpl< T > { static MPI_Datatype get() { return MPI_T; } }
680 ADD_MPI_TYPE_MAP(
float, MPI_FLOAT );
681 ADD_MPI_TYPE_MAP(
double, MPI_DOUBLE );
683 ADD_MPI_TYPE_MAP(
char, MPI_CHAR );
684 ADD_MPI_TYPE_MAP(
signed char, MPI_SIGNED_CHAR );
685 ADD_MPI_TYPE_MAP(
unsigned char, MPI_UNSIGNED_CHAR );
687 ADD_MPI_TYPE_MAP(
int, MPI_INT );
688 ADD_MPI_TYPE_MAP(
long int, MPI_LONG );
689 ADD_MPI_TYPE_MAP(
long long int, MPI_LONG_LONG );
691 ADD_MPI_TYPE_MAP(
unsigned int, MPI_UNSIGNED );
692 ADD_MPI_TYPE_MAP(
unsigned long int, MPI_UNSIGNED_LONG );
693 ADD_MPI_TYPE_MAP(
unsigned long long int, MPI_UNSIGNED_LONG_LONG );
695 #undef ADD_MPI_TYPE_MAP
697 template<
typename T >
698 struct MpiTypeImpl< T, std::enable_if_t< std::is_enum< T >::value > >
700 static MPI_Datatype get() {
return MpiTypeImpl< std::underlying_type_t< T > >::get(); }
703 template<
typename T >
704 MPI_Datatype getMpiType()
706 return MpiTypeImpl< T >::get();
740 GEOS_ERROR(
"Unsupported reduction operation" );
745 template<
typename T_SEND,
typename T_RECV >
748 T_RECV *
const recvbuf,
750 MPI_Comm MPI_PARAM( comm ) )
753 return MPI_Allgather( sendbuf, sendcount, internal::getMpiType< T_SEND >(),
754 recvbuf, recvcount, internal::getMpiType< T_RECV >(),
757 static_assert( std::is_same< T_SEND, T_RECV >::value,
758 "MpiWrapper::allgather() for serial run requires send and receive buffers are of the same type" );
760 std::copy( sendbuf, sendbuf + sendcount, recvbuf )
765 template<
typename T_SEND,
typename T_RECV >
768 T_RECV *
const recvbuf,
771 MPI_Comm MPI_PARAM( comm ) )
774 return MPI_Allgatherv( sendbuf, sendcount, internal::getMpiType< T_SEND >(),
775 recvbuf, recvcounts, displacements, internal::getMpiType< T_RECV >(),
778 static_assert( std::is_same< T_SEND, T_RECV >::value,
779 "MpiWrapper::allgatherv() for serial run requires send and receive buffers are of the same type" );
781 std::copy( sendbuf, sendbuf + sendcount, recvbuf )
787 template<
typename T >
791 int const mpiSize = commSize( comm );
792 allValues.resize( mpiSize );
794 MPI_Datatype
const MPI_TYPE = internal::getMpiType< T >();
796 MPI_Allgather( &myValue, 1, MPI_TYPE, allValues.data(), 1, MPI_TYPE, comm );
799 allValues.resize( 1 );
800 allValues[0] = myValue;
804 template<
typename T >
806 array1d< T > & allValues,
807 MPI_Comm MPI_PARAM( comm ) )
809 int const sendSize = LvArray::integerConversion< int >( sendValues.size() );
811 int const mpiSize = commSize( comm );
812 allValues.resize( mpiSize * sendSize );
813 return MPI_Allgather( sendValues.data(),
815 internal::getMpiType< T >(),
818 internal::getMpiType< T >(),
822 allValues.resize( sendSize );
825 allValues[a] = sendValues[a];
831 template<
typename T >
835 MPI_Op
const MPI_PARAM( op ),
836 MPI_Comm
const MPI_PARAM( comm ) )
839 MPI_Datatype
const mpiType = internal::getMpiType< T >();
840 return MPI_Allreduce( sendbuf == recvbuf ? MPI_IN_PLACE : sendbuf, recvbuf, count, mpiType, op, comm );
842 if( sendbuf != recvbuf )
844 memcpy( recvbuf, sendbuf, count *
sizeof( T ) );
850 template<
typename T >
854 MPI_Op
const MPI_PARAM( op ),
856 MPI_Comm
const MPI_PARAM( comm ) )
859 MPI_Datatype
const mpiType = internal::getMpiType< T >();
860 return MPI_Reduce( sendbuf == recvbuf ? MPI_IN_PLACE : sendbuf, recvbuf, count, mpiType, op, root, comm );
862 if( sendbuf != recvbuf )
864 memcpy( recvbuf, sendbuf, count *
sizeof( T ) );
870 template<
typename T >
871 int MpiWrapper::scan( T
const *
const sendbuf,
874 MPI_Op MPI_PARAM( op ),
875 MPI_Comm MPI_PARAM( comm ) )
878 return MPI_Scan( sendbuf, recvbuf, count, internal::getMpiType< T >(), op, comm );
880 memcpy( recvbuf, sendbuf, count*
sizeof(T) );
885 template<
typename T >
886 int MpiWrapper::exscan( T
const *
const MPI_PARAM( sendbuf ),
889 MPI_Op MPI_PARAM( op ),
890 MPI_Comm MPI_PARAM( comm ) )
893 return MPI_Exscan( sendbuf, recvbuf, count, internal::getMpiType< T >(), op, comm );
895 memset( recvbuf, 0, count*
sizeof(T) );
900 template<
typename T >
902 int MPI_PARAM( count ),
903 int MPI_PARAM( root ),
904 MPI_Comm MPI_PARAM( comm ) )
907 return MPI_Bcast( buffer, count, internal::getMpiType< T >(), root, comm );
914 template<
typename T >
915 void MpiWrapper::broadcast( T & MPI_PARAM( value ),
int MPI_PARAM( srcRank ), MPI_Comm MPI_PARAM( comm ) )
918 MPI_Bcast( &value, 1, internal::getMpiType< T >(), srcRank, comm );
924 void MpiWrapper::broadcast< string >(
string & MPI_PARAM( value ),
925 int MPI_PARAM( srcRank ),
926 MPI_Comm MPI_PARAM( comm ) )
929 int size = LvArray::integerConversion< int >( value.size() );
931 value.resize( size );
932 MPI_Bcast(
const_cast< char *
>( value.data() ), size, internal::getMpiType< char >(), srcRank, comm );
936 template<
typename TS,
typename TR >
941 int MPI_PARAM( root ),
942 MPI_Comm MPI_PARAM( comm ) )
945 return MPI_Gather( sendbuf, sendcount, internal::getMpiType< TS >(),
946 recvbuf, recvcount, internal::getMpiType< TR >(),
949 static_assert( std::is_same< TS, TR >::value,
950 "MpiWrapper::gather() for serial run requires send and receive buffers are of the same type" );
951 std::size_t const sendBufferSize = sendcount *
sizeof(TS);
952 std::size_t const recvBufferSize = recvcount *
sizeof(TR);
953 GEOS_ERROR_IF_NE_MSG( sendBufferSize, recvBufferSize,
"size of send buffer and receive buffer are not equal" );
954 memcpy( recvbuf, sendbuf, sendBufferSize );
959 template<
typename T,
typename DST_CONTAINER,
typename >
961 DST_CONTAINER & destValuesBuffer,
963 MPI_Comm MPI_PARAM( comm ) )
965 if( commRank() == 0 )
967 "Receive buffer is not large enough to contain the values to receive." );
969 return MPI_Gather( &value,
sizeof( T ), internal::getMpiType< uint8_t >(),
970 destValuesBuffer.data(),
sizeof( T ), internal::getMpiType< uint8_t >(),
973 memcpy( destValuesBuffer.data(), &value, sendBufferSize );
978 template<
typename TS,
typename TR >
982 const int * recvcounts,
983 const int * MPI_PARAM( displs ),
984 int MPI_PARAM( root ),
985 MPI_Comm MPI_PARAM( comm ) )
988 return MPI_Gatherv( sendbuf, sendcount, internal::getMpiType< TS >(),
989 recvbuf, recvcounts, displs, internal::getMpiType< TR >(),
992 static_assert( std::is_same< TS, TR >::value,
993 "MpiWrapper::gather() for serial run requires send and receive buffers are of the same type" );
994 std::size_t const sendBufferSize = sendcount *
sizeof(TS);
995 std::size_t const recvBufferSize = recvcounts[0] *
sizeof(TR);
996 GEOS_ERROR_IF_NE_MSG( sendBufferSize, recvBufferSize,
"size of send buffer and receive buffer are not equal" );
997 memcpy( recvbuf, sendbuf, sendBufferSize );
1002 template<
typename T >
1005 int MPI_PARAM( source ),
1007 MPI_Comm MPI_PARAM( comm ),
1008 MPI_Request * MPI_PARAM( request ) )
1012 "Attempting to use an MPI_Request that is still in use." );
1013 return MPI_Irecv( buf, count, internal::getMpiType< T >(), source, tag, comm, request );
1015 std::map< int, std::pair< int, void * > > & pointerMap = getTagToPointersMap();
1016 std::map< int, std::pair< int, void * > >::iterator iPointer = pointerMap.find( tag );
1018 if( iPointer==pointerMap.end() )
1020 pointerMap.insert( {tag, {1, buf} } );
1025 "Tag does is assigned, but pointer was not set by iSend." );
1026 memcpy( buf, iPointer->second.second, count*
sizeof(T) );
1027 pointerMap.erase( iPointer );
1033 template<
typename T >
1034 int MpiWrapper::recv( array1d< T > & buf,
1035 int MPI_PARAM( source ),
1037 MPI_Comm MPI_PARAM( comm ),
1043 MPI_Probe( source, tag, comm, &status );
1044 MPI_Get_count( &status, MPI_CHAR, &count );
1047 buf.resize( count /
sizeof( T ) );
1049 return MPI_Recv(
reinterpret_cast< char *
>( buf.data() ),
1062 template<
typename T >
1063 int MpiWrapper::iSend( arrayView1d< T >
const & buf,
1064 int MPI_PARAM( dest ),
1066 MPI_Comm MPI_PARAM( comm ),
1067 MPI_Request * MPI_PARAM( request ) )
1071 "Attempting to use an MPI_Request that is still in use." );
1072 return MPI_Isend(
reinterpret_cast< void const *
>( buf.data() ),
1073 buf.size() *
sizeof( T ),
1085 template<
typename T >
1086 int MpiWrapper::iSend( T
const *
const buf,
1088 int MPI_PARAM( dest ),
1090 MPI_Comm MPI_PARAM( comm ),
1091 MPI_Request * MPI_PARAM( request ) )
1095 "Attempting to use an MPI_Request that is still in use." );
1096 return MPI_Isend( buf, count, internal::getMpiType< T >(), dest, tag, comm, request );
1098 std::map< int, std::pair< int, void * > > & pointerMap = getTagToPointersMap();
1099 std::map< int, std::pair< int, void * > >::iterator iPointer = pointerMap.find( tag );
1101 if( iPointer==pointerMap.end() )
1103 pointerMap.insert( {tag, {0,
const_cast< T *
>(buf)}
1109 "Tag does is assigned, but pointer was not set by iRecv." );
1110 memcpy( iPointer->second.second, buf, count*
sizeof(T) );
1111 pointerMap.erase( iPointer );
1117 template<
typename U,
typename T >
1123 U
const convertedValue = value;
1124 int const error = MPI_Exscan( &convertedValue, &localResult, 1, internal::getMpiType< U >(), MPI_SUM, comm );
1125 MPI_CHECK_ERROR( error );
1127 if( commRank() == 0 )
1136 template<
typename T >
1144 template<
typename T >
1151 template<
typename SRC_CONTAINER_TYPE,
typename DST_CONTAINER_TYPE >
1155 "The type in the source container must be trivially copyable." );
1157 "The type in the destination container must be trivially copyable." );
1160 "Source and destination containers must have the same value type." );
1166 template<
typename SRC_CONTAINER_TYPE,
typename DST_CONTAINER_TYPE >
1170 "The type in the source container must be trivially copyable." );
1172 "The type in the destination container must be trivially copyable." );
1175 "Source and destination containers must have the same value type." );
1177 allReduce( src.data(), dst.data(), LvArray::integerConversion< int >( src.size() ),
getMpiOp( op ), comm );
1180 template<
typename T >
1186 template<
typename T >
1192 template<
typename T >
1198 template<
typename T >
1204 template<
typename T >
1210 template<
typename T >
1217 template<
typename T >
1225 template<
typename T >
1233 template<
typename T >
1237 static_assert( std::is_trivially_copyable< T >::value,
"maxValLoc requires a trivially copyable type" );
1240 static_assert( (
sizeof(T::value)+
sizeof(T::location)) ==
sizeof(T) );
1243 static_assert( std::is_scalar_v< decltype(T::value) > || std::is_scalar_v< decltype(T::location) >,
"members of struct should be scalar" );
1244 static_assert( !std::is_pointer_v< decltype(T::value) > && !std::is_pointer_v< decltype(T::location) >,
"members of struct should not be pointers" );
1247 int const numProcs = commSize( comm );
1248 std::vector< T > recvValLoc( numProcs );
1250 MPI_Allgather( &localValueLocation,
sizeof(T), MPI_BYTE, recvValLoc.data(),
sizeof(T), MPI_BYTE, comm );
1252 T
maxValLoc= *std::max_element( recvValLoc.begin(),
1254 [](
auto & lhs,
auto & rhs ) ->
bool {return lhs.value < rhs.value; } );
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
#define GEOS_ERROR_IF(EXP, msg)
Conditionally raise a hard error and terminate the program.
#define GEOS_ASSERT_GE(lhs, rhs)
Assert that one value compares greater than or equal to the other in debug builds.
#define GEOS_ERROR_IF_LT_MSG(lhs, rhs, msg)
Raise a hard error if one value compares less than the other.
#define GEOS_ERROR_IF_NE_MSG(lhs, rhs, msg)
Raise a hard error if two values are not equal.
#define GEOS_ASSERT_EQ(lhs, rhs)
Assert that two values compare equal in debug builds.
Lightweight non-owning wrapper over a contiguous range of elements.
constexpr T * data() const noexcept
constexpr size_type size() const noexcept
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
int MPI_COMM_GEOS
Global MPI communicator used by GEOSX.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
std::size_t size_t
Unsigned size type.
Array< T, 1 > array1d
Alias for 1D array.
static MPI_Op getMpiOp(Reduction const op)
Returns an MPI_Op associated with our strongly typed Reduction enum.
static int activeWaitSomeCompletePhase(const int participants, std::vector< std::tuple< MPI_Request *, MPI_Status *, std::function< MPI_Request(int) > > > const &phases)
static int checkAll(int count, MPI_Request array_of_requests[], int *flag, MPI_Status array_of_statuses[])
static int allgatherv(T_SEND const *sendbuf, int sendcount, T_RECV *recvbuf, int *recvcounts, int *displacements, MPI_Comm comm=MPI_COMM_GEOS)
Strongly typed wrapper around MPI_Allgatherv.
static int activeWaitOrderedCompletePhase(const int participants, std::vector< std::tuple< MPI_Request *, MPI_Status *, std::function< MPI_Request(int) > > > const &phases)
static int check(MPI_Request *request, int *flag, MPI_Status *status)
static int activeWaitAny(const int count, MPI_Request array_of_requests[], MPI_Status array_of_statuses[], std::function< MPI_Request(int) > func)
static int iSend(T const *const buf, int count, int dest, int tag, MPI_Comm comm, MPI_Request *request)
Strongly typed wrapper around MPI_Isend()
static int bcast(T *buffer, int count, int root, MPI_Comm comm=MPI_COMM_GEOS)
Strongly typed wrapper around MPI_Bcast.
static void allGather(T const myValue, array1d< T > &allValues, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for MPI_Allgather.
static T max(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_MAX operation.
static int allgather(T_SEND const *sendbuf, int sendcount, T_RECV *recvbuf, int recvcount, MPI_Comm comm=MPI_COMM_GEOS)
Strongly typed wrapper around MPI_Allgather.
static int activeWaitSome(const int count, MPI_Request array_of_requests[], MPI_Status array_of_statuses[], std::function< MPI_Request(int) > func)
static U prefixSum(T const value, MPI_Comm comm=MPI_COMM_GEOS)
Compute exclusive prefix sum and full sum.
static int gather(T const &value, DST_CONTAINER &destValuesBuffer, int root, MPI_Comm comm=MPI_COMM_GEOS)
Strongly typed wrapper around MPI_Gather().
static T allReduce(T const &value, Reduction const op, MPI_Comm comm=MPI_COMM_GEOS)
Convenience wrapper for the MPI_Allreduce function.
static T maxValLoc(T localValueLocation, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for MPI_Gather using a MPI_MAX operation on struct of value and location.
static int checkAny(int count, MPI_Request array_of_requests[], int *idx, int *flag, MPI_Status array_of_statuses[])
static int gather(TS const *const sendbuf, int sendcount, TR *const recvbuf, int recvcount, int root, MPI_Comm comm=MPI_COMM_GEOS)
Strongly typed wrapper around MPI_Gather().
static int iRecv(T *const buf, int count, int source, int tag, MPI_Comm comm, MPI_Request *request)
Strongly typed wrapper around MPI_Irecv()
static T sum(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_SUM operation.
static T min(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_MIN operation.
static int nodeCommSize()
Compute the number of ranks allocated on the same node.
static int gatherv(TS const *const sendbuf, int sendcount, TR *const recvbuf, const int *recvcounts, const int *displs, int root, MPI_Comm comm=MPI_COMM_GEOS)
Strongly typed wrapper around MPI_Gatherv.
static void broadcast(T &value, int srcRank=0, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for MPI_Broadcast.
static int reduce(T const *sendbuf, T *recvbuf, int count, MPI_Op op, int root, MPI_Comm comm=MPI_COMM_GEOS)
Strongly typed wrapper around MPI_Reduce.
Trait to retrieve the value_type or ValueType of a type T.