On Feb 19, 2008, at 12:52 PM, Ben Allan wrote:
Is there some subtle reason that ompi's mpi.h
leaves the following macros both
unguarded with an ifndef and un-prefixed with OMPI_ ?
Mainly because they come from standard autoconf/configure tests (e.g.,
AC_CHECK_SIZEOF), meaning that we (OMPI) aren't setting those macros
directly -- the built-in AC test is doing it. Indeed, OMPI's
configure script doesn't have [public] access to the value that it
sets -- AC_CHECK_SIZEOF's public interface sets a #define in the
output header file.
The #defines that are mpi.h are limited to the ones that we need for
that file itself. More specifically: the majority of the #define's
that are generated via OMPI's configure are not in mpi.h.
This produces considerable amounts of compiler whinage for other
codes that include mpi.h. As always, extraneous whinage makes real
errors harder to find. (And yes, those other codes also need
*their* definitions of HAVE_LONG_LONG, etc properly protected).
And of course who knows how the answer was defined for any given
unprotected appearance of these macros?
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
/* The size of a `bool', as computed by sizeof. */
#undef SIZEOF_BOOL
/* The size of a `int', as computed by sizeof. */
#undef SIZEOF_INT
Our assumption was that if some other package defined these values,
they would either likely be coming from the same standard autoconf
tests or use the same #define conventions as the autoconf tests. As
such, the values that they are #defined to would be the same (and
compilers don't whine about multiple #defines of the same macro to the
same value -- they only whine if the values are different).
I'm assuming that you're seeing cases where the defined values are
different. Isn't that a bit scary? E.g., why would OMPI be reporting
a different value for SIZEOF_BOOL and SIZEOF_INT than what is in your
app's header files?
If it's simply a matter of developer hours, I can post a patch
somewhere to address this. It appears that of these, only
sizeof_int affects more than a few source files.
There's two places that would need to be changed:
- the relevant parts of OMPI's configure script to *also* define an
OMPI_* equivalent of the macro (which will sometimes mean extracting
non-public information from the Autoconf tests -- usually a risky
proposition because Autoconf can change their internals at any time).
The only safe way I can think of would be to AC_TRY_RUN and write the
#define'd value out to a temp file. This, of course, won't work for
cross-compiling environments, though.
- modify mpi.h.in to use the new OMPI_* macros.
Keep in mind that mpi.h only has a small subset of the #defines from
OMPI's configure script. opal_config.h (and internal OMPI file that
is not installed) has *all* the #defines; that's what's used to
compile the OMPI code base. mpi.h replicates a small number of these
defines that are used by OMPI's public interface.
--
Jeff Squyres
Cisco Systems