From f6a06fcbb59d36d4ff312dbfb97c77953b4618ae Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 14 Sep 2004 17:03:41 +0000 Subject: [PATCH] There is a very confusing situation dealing with MPI-defined functions such as MPI_DUP_FN: MPI says that they have to be available via that name in both C and Fortran. However, for implementation reasons, we have to have them as separate functions. But if a Fortran compiler's naming convention is ALL_CAPS, this is not possible. Hence, we need to put in #define's in mpi.h to change the C names something like this: MPI_DUP_FN -> OMPI_C_MPI_DUP_FN. This was actually done a long time ago. However, the source code where those C functions actually live (src/mpi/c/attr_fn.c) still reflected the old names (e.g., MPI_DUP_FN). This is fine, actually -- mpi.h would come in and #define them to their real names (OMPI_C_MPI_DUP_FN). So it was functionally correct, but confusing at hell (and it just bit Edgar and me today). So I'm changing src/mpi/c/attr_fn.c to use the real names (OMPI_C_MPI_DUP_FN) so that tools like ctags and grep can find them in the source code when you go looking. Plus, the code is just more clear that way. I also put in massive comments about this in src/mpi/c/attr_fn.c and src/mpi/f77/attr_fn_f.c so that we remember why the heck we did this. :-) This commit was SVN r2670. --- src/mpi/c/attr_fn.c | 113 +++++++++++++++++++++++++--------------- src/mpi/f77/attr_fn_f.c | 23 ++++++++ 2 files changed, 94 insertions(+), 42 deletions(-) diff --git a/src/mpi/c/attr_fn.c b/src/mpi/c/attr_fn.c index 0c2311d328..ef24d93c47 100644 --- a/src/mpi/c/attr_fn.c +++ b/src/mpi/c/attr_fn.c @@ -10,71 +10,100 @@ #include "communicator/communicator.h" #include "win/win.h" -int MPI_TYPE_NULL_DELETE_FN( MPI_Datatype datatype, int type_keyval, - void* attribute_val_out, - void* flag ) +/* + * Note that these are the back-end functions for MPI_DUP_FN (and + * friends). They have an OMPI_C_* prefix because of weird reasons + * listed in a lengthy comment in mpi.h. + * + * Specifically: + * + * MPI_NULL_DELETE_FN -> OMPI_C_MPI_NULL_DELETE_FN + * MPI_NULL_COPY_FN -> OMPI_C_MPI_NULL_COPY_FN + * MPI_DUP_FN -> OMPI_C_MPI_DUP_FN + * + * MPI_TYPE_NULL_DELETE_FN -> OMPI_C_MPI_TYPE_NULL_DELETE_FN + * MPI_TYPE_NULL_COPY_FN -> OMPI_C_MPI_TYPE_NULL_COPY_FN + * MPI_TYPE_DUP_FN -> OMPI_C_MPI_TYPE_DUP_FN + * + * MPI_COMM_NULL_DELETE_FN -> OMPI_C_MPI_COMM_NULL_DELETE_FN + * MPI_COMM_NULL_COPY_FN -> OMPI_C_MPI_COMM_NULL_COPY_FN + * MPI_COMM_DUP_FN -> OMPI_C_MPI_COMM_DUP_FN + * + * MPI_WIN_NULL_DELETE_FN -> OMPI_C_MPI_WIN_NULL_DELETE_FN + * MPI_WIN_NULL_COPY_FN -> OMPI_C_MPI_WIN_NULL_COPY_FN + * MPI_WIN_DUP_FN -> OMPI_C_MPI_WIN_DUP_FN + */ + +int OMPI_C_MPI_TYPE_NULL_DELETE_FN( MPI_Datatype datatype, int type_keyval, + void* attribute_val_out, + void* flag ) { /* Why not all MPI functions are like this ?? */ return MPI_SUCCESS; } -int MPI_TYPE_NULL_COPY_FN( MPI_Datatype datatype, int type_keyval, void* extra_state, - void* attribute_val_in, void* attribute_val_out, - int* flag ) +int OMPI_C_MPI_TYPE_NULL_COPY_FN( MPI_Datatype datatype, int type_keyval, + void* extra_state, + void* attribute_val_in, + void* attribute_val_out, + int* flag ) { *flag = 0; return MPI_SUCCESS; } -int MPI_TYPE_DUP_FN( MPI_Datatype datatype, int type_keyval, void* extra_state, - void* attribute_val_in, void* attribute_val_out, - int* flag ) +int OMPI_C_MPI_TYPE_DUP_FN( MPI_Datatype datatype, int type_keyval, + void* extra_state, + void* attribute_val_in, void* attribute_val_out, + int* flag ) { *flag = 1; *(void**)attribute_val_out = attribute_val_in; return MPI_SUCCESS; } -int MPI_WIN_NULL_DELETE_FN( MPI_Win window, int win_keyval, - void* attribute_val_out, - void* flag ) +int OMPI_C_MPI_WIN_NULL_DELETE_FN( MPI_Win window, int win_keyval, + void* attribute_val_out, + void* flag ) { return MPI_SUCCESS; } -int MPI_WIN_NULL_COPY_FN( MPI_Win window, int win_keyval, void* extra_state, - void* attribute_val_in, void* attribute_val_out, - int* flag ) +int OMPI_C_MPI_WIN_NULL_COPY_FN( MPI_Win window, int win_keyval, + void* extra_state, + void* attribute_val_in, + void* attribute_val_out, int* flag ) { *flag= 0; return MPI_SUCCESS; } -int MPI_WIN_DUP_FN( MPI_Win window, int win_keyval, void* extra_state, - void* attribute_val_in, void* attribute_val_out, - int* flag ) -{ - *flag = 1; - *(void**)attribute_val_out = attribute_val_in; - return MPI_SUCCESS; -} - -int MPI_COMM_NULL_DELETE_FN( MPI_Comm comm, int comm_keyval, - void* attribute_val_out, - void* flag ) -{ - return MPI_SUCCESS; -} - -int MPI_COMM_NULL_COPY_FN( MPI_Comm comm, int comm_keyval, void* extra_state, +int OMPI_C_MPI_WIN_DUP_FN( MPI_Win window, int win_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag ) +{ + *flag = 1; + *(void**)attribute_val_out = attribute_val_in; + return MPI_SUCCESS; +} + +int OMPI_C_MPI_COMM_NULL_DELETE_FN( MPI_Comm comm, int comm_keyval, + void* attribute_val_out, + void* flag ) +{ + return MPI_SUCCESS; +} + +int OMPI_C_MPI_COMM_NULL_COPY_FN( MPI_Comm comm, int comm_keyval, + void* extra_state, + void* attribute_val_in, + void* attribute_val_out, int* flag ) { *flag= 0; return MPI_SUCCESS; } -int MPI_COMM_DUP_FN( MPI_Comm comm, int comm_keyval, void* extra_state, +int OMPI_C_MPI_COMM_DUP_FN( MPI_Comm comm, int comm_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, int* flag ) { @@ -83,24 +112,24 @@ int MPI_COMM_DUP_FN( MPI_Comm comm, int comm_keyval, void* extra_state, return MPI_SUCCESS; } -int MPI_NULL_DELETE_FN( MPI_Comm comm, int comm_keyval, - void* attribute_val_out, - void* flag ) +int OMPI_C_MPI_NULL_DELETE_FN( MPI_Comm comm, int comm_keyval, + void* attribute_val_out, + void* flag ) { return MPI_SUCCESS; } -int MPI_NULL_COPY_FN( MPI_Comm comm, int comm_keyval, void* extra_state, - void* attribute_val_in, void* attribute_val_out, - int* flag ) +int OMPI_C_MPI_NULL_COPY_FN( MPI_Comm comm, int comm_keyval, void* extra_state, + void* attribute_val_in, void* attribute_val_out, + int* flag ) { *flag= 0; return MPI_SUCCESS; } -int MPI_DUP_FN( MPI_Comm comm, int comm_keyval, void* extra_state, - void* attribute_val_in, void* attribute_val_out, - int* flag ) +int OMPI_C_MPI_DUP_FN( MPI_Comm comm, int comm_keyval, void* extra_state, + void* attribute_val_in, void* attribute_val_out, + int* flag ) { *flag = 1; *(void**)attribute_val_out = attribute_val_in; diff --git a/src/mpi/f77/attr_fn_f.c b/src/mpi/f77/attr_fn_f.c index f3e3cdc0f8..555e3a3905 100644 --- a/src/mpi/f77/attr_fn_f.c +++ b/src/mpi/f77/attr_fn_f.c @@ -148,6 +148,29 @@ OMPI_GENERATE_F77_BINDINGS( MPI_WIN_DUP_FN, (window, win_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) ) #endif +/* + * Note that in this file, we invoke OMPI_C_ rather than + * , where is MPI_DUP_FN (and all the rest). + * Specifically: + * + * MPI_NULL_DELETE_FN -> OMPI_C_MPI_NULL_DELETE_FN + * MPI_NULL_COPY_FN -> OMPI_C_MPI_NULL_COPY_FN + * MPI_DUP_FN -> OMPI_C_MPI_DUP_FN + * + * MPI_TYPE_NULL_DELETE_FN -> OMPI_C_MPI_TYPE_NULL_DELETE_FN + * MPI_TYPE_NULL_COPY_FN -> OMPI_C_MPI_TYPE_NULL_COPY_FN + * MPI_TYPE_DUP_FN -> OMPI_C_MPI_TYPE_DUP_FN + * + * MPI_COMM_NULL_DELETE_FN -> OMPI_C_MPI_COMM_NULL_DELETE_FN + * MPI_COMM_NULL_COPY_FN -> OMPI_C_MPI_COMM_NULL_COPY_FN + * MPI_COMM_DUP_FN -> OMPI_C_MPI_COMM_DUP_FN + * + * MPI_WIN_NULL_DELETE_FN -> OMPI_C_MPI_WIN_NULL_DELETE_FN + * MPI_WIN_NULL_COPY_FN -> OMPI_C_MPI_WIN_NULL_COPY_FN + * MPI_WIN_DUP_FN -> OMPI_C_MPI_WIN_DUP_FN + * + * The reason why is discussed in a lengthy comment in mpi.h. + */ void mpi_type_null_delete_fn_f( MPI_Fint* type, int* type_keyval, void* attribute_val_out, int* flag, int* ierr ) {