Skip to content

Commit 1a9a108

Browse files
committed
Generate interfaces for Fortran and C with bigcount
This adds scripts for generating the Fortran and C API bindings from template files, while also generating bigcount interfaces for those that require them. The Fortran binding code (for mpi_f08) is designed to generate both the Fortran subroutines and wrapping C code which calls into the MPI C api. Python >=3.6 is required for running these scripts, which is only necessary when the binding files have not already been generated. Users of the distribution tarball should not need to generate these files and thus should not require Python. Signed-off-by: Jake Tronge <[email protected]>
1 parent 5fa32f7 commit 1a9a108

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2314
-1028
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,11 @@ docs/schizo-ompi-rst-content
543543
# tarballs)
544544
docs/html
545545
docs/man
546+
547+
# Generated C Bindings
548+
ompi/mpi/c/ompi_*.c
549+
550+
# Generated Fortran Bindings
551+
ompi/mpi/fortran/use-mpi-f08/*_generated.F90
552+
ompi/mpi/fortran/use-mpi-f08/base/*_generated.c
553+
ompi/mpi/fortran/use-mpi-f08/generate_bindings.py

config/ompi_config_files.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ AC_DEFUN([OMPI_CONFIG_FILES],[
4141
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-removed-interfaces.h
4242
ompi/mpi/fortran/use-mpi-f08/Makefile
4343
ompi/mpi/fortran/use-mpi-f08/base/Makefile
44-
ompi/mpi/fortran/use-mpi-f08/profile/Makefile
4544
ompi/mpi/fortran/use-mpi-f08/bindings/Makefile
4645
ompi/mpi/fortran/use-mpi-f08/mod/Makefile
4746
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h
47+
ompi/mpi/fortran/use-mpi-f08/generate_bindings.py
4848
ompi/mpi/fortran/mpiext-use-mpi/Makefile
4949
ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile
5050
ompi/mpi/tool/Makefile

config/ompi_configure_options.m4

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,12 @@ else
244244
fi
245245
AM_CONDITIONAL(OMPI_OMPIO_SUPPORT, test "$ompi_want_ompio" = "1")
246246

247+
# If the binding source files don't exist, then we need Python to generate them
248+
AM_PATH_PYTHON([3.6],,[:])
249+
binding_file="${srcdir}/ompi/mpi/c/ompi_send.c"
250+
AS_IF([! test -e "$binding_file" && test "$PYTHON" = ":"],
251+
[AC_MSG_ERROR([Open MPI requires Python >=3.6 for generating the bindings. Aborting])])
252+
AM_CONDITIONAL(OMPI_GENERATE_BINDINGS,[test "$PYTHON" != ":"])
253+
247254
])dnl
248255

ompi/include/mpi.h.in

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub;
13891389
/*
13901390
* MPI API
13911391
*/
1392-
1392+
#ifndef OMPI_NO_MPI_PROTOTYPES
13931393
OMPI_DECLSPEC int MPI_Abort(MPI_Comm comm, int errorcode);
13941394
OMPI_DECLSPEC int MPI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
13951395
int target_rank, MPI_Aint target_disp, int target_count,
@@ -1419,6 +1419,8 @@ OMPI_DECLSPEC int MPI_Alloc_mem(MPI_Aint size, MPI_Info info,
14191419
void *baseptr);
14201420
OMPI_DECLSPEC int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
14211421
MPI_Op op, MPI_Comm comm);
1422+
OMPI_DECLSPEC int MPI_Allreduce_c(const void *sendbuf, void *recvbuf, MPI_Count count, MPI_Datatype datatype,
1423+
MPI_Op op, MPI_Comm comm);
14221424
OMPI_DECLSPEC int MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
14231425
MPI_Op op, MPI_Comm comm, MPI_Request *request);
14241426
OMPI_DECLSPEC int MPI_Allreduce_init(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
@@ -1774,10 +1776,14 @@ OMPI_DECLSPEC int MPI_Iprobe(int source, int tag, MPI_Comm comm, int *flag,
17741776
MPI_Status *status);
17751777
OMPI_DECLSPEC int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
17761778
int tag, MPI_Comm comm, MPI_Request *request);
1779+
OMPI_DECLSPEC int MPI_Irecv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source,
1780+
int tag, MPI_Comm comm, MPI_Request *request);
17771781
OMPI_DECLSPEC int MPI_Irsend(const void *buf, int count, MPI_Datatype datatype, int dest,
17781782
int tag, MPI_Comm comm, MPI_Request *request);
17791783
OMPI_DECLSPEC int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest,
17801784
int tag, MPI_Comm comm, MPI_Request *request);
1785+
OMPI_DECLSPEC int MPI_Isend_c(const void *buf, MPI_Count count, MPI_Datatype datatype, int dest,
1786+
int tag, MPI_Comm comm, MPI_Request *request);
17811787
OMPI_DECLSPEC int MPI_Isendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
17821788
int dest, int sendtag, void *recvbuf, int recvcount,
17831789
MPI_Datatype recvtype, int source, int recvtag,
@@ -1882,6 +1888,8 @@ OMPI_DECLSPEC int MPI_Recv_init(void *buf, int count, MPI_Datatype datatype, in
18821888
int tag, MPI_Comm comm, MPI_Request *request);
18831889
OMPI_DECLSPEC int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source,
18841890
int tag, MPI_Comm comm, MPI_Status *status);
1891+
OMPI_DECLSPEC int MPI_Recv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source,
1892+
int tag, MPI_Comm comm, MPI_Status *status);
18851893
OMPI_DECLSPEC int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
18861894
MPI_Op op, int root, MPI_Comm comm);
18871895
OMPI_DECLSPEC int MPI_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
@@ -1957,6 +1965,8 @@ OMPI_DECLSPEC int MPI_Send_init(const void *buf, int count, MPI_Datatype dataty
19571965
MPI_Request *request);
19581966
OMPI_DECLSPEC int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest,
19591967
int tag, MPI_Comm comm);
1968+
OMPI_DECLSPEC int MPI_Send_c(const void *buf, MPI_Count count, MPI_Datatype datatype, int dest,
1969+
int tag, MPI_Comm comm);
19601970
OMPI_DECLSPEC int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
19611971
int dest, int sendtag, void *recvbuf, int recvcount,
19621972
MPI_Datatype recvtype, int source, int recvtag,
@@ -2153,6 +2163,9 @@ OMPI_DECLSPEC int PMPI_Abort(MPI_Comm comm, int errorcode);
21532163
OMPI_DECLSPEC int PMPI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
21542164
int target_rank, MPI_Aint target_disp, int target_count,
21552165
MPI_Datatype target_datatype, MPI_Op op, MPI_Win win);
2166+
OMPI_DECLSPEC int PMPI_Accumulate_c(const void *origin_addr, MPI_Count origin_count, MPI_Datatype origin_datatype,
2167+
int target_rank, MPI_Aint target_disp, MPI_Count target_count,
2168+
MPI_Datatype target_datatype, MPI_Op op, MPI_Win win);
21562169
OMPI_DECLSPEC int PMPI_Add_error_class(int *errorclass);
21572170
OMPI_DECLSPEC int PMPI_Add_error_code(int errorclass, int *errorcode);
21582171
OMPI_DECLSPEC int PMPI_Add_error_string(int errorcode, const char *string);
@@ -2178,6 +2191,8 @@ OMPI_DECLSPEC int PMPI_Alloc_mem(MPI_Aint size, MPI_Info info,
21782191
void *baseptr);
21792192
OMPI_DECLSPEC int PMPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
21802193
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
2194+
OMPI_DECLSPEC int PMPI_Allreduce_c(const void *sendbuf, void *recvbuf, MPI_Count count,
2195+
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
21812196
OMPI_DECLSPEC int PMPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
21822197
MPI_Op op, MPI_Comm comm, MPI_Request *request);
21832198
OMPI_DECLSPEC int PMPI_Allreduce_init(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
@@ -2535,10 +2550,14 @@ OMPI_DECLSPEC int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int *flag,
25352550
MPI_Status *status);
25362551
OMPI_DECLSPEC int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source,
25372552
int tag, MPI_Comm comm, MPI_Request *request);
2553+
OMPI_DECLSPEC int PMPI_Irecv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source,
2554+
int tag, MPI_Comm comm, MPI_Request *request);
25382555
OMPI_DECLSPEC int PMPI_Irsend(const void *buf, int count, MPI_Datatype datatype, int dest,
25392556
int tag, MPI_Comm comm, MPI_Request *request);
25402557
OMPI_DECLSPEC int PMPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest,
25412558
int tag, MPI_Comm comm, MPI_Request *request);
2559+
OMPI_DECLSPEC int PMPI_Isend_c(const void *buf, MPI_Count count, MPI_Datatype datatype, int dest,
2560+
int tag, MPI_Comm comm, MPI_Request *request);
25422561
OMPI_DECLSPEC int PMPI_Isendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
25432562
int dest, int sendtag, void *recvbuf, int recvcount,
25442563
MPI_Datatype recvtype, int source, int recvtag,
@@ -2643,6 +2662,8 @@ OMPI_DECLSPEC int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, i
26432662
int tag, MPI_Comm comm, MPI_Request *request);
26442663
OMPI_DECLSPEC int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int source,
26452664
int tag, MPI_Comm comm, MPI_Status *status);
2665+
OMPI_DECLSPEC int PMPI_Recv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source,
2666+
int tag, MPI_Comm comm, MPI_Status *status);
26462667
OMPI_DECLSPEC int PMPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
26472668
MPI_Op op, int root, MPI_Comm comm);
26482669
OMPI_DECLSPEC int PMPI_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
@@ -2718,6 +2739,8 @@ OMPI_DECLSPEC int PMPI_Send_init(const void *buf, int count, MPI_Datatype datat
27182739
MPI_Request *request);
27192740
OMPI_DECLSPEC int PMPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest,
27202741
int tag, MPI_Comm comm);
2742+
OMPI_DECLSPEC int PMPI_Send_c(const void *buf, MPI_Count count, MPI_Datatype datatype, int dest,
2743+
int tag, MPI_Comm comm);
27212744
OMPI_DECLSPEC int PMPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
27222745
int dest, int sendtag, void *recvbuf, int recvcount,
27232746
MPI_Datatype recvtype, int source, int recvtag,
@@ -3176,6 +3199,8 @@ OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub)
31763199
#define MPI_Type_ub(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Type_ub, MPI_Type_get_extent)
31773200
#endif
31783201

3202+
#endif /* OMPI_NO_MPI_PROTOTYPES */
3203+
31793204
#if defined(c_plusplus) || defined(__cplusplus)
31803205
}
31813206
#endif

ompi/mpi/c/Makefile.am

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,36 @@ endif
4141

4242
headers = bindings.h
4343

44+
prototype_sources = \
45+
abort.c.in \
46+
send.c.in \
47+
isend.c.in \
48+
recv.c.in \
49+
irecv.c.in \
50+
waitsome.c.in \
51+
accumulate.c.in \
52+
comm_f2c.c.in \
53+
wtime.c.in \
54+
file_open.c.in \
55+
init.c.in \
56+
finalize.c.in \
57+
comm_rank.c.in \
58+
comm_size.c.in \
59+
waitall.c.in \
60+
comm_split.c.in \
61+
comm_split_type.c.in \
62+
comm_free.c.in \
63+
finalized.c.in \
64+
initialized.c.in \
65+
allreduce.c.in \
66+
get_library_version.c.in \
67+
get_processor_name.c.in \
68+
barrier.c.in
69+
70+
# Include script and template files in case someone wants to update the
71+
# template files
72+
EXTRA_DIST = generate_bindings.py $(prototype_sources)
73+
4474
# attr_fn.c contains attribute manipulation functions which do not
4575
# profiling implications, and so are always built.
4676
libmpi_c_la_SOURCES = \
@@ -60,7 +90,7 @@ endif
6090
# List of all C files that have profile versions
6191
#
6292
interface_profile_sources = \
63-
abort.c \
93+
ompi_abort.c \
6494
add_error_class.c \
6595
add_error_code.c \
6696
add_error_string.c \
@@ -71,7 +101,7 @@ interface_profile_sources = \
71101
iallgatherv.c \
72102
allgatherv_init.c \
73103
alloc_mem.c \
74-
allreduce.c \
104+
ompi_allreduce.c \
75105
iallreduce.c \
76106
allreduce_init.c \
77107
alltoall.c \
@@ -86,7 +116,7 @@ interface_profile_sources = \
86116
attr_delete.c \
87117
attr_get.c \
88118
attr_put.c \
89-
barrier.c \
119+
ompi_barrier.c \
90120
ibarrier.c \
91121
barrier_init.c \
92122
bcast.c \
@@ -122,8 +152,8 @@ interface_profile_sources = \
122152
comm_dup_with_info.c \
123153
comm_idup.c \
124154
comm_idup_with_info.c \
125-
comm_f2c.c \
126-
comm_free.c \
155+
ompi_comm_f2c.c \
156+
ompi_comm_free.c \
127157
comm_free_keyval.c \
128158
comm_get_attr.c \
129159
comm_get_errhandler.c \
@@ -132,7 +162,7 @@ interface_profile_sources = \
132162
comm_get_parent.c \
133163
comm_group.c \
134164
comm_join.c \
135-
comm_rank.c \
165+
ompi_comm_rank.c \
136166
comm_remote_group.c \
137167
comm_remote_size.c \
138168
comm_set_attr.c \
@@ -143,11 +173,11 @@ interface_profile_sources = \
143173
dist_graph_neighbors_count.c \
144174
comm_set_errhandler.c \
145175
comm_set_name.c \
146-
comm_size.c \
176+
ompi_comm_size.c \
147177
comm_spawn.c \
148178
comm_spawn_multiple.c \
149-
comm_split.c \
150-
comm_split_type.c \
179+
ompi_comm_split.c \
180+
ompi_comm_split_type.c \
151181
comm_test_inter.c \
152182
compare_and_swap.c \
153183
dims_create.c \
@@ -187,7 +217,7 @@ interface_profile_sources = \
187217
file_iwrite.c \
188218
file_iwrite_all.c \
189219
file_iwrite_shared.c \
190-
file_open.c \
220+
ompi_file_open.c \
191221
file_preallocate.c \
192222
file_read_all_begin.c \
193223
file_read_all.c \
@@ -221,8 +251,8 @@ interface_profile_sources = \
221251
file_write_ordered.c \
222252
file_write_ordered_end.c \
223253
file_write_shared.c \
224-
finalize.c \
225-
finalized.c \
254+
ompi_finalize.c \
255+
ompi_finalized.c \
226256
free_mem.c \
227257
gather.c \
228258
igather.c \
@@ -235,8 +265,8 @@ interface_profile_sources = \
235265
get_elements.c \
236266
get_elements_x.c \
237267
get_accumulate.c \
238-
get_library_version.c \
239-
get_processor_name.c \
268+
ompi_get_library_version.c \
269+
ompi_get_processor_name.c \
240270
get_version.c \
241271
graph_create.c \
242272
graph_get.c \
@@ -277,17 +307,17 @@ interface_profile_sources = \
277307
info_get_string.c \
278308
info_get_valuelen.c \
279309
info_set.c \
280-
init.c \
310+
ompi_init.c \
281311
init_thread.c \
282-
initialized.c \
312+
ompi_initialized.c \
283313
intercomm_create.c \
284314
intercomm_create_from_groups.c \
285315
intercomm_merge.c \
286316
iprobe.c \
287-
irecv.c \
317+
ompi_irecv.c \
288318
irsend.c \
289319
is_thread_main.c \
290-
isend.c \
320+
ompi_isend.c \
291321
isendrecv.c \
292322
isendrecv_replace.c \
293323
issend.c \
@@ -335,7 +365,7 @@ interface_profile_sources = \
335365
query_thread.c \
336366
raccumulate.c \
337367
recv_init.c \
338-
recv.c \
368+
ompi_recv.c \
339369
reduce.c \
340370
ireduce.c \
341371
reduce_init.c \
@@ -365,7 +395,6 @@ interface_profile_sources = \
365395
scatterv.c \
366396
iscatterv.c \
367397
scatterv_init.c \
368-
send.c \
369398
send_init.c \
370399
sendrecv.c \
371400
sendrecv_replace.c \
@@ -440,12 +469,12 @@ interface_profile_sources = \
440469
unpack.c \
441470
unpublish_name.c \
442471
wait.c \
443-
waitall.c \
472+
ompi_waitall.c \
444473
waitany.c \
445-
waitsome.c \
446-
wtime.c \
474+
ompi_waitsome.c \
475+
ompi_wtime.c \
447476
wtick.c \
448-
accumulate.c \
477+
ompi_accumulate.c \
449478
get.c \
450479
put.c \
451480
win_allocate.c \
@@ -486,6 +515,7 @@ interface_profile_sources = \
486515
win_test.c \
487516
win_unlock.c \
488517
win_unlock_all.c \
518+
ompi_send.c \
489519
win_wait.c
490520

491521
# The following functions were removed from the MPI standard, but are
@@ -509,3 +539,12 @@ libmpi_c_profile_la_CPPFLAGS = -DOMPI_BUILD_MPI_PROFILING=1
509539

510540
libmpi_c_noprofile_la_SOURCES = $(interface_profile_sources)
511541
libmpi_c_noprofile_la_CPPFLAGS = -DOMPI_BUILD_MPI_PROFILING=0
542+
543+
# ABI generation rules
544+
if OMPI_GENERATE_BINDINGS
545+
ompi_%.c: %.c.in generate_bindings.py
546+
$(PYTHON) $(srcdir)/generate_bindings.py source ompi $< > $@
547+
548+
distclean-local:
549+
-rm -rf ompi_*.c
550+
endif

ompi/mpi/c/abort.c renamed to ompi/mpi/c/abort.c.in

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,7 @@
2828
#include "ompi/memchecker.h"
2929
#include "ompi/communicator/communicator.h"
3030

31-
#if OMPI_BUILD_MPI_PROFILING
32-
#if OPAL_HAVE_WEAK_SYMBOLS
33-
#pragma weak MPI_Abort = PMPI_Abort
34-
#endif
35-
#define MPI_Abort PMPI_Abort
36-
#endif
37-
38-
static const char FUNC_NAME[] = "MPI_Abort";
39-
40-
41-
int MPI_Abort(MPI_Comm comm, int errorcode)
31+
PROTOTYPE ERROR_CLASS abort(COMM comm, INT errorcode)
4232
{
4333
MEMCHECKER(
4434
memchecker_comm(comm);

ompi/mpi/c/accumulate.c renamed to ompi/mpi/c/accumulate.c.in

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,9 @@
3434
#include "ompi/datatype/ompi_datatype_internal.h"
3535
#include "ompi/memchecker.h"
3636

37-
#if OMPI_BUILD_MPI_PROFILING
38-
#if OPAL_HAVE_WEAK_SYMBOLS
39-
#pragma weak MPI_Accumulate = PMPI_Accumulate
40-
#endif
41-
#define MPI_Accumulate PMPI_Accumulate
42-
#endif
43-
44-
static const char FUNC_NAME[] = "MPI_Accumulate";
45-
46-
int MPI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
47-
int target_rank, MPI_Aint target_disp, int target_count,
48-
MPI_Datatype target_datatype, MPI_Op op, MPI_Win win)
37+
PROTOTYPE ERROR_CLASS accumulate(BUFFER origin_addr, COUNT origin_count, DATATYPE origin_datatype,
38+
INT target_rank, AINT target_disp, COUNT target_count,
39+
DATATYPE target_datatype, OP op, WIN win)
4940
{
5041
int rc;
5142
ompi_win_t *ompi_win = (ompi_win_t*) win;

0 commit comments

Comments
 (0)