Commit 2798fd8
committed
Fortran mpi module: remove interface names
Fortran is a deceptively complicated language. It turns out that it
is permissable to pass arrays of many sizes and shapes to subroutines
that expect 1-dimensional array parameters. For example, a C
programmer might look at the following subroutine declaration and
assume that it means that the ARRAY_OF_REQUESTS parameter is a
1-dimensional array of any length:
```
MPI_WAITALL(COUNT, ARRAY_OF_REQUESTS, ARRAY_OF_STATUSES, IERROR)
INTEGER COUNT, ARRAY_OF_REQUESTS(*),
ARRAY_OF_STATUSES(MPI_STATUS_SIZE, *), IERROR
```
However, rules of the Fortran language allow the compiler to
effectively morph non-1-dimensional array source parameters to match,
for example, the 1-dimensional ARRAY_OF_REQUESTS dummy parameter.
Sometimes this will be done by copy-in-copy-out; other times, the
compiler can just swizzle the types to match because the source array
data is already contiguous in memory.
Regardless, there are several rules about when this type swizzling can
happen, and there are differences in the rules between when the target
subroutine in question is in a named interface such as:
```
INTERFACE FOO
SUBROUTINE FOO(arg)
INTEGER ARG(*)
END SUBROUTINE FOO
END INTERFACE
```
versus when the subroutine is in an unnamed interface such as:
```
INTERFACE
SUBROUTINE FOO(arg)
INTEGER ARG(*)
END SUBROUTINE FOO
END INTERFACE
```
I will not pretend to be a Fortran language expert and won't quote the
language rules here. The short version is that unnamed interfaces
allow more flexible type swizzling. For example, a user can pass a
2-dimensional INTEGER array to MPI_WAITALL's ARRAY_OF_REQUESTS
argument, and -- assuming that the 2D array is contiguous in memory --
the compiler will make the 2D array type match the 1D
ARRAY_OF_REQUESTS argument. Open MPI will get a contiguous chunk of
memory of integers, so it doesn't know/care.
The MPI standard does not address this issue at all. I.e., it doesn't
say whether passing N-dimensional parameters to subroutines like
MPI_WAITALL are permissable or not. It also does not specify whether
interfaces need to be used, or if interfaces are used, whether they
need to be named or unnamed -- these are all implementation decisions.
However, there has been a lot of discussion about this in the Fortran
group at the MPI Forum over the last week; there will almost certainly
be an errata to MPI-4.0 and/or some text changes in MPI-4.1 to clarify
the situation. I'm not going to speculate on the final language that
will get accepted by the Forum, but it seems like since Open MPI's
implentation decision to use named interfaces is perhaps the most
restrictive in terms of compiler swizzling functionality, we should
probably ease those restrictions so as not to violate the Law of Least
Astonishment from the user's perspective (who would expect that the
Fortran compiler will be able to swizzle array sizes and shapes).
As such, this commit removes all interface names from the Fortran
"mpi" bindings module where there's only a single subroutine in the
interface, and that subroutine name exactly matches the interface
name. Note that this specifically excludes the following routines,
which have multiple subroutines in the interface (for two different
types of Fortran pointers):
* MPI_Alloc_mem
* MPI_Win_allocate
* MPI_Win_allocate_shared
* MPI_Win_shared_query
Deleting the interface names *may* cause ABI implications in some
compilers. I have not exhaustively tested Fortran compilers to know
if this is an issue or not. The safest thing to do is to implement
this change for Open MPI v5.0.0 where we're breaking lots of ABI
things as compared to prior versions of Open MPI.
Note that this issue does *not* affect the mpi_f08 module. Using
named interfaces were distinctly specified in the MPI standard.
Also, this doesn't affect mpif.h, because Open MPI doesn't declare
most interfaces/subroutines in mpif.h.
Signed-off-by: Jeff Squyres <jsquyres@cisco.com>1 parent d6d033f commit 2798fd8
File tree
9 files changed
+623
-613
lines changed- ompi/mpi/fortran
- use-mpi-ignore-tkr
- use-mpi-tkr
9 files changed
+623
-613
lines changedLines changed: 60 additions & 60 deletions
Large diffs are not rendered by default.
Lines changed: 320 additions & 316 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
0 commit comments