[MPI3 Fortran] MPI buffer arguments - void and call-by-reference
Rolf Rabenseifner
rabenseifner at hlrs.de
Mon Feb 9 16:59:21 CST 2009
This is the second part of my two mails:
B) VOID buffer declaration
--------------------------
B.1 Current status
INTEGER :: ibuf
CALL MPI_SEND(ibuf,...)
REAL, DIMENSION(100) :: rarr
CALL MPI_SEND(rarr,...)
CALL MPI_SEND(rarr(5:30:3),...)
COMPLEX, DIMENSION(10,20,30) :: carr3dim
CALL MPI_SEND(carr3dim,...)
TYPE buff_type
SEQUENCE
INTEGER, DIMENSION(3):: i_val
DOUBLE PRECISION, DIMENSION(5):: d_val
END TYPE buff_type
TYPE (buff_type) :: struct
CALL MPI_SEND(struct,...)
TYPE (buff_type), DIMENSION(10,20) :: struct2dim
CALL MPI_SEND(struct2dim,...)
... ... ... ...
All this works and the C-writte MPI_SEND receives the address
of the first data element of each buffer.
Currently, there isn't a F90 interface definition
(i.e. only F77 style is used)
MPI has its own interface to handle the data structure behind
the starting pointer, the so called MPI datatypes.
Such an MPI datatype need not to describe the whole
structure, i.e., there may be differences between the
type information that was told the compiler and the MPI datatype
information.
B.2 Goals
B.2.1 To allow F90 interfaces that do not break eisting codes
B.2.2 To minimize the burden for MPI libraries implementers
and Fortran compiler implementers.
B.3 Maybe a simple but efficient solution
SUBROUTINE MPI_SEND(buf,...
VOID :: buf
END
This can be used only in a interface definition for routines
that are implemented in C.
There is no meaning if one wants to write the routine MPI_SEND
in Fortran.
Meaning of VOID buf:
Exactly the same as if implicit (F77) interfaces are used.
(Not needed for MPI, but a possible extension:
Instead of VOID, one is using IMPLARG, meaning the
same as VOID on the caller side and is also allowed
on the soubroutine side.
Meaning: Same argument handlich as with implicit interfaces,
i.e., handing over the pointer to the data or
in cases of noncontiguos subarrays only a pointer to
a contiguous copy of the data.
)
C) Call by reference and not by in-copy-out-copy
------------------------------------------------
It is clear, that F77 interfaces cannot do strided arrays
directly with call-by-reference.
For contiguous arrays and non-arrays, it isn't a problem.
Fortran compilers are allowed to choose call-by-incopy-and-outcopy
instead of call-by-reference.
Maybe the following additional option may solve the problem:
SUBROUTINE MPI_SEND(buf,...
VOID, CALLBYREFERENCE :: buf
Meaning: Same as what currently done, i.e., call-by-reference
on the caller side, if call-by-reference is possible (i.e.,
not for non-contiguous subarrays)
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: Allmandring 30)
More information about the mpiwg-fortran
mailing list