diff --git a/src/mpi/interface/c/Makefile.am b/src/mpi/interface/c/Makefile.am index 705c229941..79b770a20f 100644 --- a/src/mpi/interface/c/Makefile.am +++ b/src/mpi/interface/c/Makefile.am @@ -22,10 +22,12 @@ noinst_LTLIBRARIES = libmpi_c.la headers = bindings.h libmpi_c_la_SOURCES = \ + alloc_mem.c \ comm_get_name.c \ comm_set_name.c \ init.c \ - finalize.c + finalize.c \ + free_mem.c libmpi_c_la_LIBADD = $(profile_lib) diff --git a/src/mpi/interface/c/alloc_mem.c b/src/mpi/interface/c/alloc_mem.c new file mode 100644 index 0000000000..d504da6fca --- /dev/null +++ b/src/mpi/interface/c/alloc_mem.c @@ -0,0 +1,34 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include + +#include "mpi.h" +#include "mpi/c/bindings.h" + +#if LAM_WANT_MPI_PROFILING && LAM_HAVE_WEAK_SYMBOLS +#pragma weak PMPI_Alloc_mem = MPI_Alloc_mem +#endif + + +int MPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr) +{ + if (size < 0) { + /* Return error on MPI_COMM_WORLD */ + } + if (baseptr == NULL) { + /* Return error on MPI_COMM_WORLD */ + } + + /* Check the MPI_Info and see if we requested a specific MCA + type/module. If so, invoke that module's alloc_mem function + (query the MCA base ?or the type base? to find the module and/or + invoke the alloc_mem on it). Otherwise, call malloc(). + + If either fails, return an error on MPI_COMM_WORLD. */ + + return MPI_SUCCESS; +} diff --git a/src/mpi/interface/c/free_mem.c b/src/mpi/interface/c/free_mem.c new file mode 100644 index 0000000000..5323d160d1 --- /dev/null +++ b/src/mpi/interface/c/free_mem.c @@ -0,0 +1,30 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include + +#include "mpi.h" + +#if LAM_WANT_MPI_PROFILING && LAM_HAVE_WEAK_SYMBOLS +#pragma weak PMPI_Free_mem = MPI_Free_mem +#endif + + +int MPI_Free_mem(void *baseptr) +{ + if (baseptr == NULL) { + /* Return error on MPI_COMM_WORLD */ + } + + /* Look and see if this pointer was allocated with a specific + MPI_Info that got the memory from a module's alloc_mem function. + If so, call the module's corresponding free_mem function. + Otherwise, call free(). + + If either fails, return an error on MPI_COMM_WORLD. */ + + return MPI_SUCCESS; +} diff --git a/src/mpi/interface/c/profile/Makefile.am b/src/mpi/interface/c/profile/Makefile.am index 5834e23c83..9924cfbc43 100644 --- a/src/mpi/interface/c/profile/Makefile.am +++ b/src/mpi/interface/c/profile/Makefile.am @@ -22,10 +22,12 @@ noinst_LTLIBRARIES = $(lib) headers = defines.h nodist_libmpi_c_profile_la_SOURCES = \ + palloc_mem.c \ pcomm_get_name.c \ pcomm_set_name.c \ pinit.c \ - pfinalize.c + pfinalize.c \ + pfree_mem.c # Sym link in the sources from the real MPI directory diff --git a/src/mpi/interface/f77/Makefile.am b/src/mpi/interface/f77/Makefile.am index cf50a4c1c1..7cf3ed547b 100644 --- a/src/mpi/interface/f77/Makefile.am +++ b/src/mpi/interface/f77/Makefile.am @@ -36,10 +36,12 @@ headers = \ prototypes.h libmpi_f77_la_SOURCES = \ + alloc_mem_f.c \ comm_get_name_f.c \ comm_set_name_f.c \ init_f.c \ - finalize_f.c + finalize_f.c \ + free_mem_f.c libmpi_f77_la_LIBADD = $(profile_lib) diff --git a/src/mpi/interface/f77/alloc_mem_f.c b/src/mpi/interface/f77/alloc_mem_f.c new file mode 100644 index 0000000000..de3226a8bd --- /dev/null +++ b/src/mpi/interface/f77/alloc_mem_f.c @@ -0,0 +1,33 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include + +#include "mpi.h" +#include "mpi/f77/bindings.h" + +#if LAM_HAVE_WEAK_SYMBOLS +#pragma weak MPI_ALLOC_MEM = mpi_alloc_mem_f +#pragma weak mpi_alloc_mem = mpi_alloc_mem_f +#pragma weak mpi_alloc_mem_ = mpi_alloc_mem_f +#pragma weak mpi_alloc_mem__ = mpi_alloc_mem_f +#if LAM_WANT_MPI_PROFILING +#pragma weak PMPI_ALLOC_MEM = mpi_alloc_mem_f +#pragma weak pmpi_alloc_mem = mpi_alloc_mem_f +#pragma weak pmpi_alloc_mem_ = mpi_alloc_mem_f +#pragma weak pmpi_alloc_mem__ = mpi_alloc_mem_f +#endif +#endif + + +void mpi_alloc_mem_(int *size, int *info, char *baseptr, int *ierr) +{ +#if 0 + /* JMS Need fortran -> C handle lookups, and a safe way to do the + baseptr pointer */ + *ierr = MPI_Alloc_mem(*size, GETHDL(*info), BUF(baseptr)); +#endif +} diff --git a/src/mpi/interface/f77/free_mem_f.c b/src/mpi/interface/f77/free_mem_f.c new file mode 100644 index 0000000000..e8cc6886e8 --- /dev/null +++ b/src/mpi/interface/f77/free_mem_f.c @@ -0,0 +1,33 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include + +#include "mpi.h" +#include "mpi/f77/bindings.h" + +#if LAM_HAVE_WEAK_SYMBOLS +#pragma weak MPI_FREE_MEM = mpi_free_mem_f +#pragma weak mpi_free_mem = mpi_free_mem_f +#pragma weak mpi_free_mem_ = mpi_free_mem_f +#pragma weak mpi_free_mem__ = mpi_free_mem_f +#if LAM_WANT_MPI_PROFILING +#pragma weak PMPI_FREE_MEM = mpi_free_mem_f +#pragma weak pmpi_free_mem = mpi_free_mem_f +#pragma weak pmpi_free_mem_ = mpi_free_mem_f +#pragma weak pmpi_free_mem__ = mpi_free_mem_f +#endif +#endif + + +void mpi_free_mem_(char *baseptr, int *ierr) +{ +#if 0 + /* JMS Need fortran -> C handle lookups, and a safe way to do the + baseptr pointer */ + *ierr = MPI_Free_mem(BUF(baseptr)); +#endif +} diff --git a/src/mpi/interface/f77/profile/Makefile.am b/src/mpi/interface/f77/profile/Makefile.am index d0bcbad5e8..e2d55dfe04 100644 --- a/src/mpi/interface/f77/profile/Makefile.am +++ b/src/mpi/interface/f77/profile/Makefile.am @@ -27,10 +27,12 @@ noinst_LTLIBRARIES = $(f77_lib) headers = defines.h nodist_libmpi_f77_profile_la_SOURCES = \ + palloc_mem_f.c \ pcomm_get_name_f.c \ pcomm_set_name_f.c \ pinit_f.c \ - pfinalize_f.c + pfinalize_f.c \ + pfree_mem_f.c # Sym link in the sources from the real MPI directory