[Mpi-forum] overloading MPI_Init etc.

Jeffrey Squyres jsquyres at cisco.com
Mon Mar 5 07:29:26 CST 2012


Bronis --

I was thinking the same thing, but then I noticed that the user changed the signature of MPI_Init.  I think that that use over C overloading (changing the signature) is "dodgy" at best, because they're technically infringing on the MPI_* namespace (i.e., they're changing it).

Overloading to do profiling is really just that: overloading (or intercepting, if you will).  It's not changing or adding to the MPI_* namespace.

So yes, I think Fab's comment is that this guy is going against the MPI spec is correct here.  And therefore the user's argument is moot.  (plus, the argument is kinda silly in that any C-based API is going to run into the same problems in C++ -- singling out MPI is kinda meaningless here, IMHO)

Patient: "Doc, it hurts when I move my arm like this."
Doc: "Don't do that.  $20 co-pay, please."



On Mar 5, 2012, at 5:27 AM, Bronis R. de Supinski wrote:

> 
> Um, it is standard practice when using the profiling
> interface to redefine MPI_* functions. I think this
> question is one for the C and C++ standards, not MPI...
> 
> On Sun, 4 Mar 2012, Jeff Hammond wrote:
> 
>> What was ambiguous to me - looking at 2.6.3-4 - was if using MPI_ was
>> still a protected namespace in C++.  The standard really only says
>> explicitly that it is so in C.  It is only with an indirect argument
>> that mpi.h can define both C and C++ bindings that I can see C++ code
>> not being able to define MPI_ functions.
>> 
>> Note that MyMPI_ was ~exactly~ how I fixed the user's code :-)
>> 
>> Jeff
>> 
>> On Sun, Mar 4, 2012 at 9:39 PM, Fab Tillier <ftillier at microsoft.com> wrote:
>>> 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
>>>> 
>>> 
>>> 
>>> _______________________________________________
>>> mpi-forum mailing list
>>> mpi-forum at lists.mpi-forum.org
>>> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum
>> 
>> 
>> 
>> -- 
>> Jeff Hammond
>> Argonne Leadership Computing Facility
>> University of Chicago Computation Institute
>> jhammond at alcf.anl.gov / (630) 252-5381
>> http://www.linkedin.com/in/jeffhammond
>> https://wiki.alcf.anl.gov/old/index.php/User:Jhammond
>> https://wiki-old.alcf.anl.gov/index.php/User:Jhammond
>> 
>> _______________________________________________
>> mpi-forum mailing list
>> mpi-forum at lists.mpi-forum.org
>> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum
> _______________________________________________
> mpi-forum mailing list
> mpi-forum at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum


-- 
Jeff Squyres
jsquyres at cisco.com
For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/





More information about the mpi-forum mailing list