Discussion:
[OMPI users] Are MPI datatypes guaranteed to be compile-time constants?
Benjamin Brock
2018-09-04 21:22:22 UTC
Permalink
Are MPI datatypes like MPI_INT and MPI_CHAR guaranteed to be compile-time
constants? Is this defined by the MPI standard, or in the Open MPI
implementation?

I've written some template code where MPI datatypes are constexpr members,
which requires that they be known at compile time. This works in Open MPI
and MPICH, but not in Spectrum MPI--I'm not sure what they've done that
breaks this, but I'm trying to file a bug and any information you have
about whether these are compile-time constants would be useful.

Ben
Jeff Squyres (jsquyres) via users
2018-09-04 21:55:05 UTC
Permalink
Are MPI datatypes like MPI_INT and MPI_CHAR guaranteed to be compile-time constants?
No. They are guaranteed to be link-time constants.
Is this defined by the MPI standard, or in the Open MPI implementation?
MPI standard: https://www.mpi-forum.org/docs/mpi-3.1/mpi31-report/node28.htm#Node28
All named constants, with the exceptions noted below for Fortran, can be used in initialization expressions or assignments, but not necessarily in array declarations or as labels in C switch or Fortran select/case statements. This implies named constants to be link-time but not necessarily compile-time constants. The named constants listed below are required to be compile-time constants in both C and Fortran. These constants do not change values during execution. Opaque objects accessed by constant handles are defined and do not change value between MPI initialization (MPI_INIT) and MPI completion (MPI_FINALIZE). The handles themselves are constants and can be also used in initialization expressions or assignments.
The pre-defined datatypes -- such as MPI_INT and MPI_CHAR -- are not in the list of compile-time constants, so they are only guaranteed to be link-time constants.

Open MPI implements MPI_INT, MPI_CHAR, and other MPI handles as pointers.
I've written some template code where MPI datatypes are constexpr members, which requires that they be known at compile time. This works in Open MPI and MPICH, but not in Spectrum MPI--I'm not sure what they've done that breaks this, but I'm trying to file a bug and any information you have about whether these are compile-time constants would be useful.
Don't know why that works in Open MPI, because Spectrum MPI is derived from Open MPI, and AFAIK both use the same kinds of constructs for MPI_INT, MPI_CHAR, and others.
--
Jeff Squyres
***@cisco.com
Reuti
2018-09-04 22:31:49 UTC
Permalink
Hi,
Are MPI datatypes like MPI_INT and MPI_CHAR guaranteed to be compile-time constants? Is this defined by the MPI standard, or in the Open MPI implementation?
I've written some template code where MPI datatypes are constexpr members, which requires that they be known at compile time. This works in Open MPI and MPICH, but not in Spectrum MPI--I'm not sure what they've done that breaks this, but I'm trying to file a bug and any information you have about whether these are compile-time constants would be useful.
For Open MPI and MPICH you can check the definitions with a command like:

$ find . -type f -exec egrep -H ".*define.*MPI_INT.*" {} \;

and get some constants (both *inside* a compiled directory of each, not the source directories).

What does Spectrum MPI show here? While Platform-MPI was something unique, I thought Spectrum MPI is based on Open MPI.

How does this effect manifests in Spectrum MPI? It changes between each compilation of all your source files, i.e. foo.c sees other values than baz.c, despite the fact that they work together later on when they are linked?

-- Reuti
David L. Braun
2018-09-05 00:20:40 UTC
Permalink
David L. BraunThe Brooks Research Group (734) 615-1450
-------- Original message --------From: Reuti <***@staff.uni-marburg.de> Date: 9/4/18 6:31 PM (GMT-05:00) To: Open MPI Users <***@lists.open-mpi.org> Subject: Re: [OMPI users] Are MPI datatypes guaranteed to be compile-time
  constants?
Hi,
Are M PI datatypes like MPI_INT and MPI_CHAR guaranteed to be compile-time constants?  Is this defined by the MPI standard, or in the Open MPI implementation?
I've written some template code where MPI datatypes are constexpr members, which requires that they be known at compile time.  This works in Open MPI and MPICH, but not in Spectrum MPI--I'm not sure what they've done that breaks this, but I'm trying to file a bug and any information you have about whether these are compile-time constants would be useful.
For Open MPI and MPICH you can check the definitions with a command like:

$ find . -type f -exec egrep -H ".*define.*MPI_INT.*" {} \;

and get some constants (both *inside* a compiled directory of each, not the source directories).

What does Spectrum MPI show here? While Platform-MPI was something unique, I thought Spectrum MPI is based on Open MPI.

How does this effect manifests in Spectrum MPI? It changes between each compilation of all your source files, i.e. foo.c sees other values than baz.c, despite the fact that they work together later on when they are linked?

-- Reuti
Benjamin Brock
2018-09-07 02:02:41 UTC
Permalink
Thanks for the responses--from what you've said, it seems like MPI types
are indeed not guaranteed to be compile-time constants.

However, I worked with the people at IBM, and it seems like the difference
in behavior was caused by the IBM compiler, not the Spectrum IBM
implementation.

Ben

Loading...