Add support for profiling, both via weak symbols and separate compilation.
This commit was SVN r164.
Этот коммит содержится в:
родитель
2620d1fd22
Коммит
034d0ebcb5
@ -22,9 +22,10 @@ DIST_SUBDIRS = profile
|
||||
noinst_LTLIBRARIES = libmpi_c.la
|
||||
|
||||
libmpi_c_la_SOURCES = \
|
||||
bindings.h \
|
||||
bindings_profiling.h \
|
||||
comm_get_name.c \
|
||||
comm_set_name.c \
|
||||
datatype_get_name.c \
|
||||
datatype_set_name.c \
|
||||
profiling.h
|
||||
init.c \
|
||||
finalize.c \
|
||||
libmpi_c_la_LIBADD = $(profile_lib)
|
||||
|
25
src/mpi/interface/c/bindings.h
Обычный файл
25
src/mpi/interface/c/bindings.h
Обычный файл
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef LAM_C_BINDINGS_H
|
||||
#define LAM_C_BINDINGS_H
|
||||
|
||||
#include "lam_config.h"
|
||||
#include "mpi.h"
|
||||
|
||||
#ifndef LAM_PROFILING_DEFINES
|
||||
#define LAM_PROFILING_DEFINES 0
|
||||
#endif
|
||||
|
||||
/* If compiling in the profile directory, then we don't have weak
|
||||
symbols and therefore we need the defines to map from MPI->PMPI.
|
||||
NOTE: pragma weak stuff is handled on a file-by-file basis; it
|
||||
doesn't work to simply list all of the pragmas in a top-level
|
||||
header file. */
|
||||
|
||||
#if LAM_PROFILING_DEFINES
|
||||
#include "mpi/c/profile/defines.h"
|
||||
#endif
|
||||
|
||||
#endif /* LAM_C_BINDINGS_H */
|
@ -6,8 +6,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "mpi.h"
|
||||
#include "mpi/c/profiling.h"
|
||||
#include "mpi/c/bindings.h"
|
||||
#include "lam/util/strncpy.h"
|
||||
#include "communicator.h"
|
||||
#include "totalview.h"
|
||||
@ -16,6 +15,7 @@
|
||||
#pragma weak PMPI_Comm_set_name = MPI_Comm_set_name
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
MPI_Comm_set_name(MPI_Comm comm, char *name)
|
||||
{
|
||||
|
@ -9,11 +9,13 @@ AM_CPPFLAGS = -DLAM_PROFILING_DEFINES=1
|
||||
|
||||
noinst_LTLIBRARIES = libmpi_c_profile.la
|
||||
|
||||
noinst_HEADERS = defines.h
|
||||
|
||||
nodist_libmpi_c_profile_la_SOURCES= \
|
||||
pcomm_get_name.c \
|
||||
pcomm_set_name.c \
|
||||
pdatatype_get_name.c \
|
||||
pdatatype_set_name.c
|
||||
pinit.c \
|
||||
pfinalize.c
|
||||
|
||||
# Sym link in the sources from the real MPI directory
|
||||
|
||||
|
20
src/mpi/interface/c/profile/defines.h
Обычный файл
20
src/mpi/interface/c/profile/defines.h
Обычный файл
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef LAM_C_PROFILE_DEFINES_H
|
||||
#define LAM_C_PROFILE_DEFINES_H
|
||||
|
||||
/*
|
||||
* This file contains the #defines for the profiled versions of all
|
||||
* the MPI C bindings. It is only included if we do not have weak
|
||||
* symbols, or weak symbol support was explicitly disabled.
|
||||
*/
|
||||
|
||||
#if LAM_PROFILING_DEFINES
|
||||
#define MPI_Comm_set_name PMPI_Comm_set_name
|
||||
#define MPI_Init PMPI_Init
|
||||
#define MPI_Finalize PMPI_Finalize
|
||||
#endif
|
||||
|
||||
#endif /* LAM_C_PROFILE_DEFINES_H */
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef LAM_MPI_C_PROFILING_H
|
||||
#define LAM_MPI_C_PROFILING_H
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
/* Unless explicitly asked for (i.e., when we're compiling in
|
||||
src/mpi/<lang>/profile, don't automatically convert MPI_Foo ->
|
||||
PMPI_Foo via #defines. */
|
||||
|
||||
#ifndef LAM_PROFILING_DEFINES
|
||||
#define LAM_PROFILING_DEFINES 0
|
||||
#endif
|
||||
|
||||
/* If requested, add a #define for each MPI function to convert it to
|
||||
it's PMPI equivalent. */
|
||||
|
||||
#if LAM_PROFILING_DEFINES
|
||||
#define MPI_Comm_set_name PMPI_Comm_set_name
|
||||
#endif
|
||||
|
||||
#endif /* LAM_MPI_C_PROFILING_H */
|
@ -22,10 +22,11 @@ DIST_SUBDIRS = profile
|
||||
noinst_LTLIBRARIES = libmpi_f77.la
|
||||
|
||||
libmpi_f77_la_SOURCES = \
|
||||
bindings.h \
|
||||
comm_get_name_f.c \
|
||||
comm_set_name_f.c \
|
||||
datatype_get_name_f.c \
|
||||
datatype_set_name_f.c \
|
||||
profiling.h
|
||||
init_f.c \
|
||||
finalize_f.c \
|
||||
prototypes.h
|
||||
|
||||
libmpi_f77_la_LIBADD = $(profile_lib)
|
||||
|
46
src/mpi/interface/f77/bindings.h
Обычный файл
46
src/mpi/interface/f77/bindings.h
Обычный файл
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef LAM_F77_BINDINGS_H
|
||||
#define LAM_F77_BINDINGS_H
|
||||
|
||||
#include "lam_config.h"
|
||||
#include "mpi.h"
|
||||
|
||||
/*
|
||||
* If we have no weak symbols, then get the #defines to map from the
|
||||
* LAM-native mpi_foo_f function to the profiled or non-profiled
|
||||
* function name in the right fortran external symbol convention.
|
||||
* Yes, kids, that's one of 8 possible sets of #define's. :-\
|
||||
*/
|
||||
|
||||
#include "mpi/f77/prototypes.h"
|
||||
|
||||
#if LAM_HAVE_WEAK_SYMBOLS
|
||||
/* If we have weak symbols, then we compile the functions as the
|
||||
LAM-native mpi_foo_f and use the weak symbols to create the
|
||||
aliases. We include the prototypes for the profiled versions of
|
||||
the MPI functions here because some compilers won't generate weak
|
||||
symbols unless the real symbols are at least prototyped. We only
|
||||
include the profiled prototypes if we're doing weak symbols because
|
||||
the profiled prototypes are generated with #defines that map
|
||||
mpi->pmpi and MPI->PMPI, which screws up the non-weak-symbols stuff
|
||||
(because they have their own #defines). */
|
||||
#include "mpi/f77/profile/prototypes.h"
|
||||
#else
|
||||
/* We don't have weak symbols. */
|
||||
#if LAM_PROFILING_DEFINES
|
||||
/* If we're compiling in the profile/ directory, then
|
||||
LAM_PROFILING_DEFINES will be 1. In this case, get the defines
|
||||
mapping from mpi_foo_f to the profiling name in the proper symbol
|
||||
convention. */
|
||||
#include "mpi/f77/profile/defines.h"
|
||||
#else
|
||||
/* Otherwise, we're compiling in the main directory, so get the
|
||||
defines mapping from mpi_foo_f to the proper symbol convention. */
|
||||
#include "mpi/f77/defines.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* LAM_F77_BINDINGS_H */
|
@ -4,41 +4,29 @@
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "mpi.h"
|
||||
#if 0
|
||||
/* JMS Need to continue here */
|
||||
#include "mpi/f77/profiling.h"
|
||||
#endif
|
||||
#include "mpi/f77/bindings.h"
|
||||
|
||||
#if LAM_HAVE_WEAK_SYMBOLS
|
||||
#include "mpi/f77/weak_prototypes.h"
|
||||
#pragma weak MPI_COMM_SET_NAME = mpi_comm_set_name_f
|
||||
#pragma weak mpi_comm_set_name = mpi_comm_set_name_f
|
||||
#pragma weak mpi_comm_set_name_ = mpi_comm_set_name_f
|
||||
#pragma weak mpi_comm_set_name__ = mpi_comm_set_name_f
|
||||
#pragma weak mpi_comm_set_name = mpi_comm_set_name_f
|
||||
#pragma weak MPI_COMM_SET_NAME = mpi_comm_set_name_f
|
||||
|
||||
#if LAM_WANT_MPI_PROFILING
|
||||
#pragma weak PMPI_COMM_SET_NAME = mpi_comm_set_name_f
|
||||
#pragma weak pmpi_comm_set_name = mpi_comm_set_name_f
|
||||
#pragma weak pmpi_comm_set_name_ = mpi_comm_set_name_f
|
||||
#pragma weak pmpi_comm_set_name__ = mpi_comm_set_name_f
|
||||
#pragma weak pmpi_comm_set_name = mpi_comm_set_name_f
|
||||
#pragma weak PMPI_COMM_SET_NAME = mpi_comm_set_name_f
|
||||
|
||||
#endif
|
||||
#else
|
||||
#if 0
|
||||
/* JMS Need to continue here */
|
||||
//#include "mpi-fortran-"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int
|
||||
mpi_comm_set_name_f(int *comm, char *name)
|
||||
|
||||
void
|
||||
mpi_comm_set_name_f(int *comm, char *name, int *ierror, int charlen)
|
||||
{
|
||||
/* JMS: Translate comm from int to MPI_Comm */
|
||||
|
||||
MPI_Comm c_comm = MPI_COMM_WORLD;
|
||||
|
||||
return MPI_Comm_set_name(c_comm, name);
|
||||
*ierror = MPI_Comm_set_name(c_comm, name);
|
||||
}
|
||||
|
50
src/mpi/interface/f77/defines.h
Обычный файл
50
src/mpi/interface/f77/defines.h
Обычный файл
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef LAM_F77_DEFINES_H
|
||||
#define LAM_F77_DEFINES_H
|
||||
|
||||
/*
|
||||
* This file makes a mapping from mpi_foo_f to the proper fortran
|
||||
* external symbol convention via 4 sets of #define's.
|
||||
*
|
||||
* This file is never included at the same time as
|
||||
* mpi/f77/profile/prototypes.h (some of the #define's conflict).
|
||||
*/
|
||||
|
||||
/*
|
||||
* First, all caps.
|
||||
*/
|
||||
#if LAM_F77_CAPS
|
||||
#define mpi_comm_set_name_f MPI_COMM_SET_NAME
|
||||
#define mpi_init_f MPI_INIT
|
||||
#define mpi_finalize_f MPI_FINALIZE
|
||||
|
||||
/*
|
||||
* Second, all lower case.
|
||||
*/
|
||||
#elif LAM_F77_PLAIN
|
||||
#define mpi_comm_set_name_f mpi_comm_set_name
|
||||
#define mpi_init_f mpi_init
|
||||
#define mpi_finalize_f mpi_finalize
|
||||
|
||||
/*
|
||||
* Third, one trailing underscore.
|
||||
*/
|
||||
#elif LAM_F77_SINGLE_UNDERSCORE
|
||||
#define mpi_comm_set_name_f mpi_comm_set_name_
|
||||
#define mpi_init_f mpi_init_
|
||||
#define mpi_finalize_f mpi_finalize_
|
||||
|
||||
/*
|
||||
* Fourth, two trailing underscores.
|
||||
*/
|
||||
#elif LAM_F77_DOUBLE_UNDERSCORE
|
||||
#define mpi_comm_set_name_f mpi_comm_set_name__
|
||||
#define mpi_init_f mpi_init__
|
||||
#define mpi_finalize_f mpi_finalize__
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* LAM_F77_DEFINES_H */
|
@ -9,11 +9,13 @@ AM_CPPFLAGS = -DLAM_PROFILING_DEFINES=1
|
||||
|
||||
noinst_LTLIBRARIES = libmpi_f77_profile.la
|
||||
|
||||
noinst_HEADERS = defines.h
|
||||
|
||||
nodist_libmpi_f77_profile_la_SOURCES= \
|
||||
pcomm_get_name_f.c \
|
||||
pcomm_set_name_f.c \
|
||||
pdatatype_get_name_f.c \
|
||||
pdatatype_set_name_f.c
|
||||
pinit_f.c \
|
||||
pfinalize_f.c
|
||||
|
||||
# Sym link in the sources from the real MPI directory
|
||||
|
||||
|
48
src/mpi/interface/f77/profile/defines.h
Обычный файл
48
src/mpi/interface/f77/profile/defines.h
Обычный файл
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef LAM_F77_PROFILE_DEFINES_H
|
||||
#define LAM_F77_PROFILE_DEFINES_H
|
||||
|
||||
/*
|
||||
* This file makes a mapping from mpi_foo_f to the profiled version of
|
||||
* the proper fortran external symbol convention via 4 sets of
|
||||
* #define's.
|
||||
*/
|
||||
|
||||
/*
|
||||
* First, all caps.
|
||||
*/
|
||||
#if LAM_F77_CAPS
|
||||
#define mpi_comm_set_name_f PMPI_COMM_SET_NAME
|
||||
#define mpi_init_f PMPI_INIT
|
||||
#define mpi_finalize_f PMPI_FINALIZE
|
||||
|
||||
/*
|
||||
* Second, all lower case.
|
||||
*/
|
||||
#elif LAM_F77_PLAIN
|
||||
#define mpi_comm_set_name_f pmpi_comm_set_name
|
||||
#define mpi_init_f pmpi_init
|
||||
#define mpi_finalize_f pmpi_finalize
|
||||
|
||||
/*
|
||||
* Third, one trailing underscore.
|
||||
*/
|
||||
#elif LAM_F77_SINGLE_UNDERSCORE
|
||||
#define mpi_comm_set_name_f pmpi_comm_set_name_
|
||||
#define mpi_init_f pmpi_init_
|
||||
#define mpi_finalize_f pmpi_finalize_
|
||||
|
||||
/*
|
||||
* Fourth, two trailing underscores.
|
||||
*/
|
||||
#elif LAM_F77_DOUBLE_UNDERSCORE
|
||||
#define mpi_comm_set_name_f pmpi_comm_set_name__
|
||||
#define mpi_init_f pmpi_init__
|
||||
#define mpi_finalize_f pmpi_finalize__
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* LAM_F77_PROFILE_DEFINES_H */
|
54
src/mpi/interface/f77/profile/prototypes.h
Обычный файл
54
src/mpi/interface/f77/profile/prototypes.h
Обычный файл
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef LAM_F77_PROTOTYPES_PROFILING_H
|
||||
#define LAM_F77_PROTOTYPES_PROFILING_H
|
||||
|
||||
/*
|
||||
* This file prototypes all profiled MPI fortran functions in all four
|
||||
* fortran symbol conventions. It is only included when we need the
|
||||
* profiling prototypes.
|
||||
*
|
||||
* Save some coding (i.e., don't re-specify all the return types and
|
||||
* function arguments) -- make #define's to make from mpi->pmpi and
|
||||
* then include mpi/f77/prototypes.h.
|
||||
*
|
||||
* This file is never included at the same time as
|
||||
* mpi/f77/defines.h (some of the #define's conflict).
|
||||
*/
|
||||
|
||||
/*
|
||||
* First, all caps.
|
||||
*/
|
||||
#define MPI_COMM_SET_NAME PMPI_COMM_SET_NAME
|
||||
#define MPI_INIT PMPI_INIT
|
||||
#define MPI_FINALIZE PMPI_FINALIZE
|
||||
|
||||
/*
|
||||
* Second, all lower case.
|
||||
*/
|
||||
#define mpi_comm_set_name pmpi_comm_set_name
|
||||
#define mpi_init pmpi_init
|
||||
#define mpi_finalize pmpi_finalize
|
||||
|
||||
/*
|
||||
* Third, one trailing underscore.
|
||||
*/
|
||||
#define mpi_comm_set_name_ pmpi_comm_set_name_
|
||||
#define mpi_init_ pmpi_init_
|
||||
#define mpi_finalize_ pmpi_finalize_
|
||||
|
||||
/*
|
||||
* Fourth, two trailing underscores.
|
||||
*/
|
||||
#define mpi_comm_set_name__ pmpi_comm_set_name__
|
||||
#define mpi_init__ pmpi_init__
|
||||
#define mpi_finalize__ pmpi_finalize__
|
||||
|
||||
/*
|
||||
* Now include the real prototypes. Magic. :-)
|
||||
*/
|
||||
#include "mpi/f77/prototypes.h"
|
||||
|
||||
#endif /* LAM_F77_PROTOTYPES_PROFILING_H */
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef LAM_MPI_F77_PROFILING_H
|
||||
#define LAM_MPI_F77_PROFILING_H
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
/* Unless explicitly asked for (i.e., when we're compiling in
|
||||
src/mpi/<lang>/profile, don't automatically convert MPI_Foo ->
|
||||
PMPI_Foo via #defines. */
|
||||
|
||||
#ifndef LAM_PROFILING_DEFINES
|
||||
#define LAM_PROFILING_DEFINES 0
|
||||
#endif
|
||||
|
||||
/* If requested, add a #define for each MPI function to convert it to
|
||||
it's PMPI equivalent. */
|
||||
|
||||
#if LAM_PROFILING_DEFINES
|
||||
#if LAM_FORTRAN_CAPS
|
||||
#define mpi_comm_set_name_f MPI_COMM_SET_NAME
|
||||
#elif LAM_FORTRAN_NO_UNDERSCORE
|
||||
#define mpi_comm_set_name_f mpi_comm_set_name
|
||||
#elif LAM_FORTRAN_SINGLE_UNDERSCORE
|
||||
#define mpi_comm_set_name_f mpi_comm_set_name_
|
||||
#elif LAM_FORTRAN_DOUBLE_UNDERSCORE
|
||||
#define mpi_comm_set_name_f mpi_comm_set_name__
|
||||
#else
|
||||
#error I do not know how your fortran compiler exports symbols. :-(
|
||||
#endif
|
||||
|
||||
#endif /* LAM_MPI_F77_PROFILING_H */
|
59
src/mpi/interface/f77/prototypes.h
Обычный файл
59
src/mpi/interface/f77/prototypes.h
Обычный файл
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/*
|
||||
* THIS FILE IS SPECIAL: IT HAS NOT MULTIPLE-INCLUDE PROTECTION!
|
||||
*
|
||||
* It is designed to be included twice: once by mpi/f77/prototypes.h
|
||||
* to get all the "native" prototypes, then again by
|
||||
* mpi/f77/profile/prototypes after a bunch of #define's have been
|
||||
* applied to map mpi->pmpi and MPI->PMPI.
|
||||
*
|
||||
* This is necessary to get the profiling prototypes. This is even
|
||||
* necessary when using weak symbols because some compilers will not
|
||||
* generate a weak symbol unless the "real" function is at least
|
||||
* prototyped.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file prototypes all MPI fortran functions in all four fortran
|
||||
* symbol conventions as well as all the internal "real" LAM wrapper
|
||||
* functions (different from any of the four fortran symbol
|
||||
* conventions for clarity, at the cost of more typing for me...).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Zeroth, the LAM wrapper functions, with a "_f" suffix.
|
||||
*/
|
||||
void mpi_comm_set_name_f(int *comm, char *name, int *ierror, int charlen);
|
||||
void mpi_init_f(int *ierror);
|
||||
void mpi_finalize_f(int *ierror);
|
||||
|
||||
/*
|
||||
* First, all caps.
|
||||
*/
|
||||
void MPI_COMM_SET_NAME(int *comm, char *name, int *ierror, int charlen);
|
||||
void MPI_INIT(void *ierror);
|
||||
void MPI_FINALIZE(int *ierror);
|
||||
|
||||
/*
|
||||
* Second, all lower case.
|
||||
*/
|
||||
void mpi_comm_set_name(int *comm, char *name, int *ierror, int charlen);
|
||||
void mpi_init(int *ierror);
|
||||
void mpi_finalize(int *ierror);
|
||||
|
||||
/*
|
||||
* Third, one trailing underscore.
|
||||
*/
|
||||
void mpi_comm_set_name_(int *comm, char *name, int *ierror, int charlen);
|
||||
void mpi_init_(int *ierror);
|
||||
void mpi_finalize_(int *ierror);
|
||||
|
||||
/*
|
||||
* Fourth, two trailing underscores.
|
||||
*/
|
||||
void mpi_comm_set_name__(int *comm, char *name, int *ierror, int charlen);
|
||||
void mpi_init__(int *ierror);
|
||||
void mpi_finalize__(int *ierror);
|
Загрузка…
Ссылка в новой задаче
Block a user