Build process: sizeof (MPI_Offset)
Rob Ross
rross at mcs.anl.gov
Mon Nov 20 19:17:59 CST 2006
Hi Christopher,
Looks like you have a better approach for this than we do. We'll mull
this over a bit, and unless we can find some catch, we'll probably switch.
Thanks!
Rob
Christopher Subich wrote:
> As is documented in the configure script, checking the size of
> MPI_Offset is particularly troublesome. There are, however, a couple
> bugs related to this:
>
> In the actual check (configure.in), the comment says to compile with
> $MPICC and link with $CC. In the code, both compilation and linking are
> done with $MPICC, which can cause an error at execution.
>
> If the execution happens to fail, then $ac_cv_sizeof_MPI_Offset is left
> undefined. When checking the Fortran datatypes, the check for "Integer
> * sizeof_MPI_Offset" will fail -- it will be a check for "Integer *
> [blank]".
>
> There is a way to check sizeof_MPI_Offset at compile time; this example
> was adapted from the autoconf manual, which describes the same pattern
> for checking sizeof(int):
>
> AC_DEFUN(UD_MPI_OFFSET,[
> if test ! $ac_cv_sizeof_MPI_Offset; then
> AC_MSG_CHECKING(if MPI_Offset is size $1)
> AC_COMPILE_IFELSE([
> #include "mpi.h"
> #include <stdio.h>
> int main( int argc, char **argv )
> {
> static int test_array [[sizeof (MPI_Offset) == $1 ? 1 : -1]];
> return 0;
> }],AC_MSG_RESULT(yes)
> ac_cv_sizeof_MPI_Offset=$1
> ,AC_MSG_RESULT(no))
> fi
> ])
>
> UD_MPI_OFFSET(8)
> UD_MPI_OFFSET(4)
> UD_MPI_OFFSET(16)
>
>
> This code will check, using compile-only tests, whether
> sizeof(MPI_Offset) is 8, 4, or 16. (8 and 4 are the only values I've
> personally seen it take). It should be placed inside the "compilation
> with $MPICC" section, in configure.in (the DEFUN could be moved to
> acloal.m4).
>
> If the compile checks work, it will set ac_cv_sizeof_MPI_Offset to the
> proper size, causing the later runtime check to be skipped, with a
> (cached) value. If the compilations all fail, then the runtime check
> will be executed as normal.
>
> Additionally, at least one MPI implementation (HP's) requires a seperate
> library to be linked in for MPI-IO. At the end of the configure script
> (after all the other TRY_COMPILEs), I resolve this by adding:
>
> SAVECC=$CC
> CC=$MPICC
> AC_SEARCH_LIBS(MPI_File_sync,mpio hpmpio,,
> AC_MSG_ERROR(Cannot find MPI-IO library)
> )
> CC=$SAVECC
>
> This code must go after any other compilation tests, as when successful
> it adds -l[library] to LIBS. This library will then be linked in with
> any other TRY_COMPILES, and if those are done with $CC rather than
> $MPICC the compilation might fail.
>
More information about the parallel-netcdf
mailing list