1
1

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.
Этот коммит содержится в:
Jeff Squyres 2004-09-14 17:03:41 +00:00
родитель edcc35795b
Коммит f6a06fcbb5
2 изменённых файлов: 94 добавлений и 42 удалений

Просмотреть файл

@ -10,7 +10,31 @@
#include "communicator/communicator.h" #include "communicator/communicator.h"
#include "win/win.h" #include "win/win.h"
int MPI_TYPE_NULL_DELETE_FN( MPI_Datatype datatype, int type_keyval, /*
* 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* attribute_val_out,
void* flag ) void* flag )
{ {
@ -18,15 +42,18 @@ int MPI_TYPE_NULL_DELETE_FN( MPI_Datatype datatype, int type_keyval,
return MPI_SUCCESS; return MPI_SUCCESS;
} }
int MPI_TYPE_NULL_COPY_FN( MPI_Datatype datatype, int type_keyval, void* extra_state, int OMPI_C_MPI_TYPE_NULL_COPY_FN( MPI_Datatype datatype, int type_keyval,
void* attribute_val_in, void* attribute_val_out, void* extra_state,
void* attribute_val_in,
void* attribute_val_out,
int* flag ) int* flag )
{ {
*flag = 0; *flag = 0;
return MPI_SUCCESS; return MPI_SUCCESS;
} }
int MPI_TYPE_DUP_FN( MPI_Datatype datatype, int type_keyval, void* extra_state, int OMPI_C_MPI_TYPE_DUP_FN( MPI_Datatype datatype, int type_keyval,
void* extra_state,
void* attribute_val_in, void* attribute_val_out, void* attribute_val_in, void* attribute_val_out,
int* flag ) int* flag )
{ {
@ -35,14 +62,64 @@ int MPI_TYPE_DUP_FN( MPI_Datatype datatype, int type_keyval, void* extra_state,
return MPI_SUCCESS; return MPI_SUCCESS;
} }
int MPI_WIN_NULL_DELETE_FN( MPI_Win window, int win_keyval, int OMPI_C_MPI_WIN_NULL_DELETE_FN( MPI_Win window, int win_keyval,
void* attribute_val_out, void* attribute_val_out,
void* flag ) void* flag )
{ {
return MPI_SUCCESS; return MPI_SUCCESS;
} }
int MPI_WIN_NULL_COPY_FN( MPI_Win window, int win_keyval, void* extra_state, 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 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 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 )
{
*flag = 1;
*(void**)attribute_val_out = attribute_val_in;
return MPI_SUCCESS;
}
int OMPI_C_MPI_NULL_DELETE_FN( MPI_Comm comm, int comm_keyval,
void* attribute_val_out,
void* flag )
{
return MPI_SUCCESS;
}
int OMPI_C_MPI_NULL_COPY_FN( MPI_Comm comm, int comm_keyval, void* extra_state,
void* attribute_val_in, void* attribute_val_out, void* attribute_val_in, void* attribute_val_out,
int* flag ) int* flag )
{ {
@ -50,55 +127,7 @@ int MPI_WIN_NULL_COPY_FN( MPI_Win window, int win_keyval, void* extra_state,
return MPI_SUCCESS; return MPI_SUCCESS;
} }
int MPI_WIN_DUP_FN( MPI_Win window, int win_keyval, void* extra_state, 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;
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,
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,
void* attribute_val_in, void* attribute_val_out,
int* flag )
{
*flag = 1;
*(void**)attribute_val_out = attribute_val_in;
return MPI_SUCCESS;
}
int 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 )
{
*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, void* attribute_val_in, void* attribute_val_out,
int* flag ) int* flag )
{ {

Просмотреть файл

@ -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) ) (window, win_keyval, extra_state, attribute_val_in, attribute_val_out, flag, ierr) )
#endif #endif
/*
* Note that in this file, we invoke OMPI_C_<function> rather than
* <function>, where <function> 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 mpi_type_null_delete_fn_f( MPI_Fint* type, int* type_keyval,
void* attribute_val_out, int* flag, int* ierr ) void* attribute_val_out, int* flag, int* ierr )
{ {