From 9cc317556782809a0e0d804b7895cfa70794bf8f Mon Sep 17 00:00:00 2001 From: carns Date: Wed, 28 Oct 2009 22:08:45 +0000 Subject: [PATCH] adapted test compilers to match the others git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@87 3b7491f3-a168-0410-bf4b-c445ed680a29 --- compilers/mpicc-trace-pcarns.in | 48 +++++++++++++++++++++++++++----- compilers/mpicxx-trace-pcarns.in | 48 +++++++++++++++++++++++++++----- compilers/mpif77-trace-pcarns.in | 48 +++++++++++++++++++++++++++----- 3 files changed, 123 insertions(+), 21 deletions(-) diff --git a/compilers/mpicc-trace-pcarns.in b/compilers/mpicc-trace-pcarns.in index 5731064..6ae5ec7 100755 --- a/compilers/mpicc-trace-pcarns.in +++ b/compilers/mpicc-trace-pcarns.in @@ -234,13 +234,47 @@ if [ "$linking" = yes ] ; then # prepend the path for the shared libraries to the library list mpilibs="$C_LINKPATH_SHL$libdir $mpilibs" fi - # check to see if the command line refers to any profilers that might - # use PMPI. - profiler_check=`echo "${allargs[@]}" | ${DARSHAN_BIN_PATH}/darshan-pmpi-filter.sh` - if [ "$profiler_check" = "" ] ; then - $Show $CC $CFLAGS ${CP_WRAPPERS} $LDFLAGS "${allargs[@]}" -L${DARSHAN_LIB_PATH} ${CP_ZLIB_LINK_FLAGS} -ldarshan-mpi-io -lz -I$includedir -L$libdir $mpilibs $MPI_OTHERLIBS -L${DARSHAN_LIB_PATH} -ldarshan-posix - else - $Show $CC $CFLAGS $LDFLAGS "${allargs[@]}" -I$includedir -L$libdir $mpilibs $MPI_OTHERLIBS + + # Trial run to generate a symbol listing. We only enable Darshan if: + # a) MPI is used + # b) PMPI is _not_ used + # + # We want Darshan to get out of the way if the user is doing a runtime + # test in configure (in which case MPI objects break the executable) or + # if the user is using another PMPI based tool + + stock_link_cmd="$CC ${allargs[@]} -I$includedir $CFLAGS $LDFLAGS -L$libdir $mpilibs $MPI_OTHERLIBS" + + darshan_link_cmd="$CC ${allargs[@]} -L${DARSHAN_LIB_PATH} ${CP_ZLIB_LINK_FLAGS} -ldarshan-mpi-io -lz -I$includedir $CFLAGS ${CP_WRAPPERS} $LDFLAGS -L$libdir $mpilibs $MPI_OTHERLIBS -L${DARSHAN_LIB_PATH} -ldarshan-posix" + + used_darshan=0 + + # create a temporary file + tmpfile=`mktemp` + # generate a map of the symbol names + $stock_link_cmd -Wl,-Map,$tmpfile $LDFLAGS -o /dev/null >& /dev/null + # is MPI in there? + grep MPI $tmpfile >& /dev/null + rc_mpi=$? + # is PMPI in there (except for the mpich library itself)? + grep \(PMPI $tmpfile | grep -v mpich.a >& /dev/null + rc_pmpi=$? + rm $tmpfile >& /dev/null + + # disable darshan if the executable is not an MPI program (this feature + # mainly allows runtime configure tests to work + if [ $rc_mpi -eq 0 ] ; then + # disable darshan if something else is already using PMPI; we don't + # want to cause any symbol conflicts + if [ $rc_pmpi -ne 0 ] ; then + $Show $darshan_link_cmd + used_darshan=1 + fi + fi + + # otherwise use the normal command line + if [ "$used_darshan" = "0" ] ; then + $Show $stock_link_cmd fi rc=$? else diff --git a/compilers/mpicxx-trace-pcarns.in b/compilers/mpicxx-trace-pcarns.in index e737b03..b6d809d 100755 --- a/compilers/mpicxx-trace-pcarns.in +++ b/compilers/mpicxx-trace-pcarns.in @@ -234,13 +234,47 @@ if [ "$linking" = yes ] ; then # Prepend the path for the shared libraries to the library list shllibpath="$CXX_LINKPATH_SHL$libdir" fi - # check to see if the command line refers to any profilers that might - # use PMPI. - profiler_check=`echo "${allargs[@]}" | ${DARSHAN_BIN_PATH}/darshan-pmpi-filter.sh` - if [ "$profiler_check" = "" ] ; then - $Show $CXX $CXXFLAGS ${CP_WRAPPERS} $LDFLAGS "${allargs[@]}" -L${DARSHAN_LIB_PATH} ${CP_ZLIB_LINK_FLAGS} -lmpichcxx -ldarshan-mpi-io -lz -I$includedir -L$libdir $shllibpath $cxxlibs $mpilibs $MPI_OTHERLIBS -L${DARSHAN_LIB_PATH} -ldarshan-posix - else - $Show $CXX $CXXFLAGS $LDFLAGS "${allargs[@]}" -lmpichcxx -I$includedir -L$libdir $shllibpath $cxxlibs $mpilibs $MPI_OTHERLIBS + + # Trial run to generate a symbol listing. We only enable Darshan if: + # a) MPI is used + # b) PMPI is _not_ used + # + # We want Darshan to get out of the way if the user is doing a runtime + # test in configure (in which case MPI objects break the executable) or + # if the user is using another PMPI based tool + + stock_link_cmd="$CXX ${allargs[@]} -I$includedir $CXXFLAGS $LDFLAGS -L$libdir $shllibpath $cxxlibs $mpilibs $MPI_OTHERLIBS" + + darshan_link_cmd="$CXX ${allargs[@]} -L${DARSHAN_LIB_PATH} ${CP_ZLIB_LINK_FLAGS} -lmpichcxx -ldarshan-mpi-io -lz -I$includedir $CXXFLAGS ${CP_WRAPPERS} $LDFLAGS -L$libdir $shllibpath $cxxlibs $mpilibs $MPI_OTHERLIBS -L${DARSHAN_LIB_PATH} -ldarshan-posix" + + used_darshan=0 + + # create a temporary file + tmpfile=`mktemp` + # generate a map of the symbol names + $stock_link_cmd -Wl,-Map,$tmpfile $LDFLAGS -o /dev/null >& /dev/null + # is MPI in there? + grep MPI $tmpfile >& /dev/null + rc_mpi=$? + # is PMPI in there (except for the mpich library itself)? + grep \(PMPI $tmpfile | grep -E -v \(mpich.a\)\|\(mpichcxx.a\) >& /dev/null + rc_pmpi=$? + rm $tmpfile >& /dev/null + + # disable darshan if the executable is not an MPI program (this feature + # mainly allows runtime configure tests to work + if [ $rc_mpi -eq 0 ] ; then + # disable darshan if something else is already using PMPI; we don't + # want to cause any symbol conflicts + if [ $rc_pmpi -ne 0 ] ; then + $Show $darshan_link_cmd + used_darshan=1 + fi + fi + + # otherwise use the normal command line + if [ "$used_darshan" = "0" ] ; then + $Show $stock_link_cmd fi rc=$? else diff --git a/compilers/mpif77-trace-pcarns.in b/compilers/mpif77-trace-pcarns.in index 8e0c85c..c76fd9a 100755 --- a/compilers/mpif77-trace-pcarns.in +++ b/compilers/mpif77-trace-pcarns.in @@ -280,13 +280,47 @@ if [ "$linking" = yes ] ; then # Prepend the path for the shared libraries to the library list mpilibs="$FC_LINKPATH_SHL$libdir $mpilibs" fi - # check to see if the command line refers to any profilers that might - # use PMPI. - profiler_check=`echo "${allargs[@]}" | ${DARSHAN_BIN_PATH}/darshan-pmpi-filter.sh` - if [ "$profiler_check" = "" ] ; then - $Show $FC $FFLAGS ${CP_WRAPPERS} $LDFLAGS "${allargs[@]}" -L${DARSHAN_LIB_PATH} ${CP_ZLIB_LINK_FLAGS} -lfmpich -ldarshan-mpi-io -lz -I$includedir -L$libdir $mpilibs $MPI_OTHERLIBS -L${DARSHAN_LIB_PATH} -ldarshan-posix - else - $Show $FC $FFLAGS $LDFLAGS "${allargs[@]}" -I$includedir -L$libdir $mpilibs $MPI_OTHERLIBS + + # Trial run to generate a symbol listing. We only enable Darshan if: + # a) MPI is used + # b) PMPI is _not_ used + # + # We want Darshan to get out of the way if the user is doing a runtime + # test in configure (in which case MPI objects break the executable) or + # if the user is using another PMPI based tool + + stock_link_cmd="$FC ${allargs[@]} -I$includedir $FFLAGS $LDFLAGS -L$libdir $mpilibs $MPI_OTHERLIBS" + + darshan_link_cmd="$FC ${CP_WRAPPERS} ${allargs[@]} -L${DARSHAN_LIB_PATH} ${CP_ZLIB_LINK_FLAGS} -lfmpich -ldarshan-posix -ldarshan-mpi-io -I$includedir $FFLAGS $LDFLAGS -L$libdir $mpilibs $MPI_OTHERLIBS -L${DARSHAN_LIB_PATH} -ldarshan-posix -ldarshan-mpi-io -lz" + + used_darshan=0 + + # create a temporary file + tmpfile=`mktemp` + # generate a map of the symbol names + $stock_link_cmd -Wl,-Map,$tmpfile $LDFLAGS -o /dev/null >& /dev/null + # is MPI in there? + grep MPI $tmpfile >& /dev/null + rc_mpi=$? + # is PMPI in there (except for the mpich library itself)? + grep \(PMPI $tmpfile | grep -v mpich.a >& /dev/null + rc_pmpi=$? + rm $tmpfile >& /dev/null + + # disable darshan if the executable is not an MPI program (this feature + # mainly allows runtime configure tests to work + if [ $rc_mpi -eq 0 ] ; then + # disable darshan if something else is already using PMPI; we don't + # want to cause any symbol conflicts + if [ $rc_pmpi -ne 0 ] ; then + $Show $darshan_link_cmd + used_darshan=1 + fi + fi + + # otherwise use the normal command line + if [ "$used_darshan" = "0" ] ; then + $Show $stock_link_cmd fi rc=$? else -- 2.26.2