Re: [Mpi-forum] overloading MPI_Init etc.
I don't think defining one's own mpi.h is an issue from a compliance perspective. However, overloading MPI_Init definitely is - the standard reserves the MPI_ namespace, so if it isn't in the standard, it's not standard compliant. Now, if they named it MyMPI_Init, it'd be fine. -Fab Jeff Hammond wrote on Sun, 4 Mar 2012 at 18:22:40
I have a user who insists it is MPI-compliant to do the following:
user file mpi.h, which is included in the application with #include "mpi.h": ================================== #include <mpi.h>
<snip>
void MPI_Init(int argc, char* argv[], int& my_rank, int& mpi_size, int& Master) { MPI::Init(argc, argv); my_rank = MPI::COMM_WORLD.Get_rank(); mpi_size = MPI::COMM_WORLD.Get_size(); Master = 0;
std::cout << "Hello World! I am " << my_rank << " of " << mpi_size << std::endl; }
void MPI_finalize() {MPI::Finalize();}
==================================
I believe that it is a terrible practice, if not a violation of the MPI standard to: (1) define one's own mpi.h, since this may confuse the preprocessor (or are there precedence rules in the ANSI C standard?) as to which to include first (especially if CC=mpicc or CXX=mpicxx), and (2) overload MPI_Init, even if one is using C++ and relying upon C++ name-mangling to avoid a symbol conflict.
The user believes that the inability to overload MPI_Init in C++ means that MPI is not compliant with the C++ standard.
Thanks,
Jeff
participants (1)
-
Fab Tillier