mpich
mpich copied to clipboard
MPI_Aint bigger than long long
In porting MPICH to CHERI, I need a way to define MPI_Aint to 16 bytes, because that is how big void* and intptr_t are.
MPICH only tests for integers up to long long, for reasons that make sense historically. However, intptr_t needs to be added to that list, since the only C type that is actually guaranteed to hold a pointer (=address, as of C99) is intptr_t. This also means that stdint.h needs to be included before MPI_Aint is declared.
Unfortunately, I can't figure out how to hack the build system to let me do this.
I run ./autogen.sh -yaksa-depth=0 && ./configure --with-aint-size=16 with these patches:
diff --git a/confdb/aclocal_datatype.m4 b/confdb/aclocal_datatype.m4
index a1d747b210..2c06efb985 100644
--- a/confdb/aclocal_datatype.m4
+++ b/confdb/aclocal_datatype.m4
@@ -32,7 +32,7 @@ to_dec() {
get_c_int_type() {
len=$[]1
pac_retval=
- for c_type in char short int long "long_long" ; do
+ for c_type in char short int long "long_long" intptr_t ; do
eval ctypelen=\$"ac_cv_sizeof_$c_type"
if test "$len" = "$ctypelen" -a "$ctypelen" -gt 0 ; then
if test "$c_type" = "long_long" ; then
@@ -43,7 +43,7 @@ get_c_int_type() {
return
fi
done
- pac_retval="unavailable"
+ pac_retval="unavailable_int_type"
}
# return the C type matching integer of size
diff --git a/configure.ac b/configure.ac
index e7c2318964..d878df43d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3746,6 +3746,13 @@ AC_SUBST(LPMPILIBNAME)
# with MPI_AINT defined, now we can
# Get the size for the bsendoverhead
AC_CHECK_SIZEOF(MPII_Bsend_data_t,0,[
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
#define MPI_Datatype int
typedef $MPI_AINT MPI_Aint;
@@ -3755,13 +3762,6 @@ typedef struct MPIR_Request MPIR_Request;
struct MPIR_Comm;
typedef struct MPIR_Comm MPIR_Comm;
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-
#include "${main_top_srcdir}/src/include/mpir_bsend.h"]
)
if test "$ac_cv_sizeof_MPII_Bsend_data_t" = "0" ; then
It always fails because the integer type is unavailable because get_c_int_type failed to do what I wanted.
checking size of MPII_Bsend_data_t... 0
configure: error: Unable to determine the size of MPI_BSEND_OVERHEAD
I can hack around this with MPI_AINT=intptr_t after the test.
Also, you can reproduce this on any machine. It doesn't have to be CHERI.
If you peek into stdint.h, how is intptr_t defined?
Sorry, on my Mac, I forcing MPI_Aint to be 16 bytes and using __int128 to make a simpler reproducer. The hacking is in https://github.com/jeffhammond/mpich/tree/aint_size_options.
I got cpi working on MacOS with the above hacks, after I disable this assert, which won't fire on CHERI.
/* Yaksa API uses intptr_t, while we use MPI_Aint. They should be identical,
* but lets assert to just make sure.
*/
MPIR_Assert(sizeof(MPI_Aint) == sizeof(intptr_t));