From c9b1679970335a770978dbc36d83b6394ecc29b8 Mon Sep 17 00:00:00 2001 From: Ruipeng Li Date: Mon, 20 Sep 2021 10:43:27 -0700 Subject: [PATCH] hypre MPI interface without MPI and with longdouble (#465) This PR will fix #439 where hypre was configured with --enable-longdouble --without-MPI. --- src/utilities/_hypre_utilities.h | 5 +- src/utilities/mpistubs.c | 99 ++++++++++++++++++++++++++++++-- src/utilities/mpistubs.h | 5 +- 3 files changed, 100 insertions(+), 9 deletions(-) diff --git a/src/utilities/_hypre_utilities.h b/src/utilities/_hypre_utilities.h index 07ccf9a72..0c65a1770 100644 --- a/src/utilities/_hypre_utilities.h +++ b/src/utilities/_hypre_utilities.h @@ -194,13 +194,13 @@ extern "C" { #define MPI_COMM_SELF hypre_MPI_COMM_SELF #define MPI_COMM_TYPE_SHARED hypre_MPI_COMM_TYPE_SHARED -#define MPI_BOTTOM hypre_MPI_BOTTOM +#define MPI_BOTTOM hypre_MPI_BOTTOM #define MPI_FLOAT hypre_MPI_FLOAT #define MPI_DOUBLE hypre_MPI_DOUBLE #define MPI_LONG_DOUBLE hypre_MPI_LONG_DOUBLE #define MPI_INT hypre_MPI_INT -#define MPI_LONG_LONG_INT hypre_MPI_INT +#define MPI_LONG_LONG_INT hypre_MPI_LONG_LONG_INT #define MPI_CHAR hypre_MPI_CHAR #define MPI_LONG hypre_MPI_LONG #define MPI_BYTE hypre_MPI_BYTE @@ -317,6 +317,7 @@ typedef HYPRE_Int hypre_MPI_Info; #define hypre_MPI_BYTE 6 #define hypre_MPI_REAL 7 #define hypre_MPI_COMPLEX 8 +#define hypre_MPI_LONG_LONG_INT 9 #define hypre_MPI_SUM 0 #define hypre_MPI_MIN 1 diff --git a/src/utilities/mpistubs.c b/src/utilities/mpistubs.c index 7e5db5d7a..3604efcbb 100644 --- a/src/utilities/mpistubs.c +++ b/src/utilities/mpistubs.c @@ -73,6 +73,7 @@ hypre_MPI_Comm_create( hypre_MPI_Comm comm, hypre_MPI_Group group, hypre_MPI_Comm *newcomm ) { + *newcomm = hypre_MPI_COMM_NULL; return(0); } @@ -80,6 +81,7 @@ HYPRE_Int hypre_MPI_Comm_dup( hypre_MPI_Comm comm, hypre_MPI_Comm *newcomm ) { + *newcomm = comm; return(0); } @@ -182,7 +184,29 @@ hypre_MPI_Allgather( void *sendbuf, HYPRE_Int *csendbuf = (HYPRE_Int *)sendbuf; for (i = 0; i < sendcount; i++) { - crecvbuf[i] = csendbuf[i]; + crecvbuf[i] = csendbuf[i]; + } + } + break; + + case hypre_MPI_LONG_LONG_INT: + { + HYPRE_BigInt *crecvbuf = (HYPRE_BigInt *)recvbuf; + HYPRE_BigInt *csendbuf = (HYPRE_BigInt *)sendbuf; + for (i = 0; i < sendcount; i++) + { + crecvbuf[i] = csendbuf[i]; + } + } + break; + + case hypre_MPI_FLOAT: + { + float *crecvbuf = (float *)recvbuf; + float *csendbuf = (float *)sendbuf; + for (i = 0; i < sendcount; i++) + { + crecvbuf[i] = csendbuf[i]; } } break; @@ -193,7 +217,18 @@ hypre_MPI_Allgather( void *sendbuf, double *csendbuf = (double *)sendbuf; for (i = 0; i < sendcount; i++) { - crecvbuf[i] = csendbuf[i]; + crecvbuf[i] = csendbuf[i]; + } + } + break; + + case hypre_MPI_LONG_DOUBLE: + { + long double *crecvbuf = (long double *)recvbuf; + long double *csendbuf = (long double *)sendbuf; + for (i = 0; i < sendcount; i++) + { + crecvbuf[i] = csendbuf[i]; } } break; @@ -204,7 +239,18 @@ hypre_MPI_Allgather( void *sendbuf, char *csendbuf = (char *)sendbuf; for (i = 0; i < sendcount; i++) { - crecvbuf[i] = csendbuf[i]; + crecvbuf[i] = csendbuf[i]; + } + } + break; + + case hypre_MPI_LONG: + { + hypre_longint *crecvbuf = (hypre_longint *)recvbuf; + hypre_longint *csendbuf = (hypre_longint *)sendbuf; + for (i = 0; i < sendcount; i++) + { + crecvbuf[i] = csendbuf[i]; } } break; @@ -221,7 +267,7 @@ hypre_MPI_Allgather( void *sendbuf, HYPRE_Real *csendbuf = (HYPRE_Real *)sendbuf; for (i = 0; i < sendcount; i++) { - crecvbuf[i] = csendbuf[i]; + crecvbuf[i] = csendbuf[i]; } } break; @@ -232,7 +278,7 @@ hypre_MPI_Allgather( void *sendbuf, HYPRE_Complex *csendbuf = (HYPRE_Complex *)sendbuf; for (i = 0; i < sendcount; i++) { - crecvbuf[i] = csendbuf[i]; + crecvbuf[i] = csendbuf[i]; } } break; @@ -495,7 +541,28 @@ hypre_MPI_Allreduce( void *sendbuf, { crecvbuf[i] = csendbuf[i]; } + } + break; + case hypre_MPI_LONG_LONG_INT: + { + HYPRE_BigInt *crecvbuf = (HYPRE_BigInt *)recvbuf; + HYPRE_BigInt *csendbuf = (HYPRE_BigInt *)sendbuf; + for (i = 0; i < count; i++) + { + crecvbuf[i] = csendbuf[i]; + } + } + break; + + case hypre_MPI_FLOAT: + { + float *crecvbuf = (float *)recvbuf; + float *csendbuf = (float *)sendbuf; + for (i = 0; i < count; i++) + { + crecvbuf[i] = csendbuf[i]; + } } break; @@ -510,6 +577,17 @@ hypre_MPI_Allreduce( void *sendbuf, } break; + case hypre_MPI_LONG_DOUBLE: + { + long double *crecvbuf = (long double *)recvbuf; + long double *csendbuf = (long double *)sendbuf; + for (i = 0; i < count; i++) + { + crecvbuf[i] = csendbuf[i]; + } + } + break; + case hypre_MPI_CHAR: { char *crecvbuf = (char *)recvbuf; @@ -521,6 +599,17 @@ hypre_MPI_Allreduce( void *sendbuf, } break; + case hypre_MPI_LONG: + { + hypre_longint *crecvbuf = (hypre_longint *)recvbuf; + hypre_longint *csendbuf = (hypre_longint *)sendbuf; + for (i = 0; i < count; i++) + { + crecvbuf[i] = csendbuf[i]; + } + } + break; + case hypre_MPI_BYTE: { hypre_Memcpy(recvbuf, sendbuf, count, HYPRE_MEMORY_HOST, HYPRE_MEMORY_HOST); diff --git a/src/utilities/mpistubs.h b/src/utilities/mpistubs.h index cedbe2ba5..eac5a87a3 100644 --- a/src/utilities/mpistubs.h +++ b/src/utilities/mpistubs.h @@ -45,13 +45,13 @@ extern "C" { #define MPI_COMM_SELF hypre_MPI_COMM_SELF #define MPI_COMM_TYPE_SHARED hypre_MPI_COMM_TYPE_SHARED -#define MPI_BOTTOM hypre_MPI_BOTTOM +#define MPI_BOTTOM hypre_MPI_BOTTOM #define MPI_FLOAT hypre_MPI_FLOAT #define MPI_DOUBLE hypre_MPI_DOUBLE #define MPI_LONG_DOUBLE hypre_MPI_LONG_DOUBLE #define MPI_INT hypre_MPI_INT -#define MPI_LONG_LONG_INT hypre_MPI_INT +#define MPI_LONG_LONG_INT hypre_MPI_LONG_LONG_INT #define MPI_CHAR hypre_MPI_CHAR #define MPI_LONG hypre_MPI_LONG #define MPI_BYTE hypre_MPI_BYTE @@ -168,6 +168,7 @@ typedef HYPRE_Int hypre_MPI_Info; #define hypre_MPI_BYTE 6 #define hypre_MPI_REAL 7 #define hypre_MPI_COMPLEX 8 +#define hypre_MPI_LONG_LONG_INT 9 #define hypre_MPI_SUM 0 #define hypre_MPI_MIN 1