From the MPI 3.1 standard (page 338)

Rationale. The C bindings of MPI_ALLOC_MEM and MPI_FREE_MEM are similar
to the bindings for the malloc and free C library calls: a call to
MPI_Alloc_mem(: : :, &base) should be paired with a call to MPI_Free_mem(base) (one
less level of indirection). Both arguments are declared to be of same type
void* so as to facilitate type casting. The Fortran binding is consistent with the C bindings: the Fortran MPI_ALLOC_MEM call returns in baseptr the TYPE(C_PTR) pointer or the (integer valued) address of the allocated memory. The base argument of MPI_FREE_MEM is a choice argument, which passes (a reference to) the variable
stored at that location. (End of rationale.)


at first glance, i also thought type should have been char ** instead of char *, but it is not a typo nor a mistake


Cheers,


Gilles


On 10/27/2016 5:13 PM, Bader, Reinhold wrote:

I've had a look at the OpenMPI 1.10.3 sources, and the trouble appears to me to be that the MPI wrappers declare

the argument

  TYPE(C_PTR), INTENT(OUT) ::  baseptr

inside the BIND(C) interface on the Fortran side (for OpenMPI this would, for example be ompi_win_allocate_f), and

the C implementation has "char *baseptr" as parameter. This is incorrect, it needs to be

char **baseptr

I believe this actually points to a design weakness of the C-side interface. For establishment of a C pointer, usually

functions that return such a pointer are defined (e.g. malloc()). If a formal parameter is desired, this should be

a pointer-to-pointer entity, i.e. it would have been better to define the MPI_Win_allocate prototype as

int MPI_Win_allocate(MPI_Aint size, int disp_unit, MPI_Info info, MPI_comm comm, *void **baseptr*, MPI_Win win);

Note that the C example pretends that this is the case – it passes the address of the pointer to

MPI_Win_allocate, not the pointer itself.

Cheers

--

Dr. Reinhold Bader

Leibniz Supercomputing Centre (http://www.lrz.de) / HPC Systems and Services

Tel.: 0049 89 35831 8825  Fax: 8625



_______________________________________________
users mailing list
users@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/users

_______________________________________________
users mailing list
users@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/users

Reply via email to