On Sun, Feb 7, 2016 at 8:29 AM, Jeff Squyres (jsquyres) <jsquy...@cisco.com> wrote: > > On Feb 4, 2016, at 9:46 PM, Brian Taylor <spam.brian.tay...@gmail.com> wrote: > > > > Thanks for the explanation, Jeff. I'm not surprised to hear that using a Fortran type from C in this manner is potentially buggy and not portable. However, assuming that the C and Fortran types are interoperable, is there any guarantee that the call to MPI_Reduce in the program above will execute successfully? > > If the representations of the C and Fortran datatypes are the same, then yes, it should work. > > > If OpenMPI 1.10.2 is built with Fortran support, the program above runs and gives the expected output. If OpenMPI 1.10.2 is built without Fortran support, the program exits with the following error: > > > > taylor@host $ mpirun -np 1 ./bug > > [host:49234] *** An error occurred in MPI_Reduce: the reduction operation MPI_MAXLOC is not defined on the MPI_2DBLPREC datatype > > [host:49234] *** reported by process [3133079553,0] > > [host:49234] *** on communicator MPI_COMM_WORLD > > [host:49234] *** MPI_ERR_OP: invalid reduce operation > > [host:49234] *** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort, > > [host:49234] *** and potentially your MPI job) > > I suppose that error message is a bit misleading -- it's not available because we disabled *all* Fortran support, including support for Fortran data types. So yes, MPI_MAXLOC is not defined for MPI2DBLPREC, but *because* there's no Fortran support *at all*. > > > It seems that the MPI_MAXLOC operator for MPI_2DOUBLE_PRECISION is not available if OpenMPI is built without Fortran support; thus, the call to MPI_Reduce fails. Is this the expected behavior? Is the MPI_MAXLOC operator for MPI_2DOUBLE_PRECISION required to be available from C for compliance with the MPI standard, or is its availability from C in OpenMPI (when built with Fortran support) an implementation-dependent "extension"? > > If there's no Fortran compiler, Open MPI can't possibly know what the Fortran representation of the Fortran datatypes.
You might think that's the case - it certainly makes sense to me! - but the following program suggests that OpenMPI "knows" more than you think. Consider the following program: #include <stdio.h> #include <mpi.h> int main(int argc, char **argv) { int rank, size; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Type_size(MPI_2DOUBLE_PRECISION, &size); if (rank == 0) printf("MPI_2DOUBLE_PRECISION is %d bytes\n", size); MPI_Finalize(); return 0; } When compiled and linked with OpenMPI 1.10.2 built without Fortran support, the program runs successfully: taylor@host $ mpicc main.c -o bug taylor@host $ mpirun -np 1 ./bug MPI_2DOUBLE_PRECISION is 16 bytes It certainly appears that MPI_2DOUBLE_PRECISION is a valid type - at least it has a sensible size. I would expect that when OpenMPI is built with Fortran support, it would either not define the Fortran types or set them to MPI_TYPE_NULL. The former would prevent C code that uses Fortran types from compiling when there is no Fortran support, while the latter would hopefully lead to more sensible run time error messages. > > BTW: is there a reason you don't want to just use the C datatypes? The fundamental output of the index is an integer value -- casting it to a float of some flavor doesn't fundamentally change its value. The code in question is not mine. I have suggested to the developers that they should use the correct C types. The reason I became aware of this issue is that one of my colleagues compiled and ran this code on a system where OpenMPI was built without Fortran support and the code started failing with errors from MPI which were not seen on other systems. > > -- > Jeff Squyres > jsquy...@cisco.com > For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/ > Thanks, Brian