[Mpi-forum] Question about MPI_Alloc_mem
rabenseifner at hlrs.de
Wed Oct 14 12:32:42 CDT 2020
please read MPI-3.1 page 338, lines 36-41.
Do these lines resolve your question?
----- Original Message -----
> From: "Main MPI Forum mailing list" <mpi-forum at lists.mpi-forum.org>
> To: "Main MPI Forum mailing list" <mpi-forum at lists.mpi-forum.org>
> Cc: "Anthony Skjellum" <skjellum at gmail.com>
> Sent: Wednesday, October 14, 2020 7:01:54 PM
> Subject: [Mpi-forum] Question about MPI_Alloc_mem
> Folks, I know we have had this function for a long time, and I've implemented
> ports of MPI that actually use it (e.g., with pre-pinned memory). But, I am
> trying to understand the logic for why baseptr is passed by value, instead of
> by reference. In C, everything is by value, so the last argument in normal C
> programs would be void **baseptr.
> The standard has:
> int MPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr);
> Now, MPICC/GCC takes this with
> void *memory = (void *)0;
> int error = MPI_Alloc_mem(1024, MPI_INFO_NULL, &memory);
> and you get the memory allocated properly.
> What is more, this is incorrect:
> int error = MPI_Alloc_mem(1024, MPI_INFO_NULL, memory);
> although it compiles fine because that is, indeed, the API.
> Why would we have the pointer going in by value, when it is coming out
> as an OUT argument?
> Isn't this plain wrong? void **baseptr means ---> I am passing you the
> address of a void pointer.
> Every viable implementation must do *(void **)baseptr = ...
> when providing the "malloc'd/special" memory. So... why did we fudge
> the C API. Is there some tie-in with the Fortran API?
> Thanks in advance,
> Tony Skjellum
> Anthony Skjellum, PhD
> [ mailto:skjellum at gmail.com | skjellum at gmail.com ]
> Cell: +1-205-807-4968
> mpi-forum mailing list
> mpi-forum at lists.mpi-forum.org
Dr. Rolf Rabenseifner . . . . . . . . . .. email rabenseifner at hlrs.de .
High Performance Computing Center (HLRS) . phone ++49(0)711/685-65530 .
University of Stuttgart . . . . . . . . .. fax ++49(0)711 / 685-65832 .
Head of Dpmt Parallel Computing . . . www.hlrs.de/people/rabenseifner .
Nobelstr. 19, D-70550 Stuttgart, Germany . . . . (Office: Room 1.307) .
More information about the mpi-forum