diff --git a/Changes b/Changes index 029242ac6..989d289b4 100644 --- a/Changes +++ b/Changes @@ -29,6 +29,13 @@ Version 2.27 changes (from 2.26): 16. Added support for OMPT TR6 (configure -ompt=download-tr6 with export TAU_OMPT_SUPPORT_LEVEL=full). 17. Added support for LIKWID 4.3.2. 18. Added Python args support. +19. Added support for armflang and armclang/armclang++ compilers. +20. Added -dyninst=download option to simplify installation of DyninstAPI and use with TAU. +21. Updated support for TAU's OMPT TR6 (-download=ompt-tr6). +22. Updated TAU's ParaTools Threadspotter [www.threadspotter.com] support in tau_exec (-ptts). +23. Added support for IBM XL compilers with MVAPICH2 under IBM Power Linux Power 9 + GPU platform. +24. Updated MPC support in TAU. + Version 2.26 changes (from 2.25): 1. Upgraded OMPT to LLVM-0.2 and introduced TAU_OPENMP_RUNTIME_EVENTS=0. diff --git a/apex b/apex index d524984d3..bc636daa5 160000 --- a/apex +++ b/apex @@ -1 +1 @@ -Subproject commit d524984d3dfedc77e07378e3d9093098b4094216 +Subproject commit bc636daa54f158a733a5d7cb0e1349d0af80faaa diff --git a/configure b/configure index 4bcd7ecec..def478c66 100755 --- a/configure +++ b/configure @@ -478,12 +478,13 @@ for arg in "$@"; do echo "Compiler Options:" echo "-c++= ............................ specify the C++ compiler." echo " options [CC|KCC|g++|*xlC*|cxx|pgc++|pgcpp|FCC|guidec++|aCC|c++|ecpc|" - echo " clang++|bgclang++|g++4|g++-*|icpc|scgcc|scpathCC|pathCC|orCC]." + echo " armclang++|clang++|bgclang++|g++4|g++-*|icpc|scgcc|scpathCC|pathCC|orCC]." echo "-cc= ................................ specify the C compiler." - echo " options [cc|gcc|clang|bgclang|gcc4|scgcc|KCC|pgcc|guidec|*xlc*|ecc|pathcc|orcc]." + echo " options [cc|gcc|clang|bgclang|gcc4|scgcc|KCC|pgcc|guidec|*xlc*|ecc|" + echo " armclang|pathcc|orcc]." echo "-fortran= ..................... specify the Fortran compiler." echo " options [gnu|sgi|ibm|ibm64|hp|cray|pgi|absoft|fujitsu|sun|compaq|" - echo " g95|open64|kai|nec|hitachi|intel|absoft|lahey|nagware|pathscale}" + echo " armflang|g95|open64|kai|nec|hitachi|intel|absoft|lahey|nagware|pathscale}" echo " gfortran|gfortran-*|gfortran4]" echo "-upc= ............................. specify the UPC compiler." echo " options [upc|gcc(GNU UPC) |upcc (Berkeley UPC) | cc (Cray CCE UPC)" @@ -630,13 +631,13 @@ for arg in "$@"; do echo " where [OPTIONS] are:" echo "-c++= ............................ specify the C++ compiler." echo " options [CC|KCC|g++|*xlC*|cxx|pgc++|pgcpp|FCC|guidec++|aCC|c++|ecpc|" - echo " clang++|bgclang++|g++4|icpc|scgcc|scpathCC|pathCC|orCC]." + echo " armclang++|clang++|bgclang++|g++4|icpc|scgcc|scpathCC|pathCC|orCC]." echo "-cc= ................................ specify the C compiler." - echo " options [cc|gcc|gcc4|scgcc|clang|pgcc|guidec|*xlc*|ecc|pathcc|orcc]." + echo " options [cc|gcc|gcc4|scgcc|clang|pgcc|guidec|*xlc*|ecc|pathcc|orcc|armclang]." echo "-fortran= ..................... specify the Fortran compiler." echo " options [gnu|sgi|ibm|ibm64|hp|cray|pgi|absoft|fujitsu|sun|compaq|" - echo " g95|open64|kai|nec|hitachi|intel|absoft|lahey|nag|nagware|pathscale}" - echo " gfortran|gfortran-*|gfortran4]" + echo " g95|open64|kai|nec|hitachi|intel|absoft|lahey|nag|nagware|pathscale}" + echo " armflang|gfortran|gfortran-*|gfortran4]" echo "-upc= ............................. specify the UPC compiler." echo " options [upc|gcc(GNU UPC) |upcc (Berkeley UPC) | cc (Cray CCE UPC)" echo "-host= ................ the type of system on which TAU runs" @@ -1113,7 +1114,7 @@ for arg in "$@"; do -cc=*) myarg=`echo $arg | sed 's/-cc=//'` - if [ $myarg = cc -o $myarg = gcc -o $myarg = gcc4 -o $myarg = gcc-5 -o $myarg = gcc-6 -o $myarg = gcc-7 -o $myarg = gcc-8 -o $myarg = KCC -o $myarg = pgcc -o $myarg = guidec -o $myarg = xlc -o $myarg = ecc -o $myarg = icc -o $myarg = powerpc64-linux-gcc -o $myarg = pathcc -o $myarg = fcc -o $myarg = orcc -o $myarg = opencc -o $myarg = qk-pgcc -o $myarg = scgcc -o $myarg = scpathcc -o $myarg = mips64el-gentoo-linux-gnu-gcc -o $myarg = powerpc64-bgq-linux-gcc -o $myarg = powerpc-bgp-linux-gcc -o $myarg = x86_64-w64-mingw32-gcc -o $myarg = mpiicc -o $myarg = mpifcc -o $myarg = mpifccpx -o $myarg = clang -o $myarg = bgclang -o $myarg = mpc_cc -o $myarg = mpc_icc -o $myarg = mpicc -o $myarg = mcc -o $myarg = oshcc ] + if [ $myarg = cc -o $myarg = gcc -o $myarg = gcc4 -o $myarg = gcc-5 -o $myarg = gcc-6 -o $myarg = gcc-7 -o $myarg = gcc-8 -o $myarg = KCC -o $myarg = pgcc -o $myarg = guidec -o $myarg = xlc -o $myarg = ecc -o $myarg = icc -o $myarg = powerpc64-linux-gcc -o $myarg = pathcc -o $myarg = fcc -o $myarg = orcc -o $myarg = opencc -o $myarg = qk-pgcc -o $myarg = scgcc -o $myarg = scpathcc -o $myarg = mips64el-gentoo-linux-gnu-gcc -o $myarg = powerpc64-bgq-linux-gcc -o $myarg = powerpc-bgp-linux-gcc -o $myarg = x86_64-w64-mingw32-gcc -o $myarg = mpiicc -o $myarg = mpifcc -o $myarg = mpifccpx -o $myarg = clang -o $myarg = bgclang -o $myarg = mpc_cc -o $myarg = mpc_icc -o $myarg = mpicc -o $myarg = mcc -o $myarg = oshcc -o $myarg = armclang ] then c_compiler=$myarg @@ -1142,7 +1143,7 @@ for arg in "$@"; do -c++=*) myarg=`echo $arg | sed 's/-c++=//'` - if [ $myarg = CC -o $myarg = KCC -o $myarg = g++ -o $myarg = g++4 -o $myarg = g++-5 -o $myarg = g++-6 -o $myarg = g++-7 -o $myarg = g++-8 -o $myarg = cxx -o $myarg = NCC -o $myarg = pgc++ -o $myarg = pgCC -o $myarg = pgcpp -o $myarg = egcs -o $myarg = FCC -o $myarg = guidec++ -o $myarg = aCC -o $myarg = c++ -o $myarg = ecpc -o $myarg = icpc -o $myarg = powerpc64-linux-g++ -o $myarg = pathCC -o $myarg = orCC -o $myarg = openCC -o $myarg = qk-pgCC -o $myarg = scg++ -o $myarg = scpathCC -o $myarg = mips64el-gentoo-linux-gnu-g++ -o $myarg = powerpc-bgp-linux-g++ -o $myarg = powerpc64-bgq-linux-g++ -o $myarg = mpicxx -o $myarg = x86_64-w64-mingw32-g++ -o $myarg = mpiicpc -o $myarg = mpiFCC -o $myarg = mpiFCCpx -o $myarg = mpc_cxx -o $myarg = mpc_icpc -o $myarg = clang++ -o $myarg = bgclang++ -o $myarg = mpicxx -o $myarg = mcxx -o $myarg = oshCC -o $myarg = oshc++ -o $myarg = oshcxx ] + if [ $myarg = CC -o $myarg = KCC -o $myarg = g++ -o $myarg = g++4 -o $myarg = g++-5 -o $myarg = g++-6 -o $myarg = g++-7 -o $myarg = g++-8 -o $myarg = cxx -o $myarg = NCC -o $myarg = pgc++ -o $myarg = pgCC -o $myarg = pgcpp -o $myarg = egcs -o $myarg = FCC -o $myarg = guidec++ -o $myarg = aCC -o $myarg = c++ -o $myarg = ecpc -o $myarg = icpc -o $myarg = powerpc64-linux-g++ -o $myarg = pathCC -o $myarg = orCC -o $myarg = openCC -o $myarg = qk-pgCC -o $myarg = scg++ -o $myarg = scpathCC -o $myarg = mips64el-gentoo-linux-gnu-g++ -o $myarg = powerpc-bgp-linux-g++ -o $myarg = powerpc64-bgq-linux-g++ -o $myarg = mpicxx -o $myarg = x86_64-w64-mingw32-g++ -o $myarg = mpiicpc -o $myarg = mpiFCC -o $myarg = mpiFCCpx -o $myarg = mpc_cxx -o $myarg = mpc_icpc -o $myarg = clang++ -o $myarg = bgclang++ -o $myarg = mpicxx -o $myarg = mcxx -o $myarg = oshCC -o $myarg = oshc++ -o $myarg = oshcxx -o $myarg = armclang++ ] then cxx_compiler=$myarg if [ $cxx_compiler = mpc_cxx -o $cxx_compiler = mpc_icpc ] @@ -1156,7 +1157,7 @@ for arg in "$@"; do testmp=`echo $myarg | sed -e 's/^mp//'` if [ "y$testxlc" = "y$myarg" -a "y$testmp" = "y$myarg" ] then - echo "WARNING: valid options for c++ are 'CC', 'KCC', 'g++', 'g++4', '*xlC*', 'cxx' , 'NCC', 'egcs', 'pgCC', 'pgcpp', 'FCC', 'guidec++', 'aCC', 'ecpc', 'icpc', 'pathCC', 'c++', 'qk-pgCC', 'x86_64-w64-mingw32-g++', 'mpiicpc', 'mpiFCC', 'mpiFCCpx', 'orCC', 'openCC', 'mpc_cxx', 'mpc_icpc', 'clang++', 'bgclang++', 'mpicxx', 'mcxx', 'oshCC', oshcxx, or 'oshc++' " + echo "WARNING: valid options for c++ are 'CC', 'KCC', 'g++', 'g++4', '*xlC*', 'cxx' , 'NCC', 'egcs', 'pgCC', 'pgcpp', 'FCC', 'guidec++', 'aCC', 'ecpc', 'icpc', 'pathCC', 'c++', 'qk-pgCC', 'x86_64-w64-mingw32-g++', 'mpiicpc', 'mpiFCC', 'mpiFCCpx', 'orCC', 'openCC', 'mpc_cxx', 'mpc_icpc', 'clang++', 'bgclang++', 'mpicxx', 'mcxx', 'oshCC', oshcxx, 'oshc++', or 'armclang++' " # exit 1 else if [ "y$testxlc" != "y$myarg" ] @@ -1180,14 +1181,14 @@ for arg in "$@"; do -fortran=*) myarg=`echo $arg | sed 's/-fortran=//'` - if [ $myarg = gnu -o $myarg = sgi -o $myarg = ibm -o $myarg = ibm64 -o $myarg = hp -o $myarg = cray -o $myarg = pgi -o $myarg = pgf90 -o $myarg = absoft -o $myarg = fujitsu -o $myarg = sun -o $myarg = compaq -o $myarg = kai -o $myarg = hitachi -o $myarg = intel -o $myarg = ifort -o $myarg = nec -o $myarg = absoft -o $myarg = lahey -o $myarg = nagware -o $myarg = nag -o $myarg = pathscale -o $myarg = gfortran -o $myarg = gfortran-5 -o $myarg = gfortran-6 -o $myarg = gfortran-7 -o $myarg = gfortran-8 -o $myarg = gfortran4 -o $myarg = g95 -o $myarg = open64 -o $myarg = openf90 -o $myarg = mpiifort -o $myarg = mpifrtpx -o $myarg = mpifrt -o $myarg = frt -o $myarg = mpif90 -o $myarg = mpc_f77 -o $myarg = mpc_ifort -o $myarg = mpc_gfortran -o $myarg = oshfort -o $myarg = caf ] ; then + if [ $myarg = gnu -o $myarg = sgi -o $myarg = ibm -o $myarg = ibm64 -o $myarg = hp -o $myarg = cray -o $myarg = pgi -o $myarg = pgf90 -o $myarg = absoft -o $myarg = fujitsu -o $myarg = sun -o $myarg = compaq -o $myarg = kai -o $myarg = hitachi -o $myarg = intel -o $myarg = ifort -o $myarg = nec -o $myarg = absoft -o $myarg = lahey -o $myarg = nagware -o $myarg = nag -o $myarg = pathscale -o $myarg = gfortran -o $myarg = gfortran-5 -o $myarg = gfortran-6 -o $myarg = gfortran-7 -o $myarg = gfortran-8 -o $myarg = gfortran4 -o $myarg = g95 -o $myarg = open64 -o $myarg = openf90 -o $myarg = mpiifort -o $myarg = mpifrtpx -o $myarg = mpifrt -o $myarg = frt -o $myarg = mpif90 -o $myarg = mpc_f77 -o $myarg = mpc_ifort -o $myarg = mpc_gfortran -o $myarg = oshfort -o $myarg = caf -o $myarg = armflang ] ; then if [ $myarg = gnu ] ; then fortran_compiler=gfortran else fortran_compiler=$myarg fi else - echo "WARNING: valid options for fortran are 'gnu', 'sgi', 'ibm', 'ibm64', 'hp', 'cray', 'pgi', 'pgf90', 'absoft', 'fujitsu', 'sun', 'compaq', 'kai', 'hitachi', 'intel', 'ifort', 'nec' , 'absoft', 'lahey', 'nag/nagware', 'pathscale', 'gfortran', 'gfortran-*', 'g95', 'open64', 'openf90', 'mpiifort', 'mpifrtpx', 'frtpx', 'frt', 'mpifrt', 'mpif90', 'mpc_f77', or 'mpc_ifort', 'mpc_gfortran', 'oshfort', or 'caf' " + echo "WARNING: valid options for fortran are 'gnu', 'sgi', 'ibm', 'ibm64', 'hp', 'cray', 'pgi', 'pgf90', 'absoft', 'fujitsu', 'sun', 'compaq', 'kai', 'hitachi', 'intel', 'ifort', 'nec' , 'absoft', 'lahey', 'nag/nagware', 'pathscale', 'gfortran', 'gfortran-*', 'g95', 'open64', 'openf90', 'mpiifort', 'mpifrtpx', 'frtpx', 'frt', 'mpifrt', 'mpif90', 'mpc_f77', or 'mpc_ifort', 'mpc_gfortran', 'oshfort', 'caf', or 'armflang' " exit 1 fi shift @@ -1840,6 +1841,12 @@ for arg in "$@"; do shift ;; + -boost=download) + boost=yes + echo "Downloading Boost..." + shift + ;; + -boost=*) boost=yes boostdir=`echo $arg | sed -e 's/-boost=//'` @@ -1881,6 +1888,14 @@ for arg in "$@"; do # shift # ;; + -dyninst=download) + dyninst=yes + boost=yes + download_dyninst=yes + echo "Downloading Dyninst..." + shift + ;; + -dyninst=*) dyninst=yes dyninstdir=`echo $arg | sed -e 's/-dyninst=//'` @@ -3523,6 +3538,9 @@ case $machine in fortran_compiler=gfortran fi fi + if [ "x$fortran_compiler" = "xarmflang" ]; then + fixmakeargs="$fixmakeargs ARMFLANG" + fi if [ $c_compiler = default ] then @@ -3892,6 +3910,9 @@ if [ $cxx_compiler = mpicxx ] ; then if [ "x$fortran_compiler" = "xxlflang" ]; then fixmakeargs="$fixmakeargs XLFLANG" fi + if [ "x$fortran_compiler" = "xarmflang" ]; then + fixmakeargs="$fixmakeargs ARMFLANG" + fi if [ "x$orig_fortran_compiler" = "xcaf" ]; then fortran_compiler=caf fi @@ -4126,8 +4147,8 @@ case $cxx_compiler in if [ "$machine" = ibm64linux ] ; then if [ ! -r $extradircxx/lib/libibmc++.a ]; then - cxxpath=`find $extradircxx -name libibmc++.a -print ` - extradircxx=`echo $cxxpath | sed -e 's@lib/libibmc++.a@@g' ` + cxxpath=`find $extradircxx -name libibmc++.a -print | tail -1` + extradircxx=`echo $cxxpath | sed -e 's@lib/libibmc++.a@@g' -e 's@alllibs/libibmc++.a@@g'` fi fi @@ -6673,7 +6694,6 @@ if [ "x$download_unwind" = xyes ] ; then cd $prebfddir fi #unwind=download - ###################################################################### # Install Scalable Observation System (SOS) if requested ###################################################################### @@ -6745,9 +6765,9 @@ if [ "x$ompt_dir" != "x" -a -d "$ompt_dir" ] ; then if [ -r $ompt_dir/$libomp_osstgz ]; then echo "NOTE: Copying $ompt_dir/$libomp_osstgz" cp $ompt_dir/$libomp_osstgz . - if [ "x$download_ompt" != "xyes" ] ; then - download_ompt_tr6=yes - fi + #if [ "x$download_ompt" != "xyes" ] ; then + # download_ompt_tr6=yes + #fi fi fi @@ -6756,19 +6776,19 @@ fi if [ $gnu = yes ] ; then ompt_c_compiler=gcc ompt_cxx_compiler=g++ - libomp_oss_name=gomp + libomp_oss_name=omp fi if [ "${architecture}" = "craycnl" ] ; then if [ "${intel}" = "yes" ] ; then ompt_c_compiler=icc ompt_cxx_compiler=icpc - libomp_oss_name=iomp5 + libomp_oss_name=omp fi fi if [ "x$download_ompt" = "xyes" -o "x$download_ompt_tr6" = "xyes" ] ; then install_ompt=yes - if [ ! -f ${libomp_ossdir_shared}/lib${libomp_oss_name}.so -o ${libomp_ossdir_shared}/lib${libomp_oss_name}.so -ot ${libomp_oss} ]; then + if [ ! -f "${libomp_ossdir_shared}/lib${libomp_oss_name}.so" -o "${libomp_ossdir_shared}/lib${libomp_oss_name}.so" -ot "${libomp_oss}" ]; then preomptdir=`pwd` #check Cmake exists @@ -6966,7 +6986,11 @@ if [ "x$mpiinc" != "x" -o "x$mpilib" != "x" -o $mpi = yes ] ; then then mpiwarnings="-qhalt=w" fi - if [ $c_compiler = "clang" ] + if [ $c_compiler = "clang" -o $c_compiler = "armclang" ] + then + mpiwarnings="-Werror" + fi + if [ $c_compiler = "gcc" -a $machine = apple ] then mpiwarnings="-Werror" fi @@ -8743,6 +8767,169 @@ fi /bin/rm -f conftest_bfd.o conftest_bfd.c conftest_bfd.so ###################################################################### +###################################################################### +# Install Dyninst and its dependencies, if requested +###################################################################### +libboost=boost_1_67_0 +libboosttgz=$libboost.tar.gz +libboosturl=http://www.cs.uoregon.edu/research/paracomp/tau/tauprofile/dist/$libboosttgz + +libdyninst=dyninst-9.3.2-working +libdyninsttgz=$libdyninst.tar.gz +libdyninsturl=http://www.cs.uoregon.edu/research/paracomp/tau/tauprofile/dist/$libdyninsttgz + +dynlibiberty=dynlibiberty +dynlibibertytgz=${dynlibiberty}.tar.gz +dynlibibertyurl=http://www.cs.uoregon.edu/research/paracomp/tau/tauprofile/dist/$dynlibibertytgz + +dynelfutils=elfutils-0.168 +dynelfutilsbz=${dynelfutils}.tar.bz2 +dynelfutilsurl=http://www.cs.uoregon.edu/research/paracomp/tau/tauprofile/dist/$dynelfutilsbz + +if [ "x$dyninstdir" = "x" ]; then + libdyninstdir=${targetdir}/${architecture} +else + libdyninstdir=$dyninstdir +fi + +libdyninst_name=dyninst + +if [ "x$dyninstdir" != "x" -a -d "$dyninstdir" ] ; then + if [ -r $dyninstdir/$libdyninsttgz ]; then + echo "NOTE: Copying $dyninstdir/$libdyninsttgz " + cp $dyninstdir/$libunwindtgz . + download_dyninst=yes + fi +fi + +## Check for boost +if [ "x$boostdir" != "x" -a -d "$boostdir" ] ; then + dyninstboostdir=${boostdir} +else + dyninstboostdir=${libdyninstdir}/${libboost} + boostdir=${dyninstboostdir} +fi +if [ "x$dyninstboostdir" != "x" -a -d "$dyninstboostdir" ] ; then + echo "Boost : found : $dyninstboostdir" + fixmakeargs="$fixmakeargs boostinc=-I${dyninstboostdir}/include" +else + if [ "x$boost" = xyes ] ; then + echo "Boost : not found, downloading..." + download_boost=yes + fi +fi + +## Download and install boost if necessary +if [ "x$download_boost" = xyes ] ; then + prebfddir=`pwd` + # get the tar file + if [ ! -f $libboosttgz ] ; then + download "$libboosturl" "$libboosttgz" + fi + # check the tar file + if [ ! -f $libboosttgz ] ; then + echo "$libboosttgz did not download. Please download it manually from: " + echo "$libboosturl" + echo "Please enter the directory containing the tarball: ${nnl}" + read RESPONSE + cp $RESPONSE/$libboosttgz . + else + echo "expanding $libboosttgz..." + rm -rf $dyninstboostdir + mkdir $dyninstboostdir + tar -xzf $libboosttgz -C $dyninstboostdir --strip-components=1 + echo "removing $libboosttgz..." + rm $libboosttgz + cd $dyninstboostdir + ./bootstrap.sh --prefix=${dyninstboostdir} # dyninst wants boost to be built in its src dir + ./b2 install -j4 + fixmakeargs="$fixmakeargs boostinc=-I${dyninstboostdir}/include" + fi + cd $prebfddir +fi #end dowload_boost + +if [ "x$download_dyninst" = xyes ] ; then + + dyninstdir=${libdyninstdir}/${libdyninst} + prebfddir=`pwd` + + #check Cmake exists + cmake_cmd=`which cmake` + if [ "x$cmake_cmd" = "x" ] ; then + echo 'ERROR: cmake version 2.8.11 or higher required to build Dyninst.' + exit 1; + fi + + if [ -r "$dyninstdir/lib/libdyninstAPI.so" -o \ + -r "$dyninstdir/lib/libdyninstAPI_RT.so" -o \ + -r "$dyninstdir/lib/libdynElf.so" ] ; then + echo "Found: dyninst" + echo "dyninst download already found, skipping" + else + echo "Not found in ${dyninstdir}: ${libdyninst_name}" + # get the tar file + if [ ! -f $libdyninsttgz ] ; then + download "$libdyninsturl" "$libdyninsttgz" + fi + + # check the tar file + if [ ! -f $libdyninsttgz ] ; then + echo "$libdyninsttgz did not download. Please download it manually from: " + echo "$libdyninsturl" + echo "Please enter the directory containing the tarball: ${nnl}" + read RESPONSE + cp $RESPONSE/$libdyninsttgz . + else + echo "expanding $libdyninsttgz..." + rm -rf $libdyninst + mkdir $libdyninst + tar -xzf $libdyninsttgz -C $libdyninst --strip-components=1 + echo "removing $libdyninsttgz..." + rm $libdyninsttgz + rm -rf $dyninstdir # remove and make the build dir + mkdir $dyninstdir + cd $dyninstdir # go to the build dir + ## Build shared libiberty + mkdir ${dyninstdir}/libiberty + download "$dynlibibertyurl" "$dynlibibertytgz" + tar -xzf $dynlibibertytgz + cd $dynlibiberty/libiberty + ./configure --enable-shared --prefix=$PWD + make + ar rcs libiberty.a pic/*.o + cp libiberty.a ${dyninstdir}/libiberty + cd ../.. + rm -rf $dynlibiberty $dynlibibertytgz + ## Build shared elfutils + mkdir ${dyninstdir}/elfutils + download "$dynelfutilsurl" "$dynelfutilsbz" + tar -xf $dynelfutilsbz -C ${dyninstdir}/elfutils --strip-components=1 + cd ${dyninstdir}/elfutils + ./configure --enable-shared --prefix=$PWD + make + make install + cd .. + rm -rf $dynelfutilsbz + ## Now we can make Dyninst + cmake ${prebfddir}/${libdyninst} -DBoost_INCLUDE_DIR=${dyninstboostdir} -DCMAKE_INSTALL_PREFIX=${dyninstdir} -DIBERTY_LIBRARIES=${dyninstdir}/libiberty/libiberty.a -DLIBDWARF_INCLUDE_DIR=${dyninstdir}/elfutils/include -DLIBDWARF_LIBRARIES=${dyninstdir}/elfutils/lib/libdw.so -DLIBELF_INCLUDE_DIR=${dyninstdir}/elfutils/include -DLIBELF_LIBRARIES=${dyninstdir}/elfutils/lib/libelf.so + make -j8 + make install + if [ -f ${dyninstdir}/elfutils/lib/libdw.so ]; then + cp ${dyninstdir}/elfutils/lib/libdw* ${dyninstdir}/lib + mv ${dyninstdir}/lib/libdw.so ${dyninstdir}/lib/libdwarf.so + fi + if [ -f ${dyninstdir}/elfutils/lib/libelf.so ]; then + cp ${dyninstdir}/elfutils/lib/libelf* ${dyninstdir}/lib + fi + if [ -f ${dyninstdir}/libiberty/libiberty.a ]; then + cp ${dyninstdir}/libiberty/libiberty.a ${dyninstdir}/lib + fi + fi + fi + cd $prebfddir +fi #dyninst=download + + ###################################################################### # Check that the Sampling allocator code is supported by compiler ###################################################################### @@ -10209,7 +10396,7 @@ if [ $papi = yes ] ; then fi if [ $opari = yes ] ; then - if [ $pthread = yes -o $smarts = yes -o $java = yes ] ; then + if [ [[ $pthread = yes -a $openmp = no ]] -o $smarts = yes -o $java = yes ] ; then echo "ERROR: -opari option requires OpenMP threads package." echo "*****************************************************" exit 1 @@ -10396,10 +10583,13 @@ if [ $cxx_compiler = icpc -o $cxx_compiler = mpiicpc ] ; then version=`icpc -v 2>&1` t="Version 1" t1="icpc version 1" + t2="icpc.orig version 1" testarg=${version#$t} testarg1=${version#$t1} + testarg2=${version#$t2} - if [ "y$testarg" != "y$version" -o "y$testarg1" != "y$version" ] ; then + + if [ "y$testarg" != "y$version" -o "y$testarg1" != "y$version" -o "y$testarg2" != "y$version" ] ; then echo "Intel v10.0+ compilers found" fixmakeargs="$fixmakeargs INTEL10FIX COMPINST_GNU" else @@ -10835,7 +11025,7 @@ if [ $ompt = yes -a $install_ompt = yes -a -r ${libomp_ossdir_shared}/lib${libom echo "BGQ ompt" else echo "TAU: Copying lib${libomp_oss_name}.so to ${targetdir}/${architecture}/lib/shared${tauoptions} ..." - ompt_instdir=${targetdir}/${architecture}/lib/shared${tauoptions} + ompt_instdir=${targetdir}/${architecture}/lib mkdir -p ${ompt_instdir} cp ${libomp_ossdir_shared}/lib${libomp_oss_name}.so ${ompt_instdir}/lib${libomp_oss_name}.so ; cp ${libomp_ossdir_shared}/libomp.so ${ompt_instdir}/libomp.so ; diff --git a/examples/mm/matmult.c b/examples/mm/matmult.c index bfba391ad..ec47ad14a 100644 --- a/examples/mm/matmult.c +++ b/examples/mm/matmult.c @@ -100,7 +100,7 @@ void compute(double **a, double **b, double **c, int rows_a, int cols_a, int col { /*** Do matrix multiply sharing iterations on outer loop ***/ /*** Display who does which iterations for demonstration purposes ***/ -#pragma omp for nowait +#pragma omp for schedule(dynamic) nowait for (i=0; i +#include +#include +#include +#include "mpi.h" + +#define MASTER 0 +#define BUFSIZE 1024 +#define NUM2SPAWN 2 + +int main( int argc, char *argv[], char ** envp ) +{ + int rank; + int size; + int np = NUM2SPAWN; + char message[BUFSIZE]; + MPI_Comm parentcomm, spawnedcomm, allcomm; + + MPI_Init(&argc, &argv); + pid_t pid = getpid(); + /* This function provides a convenient way to determine whether + ** this process is part of the original communicator (has a null + ** parent), or part of the newly spawned communicator */ + MPI_Comm_get_parent( &parentcomm ); + + /* write output according to which communicator this process is a part of */ + if (parentcomm == MPI_COMM_NULL) { + /* Create 2 more processes. + ** Here we spawn 2 more instances of this program. + ** argv[0] contains the name of the executable for this program. */ + char * spawn_args[] = {"-n", "1", NULL}; + MPI_Comm_spawn( argv[0], spawn_args, np, MPI_INFO_NULL, 0, + MPI_COMM_WORLD, &spawnedcomm, MPI_ERRCODES_IGNORE ); + /* get the process rank, in this case within the parent communicator */ + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + MPI_Comm_size(MPI_COMM_WORLD,&size); + printf("[%ld] rank %d (of %d) in the parent intra-communicator.\n", (long)pid, rank, size); + } + else { + /* notice that the spawned processes have an intra-communicator + ** called MPI_COMM_WORLD, too */ + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + MPI_Comm_size(MPI_COMM_WORLD,&size); + printf("[%ld] rank %d (of %d) in the spawned intra-communicator.\n", (long)pid, rank, size); + } + + /* we can broadcast to all processes associated with an + ** inter-communicator, e.g. the spawned processes */ + if (rank == MASTER) { + message[0] = 'g'; message[1] = 'a'; message[2] = 'l'; message[3] = 'o'; + message[4] = 'r'; message[5] = 'e'; message[6] = '!'; message[7] = '\0'; + } + /* BUT remember that broadcast is a collective operation, so all must call.. + ** but it's a tad fiddly with all the different groups of processors that + ** we have. + ** Note also that the inter-communicator has different names + ** according to the (parent/spawned) perspective. */ + if (parentcomm == MPI_COMM_NULL) { + if (rank == MASTER) { + MPI_Bcast(message,BUFSIZE,MPI_CHAR,MPI_ROOT,spawnedcomm); + } + MPI_Bcast(message,BUFSIZE,MPI_CHAR,MPI_PROC_NULL,spawnedcomm); + } + else { + MPI_Bcast(message,BUFSIZE,MPI_CHAR,MASTER,parentcomm); + printf("[%ld] spawned rank %d (of %d). Master broadcasts: %s\n", (long)pid, rank, size, message); + } + + /* A simpler manoeuvre is to (collectively) merge + ** the processes associated with an inter-communicator: */ + if (parentcomm == MPI_COMM_NULL) { + MPI_Intercomm_merge(spawnedcomm, 0, &allcomm); + } + else { + MPI_Intercomm_merge(parentcomm, 0, &allcomm); + } + + /* all processes can make calls associated with the + ** merged communicator */ + MPI_Comm_rank(allcomm,&rank); + MPI_Comm_size(allcomm,&size); + printf("[%ld] rank %d (of %d) in the merged intra-communicator.\n", (long)pid, rank, size); + + /* free communicators when we've finished with them + ** remembering the different names as seen from different + ** perspectives */ + if (parentcomm == MPI_COMM_NULL) { + MPI_Comm_free(&spawnedcomm); + MPI_Comm_free(&allcomm); + } + else { + MPI_Comm_free(&parentcomm); + MPI_Comm_free(&allcomm); + } + + /* and finalise */ + fflush(stdout); + MPI_Finalize(); + return 0; +} diff --git a/examples/python/firstprime.py b/examples/python/firstprime.py new file mode 100755 index 000000000..067dc671b --- /dev/null +++ b/examples/python/firstprime.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +#Program written by Devin Shende on August 5th 2018 + +def firstPrimeAfter(x): + import math + current = x + 1 + sqrtno = math.sqrt(current) + while True: + #search for primes starting at x until it finds one + #break once found a prime + for potentialfactor in range(2,current): + # start at 2 because 1 will always be a factor + # go all the way up to the sqrt of current looking for a factor + if current % potentialfactor == 0: + # Found factor. not prime + break # move on to next number + elif potentialfactor >= sqrtno: + print("The first prime number after {} is {}".format(x,current)) + return current + current += 1 + +firstPrimeAfter(10000000) + diff --git a/include/Makefile.skel b/include/Makefile.skel index 1ee120c7c..f51a6bdf4 100644 --- a/include/Makefile.skel +++ b/include/Makefile.skel @@ -416,6 +416,7 @@ TAU_OPENMP_OPTION = #IBM_FORTRAN#TAU_F90 = xlf90$(TAU_R) $(F90_ABI) $(TAU_F90_OPT) #ENDIF# #IBM64LINUX_XLF#TAU_F90 = xlf90$(TAU_R) $(F90_ABI) $(TAU_F90_OPT) #ENDIF# #XLFLANG#TAU_F90 = xlflang $(F90_ABI) $(TAU_F90_OPT) #ENDIF# +#ARMFLANG#TAU_F90 = armflang $(F90_ABI) $(TAU_F90_OPT) #ENDIF# #BGP#TAU_F90 = /bgsys/drivers/ppcfloor/comm/xl/bin/mpixlf90$(TAU_R) $(F90_ABI) $(TAU_F90_OPT) #ENDIF# #BGP_GFORTRAN#TAU_F90 = mpif90 $(F90_ABI) $(TAU_F90_OPT) #ENDIF# #BGQ#TAU_F90 = /bgsys/drivers/ppcfloor/comm/xl/bin/mpixlf90$(TAU_R) $(F90_ABI) $(TAU_F90_OPT) #ENDIF# @@ -771,6 +772,7 @@ TAU_GCCLIB = -lgcc_s #GNU#TAU_FORTRANLIBS = -L$(TAUGCCLIBDIR) $(TAUGCCLIBOPTS) -lstdc++ $(TAU_GCCLIB) #ENDIF# #OPEN64ORC_FORTRAN#TAU_FORTRANLIBS = -lfortran -lffio #ENDIF# #PATHSCALE_FORTRAN#TAU_FORTRANLIBS = -lpathfstart -lpathfortran #ENDIF# +#ARMFLANG#TAU_FORTRANLIBS = -lflangmain -lflang -lflangrti -lompstub -lm -lrt #ENDIF# #SC_PATHSCALE#TAU_FORTRANLIBS = -lpathfstart -lpathfortran #ENDIF# #NAGWARE_FORTRAN#TAU_FORTRANLIBS = $(EXTRADIR)/lib/quickfit.o $(EXTRADIR)/lib/f90_init.o $(EXTRADIR)/lib/libf??.so $(EXTRADIR)/lib/libf??.a -lm -Wl,-rpath,$(EXTRADIR)/lib #ENDIF# #G95_FORTRAN#TAU_FORTRANLIBS = -L$(EXTRADIR) -lf95 #ENDIF# diff --git a/include/Profile/TauEnv.h b/include/Profile/TauEnv.h index aa5d5a584..9f177dd85 100644 --- a/include/Profile/TauEnv.h +++ b/include/Profile/TauEnv.h @@ -111,6 +111,8 @@ extern "C" { double TAUDECL TauEnv_get_throttle_percall(); const char* TAUDECL TauEnv_get_profiledir(); const char* TAUDECL TauEnv_get_tracedir(); + void TAUDECL TauEnv_set_profiledir(const char * new_profiledir); + void TAUDECL TauEnv_set_tracedir(const char * new_tracedir); const char* TAUDECL TauEnv_get_metrics(); const char* TAUDECL TauEnv_get_cvar_metrics(); const char* TAUDECL TauEnv_get_cvar_values(); @@ -161,6 +163,8 @@ extern "C" { int TAUDECL TauEnv_get_mem_callpath(); const char * TAUDECL TauEnv_get_mem_classes(); int TAUDECL TauEnv_get_mem_class_present(const char * name); + const char * TAUDECL TauEnv_get_tau_exec_args(); + const char * TAUDECL TauEnv_get_tau_exec_path(); #ifdef __cplusplus void Tau_util_replaceStringInPlace(std::string& subject, const std::string& search, const std::string& replace); diff --git a/include/Profile/TauPlugin.h b/include/Profile/TauPlugin.h index 0279fb60f..0adeac9c2 100644 --- a/include/Profile/TauPlugin.h +++ b/include/Profile/TauPlugin.h @@ -21,8 +21,8 @@ extern "C" { #endif /* __cplusplus */ -void Tau_util_init_tau_plugin_callbacks(Tau_plugin_callbacks * cb); -void Tau_util_plugin_register_callbacks(Tau_plugin_callbacks * cb); +void Tau_util_init_tau_plugin_callbacks(Tau_plugin_callbacks_t * cb); +void Tau_util_plugin_register_callbacks(Tau_plugin_callbacks_t * cb); #ifdef __cplusplus } diff --git a/include/Profile/TauPluginInternals.h b/include/Profile/TauPluginInternals.h index 47a2e592c..563425b9e 100644 --- a/include/Profile/TauPluginInternals.h +++ b/include/Profile/TauPluginInternals.h @@ -25,15 +25,17 @@ extern "C" { #define TAU_PLUGIN_INIT_FUNC "Tau_plugin_init_func" int Tau_initialize_plugin_system(); -int Tau_util_load_and_register_plugins(PluginManager* plugin_manager); -void* Tau_util_load_plugin(const char *name, const char *path, PluginManager* plugin_manager); -void* Tau_util_register_plugin(const char *name, char **args, int num_args, void* handle, PluginManager* plugin_manager); +int Tau_util_load_and_register_plugins(PluginManager_t* plugin_manager); +void* Tau_util_load_plugin(const char *name, const char *path, PluginManager_t* plugin_manager); +void* Tau_util_register_plugin(const char *name, char **args, int num_args, void* handle, PluginManager_t* plugin_manager); int Tau_util_cleanup_all_plugins(); -PluginManager* Tau_util_get_plugin_manager(); +PluginManager_t* Tau_util_get_plugin_manager(); void Tau_util_invoke_callbacks(Tau_plugin_event_t event, const void * data); +extern Tau_plugin_callbacks_active_t Tau_plugins_enabled; + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/include/Profile/TauPluginTypes.h b/include/Profile/TauPluginTypes.h index c993818eb..fd151aa69 100644 --- a/include/Profile/TauPluginTypes.h +++ b/include/Profile/TauPluginTypes.h @@ -22,175 +22,159 @@ extern "C" { #endif /* __cplusplus */ -//Forward declarations -struct Tau_plugin_event_function_registration_data; -struct Tau_plugin_event_metadata_registration_data; -struct Tau_plugin_event_post_init_data; -struct Tau_plugin_event_dump; -struct Tau_plugin_event_function_entry; -struct Tau_plugin_event_function_exit; -struct Tau_plugin_event_current_timer_exit; -struct Tau_plugin_event_send; -struct Tau_plugin_event_recv; -struct Tau_plugin_event_atomic_event_trigger_data; -struct Tau_plugin_event_atomic_event_registration_data; -struct Tau_plugin_event_pre_end_of_execution_data; -struct Tau_plugin_event_end_of_execution_data; -struct Tau_plugin_event_function_finalize_data; -struct Tau_plugin_event_interrupt_trigger_data; - -/*Define callbacks for specific events*/ -typedef int (*Tau_plugin_function_registration_complete)(struct Tau_plugin_event_function_registration_data); -typedef int (*Tau_plugin_metadata_registration_complete)(struct Tau_plugin_event_metadata_registration_data); -typedef int (*Tau_plugin_post_init)(struct Tau_plugin_event_post_init_data); -typedef int (*Tau_plugin_dump)(struct Tau_plugin_event_dump_data); -typedef int (*Tau_plugin_function_entry)(struct Tau_plugin_event_function_entry_data); -typedef int (*Tau_plugin_function_exit)(struct Tau_plugin_event_function_exit_data); -typedef int (*Tau_plugin_current_timer_exit)(struct Tau_plugin_event_current_timer_exit_data); -typedef int (*Tau_plugin_send)(struct Tau_plugin_event_send_data); -typedef int (*Tau_plugin_recv)(struct Tau_plugin_event_recv_data); -typedef int (*Tau_plugin_atomic_event_registration_complete)(struct Tau_plugin_event_atomic_event_registration_data); -typedef int (*Tau_plugin_atomic_event_trigger)(struct Tau_plugin_event_atomic_event_trigger_data); -typedef int (*Tau_plugin_pre_end_of_execution)(struct Tau_plugin_event_pre_end_of_execution_data); -typedef int (*Tau_plugin_end_of_execution)(struct Tau_plugin_event_end_of_execution_data); -typedef int (*Tau_plugin_function_finalize)(struct Tau_plugin_event_function_finalize_data); -typedef int (*Tau_plugin_interrupt_trigger)(struct Tau_plugin_event_interrupt_trigger_data); - -/*Define the callback structure*/ -struct Tau_plugin_callbacks { - Tau_plugin_function_registration_complete FunctionRegistrationComplete; - Tau_plugin_metadata_registration_complete MetadataRegistrationComplete; - Tau_plugin_post_init PostInit; - Tau_plugin_dump Dump; - Tau_plugin_function_entry FunctionEntry; - Tau_plugin_function_exit FunctionExit; - Tau_plugin_current_timer_exit CurrentTimerExit; - Tau_plugin_send Send; - Tau_plugin_recv Recv; - Tau_plugin_atomic_event_registration_complete AtomicEventRegistrationComplete; - Tau_plugin_atomic_event_trigger AtomicEventTrigger; - Tau_plugin_pre_end_of_execution PreEndOfExecution; - Tau_plugin_end_of_execution EndOfExecution; - Tau_plugin_function_finalize FunctionFinalize; - Tau_plugin_interrupt_trigger InterruptTrigger; -}; - -/*Define all the events currently supported*/ -typedef enum Tau_plugin_event { - TAU_PLUGIN_EVENT_FUNCTION_REGISTRATION, - TAU_PLUGIN_EVENT_METADATA_REGISTRATION, - TAU_PLUGIN_EVENT_POST_INIT, - TAU_PLUGIN_EVENT_DUMP, - TAU_PLUGIN_EVENT_FUNCTION_ENTRY, - TAU_PLUGIN_EVENT_FUNCTION_EXIT, - TAU_PLUGIN_EVENT_CURRENT_TIMER_EXIT, - TAU_PLUGIN_EVENT_SEND, - TAU_PLUGIN_EVENT_RECV, - TAU_PLUGIN_EVENT_ATOMIC_EVENT_REGISTRATION, - TAU_PLUGIN_EVENT_ATOMIC_EVENT_TRIGGER, - TAU_PLUGIN_EVENT_PRE_END_OF_EXECUTION, - TAU_PLUGIN_EVENT_END_OF_EXECUTION, - TAU_PLUGIN_EVENT_FUNCTION_FINALIZE, - TAU_PLUGIN_EVENT_INTERRUPT_TRIGGER -} Tau_plugin_event_t; - /*Define data structures that define how TAU and the plugin exchange information*/ -struct Tau_plugin_event_function_registration_data { +typedef struct Tau_plugin_event_function_registration_data { void * function_info_ptr; int tid; -}; +} Tau_plugin_event_function_registration_data_t; -struct Tau_plugin_event_metadata_registration_data { +typedef struct Tau_plugin_event_metadata_registration_data { const char * name; Tau_metadata_value_t * value; -}; +} Tau_plugin_event_metadata_registration_data_t; -struct Tau_plugin_event_post_init_data { +typedef struct Tau_plugin_event_post_init_data { int dummy; -}; +} Tau_plugin_event_post_init_data_t; -struct Tau_plugin_event_dump_data { +typedef struct Tau_plugin_event_dump_data { int tid; -}; +} Tau_plugin_event_dump_data_t; -struct Tau_plugin_event_function_entry_data { +typedef struct Tau_plugin_event_function_entry_data { const char * timer_name; const char * timer_group; int tid; long unsigned int timestamp; -}; +} Tau_plugin_event_function_entry_data_t; -struct Tau_plugin_event_function_exit_data { +typedef struct Tau_plugin_event_function_exit_data { const char * timer_name; const char * timer_group; int tid; long unsigned int timestamp; -}; +} Tau_plugin_event_function_exit_data_t; -struct Tau_plugin_event_current_timer_exit_data { +typedef struct Tau_plugin_event_current_timer_exit_data { const char * name_prefix; -}; +} Tau_plugin_event_current_timer_exit_data_t; -struct Tau_plugin_event_send_data { +typedef struct Tau_plugin_event_send_data { long unsigned int message_tag; long unsigned int destination; long unsigned int bytes_sent; long unsigned int tid; long unsigned int timestamp; -}; +} Tau_plugin_event_send_data_t; -struct Tau_plugin_event_recv_data { +typedef struct Tau_plugin_event_recv_data { long unsigned int message_tag; long unsigned int source; long unsigned int bytes_received; long unsigned int tid; long unsigned int timestamp; -}; +} Tau_plugin_event_recv_data_t; -struct Tau_plugin_event_atomic_event_registration_data { +typedef struct Tau_plugin_event_atomic_event_registration_data { void * user_event_ptr; -}; +} Tau_plugin_event_atomic_event_registration_data_t; -struct Tau_plugin_event_atomic_event_trigger_data { +typedef struct Tau_plugin_event_atomic_event_trigger_data { const char * counter_name; int tid; long unsigned int value; long unsigned int timestamp; -}; +} Tau_plugin_event_atomic_event_trigger_data_t; -struct Tau_plugin_event_pre_end_of_execution_data { +typedef struct Tau_plugin_event_pre_end_of_execution_data { int tid; -}; +} Tau_plugin_event_pre_end_of_execution_data_t; -struct Tau_plugin_event_end_of_execution_data { +typedef struct Tau_plugin_event_end_of_execution_data { int tid; -}; +} Tau_plugin_event_end_of_execution_data_t; -struct Tau_plugin_event_function_finalize_data { +typedef struct Tau_plugin_event_function_finalize_data { int junk; -}; +} Tau_plugin_event_function_finalize_data_t; -struct Tau_plugin_event_interrupt_trigger_data { +typedef struct Tau_plugin_event_interrupt_trigger_data { int signum; -}; - -typedef struct Tau_plugin_event_function_registration_data Tau_plugin_event_function_registration_data; -typedef struct Tau_plugin_event_metadata_registration_data Tau_plugin_event_metadata_registration_data; -typedef struct Tau_plugin_event_post_init_data Tau_plugin_event_post_init_data; -typedef struct Tau_plugin_event_dump_data Tau_plugin_event_dump_data; -typedef struct Tau_plugin_event_function_entry_data Tau_plugin_event_function_entry_data; -typedef struct Tau_plugin_event_function_exit_data Tau_plugin_event_function_exit_data; -typedef struct Tau_plugin_event_current_timer_exit_data Tau_plugin_event_current_timer_exit_data; -typedef struct Tau_plugin_event_send_data Tau_plugin_event_send_data; -typedef struct Tau_plugin_event_recv_data Tau_plugin_event_recv_data; -typedef struct Tau_plugin_event_atomic_event_registration_data Tau_plugin_event_atomic_event_registration_data; -typedef struct Tau_plugin_event_atomic_event_trigger_data Tau_plugin_event_atomic_event_trigger_data; -typedef struct Tau_plugin_event_pre_end_of_execution_data Tau_plugin_event_pre_end_of_execution_data; -typedef struct Tau_plugin_event_end_of_execution_data Tau_plugin_event_end_of_execution_data; -typedef struct Tau_plugin_event_function_finalize_data Tau_plugin_event_function_finalize_data; -typedef struct Tau_plugin_event_interrupt_trigger_data Tau_plugin_event_interrupt_trigger_data; - -typedef struct Tau_plugin_callbacks Tau_plugin_callbacks; +} Tau_plugin_event_interrupt_trigger_data_t ; + +/*Define callbacks for specific events*/ +typedef int (*Tau_plugin_function_registration_complete)(Tau_plugin_event_function_registration_data_t*); +typedef int (*Tau_plugin_metadata_registration_complete)(Tau_plugin_event_metadata_registration_data_t*); +typedef int (*Tau_plugin_post_init)(Tau_plugin_event_post_init_data_t*); +typedef int (*Tau_plugin_dump)(Tau_plugin_event_dump_data_t*); +typedef int (*Tau_plugin_function_entry)(Tau_plugin_event_function_entry_data_t*); +typedef int (*Tau_plugin_function_exit)(Tau_plugin_event_function_exit_data_t*); +typedef int (*Tau_plugin_current_timer_exit)(Tau_plugin_event_current_timer_exit_data_t*); +typedef int (*Tau_plugin_send)(Tau_plugin_event_send_data_t*); +typedef int (*Tau_plugin_recv)(Tau_plugin_event_recv_data_t*); +typedef int (*Tau_plugin_atomic_event_registration_complete)(Tau_plugin_event_atomic_event_registration_data_t*); +typedef int (*Tau_plugin_atomic_event_trigger)(Tau_plugin_event_atomic_event_trigger_data_t*); +typedef int (*Tau_plugin_pre_end_of_execution)(Tau_plugin_event_pre_end_of_execution_data_t*); +typedef int (*Tau_plugin_end_of_execution)(Tau_plugin_event_end_of_execution_data_t*); +typedef int (*Tau_plugin_function_finalize)(Tau_plugin_event_function_finalize_data_t*); +typedef int (*Tau_plugin_interrupt_trigger)(Tau_plugin_event_interrupt_trigger_data_t*); + +/*Define the callback structure*/ +typedef struct Tau_plugin_callbacks { + Tau_plugin_function_registration_complete FunctionRegistrationComplete; + Tau_plugin_metadata_registration_complete MetadataRegistrationComplete; + Tau_plugin_post_init PostInit; + Tau_plugin_dump Dump; + Tau_plugin_function_entry FunctionEntry; + Tau_plugin_function_exit FunctionExit; + Tau_plugin_current_timer_exit CurrentTimerExit; + Tau_plugin_send Send; + Tau_plugin_recv Recv; + Tau_plugin_atomic_event_registration_complete AtomicEventRegistrationComplete; + Tau_plugin_atomic_event_trigger AtomicEventTrigger; + Tau_plugin_pre_end_of_execution PreEndOfExecution; + Tau_plugin_end_of_execution EndOfExecution; + Tau_plugin_function_finalize FunctionFinalize; + Tau_plugin_interrupt_trigger InterruptTrigger; +} Tau_plugin_callbacks_t; + +/*Define all the events currently supported*/ +typedef enum Tau_plugin_event { + TAU_PLUGIN_EVENT_FUNCTION_REGISTRATION, + TAU_PLUGIN_EVENT_METADATA_REGISTRATION, + TAU_PLUGIN_EVENT_POST_INIT, + TAU_PLUGIN_EVENT_DUMP, + TAU_PLUGIN_EVENT_FUNCTION_ENTRY, + TAU_PLUGIN_EVENT_FUNCTION_EXIT, + TAU_PLUGIN_EVENT_SEND, + TAU_PLUGIN_EVENT_RECV, + TAU_PLUGIN_EVENT_CURRENT_TIMER_EXIT, + TAU_PLUGIN_EVENT_ATOMIC_EVENT_REGISTRATION, + TAU_PLUGIN_EVENT_ATOMIC_EVENT_TRIGGER, + TAU_PLUGIN_EVENT_PRE_END_OF_EXECUTION, + TAU_PLUGIN_EVENT_END_OF_EXECUTION, + TAU_PLUGIN_EVENT_FUNCTION_FINALIZE, + TAU_PLUGIN_EVENT_INTERRUPT_TRIGGER +} Tau_plugin_event_t; + +/* Is the event registered with a callback? */ +typedef struct Tau_plugin_callbacks_active { + unsigned int function_registration; + unsigned int metadata_registration; + unsigned int post_init; + unsigned int dump; + unsigned int function_entry; + unsigned int function_exit; + unsigned int send; + unsigned int recv; + unsigned int current_timer_exit; + unsigned int atomic_event_registration; + unsigned int atomic_event_trigger; + unsigned int pre_end_of_execution; + unsigned int end_of_execution; + unsigned int function_finalize; + unsigned int interrupt_trigger; +} Tau_plugin_callbacks_active_t; /*Define data structures to hold information about currently loaded plugins. * Only relevant for TAU internals - not a concern to plugins themselves*/ @@ -198,25 +182,25 @@ typedef struct Tau_plugin { char plugin_name[1024]; void* handle; struct Tau_plugin * next; -} Tau_plugin; +} Tau_plugin_t; typedef struct Tau_plugin_list { - struct Tau_plugin * head; -} Tau_plugin_list; + Tau_plugin_t * head; +} Tau_plugin_list_t; -typedef struct Tau_plugin_callback_ { - Tau_plugin_callbacks cb; - struct Tau_plugin_callback_ * next; -} Tau_plugin_callback_; +typedef struct Tau_plugin_callback { + Tau_plugin_callbacks_t cb; + struct Tau_plugin_callback * next; +} Tau_plugin_callback_t; typedef struct Tau_plugin_callback_list { - Tau_plugin_callback_ * head; -} Tau_plugin_callback_list; + Tau_plugin_callback_t * head; +} Tau_plugin_callback_list_t; typedef struct PluginManager { - Tau_plugin_list * plugin_list; - Tau_plugin_callback_list * callback_list; -} PluginManager; + Tau_plugin_list_t * plugin_list; + Tau_plugin_callback_list_t * callback_list; +} PluginManager_t; typedef int (*PluginInitFunc) (int argc, char **argv); diff --git a/include/Profile/TauUtil.h b/include/Profile/TauUtil.h index bc1b77bc0..655a5bd33 100644 --- a/include/Profile/TauUtil.h +++ b/include/Profile/TauUtil.h @@ -61,8 +61,8 @@ void Tau_plugin_recvmsg(long unsigned int type, long unsigned int source, long u // Use a macro so we can compile it out if too much overhead. -#define TAU_PLUGIN_SENDMSG(t, d, l, r) Tau_plugin_sendmsg((long unsigned int)t, (long unsigned int)d, (long unsigned int)l, (long unsigned int)r) -#define TAU_PLUGIN_RECVMSG(t, s, l, r) Tau_plugin_recvmsg((long unsigned int)t, (long unsigned int)s, (long unsigned int)l, (long unsigned int)r) +#define TAU_PLUGIN_SENDMSG(t, d, l, r) if (Tau_plugins_enabled.send) { Tau_plugin_sendmsg((long unsigned int)t, (long unsigned int)d, (long unsigned int)l, (long unsigned int)r); } +#define TAU_PLUGIN_RECVMSG(t, s, l, r) if (Tau_plugins_enabled.recv) { Tau_plugin_recvmsg((long unsigned int)t, (long unsigned int)s, (long unsigned int)l, (long unsigned int)r); } /* The following macros help create a local array and assign to elements of the local C array, values from Fortran array after conversion using f2c diff --git a/plugins/examples/TauSOS.cpp b/plugins/examples/TauSOS.cpp index 5469aa260..8e5267aef 100644 --- a/plugins/examples/TauSOS.cpp +++ b/plugins/examples/TauSOS.cpp @@ -103,6 +103,7 @@ void * Tau_sos_thread_function(void* data) { // unlock after being signalled. pthread_mutex_unlock(&_my_mutex); pthread_exit((void*)0L); + return(NULL); } void TAU_SOS_make_pub() { @@ -116,11 +117,10 @@ void TAU_SOS_make_pub() { _runtime->config.comm_size = comm_size; #endif -/* Fixme! Replace these with values from TAU metadata. */ sprintf(pub_name, "TAU_SOS_SUPPORT"); sprintf(app_version, "v0.alpha"); -/* Fixme! Replace these with values from TAU metadata. */ SOS_pub_init(_runtime, &tau_sos_pub, pub_name, SOS_NATURE_DEFAULT); + SOS_pub_config(tau_sos_pub, SOS_PUB_OPTION_CACHE, thePluginOptions().env_sos_cache_depth); strcpy(tau_sos_pub->prog_ver, app_version); tau_sos_pub->meta.channel = 1; @@ -166,7 +166,6 @@ void TAU_SOS_do_fork(std::string forkCommand) { void TAU_SOS_fork_exec_sosd_shutdown(void) { #ifdef TAU_MPI // first, figure out who should fork a daemon on this node - int i; if (my_rank == daemon_rank) { int pid = vfork(); if (pid == 0) { @@ -190,7 +189,6 @@ void TAU_SOS_fork_exec_sosd_shutdown(void) { void TAU_SOS_send_shutdown_message(void) { #ifdef TAU_MPI - int i; SOS_buffer *buffer; SOS_msg_header header; int offset; @@ -214,6 +212,11 @@ void TAU_SOS_send_shutdown_message(void) { TAU_VERBOSE("Sending SOS_MSG_TYPE_SHUTDOWN ...\n"); SOS_send_to_daemon(buffer, buffer); SOS_buffer_destroy(buffer); + char * exporting = getenv("SOS_EXPORT_DB_AT_EXIT"); + if (exporting != NULL) { + TAU_VERBOSE("Waiting %d seconds for SOS to write (if necessary)...\n", thePluginOptions().env_sos_shutdown_delay); + sleep(thePluginOptions().env_sos_shutdown_delay); + } #endif } @@ -339,8 +342,10 @@ void TAU_SOS_parse_environment_variables(void) { } tmp = getenv("TAU_SOS_TRACING"); if (parse_bool(tmp, TAU_SOS_TRACING_DEFAULT)) { - thePluginOptions().env_sos_tracing = 1; + thePluginOptions().env_sos_tracing = 1; } + tmp = getenv("TAU_SOS_CACHE_DEPTH"); + thePluginOptions().env_sos_cache_depth = parse_int(tmp, TAU_SOS_CACHE_DEPTH_DEFAULT); tmp = getenv("TAU_SOS_PERIODIC"); if (parse_bool(tmp, TAU_SOS_PERIODIC_DEFAULT)) { thePluginOptions().env_sos_periodic = 1; @@ -364,7 +369,7 @@ void Tau_SOS_parse_selection_file(const char * filename) { bool excluding_timers = false; bool including_counters = false; bool excluding_counters = false; - thePluginOptions().env_sos_use_selection = 1; + thePluginOptions().env_sos_use_selection = true; while (std::getline(file, str)) { // trim right whitespace str.erase(str.find_last_not_of(" \n\r\t")+1); @@ -396,13 +401,29 @@ void Tau_SOS_parse_selection_file(const char * filename) { excluding_counters = false; } else { if (including_timers) { - thePluginOptions().included_timers.insert(str); + if (str.find("#") == string::npos && str.find("?") == string::npos) { + thePluginOptions().included_timers.insert(str); + } else { + thePluginOptions().included_timers_with_wildcards.insert(str); + } } else if (excluding_timers) { - thePluginOptions().excluded_timers.insert(str); + if (str.find("#") == string::npos && str.find("?") == string::npos) { + thePluginOptions().excluded_timers.insert(str); + } else { + thePluginOptions().excluded_timers_with_wildcards.insert(str); + } } else if (including_counters) { - thePluginOptions().included_counters.insert(str); + if (str.find("#") == string::npos && str.find("?") == string::npos) { + thePluginOptions().included_counters.insert(str); + } else { + thePluginOptions().included_counters_with_wildcards.insert(str); + } } else if (excluding_counters) { - thePluginOptions().excluded_counters.insert(str); + if (str.find("#") == string::npos && str.find("?") == string::npos) { + thePluginOptions().excluded_counters.insert(str); + } else { + thePluginOptions().excluded_counters_with_wildcards.insert(str); + } } else { std::cerr << "Warning, selection outside of include/exclude section: " << str << std::endl; @@ -450,8 +471,8 @@ void TAU_SOS_init() { } } - if (_threaded && thePluginOptions().env_sos_periodic) { - period_microseconds = thePluginOptions().env_sos_period; + if (thePluginOptions().env_sos_periodic) { + period_microseconds = thePluginOptions().env_sos_period; TAU_VERBOSE("Spawning thread for SOS.\n"); int ret = pthread_create(&worker_thread, NULL, &Tau_sos_thread_function, NULL); if (ret != 0) { @@ -471,7 +492,7 @@ void TAU_SOS_stop_worker(void) { pthread_mutex_lock(&_my_mutex); done = true; pthread_mutex_unlock(&_my_mutex); - if (_threaded && thePluginOptions().env_sos_periodic) { + if (thePluginOptions().env_sos_periodic) { TAU_VERBOSE("TAU SOS thread joining...\n"); fflush(stderr); pthread_cond_signal(&_my_cond); int ret = pthread_join(worker_thread, NULL); @@ -517,13 +538,14 @@ void TAU_SOS_finalize(void) { // shutdown the daemon, if necessary if (shutdown_daemon) { if (my_rank == daemon_rank) { - TAU_VERBOSE("Waiting for SOS to flush...\n"); + TAU_VERBOSE("Waiting %d seconds for SOS to flush...\n", thePluginOptions().env_sos_shutdown_delay); sleep(thePluginOptions().env_sos_shutdown_delay); TAU_SOS_send_shutdown_message(); } // shouldn't be necessary, but sometimes the shutdown message is ignored? //TAU_SOS_fork_exec_sosd_shutdown(); } + printf("}\n"); SOS_finalize(_runtime); } @@ -548,6 +570,7 @@ void Tau_SOS_pack_current_timer(const char * event_name) { // assume time is the first counter! // also convert it to microseconds double value = (current[0] - p->StartTime[0]) * CONVERT_TO_USEC; + // if (strlen(event_name) > 256) { printf("long string, %d: '%s'\n", strlen(event_name), event_name); } SOS_pack(tau_sos_pub, event_name, SOS_VAL_TYPE_DOUBLE, &value); } @@ -563,6 +586,7 @@ void Tau_SOS_pack_string(const char * name, char * value) { } RtsLayer::UnLockDB(); } + // if (strlen(name) > 256) { printf("long string, %d: '%s'\n", strlen(name), name); } SOS_pack(tau_sos_pub, name, SOS_VAL_TYPE_STRING, value); } @@ -578,6 +602,7 @@ void Tau_SOS_pack_double(const char * name, double value) { } RtsLayer::UnLockDB(); } + // if (strlen(name) > 256) { printf("long string, %d: '%s'\n", strlen(name), name); } SOS_pack(tau_sos_pub, name, SOS_VAL_TYPE_DOUBLE, &value); } @@ -593,6 +618,7 @@ void Tau_SOS_pack_integer(const char * name, int value) { } RtsLayer::UnLockDB(); } + // if (strlen(name) > 256) { printf("long string, %d: '%s'\n", strlen(name), name); } SOS_pack(tau_sos_pub, name, SOS_VAL_TYPE_INT, &value); } @@ -608,13 +634,14 @@ void Tau_SOS_pack_long(const char * name, long int value) { } RtsLayer::UnLockDB(); } + // if (strlen(name) > 256) { printf("long string, %d: '%s'\n", strlen(name), name); } SOS_pack(tau_sos_pub, name, SOS_VAL_TYPE_LONG, &value); } /* Necessary to use const char * because UserEvents use TauSafeString objects, * not std::string. We use the "if_empty" parameter to tell us how to treat * an empty set. For exclude lists, it's false, for include lists, it's true */ -const bool Tau_SOS_contains(std::set& myset, +bool Tau_SOS_contains(std::set& myset, const char * key, bool if_empty) { // if the set has contents, and we are in the set, then return true. std::string _key(key); @@ -647,11 +674,8 @@ void TAU_SOS_pack_profile() { for (it = TheFunctionDB().begin(); it != TheFunctionDB().end(); it++) { FunctionInfo *fi = *it; /* First, check to see if we are including/excluding this timer */ - if (thePluginOptions().env_sos_use_selection == 1) { - if (Tau_SOS_contains(thePluginOptions().excluded_timers, fi->GetName(), false) || - !Tau_SOS_contains(thePluginOptions().included_timers, fi->GetName(), true)) { - continue; - } + if (skip_timer(fi->GetName())) { + continue; } // get the number of calls int tid = 0; // todo: get ALL thread data. @@ -664,11 +688,10 @@ void TAU_SOS_pack_profile() { //foreach: THREAD for (tid = 0; tid < RtsLayer::getTotalThreads(); tid++) { calls = fi->GetCalls(tid); - int vec_index = 0; - std::stringstream calls_str; calls_str << "TAU_TIMER:" << tid << ":calls:" << fi->GetAllGroups() << ":" << fi->GetName(); const std::string& tmpcalls = calls_str.str(); + // if (strlen(tmpcalls.c_str()) > 256) { printf("long string, %d: '%s'\n", strlen(tmpcalls.c_str()), tmpcalls.c_str()); } SOS_pack(tau_sos_pub, tmpcalls.c_str(), SOS_VAL_TYPE_INT, &calls); // todo - subroutines @@ -684,6 +707,8 @@ void TAU_SOS_pack_profile() { excl_str.str(std::string()); excl_str << "TAU_TIMER:" << tid << ":exclusive_" << counterNames[m] << ":" << fi->GetAllGroups() << ":" << fi->GetName(); const std::string& tmpexcl = excl_str.str(); + // if (strlen(tmpexcl.c_str()) > 256) { printf("long string, %d: '%s'\n", strlen(tmpexcl.c_str()), tmpexcl.c_str()); } + // if (strlen(tmpincl.c_str()) > 256) { printf("long string, %d: '%s'\n", strlen(tmpincl.c_str()), tmpincl.c_str()); } SOS_pack(tau_sos_pub, tmpincl.c_str(), SOS_VAL_TYPE_DOUBLE, &inclusive); SOS_pack(tau_sos_pub, tmpexcl.c_str(), SOS_VAL_TYPE_DOUBLE, &exclusive); } @@ -702,13 +727,9 @@ void TAU_SOS_pack_profile() { for (it2 = tau::TheEventDB().begin(); it2 != tau::TheEventDB().end(); it2++) { tau::TauUserEvent *ue = (*it2); /* First, check to see if we are including/excluding this counter */ - if (thePluginOptions().env_sos_use_selection == 1) { - if (Tau_SOS_contains(thePluginOptions().excluded_counters, ue->GetName().c_str(), false) || - !Tau_SOS_contains(thePluginOptions().included_counters, ue->GetName().c_str(), true)) { - continue; - } + if (skip_counter(ue->GetName().c_str())) { + continue; } - double tmp_accum = 0.0; std::string counter_name; int tid = 0; @@ -721,18 +742,23 @@ void TAU_SOS_pack_profile() { min = ue->GetMin(tid); sumsqr = ue->GetSumSqr(tid); tmp_str << "TAU_COUNTER:" << tid << ":NumEvents:" << ue->GetName(); + // if (strlen(tmp_str.str().c_str()) > 256) { printf("long string, %d: '%s'\n", strlen(tmp_str.str().c_str()), tmp_str.str().c_str()); } SOS_pack(tau_sos_pub, tmp_str.str().c_str(), SOS_VAL_TYPE_INT, &numEvents); tmp_str.str(std::string()); tmp_str << "TAU_COUNTER:" << tid << ":Max:" << ue->GetName(); + // if (strlen(tmp_str.str().c_str()) > 256) { printf("long string, %d: '%s'\n", strlen(tmp_str.str().c_str()), tmp_str.str().c_str()); } SOS_pack(tau_sos_pub, tmp_str.str().c_str(), SOS_VAL_TYPE_DOUBLE, &max); tmp_str.str(std::string()); tmp_str << "TAU_COUNTER:" << tid << ":Min:" << ue->GetName(); + // if (strlen(tmp_str.str().c_str()) > 256) { printf("long string, %d: '%s'\n", strlen(tmp_str.str().c_str()), tmp_str.str().c_str()); } SOS_pack(tau_sos_pub, tmp_str.str().c_str(), SOS_VAL_TYPE_DOUBLE, &min); tmp_str.str(std::string()); tmp_str << "TAU_COUNTER:" << tid << ":Mean:" << ue->GetName(); + // if (strlen(tmp_str.str().c_str()) > 256) { printf("long string, %d: '%s'\n", strlen(tmp_str.str().c_str()), tmp_str.str().c_str()); } SOS_pack(tau_sos_pub, tmp_str.str().c_str(), SOS_VAL_TYPE_DOUBLE, &mean); tmp_str.str(std::string()); tmp_str << "TAU_COUNTER:" << tid << ":SumSqr:" << ue->GetName(); + // if (strlen(tmp_str.str().c_str()) > 256) { printf("long string, %d: '%s'\n", strlen(tmp_str.str().c_str()), tmp_str.str().c_str()); } SOS_pack(tau_sos_pub, tmp_str.str().c_str(), SOS_VAL_TYPE_DOUBLE, &sumsqr); tmp_str.str(std::string()); } @@ -778,4 +804,157 @@ void TAU_SOS_send_data(void) { Tau_global_decr_insideTAU(); } +// C++ program to implement wildcard +// pattern matching algorithm +// from: https://www.geeksforgeeks.org/wildcard-pattern-matching/ +#include +using namespace std; + +// Function that matches input str with +// given wildcard pattern +bool strmatch(const char str[], const char pattern[], + int n, int m) +{ + // empty pattern can only match with + // empty string + if (m == 0) + return (n == 0); + + // lookup table for storing results of + // subproblems + bool lookup[n + 1][m + 1]; // = {false}; + // PGI compiler doesn't like initialization during declaration... + for (int i = 0; i <= n; i++) { + for (int j = 0; j <= m; j++) { + lookup[i][j] = false; + } + } + + // initailze lookup table to false + //memset(lookup, false, sizeof(lookup)); + + // empty pattern can match with empty string + lookup[0][0] = true; + + // Only '#' can match with empty string + for (int j = 1; j <= m; j++) + if (pattern[j - 1] == '#') + lookup[0][j] = lookup[0][j - 1]; + + // fill the table in bottom-up fashion + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= m; j++) + { + // Two cases if we see a '#' + // a) We ignore ‘#’ character and move + // to next character in the pattern, + // i.e., ‘#’ indicates an empty sequence. + // b) '#' character matches with ith + // character in input + if (pattern[j - 1] == '#') + lookup[i][j] = lookup[i][j - 1] || + lookup[i - 1][j]; + + // Current characters are considered as + // matching in two cases + // (a) current character of pattern is '?' + // (b) characters actually match + else if (pattern[j - 1] == '?' || + str[i - 1] == pattern[j - 1]) + lookup[i][j] = lookup[i - 1][j - 1]; + + // If characters don't match + else lookup[i][j] = false; + } + } + + return lookup[n][m]; +} + +bool skip_timer(const char * key) { + // are we filtering at all? + if (!thePluginOptions().env_sos_use_selection) { + return false; + } + // check to see if this label is excluded + if (Tau_SOS_contains(thePluginOptions().excluded_timers, key, false)) { + return true; + // check to see if this label is included + } else if (Tau_SOS_contains(thePluginOptions().included_timers, key, false)) { + return false; + } else { + // check to see if it's in the excluded wildcards + for (std::set::iterator + it=thePluginOptions().excluded_timers_with_wildcards.begin(); + it!=thePluginOptions().excluded_timers_with_wildcards.end(); ++it) { + if (strmatch(key, it->c_str(), strlen(key), it->length())) { + // make the lookup faster next time + thePluginOptions().excluded_timers.insert(key); + return true; + } + } + // check to see if it's in the included wildcards + for (std::set::iterator + it=thePluginOptions().included_timers_with_wildcards.begin(); + it!=thePluginOptions().included_timers_with_wildcards.end(); ++it) { + if (strmatch(key, it->c_str(), strlen(key), it->length())) { + // make the lookup faster next time + thePluginOptions().included_timers.insert(key); + return false; + } + } + } + // neither included nor excluded? + // do we have an inclusion list? If so, then skip (because we didn't match it). + if (!thePluginOptions().included_timers.empty() || + !thePluginOptions().included_timers_with_wildcards.empty()) { + return true; + } + // by default, don't skip it. + return false; +} + +bool skip_counter(const char * key) { + // are we filtering at all? + if (!thePluginOptions().env_sos_use_selection) { + return false; + } + // check to see if this label is excluded + if (Tau_SOS_contains(thePluginOptions().excluded_counters, key, false)) { + return true; + // check to see if this label is included + } else if (Tau_SOS_contains(thePluginOptions().included_counters, key, false)) { + return false; + } else { + // check to see if it's in the excluded wildcards + for (std::set::iterator + it=thePluginOptions().excluded_counters_with_wildcards.begin(); + it!=thePluginOptions().excluded_counters_with_wildcards.end(); ++it) { + if (strmatch(key, it->c_str(), strlen(key), it->length())) { + // make the lookup faster next time + thePluginOptions().excluded_counters.insert(key); + return true; + } + } + // check to see if it's in the included wildcards + for (std::set::iterator + it=thePluginOptions().included_counters_with_wildcards.begin(); + it!=thePluginOptions().included_counters_with_wildcards.end(); ++it) { + if (strmatch(key, it->c_str(), strlen(key), it->length())) { + // make the lookup faster next time + thePluginOptions().included_counters.insert(key); + return false; + } + } + } + // neither included nor excluded? + // do we have an inclusion list? If so, then skip (because we didn't match it). + if (!thePluginOptions().included_counters.empty() || + !thePluginOptions().included_counters_with_wildcards.empty()) { + return true; + } + return false; +} + #endif // TAU_SOS diff --git a/plugins/examples/TauSOS.h b/plugins/examples/TauSOS.h index ae0a1a1ec..7b0cb147a 100644 --- a/plugins/examples/TauSOS.h +++ b/plugins/examples/TauSOS.h @@ -11,8 +11,9 @@ #define TAU_SOS_TRACE_ADIOS_DEFAULT 0 #define TAU_SOS_PERIODIC_DEFAULT 0 #define TAU_SOS_PERIOD_DEFAULT 2000000 // microseconds -#define TAU_SOS_SHUTDOWN_DELAY_DEFAULT 10 // seconds -#define TAU_SOS_USE_SELECTION_DEFAULT 0 // microseconds +#define TAU_SOS_SHUTDOWN_DELAY_DEFAULT 1 // seconds +#define TAU_SOS_USE_SELECTION_DEFAULT false // microseconds +#define TAU_SOS_CACHE_DEPTH_DEFAULT 1 // SOS frames class SOS_plugin_options { private: @@ -23,7 +24,8 @@ class SOS_plugin_options { env_sos_periodic(TAU_SOS_PERIODIC_DEFAULT), env_sos_period(TAU_SOS_PERIOD_DEFAULT), env_sos_shutdown_delay(TAU_SOS_SHUTDOWN_DELAY_DEFAULT), - env_sos_use_selection(TAU_SOS_USE_SELECTION_DEFAULT) {} + env_sos_use_selection(TAU_SOS_USE_SELECTION_DEFAULT), + env_sos_cache_depth(TAU_SOS_CACHE_DEPTH_DEFAULT) {} public: int env_sos_enabled; int env_sos_tracing; @@ -31,11 +33,16 @@ class SOS_plugin_options { int env_sos_periodic; int env_sos_period; int env_sos_shutdown_delay; - int env_sos_use_selection; + bool env_sos_use_selection; + int env_sos_cache_depth; std::set included_timers; std::set excluded_timers; + std::set included_timers_with_wildcards; + std::set excluded_timers_with_wildcards; std::set included_counters; std::set excluded_counters; + std::set included_counters_with_wildcards; + std::set excluded_counters_with_wildcards; static SOS_plugin_options& thePluginOptions() { static SOS_plugin_options tpo; return tpo; @@ -48,7 +55,7 @@ inline SOS_plugin_options& thePluginOptions() { void TAU_SOS_parse_environment_variables(void); void Tau_SOS_parse_selection_file(const char * filename); -const bool Tau_SOS_contains(std::set& myset, +bool Tau_SOS_contains(std::set& myset, const char * key, bool if_empty); void TAU_SOS_send_data(void); @@ -62,5 +69,7 @@ void Tau_SOS_pack_double(const char * name, double value); void Tau_SOS_pack_integer(const char * name, int value); void Tau_SOS_pack_long(const char * name, long int value); void * Tau_sos_thread_function(void* data); +bool skip_timer(const char * key); +bool skip_counter(const char * key); #endif // TAU_SOS_H diff --git a/plugins/examples/Tau_plugin_example_disable_instrumentation_runtime.cpp b/plugins/examples/Tau_plugin_example_disable_instrumentation_runtime.cpp index eb61803f7..eb166085b 100644 --- a/plugins/examples/Tau_plugin_example_disable_instrumentation_runtime.cpp +++ b/plugins/examples/Tau_plugin_example_disable_instrumentation_runtime.cpp @@ -492,9 +492,9 @@ char *Tau_preprocess_function_info_name(const char *name) { /*This function gets invoked at function registration. * It checks if the function getting registrtion is present in the exclude list specified by the instrumentation file * and is so, sets the function group to TAU_DISABLE, effectively disabling function from getting instrumented*/ -int Tau_plugin_example_check_and_set_disable_group(Tau_plugin_event_function_registration_data data) { +int Tau_plugin_example_check_and_set_disable_group(Tau_plugin_event_function_registration_data* data) { - const char * before_preprocessing = ((FunctionInfo *)data.function_info_ptr)->GetName(); + const char * before_preprocessing = ((FunctionInfo *)data->function_info_ptr)->GetName(); const char * name = Tau_preprocess_function_info_name(before_preprocessing); const char * pch = strchr(name, '['); @@ -528,7 +528,7 @@ int Tau_plugin_example_check_and_set_disable_group(Tau_plugin_event_function_reg if(!instrumentEntity(std::string(name, position)) || (instrument_file == false)) { RtsLayer::LockDB(); - Tau_profile_set_group(data.function_info_ptr, TAU_DISABLE); + Tau_profile_set_group(data->function_info_ptr, TAU_DISABLE); RtsLayer::UnLockDB(); } @@ -539,7 +539,7 @@ int Tau_plugin_example_check_and_set_disable_group(Tau_plugin_event_function_reg * Every plugin MUST implement this function to register callbacks for various events * that the plugin is interested in listening to*/ extern "C" int Tau_plugin_init_func(int argc, char **argv) { - Tau_plugin_callbacks * cb = (Tau_plugin_callbacks*)malloc(sizeof(Tau_plugin_callbacks)); + Tau_plugin_callbacks_t * cb = (Tau_plugin_callbacks*)malloc(sizeof(Tau_plugin_callbacks_t)); if(argc == 0) { printf("TAU PLUGIN: Please provide a selective instrumentation by setting TAU_SELECT_FILE=\n"); diff --git a/plugins/examples/Tau_plugin_example_mpit_mvapich_free_unused_vbufs.c b/plugins/examples/Tau_plugin_example_mpit_mvapich_free_unused_vbufs.c index 62576e911..cbf78fabb 100644 --- a/plugins/examples/Tau_plugin_example_mpit_mvapich_free_unused_vbufs.c +++ b/plugins/examples/Tau_plugin_example_mpit_mvapich_free_unused_vbufs.c @@ -37,7 +37,7 @@ unsigned long long int * pvar_vbuf_allocated = NULL; static int num_vbuf_pools = 0; -int Tau_plugin_example_mpit_recommend_sharp_usage(Tau_plugin_event_interrupt_trigger_data data) { +int Tau_plugin_example_mpit_recommend_sharp_usage(Tau_plugin_event_interrupt_trigger_data_t* data) { char metric_string[TAU_NAME_LENGTH], value_string[TAU_NAME_LENGTH]; unsigned long long int reduced_value_array[5] = {0}; static char reduced_value_cvar_string[TAU_NAME_LENGTH] = ""; @@ -117,7 +117,7 @@ int Tau_plugin_init_func(int argc, char **argv) { return -1; } - Tau_plugin_callbacks * cb = (Tau_plugin_callbacks*)malloc(sizeof(Tau_plugin_callbacks)); + Tau_plugin_callbacks_t * cb = (Tau_plugin_callbacks_t*)malloc(sizeof(Tau_plugin_callbacks_t)); TAU_UTIL_INIT_TAU_PLUGIN_CALLBACKS(cb); cb->InterruptTrigger = Tau_plugin_example_mpit_recommend_sharp_usage; TAU_UTIL_PLUGIN_REGISTER_CALLBACKS(cb); diff --git a/plugins/examples/Tau_plugin_example_mpit_recommend_sharp_usage.cpp b/plugins/examples/Tau_plugin_example_mpit_recommend_sharp_usage.cpp index 738b51c92..9cc6d3270 100644 --- a/plugins/examples/Tau_plugin_example_mpit_recommend_sharp_usage.cpp +++ b/plugins/examples/Tau_plugin_example_mpit_recommend_sharp_usage.cpp @@ -28,7 +28,7 @@ extern "C" int TauProfiler_updateAllIntermediateStatistics(void); * versus the total application execution time, along with the message size for MPI_Allreduce. * If the application spends a signigicant time in MPI_Allreduce, and if the message size involved in MPI_Allreduce * is low, then it recommends the user to enable SHArP through a message on TAU_METADATA*/ -extern "C" int Tau_plugin_example_mpit_recommend_sharp_usage(Tau_plugin_event_end_of_execution_data data) { +extern "C" int Tau_plugin_example_mpit_recommend_sharp_usage(Tau_plugin_event_end_of_execution_data_t* data) { double exclusiveTimeAllReduce, inclusiveTimeApp = 0.0; double meanAllReduceMessageSize = 0; @@ -102,7 +102,7 @@ extern "C" int Tau_plugin_example_mpit_recommend_sharp_usage(Tau_plugin_event_en * * Every plugin MUST implement this function to register callbacks for various events * * that the plugin is interested in listening to*/ extern "C" int Tau_plugin_init_func(int argc, char **argv) { - Tau_plugin_callbacks * cb = (Tau_plugin_callbacks*)malloc(sizeof(Tau_plugin_callbacks)); + Tau_plugin_callbacks_t * cb = (Tau_plugin_callbacks_t*)malloc(sizeof(Tau_plugin_callbacks_t)); TAU_UTIL_INIT_TAU_PLUGIN_CALLBACKS(cb); cb->EndOfExecution = Tau_plugin_example_mpit_recommend_sharp_usage; TAU_UTIL_PLUGIN_REGISTER_CALLBACKS(cb); diff --git a/plugins/examples/Tau_plugin_sos.cpp b/plugins/examples/Tau_plugin_sos.cpp index 8e00a8058..e6c328693 100644 --- a/plugins/examples/Tau_plugin_sos.cpp +++ b/plugins/examples/Tau_plugin_sos.cpp @@ -18,9 +18,17 @@ #include #include #include +#if TAU_MPI +#include "mpi.h" +#endif + +extern tau::Profiler* Tau_get_timer_at_stack_depth(int pos); + +static bool enabled(false); /* Only dump data to SOS if we aren't doing periodic dumps */ -int Tau_plugin_sos_dump(Tau_plugin_event_dump_data data) { +int Tau_plugin_sos_dump(Tau_plugin_event_dump_data_t* data) { + if (!enabled) return 0; //printf("TAU PLUGIN SOS: dump\n"); if (thePluginOptions().env_sos_periodic != 1) { TAU_SOS_send_data(); @@ -29,144 +37,129 @@ int Tau_plugin_sos_dump(Tau_plugin_event_dump_data data) { } /* This is a weird event, not sure what for */ -int Tau_plugin_finalize(Tau_plugin_event_function_finalize_data data) { +int Tau_plugin_finalize(Tau_plugin_event_function_finalize_data_t* data) { return 0; } /* This happens from MPI_Finalize, before MPI is torn down. */ -int Tau_plugin_sos_pre_end_of_execution(Tau_plugin_event_pre_end_of_execution_data data) { +int Tau_plugin_sos_pre_end_of_execution(Tau_plugin_event_pre_end_of_execution_data_t* data) { + if (!enabled) return 0; //fprintf(stdout, "TAU PLUGIN SOS Pre-Finalize\n"); fflush(stdout); // OK to do it from any thread, because it came from MPI_Finalize TAU_SOS_send_data(); /* We used to finalize now, but we no longer use MPI in the finalization * so it's ok to wait until all timers are done */ /* - if (data.tid == 0) { + if (data->tid == 0) { TAU_SOS_finalize(); } */ return 0; } -/* This happens from Profiler.cpp, when data is written out. */ -int Tau_plugin_sos_end_of_execution(Tau_plugin_event_end_of_execution_data data) { - //fprintf(stdout, "TAU PLUGIN SOS Finalize\n"); fflush(stdout); - if (data.tid == 0) { - TAU_SOS_finalize(); - } - return 0; -} - /* This happens after MPI_Init, and after all TAU metadata variables have been * read */ -int Tau_plugin_sos_post_init(Tau_plugin_event_post_init_data data) { +int Tau_plugin_sos_post_init(Tau_plugin_event_post_init_data_t* data) { + if (!enabled) return 0; //fprintf(stdout, "TAU PLUGIN SOS Post Init\n"); fflush(stdout); TAU_SOS_send_data(); return 0; } /* This happens on Tau_start() */ -int Tau_plugin_sos_function_entry(Tau_plugin_event_function_entry_data data) { +int Tau_plugin_sos_function_entry(Tau_plugin_event_function_entry_data_t* data) { + if (!enabled) return 0; /* First, check to see if we are including/excluding this timer */ - /* - if (thePluginOptions().env_sos_use_selection == 1) { - if (Tau_SOS_contains(thePluginOptions().excluded_timers, data.timer_name, false) || - !Tau_SOS_contains(thePluginOptions().included_timers, data.timer_name, true)) { - return 0; - } + if (skip_timer(data->timer_name)) { + return 0; } - */ /* todo: filter on group, timer name */ std::stringstream ss; - ss << "TAU_EVENT_ENTRY:" << data.tid << ":" << data.timer_name; + ss << "TAU_EVENT_ENTRY:" << data->tid << ":" << data->timer_name; //std::cout << ss.str() << std::endl; - Tau_SOS_pack_long(ss.str().c_str(), data.timestamp); + Tau_SOS_pack_long(ss.str().c_str(), data->timestamp); return 0; } /* This happens on Tau_stop() */ -int Tau_plugin_sos_function_exit(Tau_plugin_event_function_exit_data data) { +int Tau_plugin_sos_function_exit(Tau_plugin_event_function_exit_data_t* data) { + if (!enabled) return 0; /* First, check to see if we are including/excluding this timer */ - /* - if (thePluginOptions().env_sos_use_selection == 1) { - if (Tau_SOS_contains(thePluginOptions().excluded_timers, data.timer_name, false) || - !Tau_SOS_contains(thePluginOptions().included_timers, data.timer_name, true)) { - return 0; - } + if (skip_timer(data->timer_name)) { + return 0; } - */ /* todo: filter on group, timer name */ std::stringstream ss; - ss << "TAU_EVENT_EXIT:" << data.tid << ":" << data.timer_name; + ss << "TAU_EVENT_EXIT:" << data->tid << ":" << data->timer_name; //std::cout << ss.str() << std::endl; - Tau_SOS_pack_long(ss.str().c_str(), data.timestamp); + Tau_SOS_pack_long(ss.str().c_str(), data->timestamp); return 0; } /* This happens on Tau_userevent() */ -int Tau_plugin_sos_atomic_trigger(Tau_plugin_event_atomic_event_trigger_data data) { +int Tau_plugin_sos_atomic_trigger(Tau_plugin_event_atomic_event_trigger_data_t* data) { + if (!enabled) return 0; /* First, check to see if we are including/excluding this counter */ - /* - if (thePluginOptions().env_sos_use_selection == 1) { - if (Tau_SOS_contains(thePluginOptions().excluded_counters, data.counter_name, false) || - !Tau_SOS_contains(thePluginOptions().included_counters, data.counter_name, true)) { - return 0; - } + if (skip_counter(data->counter_name)) { + return 0; } - */ std::stringstream ss; - ss << "TAU_EVENT_COUNTER:" << data.tid << ":" << data.counter_name; - //std::cout << ss.str() << " = " << data.value << std::endl; - Tau_SOS_pack_long(ss.str().c_str(), data.value); + ss << "TAU_EVENT_COUNTER:" << data->tid << ":" << data->counter_name; + //std::cout << ss.str() << " = " << data->value << std::endl; + Tau_SOS_pack_long(ss.str().c_str(), data->value); return 0; } /* This happens for special events from ADIOS, MPI */ -int Tau_plugin_sos_current_timer_exit(Tau_plugin_event_current_timer_exit_data data) { - Tau_SOS_pack_current_timer(data.name_prefix); +int Tau_plugin_sos_current_timer_exit(Tau_plugin_event_current_timer_exit_data_t* data) { + if (!enabled) return 0; + Tau_SOS_pack_current_timer(data->name_prefix); return 0; } /* This happens on MPI_Send events (and similar) */ -int Tau_plugin_sos_send(Tau_plugin_event_send_data data) { +int Tau_plugin_sos_send(Tau_plugin_event_send_data_t* data) { + if (!enabled) return 0; /* todo: filter on group, timer name */ std::stringstream ss; - ss << "TAU_EVENT_SEND:" << data.tid - << ":" << data.message_tag - << ":" << data.destination - << ":" << data.bytes_sent; + ss << "TAU_EVENT_SEND:" << data->tid + << ":" << data->message_tag + << ":" << data->destination + << ":" << data->bytes_sent; //std::cout << ss.str() << std::endl; - Tau_SOS_pack_long(ss.str().c_str(), data.timestamp); + Tau_SOS_pack_long(ss.str().c_str(), data->timestamp); return 0; } /* This happens on MPI_Recv events (and similar) */ -int Tau_plugin_sos_recv(Tau_plugin_event_recv_data data) { +int Tau_plugin_sos_recv(Tau_plugin_event_recv_data_t* data) { + if (!enabled) return 0; /* todo: filter on group, timer name */ std::stringstream ss; - ss << "TAU_EVENT_RECV:" << data.tid - << ":" << data.message_tag - << ":" << data.source - << ":" << data.bytes_received; + ss << "TAU_EVENT_RECV:" << data->tid + << ":" << data->message_tag + << ":" << data->source + << ":" << data->bytes_received; //std::cout << ss.str() << std::endl; - Tau_SOS_pack_long(ss.str().c_str(), data.timestamp); + Tau_SOS_pack_long(ss.str().c_str(), data->timestamp); return 0; } /* This happens when a Metadata field is saved. */ -int Tau_plugin_metadata_registration_complete_func(Tau_plugin_event_metadata_registration_data data) { +int Tau_plugin_metadata_registration_complete_func(Tau_plugin_event_metadata_registration_data_t* data) { + if (!enabled) return 0; //fprintf(stdout, "TAU Metadata registration\n"); fflush(stdout); std::stringstream ss; - ss << "TAU_Metadata:" << 0 << ":" << data.name; - switch(data.value->type) { + ss << "TAU_Metadata:" << 0 << ":" << data->name; + switch(data->value->type) { case TAU_METADATA_TYPE_STRING: - Tau_SOS_pack_string(ss.str().c_str(), data.value->data.cval); + Tau_SOS_pack_string(ss.str().c_str(), data->value->data.cval); break; case TAU_METADATA_TYPE_INTEGER: - Tau_SOS_pack_integer(ss.str().c_str(), data.value->data.ival); + Tau_SOS_pack_integer(ss.str().c_str(), data->value->data.ival); break; case TAU_METADATA_TYPE_DOUBLE: - Tau_SOS_pack_double(ss.str().c_str(), data.value->data.dval); + Tau_SOS_pack_double(ss.str().c_str(), data->value->data.dval); break; case TAU_METADATA_TYPE_TRUE: Tau_SOS_pack_string(ss.str().c_str(), const_cast("true")); @@ -183,11 +176,48 @@ int Tau_plugin_metadata_registration_complete_func(Tau_plugin_event_metadata_reg return 0; } +/* This happens from Profiler.cpp, when data is written out. */ +int Tau_plugin_sos_end_of_execution(Tau_plugin_event_end_of_execution_data_t* data) { + if (!enabled || data->tid != 0) return 0; + /* If we are tracing, we need to "stop" all of the remaining timers on the stack */ + if (thePluginOptions().env_sos_tracing) { + Tau_plugin_event_function_exit_data_t exit_data; + // safe to assume 0? + //int tid = exit_data.tid; + RtsLayer::UnLockDB(); + for (int tid = TAU_MAX_THREADS-1 ; tid >= 0 ; tid--) { + int depth = Tau_get_current_stack_depth(tid); + for (int i = depth ; i > -1 ; i--) { + tau::Profiler *profiler = Tau_get_timer_at_stack_depth(i); + if (profiler->ThisFunction->GetName() == NULL) { + // small memory leak, but at shutdown. + exit_data.timer_name = strdup(".TAU application"); + } else { + exit_data.timer_name = profiler->ThisFunction->GetName(); + exit_data.timer_group = profiler->ThisFunction->GetAllGroups(); + } + exit_data.tid = tid; + double CurrentTime[TAU_MAX_COUNTERS] = { 0 }; + RtsLayer::getUSecD(tid, CurrentTime); + exit_data.timestamp = (x_uint64)CurrentTime[0]; // USE COUNTER1 for tracing + //printf("%d,%d Stopping %s\n", getpid(), tid, data.timer_name); + Tau_plugin_sos_function_exit(&exit_data); + } + } + RtsLayer::UnLockDB(); + } + enabled = false; + //fprintf(stdout, "TAU PLUGIN SOS Finalize\n"); fflush(stdout); + TAU_SOS_finalize(); + return 0; +} + + /*This is the init function that gets invoked by the plugin mechanism inside TAU. * Every plugin MUST implement this function to register callbacks for various events * that the plugin is interested in listening to*/ extern "C" int Tau_plugin_init_func(int argc, char **argv) { - Tau_plugin_callbacks * cb = (Tau_plugin_callbacks*)malloc(sizeof(Tau_plugin_callbacks)); + Tau_plugin_callbacks_t * cb = (Tau_plugin_callbacks_t*)malloc(sizeof(Tau_plugin_callbacks_t)); //fprintf(stdout, "TAU PLUGIN SOS Init\n"); fflush(stdout); // Parse our settings TAU_SOS_parse_environment_variables(); @@ -223,9 +253,30 @@ extern "C" int Tau_plugin_init_func(int argc, char **argv) { /* Register the callback object */ TAU_UTIL_PLUGIN_REGISTER_CALLBACKS(cb); + enabled = true; + + /* If we are tracing, we need to "start" all of the timers on the stack */ + if (thePluginOptions().env_sos_tracing) { + RtsLayer::LockDB(); + //int tid = RtsLayer::myThread(); + for (int tid = TAU_MAX_THREADS-1 ; tid >= 0 ; tid--) { + Tau_plugin_event_function_entry_data_t entry_data; + // safe to assume 0? + int depth = Tau_get_current_stack_depth(tid); + for (int i = 0 ; i <= depth ; i++) { + tau::Profiler *profiler = Tau_get_timer_at_stack_depth(i); + entry_data.timer_name = profiler->ThisFunction->GetName(); + entry_data.timer_group = profiler->ThisFunction->GetAllGroups(); + entry_data.tid = tid; + entry_data.timestamp = (x_uint64)profiler->StartTime[0]; + //printf("%d,%d Starting %s\n", getpid(), tid, data.timer_name); + Tau_plugin_sos_function_entry(&entry_data); + } + } + RtsLayer::UnLockDB(); + } return 0; } - #endif // TAU_SOS diff --git a/plugins/testplugins/Tau_plugin_atomic_event_registration_complete.cpp b/plugins/testplugins/Tau_plugin_atomic_event_registration_complete.cpp index 3142393bb..7f55afa36 100644 --- a/plugins/testplugins/Tau_plugin_atomic_event_registration_complete.cpp +++ b/plugins/testplugins/Tau_plugin_atomic_event_registration_complete.cpp @@ -15,9 +15,9 @@ #include -int Tau_plugin_test_event_atomic_event_registration_complete(Tau_plugin_event_atomic_event_registration_data data) { +int Tau_plugin_test_event_atomic_event_registration_complete(Tau_plugin_event_atomic_event_registration_data_t *data) { - std::cout << "TAU PLUGIN: Event with name " << ((tau::TauUserEvent *)data.user_event_ptr)->GetName() << " has been registered" << std::endl; + std::cout << "TAU PLUGIN: Event with name " << ((tau::TauUserEvent *)data->user_event_ptr)->GetName() << " has been registered" << std::endl; return 0; } diff --git a/plugins/testplugins/Tau_plugin_atomic_event_trigger.cpp b/plugins/testplugins/Tau_plugin_atomic_event_trigger.cpp index dd332d6d6..754a8333d 100644 --- a/plugins/testplugins/Tau_plugin_atomic_event_trigger.cpp +++ b/plugins/testplugins/Tau_plugin_atomic_event_trigger.cpp @@ -15,9 +15,9 @@ #include -int Tau_plugin_test_event_atomic_event_trigger(Tau_plugin_event_atomic_event_trigger_data data) { +int Tau_plugin_test_event_atomic_event_trigger(Tau_plugin_event_atomic_event_trigger_data_t*data) { - std::cout << "TAU PLUGIN: Event with name " << data.counter_name << " has been triggered with value " << data.value << std::endl; + std::cout << "TAU PLUGIN: Event with name " << data->counter_name << " has been triggered with value " << data->value << std::endl; return 0; } diff --git a/plugins/testplugins/Tau_plugin_end_of_execution.cpp b/plugins/testplugins/Tau_plugin_end_of_execution.cpp index bb6629a21..517f6b8aa 100644 --- a/plugins/testplugins/Tau_plugin_end_of_execution.cpp +++ b/plugins/testplugins/Tau_plugin_end_of_execution.cpp @@ -15,9 +15,9 @@ #include -int Tau_plugin_test_event_end_of_execution(Tau_plugin_event_end_of_execution_data data) { +int Tau_plugin_test_event_end_of_execution(Tau_plugin_event_end_of_execution_data_t* data) { - std::cout << "TAU PLUGIN: End of execution reached for threadId: " << data.tid << std::endl; + std::cout << "TAU PLUGIN: End of execution reached for threadId: " << data->tid << std::endl; return 0; } diff --git a/plugins/testplugins/Tau_plugin_function_registration_complete.cpp b/plugins/testplugins/Tau_plugin_function_registration_complete.cpp index a51e53fe2..9cc9bb410 100644 --- a/plugins/testplugins/Tau_plugin_function_registration_complete.cpp +++ b/plugins/testplugins/Tau_plugin_function_registration_complete.cpp @@ -16,8 +16,8 @@ #include #include -int Tau_plugin_test_event_function_registration_complete(Tau_plugin_event_function_registration_data data) { - printf("TAU PLUGIN: Function %s has been registered for tid: %d\n", Tau_profile_get_name(data.function_info_ptr), data.tid); +int Tau_plugin_test_event_function_registration_complete(Tau_plugin_event_function_registration_data_t* data) { + printf("TAU PLUGIN: Function %s has been registered for tid: %d\n", Tau_profile_get_name(data->function_info_ptr), data->tid); return 0; } diff --git a/plugins/testplugins/Tau_plugin_interrupt_trigger.cpp b/plugins/testplugins/Tau_plugin_interrupt_trigger.cpp index 109107ee7..5b3a1b3fa 100644 --- a/plugins/testplugins/Tau_plugin_interrupt_trigger.cpp +++ b/plugins/testplugins/Tau_plugin_interrupt_trigger.cpp @@ -15,9 +15,9 @@ #include -int Tau_plugin_test_event_interrupt_trigger(Tau_plugin_event_interrupt_trigger_data data) { +int Tau_plugin_test_event_interrupt_trigger(Tau_plugin_event_interrupt_trigger_data_t *data) { - std::cout << "TAU PLUGIN: Interrupt has been triggered for signal: " << data.signum << std::endl; + std::cout << "TAU PLUGIN: Interrupt has been triggered for signal: " << data->signum << std::endl; return 0; } diff --git a/bootstrap.sh b/scripts/bootstrap.sh similarity index 100% rename from bootstrap.sh rename to scripts/bootstrap.sh diff --git a/scripts/titan_gcc.sh b/scripts/titan_gcc.sh new file mode 100755 index 000000000..f58d3d344 --- /dev/null +++ b/scripts/titan_gcc.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +source $MODULESHOME/init/bash +module swap PrgEnv-pgi PrgEnv-gnu +module load cmake3/3.9.0 +module load cudatoolkit +module load wget +module load papi +module load python +module load perl +module list + +set -x + +WORK_DIR=$PWD +INSTALL_ROOT=/ccs/proj/super/TOOLS + +if [ ! -d ${INSTALL_ROOT} ] ; then + mkdir -p ${INSTALL_ROOT} +fi + +PDT_VERSION=3.25 +TAU_VERSION=2018-07-31 + +echo_start() +{ + echo -e "====== BUILDING $1 ======" +} + +echo_done() +{ + echo -e "====== DONE BUILDING $1 ======" +} + +build_pdt() { + echo_start "pdt" + subdir=pdtoolkit-${PDT_VERSION} + if [ ! -d ${subdir} ] ; then + if [ ! -f pdt-3.25.tar.gz ] ; then + wget https://www.cs.uoregon.edu/research/tau/pdt_releases/pdt-${PDT_VERSION}.tar.gz + fi + tar -xzf pdt-${PDT_VERSION}.tar.gz + fi + cd ${subdir} + CC=gcc CXX=g++ ./configure -GNU -prefix=${INSTALL_ROOT}/pdt/pdtoolkit-${PDT_VERSION} + make -j8 -l24 + make install + cd .. + echo_done "pdt" +} + +build_tau() +{ + echo_start "tau" + if [ ! -d tau2-${TAU_VERSION} ] ; then + if [ ! -f tau2-${TAU_VERSION}.tar.gz ] ; then + wget http://www.nic.uoregon.edu/~khuck/tau2-${TAU_VERSION}.tar.gz + fi + tar -xzf tau2-${TAU_VERSION}.tar.gz + fi + cd tau2-${TAU_VERSION} + + PAPI_PATH=`pkg-config --cflags papi | sed -r 's/^-I//' | xargs dirname` + + # base configure for front-end tools + CC=gcc CXX=g++ ./configure \ + -prefix=${INSTALL_ROOT}/tau/tau-${TAU_VERSION} \ + -pdt=${INSTALL_ROOT}/pdt/pdtoolkit-${PDT_VERSION} \ + -pdt_c++=g++ \ + -bfd=download -unwind=download -otf=download \ + -arch=craycnl + make -j8 -l32 install + +# rm -rf LLVM-openmp-0.2 +# wget http://tau.uoregon.edu/LLVM-openmp-0.2.tar.gz +# tar -xzf LLVM-openmp-0.2.tar.gz +# cd LLVM-openmp-0.2 +# mkdir build-g++ +# cd build-g++ +# cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \ +# -DCMAKE_C_FLAGS=-fPIC -DCMAKE_CXX_FLAGS=-fPIC \ +# -DCMAKE_INSTALL_PREFIX=${INSTALL_ROOT}/tau/tau-${TAU_VERSION}/craycnl/LLVM-openmp-0.2 .. +# make libomp-needed-headers +# make +# make install +# cd ../.. + + # different configurations for mutually exclusive config options. + for cuda_settings in "" "-cuda=${CUDATOOLKIT_HOME}" ; do + #for thread_settings in "-pthread" "-openmp -ompt=${INSTALL_ROOT}/tau/tau-${TAU_VERSION}/craycnl/LLVM-openmp-0.2" "-openmp -opari" ; do + for thread_settings in "-pthread" ; do + for python_settings in "" "-python" ; do + # build config with all RAPIDS support + ./configure \ + -prefix=${INSTALL_ROOT}/tau/tau-${TAU_VERSION} \ + -pdt=${INSTALL_ROOT}/pdt/pdtoolkit-${PDT_VERSION} \ + -pdt_c++=g++ \ + -bfd=download -unwind=download -otf=download \ + -arch=craycnl \ + -cc=gcc -c++=g++ -fortran=gfortran \ + -iowrapper -mpi \ + -papi=${PAPI_PATH} \ + ${thread_settings} ${cuda_settings} ${python_settings} + make -j8 -l32 install + done + done + done + + cd .. + echo_done "tau" +} + +#============================================================================== + +# build_pdt +build_tau + +rm *tar.gz diff --git a/src/Profile/FunctionInfo.cpp b/src/Profile/FunctionInfo.cpp index dca41874a..db22d4c4c 100644 --- a/src/Profile/FunctionInfo.cpp +++ b/src/Profile/FunctionInfo.cpp @@ -309,8 +309,8 @@ void FunctionInfo::FunctionInfoInit(TauGroup_t ProfileGroup, const char *Profile #endif //RENCI_STFF /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_function_registration_data plugin_data; + if(Tau_plugins_enabled.function_registration) { + Tau_plugin_event_function_registration_data_t plugin_data; plugin_data.function_info_ptr = this; plugin_data.tid = tid; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_FUNCTION_REGISTRATION, &plugin_data); diff --git a/src/Profile/PapiLayer.cpp b/src/Profile/PapiLayer.cpp index 0421167b5..9d8bc45f7 100644 --- a/src/Profile/PapiLayer.cpp +++ b/src/Profile/PapiLayer.cpp @@ -780,15 +780,15 @@ int PapiLayer::initializePerfRAPL(int tid) { /* Check paranoid setting */ FILE *para = fopen("/proc/sys/kernel/perf_event_paranoid", "r"); int para_val; - fscanf(para, "%d", ¶_val); - if (para_val != -1) { + int scanned = fscanf(para, "%d", ¶_val); + if (para_val != -1 || scanned == EOF) { fprintf(stderr, "Error: To use TAU's PAPI Perf interface please ensure that /proc/sys/kernel/perf_event_paranoid has a -1 in it.\n"); exit(1); } fclose(para); numCounters = 0; - ret = PAPI_add_named_event(ThreadList[tid]->EventSet[rapl_cid], "rapl::RAPL_ENERGY_CORES"); + ret = PAPI_add_named_event(ThreadList[tid]->EventSet[rapl_cid], (char*)"rapl::RAPL_ENERGY_CORES"); if (PAPI_OK != ret) { #ifdef DEBUG_PROF fprintf(stderr,"Error: PAPI_add_named_event(RAPL_ENERGY_CORES) because %s.\nPlease ensure that /proc/sys/kernel/perf_event_paranoid has a -1 and your system has /sys/devices/power/events/energy-pkg.scale.\n", PAPI_strerror(ret)); @@ -800,7 +800,7 @@ int PapiLayer::initializePerfRAPL(int tid) { numCounters++; } - ret = PAPI_add_named_event(ThreadList[tid]->EventSet[rapl_cid], "rapl::RAPL_ENERGY_PKG"); + ret = PAPI_add_named_event(ThreadList[tid]->EventSet[rapl_cid], (char*)"rapl::RAPL_ENERGY_PKG"); if (PAPI_OK != ret) { #ifdef DEBUG_PROF @@ -816,7 +816,7 @@ int PapiLayer::initializePerfRAPL(int tid) { #endif /* TAU_BEACON */ } - ret = PAPI_add_named_event(ThreadList[tid]->EventSet[rapl_cid], "rapl::RAPL_ENERGY_GPU"); + ret = PAPI_add_named_event(ThreadList[tid]->EventSet[rapl_cid], (char*)"rapl::RAPL_ENERGY_GPU"); if (PAPI_OK != ret) { #ifdef DEBUG_PROF fprintf(stderr,"Error: PAPI_add_named_event(RAPL_ENERGY_GPU) because %s.\nPlease ensure that /proc/sys/kernel/perf_event_paranoid has a -1 and your system has /sys/devices/power/events/energy-pkg.scale.\n", PAPI_strerror(ret)); @@ -828,7 +828,7 @@ int PapiLayer::initializePerfRAPL(int tid) { numCounters++; } - ret = PAPI_add_named_event(ThreadList[tid]->EventSet[rapl_cid], "rapl::RAPL_ENERGY_DRAM"); + ret = PAPI_add_named_event(ThreadList[tid]->EventSet[rapl_cid], (char*)"rapl::RAPL_ENERGY_DRAM"); if (PAPI_OK != ret) { // OK: this event is only available on servers } else { @@ -844,8 +844,8 @@ int PapiLayer::initializePerfRAPL(int tid) { } char line[100]; - fgets( line,100,fp ); - if( sscanf(line,"%lf",&scalingFactor) != 1 ) { + char *tmp = fgets( line,100,fp ); + if( tmp == NULL || sscanf(line,"%lf",&scalingFactor) != 1 ) { printf("%s: /sys/devices/power/events/energy-pkg.scale doesn't contain a double", line); exit(1); } diff --git a/src/Profile/Profiler.cpp b/src/Profile/Profiler.cpp index 166918da5..7bc08f981 100644 --- a/src/Profile/Profiler.cpp +++ b/src/Profile/Profiler.cpp @@ -364,8 +364,8 @@ void Profiler::Start(int tid) #endif /* TAUKTAU */ /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_function_entry_data plugin_data; + if(Tau_plugins_enabled.function_entry) { + Tau_plugin_event_function_entry_data_t plugin_data; plugin_data.timer_name = ThisFunction->GetName(); plugin_data.timer_group = ThisFunction->GetAllGroups(); plugin_data.tid = tid; @@ -701,8 +701,8 @@ void Profiler::Stop(int tid, bool useLastTimeStamp) #endif /* TAUKTAU */ /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_function_exit_data plugin_data; + if(Tau_plugins_enabled.function_exit) { + Tau_plugin_event_function_exit_data_t plugin_data; plugin_data.timer_name = ThisFunction->GetName(); plugin_data.timer_group = ThisFunction->GetAllGroups(); plugin_data.tid = tid; @@ -1482,8 +1482,8 @@ int TauProfiler_StoreData(int tid) #ifndef TAU_MPI /*Invoke plugins only if both plugin path and plugins are specified *Do this first, because the plugin can write TAU_METADATA as recommendations to the user*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_pre_end_of_execution_data plugin_data; + if(Tau_plugins_enabled.pre_end_of_execution) { + Tau_plugin_event_pre_end_of_execution_data_t plugin_data; plugin_data.tid = tid; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_PRE_END_OF_EXECUTION, &plugin_data); } @@ -1584,8 +1584,8 @@ int TauProfiler_StoreData(int tid) TAU_VERBOSE("TAU<%d,%d>: TauProfiler_StoreData 5\n", RtsLayer::myNode(), tid); /*Invoke plugins only if both plugin path and plugins are specified *Do this first, because the plugin can write TAU_METADATA as recommendations to the user*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_end_of_execution_data plugin_data; + if(Tau_plugins_enabled.end_of_execution) { + Tau_plugin_event_end_of_execution_data_t plugin_data; plugin_data.tid = tid; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_END_OF_EXECUTION, &plugin_data); } diff --git a/src/Profile/TauADIOS.cpp b/src/Profile/TauADIOS.cpp index eb8596dce..f1be74b5b 100644 --- a/src/Profile/TauADIOS.cpp +++ b/src/Profile/TauADIOS.cpp @@ -84,11 +84,10 @@ extern "C" int TAU_inside_ADIOS(void) { output a trace event if we aren't currently timing another ADIOS call. */ void Tau_SOS_conditionally_pack_current_timer(const char * name) { - int foo = TAU_decrement_stack_height(); - if (foo == 0) { + if (TAU_decrement_stack_height() == 0) { /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_current_timer_exit_data plugin_data; + if(Tau_plugins_enabled.current_timer_exit) { + Tau_plugin_event_current_timer_exit_data_t plugin_data; plugin_data.name_prefix = name; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_CURRENT_TIMER_EXIT, &plugin_data); } @@ -98,7 +97,9 @@ void Tau_SOS_conditionally_pack_current_timer(const char * name) { #define TAU_SOS_COLLECTIVE_ADIOS_EVENT(__detail) \ std::stringstream __ss; \ __ss << EVENT_TRACE_PREFIX << __detail << "()"; \ - Tau_SOS_conditionally_pack_current_timer(__ss.str().c_str()); + char * _tmp = strdup(__ss.str().c_str()); \ + Tau_SOS_conditionally_pack_current_timer(_tmp); \ + free(_tmp); void TAU_SOS_collective_ADIOS_write_event(const char * detail, const char * var_name, enum ADIOS_DATATYPES data_type, @@ -172,8 +173,9 @@ void TAU_SOS_collective_ADIOS_write_event(const char * detail, ss << "[" << dims << "]"; } ss << ")"; - //printf("%s\n", ss.str().c_str()); - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); } #else #define TAU_SOS_COLLECTIVE_ADIOS_EVENT // do nuthin. @@ -230,7 +232,19 @@ ADIOST_EXTERN void tau_adiost_open ( adiost_event_type_t type, TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - TAU_SOS_COLLECTIVE_ADIOS_EVENT(function_name); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " file_descriptor: " << std::hex << file_descriptor << ","; + ss << " group_name: '" << group_name << "',"; + ss << " file_name: '" << file_name << "',"; + ss << " mode: '" << mode << "',"; + ss << " comm: " << std::hex << "0x" << comm << ") " << type; + // need to make a copy of the temporary that comes + // out of this call + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + // delete our copy + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -244,7 +258,15 @@ ADIOST_EXTERN void tau_adiost_close(adiost_event_type_t type, TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - TAU_SOS_COLLECTIVE_ADIOS_EVENT(function_name); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " file_descriptor: " << std::hex << file_descriptor << ")"; + // need to make a copy of the temporary that comes + // out of this call + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + // delete our copy + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -784,29 +806,35 @@ ADIOST_EXTERN void tau_adiost_read_init_method( const char * parameters) { const char * function_name = "adios_read_init_method"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " method: " << method << ","; - ss << " comm: " << std::hex << "0x" << comm << ","; - // The parameters has newlines in it - strip them out. - std::string s(parameters); - std::replace(s.begin(), s.end(), '\n', ' '); - std::replace(s.begin(), s.end(), '\r', ' '); - // The parameters are corrupting the SQL insert later, disabled for now - //ss << " parameters: [" << s.c_str() << "]"; - ss << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); + Tau_increment_stack_height(); } else if (type == adiost_event_exit) { + TAU_decrement_stack_height(); TAU_PROFILE_STOP(tautimer); - Tau_increment_stack_height(); } else { // not conditional! neither start nor stop. /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_current_timer_exit_data plugin_data; - plugin_data.name_prefix = ss.str().c_str(); + if(Tau_plugins_enabled.current_timer_exit) { + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " method: " << method << ","; + ss << " comm: " << std::hex << "0x" << comm << ","; + // The parameters has newlines in it - strip them out. + std::string s(parameters); + std::replace(s.begin(), s.end(), '\n', ' '); + std::replace(s.begin(), s.end(), '\r', ' '); + // The parameters are corrupting the SQL insert later, disabled for now + ss << " parameters: [" << s.c_str() << "]"; + ss << ")"; + Tau_plugin_event_current_timer_exit_data_t plugin_data; + // need to make a copy of the temporary that comes + // out of this call + char * tmp = strdup(ss.str().c_str()); + plugin_data.name_prefix = tmp; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_CURRENT_TIMER_EXIT, &plugin_data); + // delete our copy + free(tmp); } } } @@ -816,20 +844,26 @@ ADIOST_EXTERN void tau_adiost_read_finalize_method( enum ADIOS_READ_METHOD method ) { const char * function_name = "adios_read_finalize_method"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " method: " << method << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); + Tau_increment_stack_height(); } else if (type == adiost_event_exit) { + TAU_decrement_stack_height(); TAU_PROFILE_STOP(tautimer); - Tau_increment_stack_height(); } else { /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_current_timer_exit_data plugin_data; - plugin_data.name_prefix = ss.str().c_str(); + if(Tau_plugins_enabled.current_timer_exit) { + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " method: " << method << ")"; + Tau_plugin_event_current_timer_exit_data_t plugin_data; + // need to make a copy of the temporary that comes + // out of this call + char * tmp = strdup(ss.str().c_str()); + plugin_data.name_prefix = tmp; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_CURRENT_TIMER_EXIT, &plugin_data); + // delete our copy + free(tmp); } } } @@ -843,18 +877,20 @@ ADIOST_EXTERN void tau_adiost_read_open( ADIOS_FILE * file_descriptor) { const char * function_name = "adios_read_open"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " method: " << method << ","; - ss << " comm: " << std::hex << "0x" << comm << ","; - ss << " lock_mode: " << lock_mode << ","; - ss << " timeout_sec: " << timeout_sec << ","; - ss << " file_descriptor: " << std::hex << file_descriptor << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " method: " << method << ","; + ss << " comm: " << std::hex << "0x" << comm << ","; + ss << " lock_mode: " << lock_mode << ","; + ss << " timeout_sec: " << timeout_sec << ","; + ss << " file_descriptor: " << std::hex << file_descriptor << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -868,17 +904,19 @@ ADIOST_EXTERN void tau_adiost_read_open_file( ADIOS_FILE * file_descriptor) { const char * function_name = "adios_read_open_file"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " fname: '" << fname << "',"; - ss << " method: " << method << ","; - ss << " comm: " << std::hex << "0x" << comm << ","; - ss << " file_descriptor: " << std::hex << file_descriptor << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " fname: '" << fname << "',"; + ss << " method: " << method << ","; + ss << " comm: " << std::hex << "0x" << comm << ","; + ss << " file_descriptor: " << std::hex << file_descriptor << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -891,17 +929,19 @@ ADIOST_EXTERN void tau_adiost_advance_step( float timeout_sec) { const char * function_name = "adios_advance_step"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " fp: " << std::hex << fp << ","; - ss << " last: " << last << ","; - ss << " timeout_sec: " << timeout_sec << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " fp: " << std::hex << fp << ","; + ss << " last: " << last << ","; + ss << " timeout_sec: " << timeout_sec << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); } else { } } @@ -913,16 +953,18 @@ ADIOST_EXTERN void tau_adiost_inq_var( ADIOS_VARINFO * varinfo) { const char * function_name = "adios_inq_var"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " fp: " << std::hex << fp << ","; - ss << " varname: '" << varname << "',"; - ss << " varinfo: " << std::hex << varinfo << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " fp: " << std::hex << fp << ","; + ss << " varname: '" << varname << "',"; + ss << " varinfo: " << std::hex << varinfo << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -935,16 +977,18 @@ ADIOST_EXTERN void tau_adiost_inq_var_byid( ADIOS_VARINFO * varinfo) { const char * function_name = "adios_inq_var_byid"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " fp: " << std::hex << fp << ","; - ss << " varid: " << varid << ","; - ss << " varinfo: " << std::hex << varinfo << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " fp: " << std::hex << fp << ","; + ss << " varid: " << varid << ","; + ss << " varinfo: " << std::hex << varinfo << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -955,14 +999,16 @@ ADIOST_EXTERN void tau_adiost_free_varinfo( ADIOS_VARINFO * varinfo) { const char * function_name = "adios_free_varinfo"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " varinfo: " << std::hex << varinfo << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " varinfo: " << std::hex << varinfo << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -1006,30 +1052,32 @@ ADIOST_EXTERN void tau_adiost_selection_boundingbox( ADIOS_SELECTION * selection) { const char * function_name = "adios_selection_boundingbox"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " ndim: " << ndim << ", start: ["; - int i; - if (ndim > 0) { - ss << start[0]; - } - for (i = 1 ; i < ndim ; i++) { - ss << "," << start[i]; - } - ss << "], end: ["; - if (ndim > 0) { - ss << count[0]; - } - for (i = 1 ; i < ndim ; i++) { - ss << "," << count[i]; - } - ss << "],"; - ss << " selection: " << std::hex << selection << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " ndim: " << ndim << ", start: ["; + int i; + if (ndim > 0) { + ss << start[0]; + } + for (i = 1 ; i < ndim ; i++) { + ss << "," << start[i]; + } + ss << "], end: ["; + if (ndim > 0) { + ss << count[0]; + } + for (i = 1 ; i < ndim ; i++) { + ss << "," << count[i]; + } + ss << "],"; + ss << " selection: " << std::hex << selection << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -1086,14 +1134,16 @@ ADIOST_EXTERN void tau_adiost_selection_delete( ADIOS_SELECTION * selection) { const char * function_name = "adios_selection_delete"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " selection: " << std::hex << selection << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " selection: " << std::hex << selection << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -1110,27 +1160,29 @@ ADIOST_EXTERN void tau_adiost_schedule_read( void * data) { const char * function_name = "adios_schedule_read"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " fp: " << std::hex << fp << ","; - ss << " selection: " << std::hex << selection << ","; - ss << " varname: '" << varname << "',"; - ss << " from_steps: " << from_steps << ","; - ss << " nsteps: " << nsteps << ", param: '"; - if (param != NULL) { - std::string s(param); - std::replace(s.begin(), s.end(), '\n', ' '); - std::replace(s.begin(), s.end(), '\r', ' '); - std::replace(s.begin(), s.end(), ';', ','); - ss << s.c_str(); - } - ss << "',"; - ss << " data: " << std::hex << data << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " fp: " << std::hex << fp << ","; + ss << " selection: " << std::hex << selection << ","; + ss << " varname: '" << varname << "',"; + ss << " from_steps: " << from_steps << ","; + ss << " nsteps: " << nsteps << ", param: '"; + if (param != NULL) { + std::string s(param); + std::replace(s.begin(), s.end(), '\n', ' '); + std::replace(s.begin(), s.end(), '\r', ' '); + std::replace(s.begin(), s.end(), ';', ','); + ss << s.c_str(); + } + ss << "',"; + ss << " data: " << std::hex << data << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -1147,27 +1199,29 @@ ADIOST_EXTERN void tau_adiost_schedule_read_byid( void * data) { const char * function_name = "adios_schedule_read_byid"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " fp: " << std::hex << fp << ","; - ss << " selection: " << std::hex << selection << ","; - ss << " varid: " << varid << ","; - ss << " from_steps: " << from_steps << ","; - ss << " nsteps: " << nsteps << ", param: '"; - if (param != NULL) { - std::string s(param); - std::replace(s.begin(), s.end(), '\n', ' '); - std::replace(s.begin(), s.end(), '\r', ' '); - std::replace(s.begin(), s.end(), ';', ','); - ss << s.c_str(); - } - ss << "',"; - ss << " data: " << std::hex << data << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " fp: " << std::hex << fp << ","; + ss << " selection: " << std::hex << selection << ","; + ss << " varid: " << varid << ","; + ss << " from_steps: " << from_steps << ","; + ss << " nsteps: " << nsteps << ", param: '"; + if (param != NULL) { + std::string s(param); + std::replace(s.begin(), s.end(), '\n', ' '); + std::replace(s.begin(), s.end(), '\r', ' '); + std::replace(s.begin(), s.end(), ';', ','); + ss << s.c_str(); + } + ss << "',"; + ss << " data: " << std::hex << data << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } @@ -1179,15 +1233,17 @@ ADIOST_EXTERN void tau_adiost_perform_reads( int blocking) { const char * function_name = "adios_perform_reads"; TAU_PROFILE_TIMER(tautimer, function_name, " ", TAU_IO); - std::stringstream ss; - ss << EVENT_TRACE_PREFIX << function_name << "("; - ss << " fp: " << std::hex << fp << ","; - ss << " blocking: " << blocking << ")"; if (type == adiost_event_enter) { TAU_PROFILE_START(tautimer); Tau_increment_stack_height(); } else if (type == adiost_event_exit) { - Tau_SOS_conditionally_pack_current_timer(ss.str().c_str()); + std::stringstream ss; + ss << EVENT_TRACE_PREFIX << function_name << "("; + ss << " fp: " << std::hex << fp << ","; + ss << " blocking: " << blocking << ")"; + char * tmp = strdup(ss.str().c_str()); + Tau_SOS_conditionally_pack_current_timer(tmp); + free(tmp); TAU_PROFILE_STOP(tautimer); } else { } diff --git a/src/Profile/TauCAPI.cpp b/src/Profile/TauCAPI.cpp index 5d69d9d2f..fa674d6e9 100644 --- a/src/Profile/TauCAPI.cpp +++ b/src/Profile/TauCAPI.cpp @@ -885,6 +885,14 @@ extern "C" int Tau_show_profiles() return 0; } +/* Used by SOS plugin to start all currently running timers + * because "tracing" is not enabled until after some timers + * are started. */ +extern Profiler * Tau_get_timer_at_stack_depth(int pos) +{ + return &(Tau_thread_flags[RtsLayer::myThread()].Tau_global_stack[pos]); +} + extern "C" void Tau_stop_all_timers(int tid) { TauInternalFunctionGuard protects_this_function; @@ -959,8 +967,8 @@ extern "C" void Tau_exit(const char * msg) { /*Invoke plugins only if both plugin path and plugins are specified * *Do this first, because the plugin can write TAU_METADATA as recommendations to the user*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_function_finalize_data plugin_data; + if(Tau_plugins_enabled.function_finalize) { + Tau_plugin_event_function_finalize_data_t plugin_data; plugin_data.junk = -1; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_FUNCTION_FINALIZE, &plugin_data); } @@ -997,8 +1005,8 @@ extern "C" void Tau_init(int argc, char **argv) { /////////////////////////////////////////////////////////////////////////// extern "C" void Tau_post_init(void) { /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_post_init_data plugin_data; + if(Tau_plugins_enabled.post_init) { + Tau_plugin_event_post_init_data_t plugin_data; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_POST_INIT, &plugin_data); } } @@ -1049,8 +1057,8 @@ extern "C" int Tau_dump(void) { TauProfiler_DumpData(); /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_dump_data plugin_data; + if(Tau_plugins_enabled.dump) { + Tau_plugin_event_dump_data_t plugin_data; plugin_data.tid = RtsLayer::myThread(); Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_DUMP, &plugin_data); } @@ -2551,8 +2559,8 @@ extern "C" void Tau_dynamic_stop(char const * name, int isPhase) Tau_stop_timer(fi, Tau_get_thread()); /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_dump_data plugin_data; + if(Tau_plugins_enabled.dump) { + Tau_plugin_event_dump_data_t plugin_data; plugin_data.tid = RtsLayer::myThread(); Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_DUMP, &plugin_data); } diff --git a/src/Profile/TauEnv.cpp b/src/Profile/TauEnv.cpp index 257690556..f1670263a 100644 --- a/src/Profile/TauEnv.cpp +++ b/src/Profile/TauEnv.cpp @@ -116,6 +116,12 @@ using namespace std; #define TAU_EBS_PERIOD_DEFAULT 50000 // Sameer made this bigger, #else #define TAU_EBS_PERIOD_DEFAULT 10000 // Kevin made this bigger, + +#ifdef TAU_PYTHON +#undef TAU_EBS_PERIOD_DEFAULT +#define TAU_EBS_PERIOD_DEFAULT 30000 // Sameer made this bigger, +#endif /* TAU_PYTHON */ + #endif /* CRAYCNL */ #endif // because smaller causes problems sometimes. @@ -343,6 +349,9 @@ static const char *env_mem_classes = NULL; static std::set * env_mem_classes_set = NULL; static int env_region_addresses = TAU_REGION_ADDRESSES_DEFAULT; +static const char *env_tau_exec_args = NULL; +static const char *env_tau_exec_path = NULL; + } // extern "C" /********************************************************************* @@ -760,6 +769,14 @@ extern "C" const char *TauEnv_get_tracedir() { return env_tracedir; } +extern "C" void TauEnv_set_profiledir(const char * new_profiledir) { + env_profiledir = strdup(new_profiledir); +} + +extern "C" void TauEnv_set_tracedir(const char * new_tracedir) { + env_tracedir = strdup(new_tracedir); +} + int TauEnv_get_synchronize_clocks() { return env_synchronize_clocks; } @@ -1192,6 +1209,15 @@ int TauEnv_get_mem_class_present(const char * name) { return env_mem_classes_set->count(name); } +const char * TauEnv_get_tau_exec_args() { + return env_tau_exec_args; +} + +const char * TauEnv_get_tau_exec_path() { + return env_tau_exec_path; +} + + /********************************************************************* * Initialize the TauEnv module, get configuration values ********************************************************************/ @@ -2006,7 +2032,8 @@ void TauEnv_initialize() } else { if ((env_plugins == NULL) && (env_plugins_path == NULL)) { TAU_VERBOSE("TAU: TAU_SELECT_FILE is set to %s when TAU plugins are not initialized\n", env_select_file); - env_plugins_path=strdup(TAU_LIB_DIR); + //env_plugins_path=strdup(TAU_LIB_DIR); + env_plugins_path=strdup("."); TAU_VERBOSE("TAU: TAU_PLUGINS_PATH is now %s\n", env_plugins_path); //sprintf(env_plugins,"libTAU-filter-plugin.so(%s)", env_select_file); char *plugins = (char *) malloc(1024); @@ -2016,7 +2043,10 @@ void TauEnv_initialize() TAU_VERBOSE("TAU: TAU plugin is now %s\n", env_plugins); TAU_METADATA("TAU_SELECT_FILE", filename); } else { - TAU_VERBOSE("TAU: Ignoring TAU_SELECT_FILE because TAU_PLUGINS and/or TAU_PLUGINS_PATH is set.\nPlease use export TAU_PLUGINS_PATH=%s and export TAU_PLUGINS=\"libTAU-filter-plugin.so(%s)\"\n", strdup(TAU_LIB_DIR), strdup(env_select_file)); + TAU_VERBOSE("TAU: Ignoring TAU_SELECT_FILE because TAU_PLUGINS and/or TAU_PLUGINS_PATH is set.\nPlease use export TAU_PLUGINS_PATH=%s and export TAU_PLUGINS=\"libTAU-filter-plugin.so(%s)\"\n", + //strdup(TAU_LIB_DIR), + strdup("."), + strdup(env_select_file)); } } @@ -2443,9 +2473,9 @@ void TauEnv_initialize() if ((env_mem_classes = getconf("TAU_MEM_CLASSES")) == NULL) { env_mem_classes = ""; - TAU_VERBOSE("TAU: MEM_CLASSES is not set\n", env_metrics); + TAU_VERBOSE("TAU: MEM_CLASSES is not set\n"); } else { - TAU_VERBOSE("TAU: MEM_CLASSES is \"%s\"\n", env_metrics); + TAU_VERBOSE("TAU: MEM_CLASSES is \"%s\"\n", env_mem_classes); if(strcmp(env_mem_classes, "all") == 0) { env_mem_all = 1; TAU_VERBOSE("TAU: Tracking All Class Allocations\n"); @@ -2458,6 +2488,20 @@ void TauEnv_initialize() } } + if ((env_tau_exec_args = getconf("TAU_EXEC_ARGS")) == NULL) { + env_tau_exec_args = ""; + TAU_VERBOSE("TAU: TAU_EXEC_ARGS is not set\n"); + } else { + TAU_VERBOSE("TAU: TAU_EXEC_ARGS is \"%s\"\n", env_tau_exec_args); + } + + if ((env_tau_exec_path = getconf("TAU_EXEC_PATH")) == NULL) { + env_tau_exec_path = ""; + TAU_VERBOSE("TAU: TAU_EXEC_PATH is not set\n"); + } else { + TAU_VERBOSE("TAU: TAU_EXEC_PATH is \"%s\"\n", env_tau_exec_path); + } + initialized = 1; TAU_VERBOSE("TAU: Initialized TAU (TAU_VERBOSE=1)\n"); diff --git a/src/Profile/TauHandler.cpp b/src/Profile/TauHandler.cpp index f74a931e8..4d8fa88ce 100644 --- a/src/Profile/TauHandler.cpp +++ b/src/Profile/TauHandler.cpp @@ -334,8 +334,8 @@ void TauAlarmHandler(int signum) { alarm(TheTauInterruptInterval()); #endif /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_interrupt_trigger_data plugin_data; + if(Tau_plugins_enabled.interrupt_trigger) { + Tau_plugin_event_interrupt_trigger_data_t plugin_data; plugin_data.signum = signum; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_INTERRUPT_TRIGGER, &plugin_data); } diff --git a/src/Profile/TauInit.cpp b/src/Profile/TauInit.cpp index 3499b10a0..e3a8edb93 100644 --- a/src/Profile/TauInit.cpp +++ b/src/Profile/TauInit.cpp @@ -443,15 +443,8 @@ extern "C" int Tau_init_initializeTAU() TauEnv_initialize(); #ifndef TAU_MPI - /*Initialize the plugin system only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - TAU_VERBOSE("TAU INIT: Initializing plugin system...\n"); - if(!Tau_initialize_plugin_system()) { - TAU_VERBOSE("TAU INIT: Successfully Initialized the plugin system.\n"); - } else { - printf("TAU INIT: Error initializing the plugin system\n"); - } - } + /* Initialize the plugin system */ + Tau_initialize_plugin_system(); #endif // TAU_MPI #ifdef TAU_EPILOG diff --git a/src/Profile/TauMetaData.cpp b/src/Profile/TauMetaData.cpp index c764f62bb..65f931a20 100644 --- a/src/Profile/TauMetaData.cpp +++ b/src/Profile/TauMetaData.cpp @@ -259,8 +259,8 @@ extern "C" void Tau_metadata_task(const char *name, const char *value, int tid) //printf("%s : %s\n", key.name, tmv->data.cval); /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_metadata_registration_data plugin_data; + if(Tau_plugins_enabled.metadata_registration) { + Tau_plugin_event_metadata_registration_data_t plugin_data; plugin_data.name = name; plugin_data.value = tmv; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_METADATA_REGISTRATION, &plugin_data); @@ -279,8 +279,8 @@ void Tau_metadata_push_to_plugins(void) { char tmp[128] = {0}; /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_metadata_registration_data plugin_data; + if(Tau_plugins_enabled.metadata_registration) { + Tau_plugin_event_metadata_registration_data_t plugin_data; plugin_data.name = it->first.name; plugin_data.value = it->second; Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_METADATA_REGISTRATION, &plugin_data); @@ -797,7 +797,7 @@ extern "C" int writeMetaDataAfterMPI_Init(void) { #endif /* TAU_FUJITSU && TAU_MPI */ /****** CRAY RELATED DATA *********/ - +#ifdef TAU_CRAYCNL FILE* procfile = fopen("/proc/self/stat", "r"); long to_read = 8192; char buffer[to_read]; @@ -814,6 +814,7 @@ extern "C" int writeMetaDataAfterMPI_Init(void) { } line = strtok(NULL, " "); + TAU_VERBOSE("WEIRD CRAY LINE: %s", line); Tau_metadata_register("CRAY_CORE_ID", line); } @@ -835,7 +836,8 @@ extern "C" int writeMetaDataAfterMPI_Init(void) { FILE *cfile; cfile = fopen("/proc/cray_xt/cname", "r"); if (cfile != NULL) { - fscanf(cfile, "%s", cname); + int scanned = fscanf(cfile, "%s", cname); + if (scanned == EOF) { perror("Error scanning /proc/cray_xt/cname !\n"); return 0; } fclose(cfile); Tau_metadata_register("CRAY_NODENAME", cname); @@ -855,7 +857,7 @@ extern "C" int writeMetaDataAfterMPI_Init(void) { Tau_metadata_register("CRAY_TOPO_SLOT_ID", slot); Tau_metadata_register("CRAY_TOPO_NODE_ID", node); } - +#endif /****** END CRAY RELATED DATA *********/ return 0; diff --git a/src/Profile/TauMetaDataMerge.cpp b/src/Profile/TauMetaDataMerge.cpp index a2a1a15d2..dda32ef26 100644 --- a/src/Profile/TauMetaDataMerge.cpp +++ b/src/Profile/TauMetaDataMerge.cpp @@ -48,36 +48,132 @@ using namespace std; extern "C" int TAU_MPI_Finalized(); +extern "C" int Tau_metadataMerge_mergeMetaData_bis() { + + Tau_metadata_fillMetaData(); + +#if 1 + static int merged = 0; + if (merged == 1) { + TAU_VERBOSE("merged = 1, return\n"); + return 0; + } + merged = 1; +#endif + + int rank = 0; + +#ifdef TAU_MPI + int numRanks; + +#if 1 + if (TAU_MPI_Finalized()) { + TAU_VERBOSE("TAU_MPI_Finalized() called, return\n"); + return 0; + } +#endif + + PMPI_Comm_rank(MPI_COMM_WORLD, &rank); + PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + TAU_VERBOSE("TAU Merge bis: rank=%d, numRanks=%d\n", rank, numRanks); +#endif /* TAU_MPI */ + + x_uint64 start, end; + +#if 1 + if (rank == 0) { + + TAU_VERBOSE("TAU: Merging MetaData...\n"); + start = TauMetrics_getTimeOfDay(); + +#if 1 +#ifdef TAU_MPI + Tau_util_outputDevice *out = Tau_metadata_generateMergeBuffer(); + char *defBuf = Tau_util_getOutputBuffer(out); + int defBufSize = Tau_util_getOutputBufferLength(out); + + PMPI_Bcast(&defBufSize, 1, MPI_INT, 0, MPI_COMM_WORLD); + PMPI_Bcast(defBuf, defBufSize, MPI_CHAR, 0, MPI_COMM_WORLD); +#endif /* TAU_MPI */ +#endif + + end = TauMetrics_getTimeOfDay(); + TAU_VERBOSE("TAU: MetaData Merging Complete, duration = %.4G seconds\n", ((double)(end-start))/1000000.0f); + char tmpstr[256]; + sprintf(tmpstr, "%.4G seconds", ((double)(end-start))/1000000.0f); + TAU_METADATA("TAU MetaData Merge Time", tmpstr); + +#if 1 +#ifdef TAU_MPI + Tau_util_destroyOutputDevice(out); +#endif /* TAU_MPI */ +#endif + + TAU_VERBOSE("TAU - MetaData bis: end if condition for rank 0\n"); + + } else { + +#if 1 +#ifdef TAU_MPI + TAU_VERBOSE("TAU: Metadata, rank different from 0\n"); + int BufferSize; + PMPI_Bcast(&BufferSize, 1, MPI_INT, 0, MPI_COMM_WORLD); + char *Buffer = (char*) TAU_UTIL_MALLOC(BufferSize); + PMPI_Bcast(Buffer, BufferSize, MPI_CHAR, 0, MPI_COMM_WORLD); + Tau_metadata_removeDuplicates(Buffer, BufferSize); + free(Buffer); +#endif /* TAU_MPI */ +#endif + + TAU_VERBOSE("TAU - MetaData bis: end if condition for other ranks\n"); + } +#endif + + TAU_VERBOSE("Tau_metadataMerge_mergeMetaData_bis END for rank #%d\n", rank); + + return 0; +} extern "C" int Tau_metadataMerge_mergeMetaData() { + TAU_VERBOSE("Tau_metadataMerge_mergeMetaData() begin\n"); + Tau_metadata_fillMetaData(); +#if 0 static int merged = 0; if (merged == 1) { + TAU_VERBOSE("merged = 1, return\n"); return 0; } merged = 1; +#endif int rank = 0; int numRanks = 1; #ifdef TAU_MPI if (TAU_MPI_Finalized()) { + fprintf(stdout, "TAU_MPI_Finalized() called\n"); return 0; } PMPI_Comm_rank(MPI_COMM_WORLD, &rank); PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + TAU_VERBOSE("TAU: rank=%d, numRanks=%d\n", rank, numRanks); #endif /* TAU_MPI */ x_uint64 start, end; +#if 1 if (rank == 0) { TAU_VERBOSE("TAU: Merging MetaData...\n"); start = TauMetrics_getTimeOfDay(); +#if 1 #ifdef TAU_MPI Tau_util_outputDevice *out = Tau_metadata_generateMergeBuffer(); char *defBuf = Tau_util_getOutputBuffer(out); @@ -86,18 +182,25 @@ extern "C" int Tau_metadataMerge_mergeMetaData() { PMPI_Bcast(&defBufSize, 1, MPI_INT, 0, MPI_COMM_WORLD); PMPI_Bcast(defBuf, defBufSize, MPI_CHAR, 0, MPI_COMM_WORLD); #endif /* TAU_MPI */ +#endif end = TauMetrics_getTimeOfDay(); TAU_VERBOSE("TAU: MetaData Merging Complete, duration = %.4G seconds\n", ((double)(end-start))/1000000.0f); char tmpstr[256]; sprintf(tmpstr, "%.4G seconds", ((double)(end-start))/1000000.0f); TAU_METADATA("TAU MetaData Merge Time", tmpstr); + +#if 1 #ifdef TAU_MPI Tau_util_destroyOutputDevice(out); #endif /* TAU_MPI */ +#endif } else { + +#if 1 #ifdef TAU_MPI + TAU_VERBOSE("TAU: Metadata, rank different from 0\n"); int BufferSize; PMPI_Bcast(&BufferSize, 1, MPI_INT, 0, MPI_COMM_WORLD); char *Buffer = (char*) TAU_UTIL_MALLOC(BufferSize); @@ -105,7 +208,10 @@ extern "C" int Tau_metadataMerge_mergeMetaData() { Tau_metadata_removeDuplicates(Buffer, BufferSize); free(Buffer); #endif /* TAU_MPI */ +#endif } +#endif + return 0; } diff --git a/src/Profile/TauMpi.c b/src/Profile/TauMpi.c index 68701a2af..3a14d1e30 100644 --- a/src/Profile/TauMpi.c +++ b/src/Profile/TauMpi.c @@ -35,6 +35,9 @@ #include #include #include +#include +#include +#include #include #ifdef TAU_BEACON @@ -67,66 +70,85 @@ #define TAU_OPENMPI3_CONST #endif +#if defined(TAU_MPC) +#define TAU_NONMPC_CONST +#else +#define TAU_NONMPC_CONST const +#endif + /* These functions and macros are for creating MPI "events" in the SOS stream. */ -#ifdef TAU_SOS +#if defined(TAU_SOS) int TAU_inside_ADIOS(void); inline void Tau_plugin_trace_current_timer(const char * name) { - /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled() && TAU_inside_ADIOS() == 0) { - Tau_plugin_event_current_timer_exit_data plugin_data; - plugin_data.name_prefix = name; - Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_CURRENT_TIMER_EXIT, &plugin_data); - } + Tau_plugin_event_current_timer_exit_data_t plugin_data; + plugin_data.name_prefix = name; + Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_CURRENT_TIMER_EXIT, &plugin_data); } #define EVENT_TRACE_PREFIX "TAU_EVENT::MPI" #define TAU_SOS_COLLECTIVE_SYNC_EVENT(__desc,__comm) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s collective synchronize %s 0x%08x", EVENT_TRACE_PREFIX, __desc, __comm); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_COLLECTIVE_EXCH_EVENT(__desc,__size,__comm) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s collective exchange %s (%d) 0x%08x", EVENT_TRACE_PREFIX, __desc, __size, __comm); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_COLLECTIVE_EXCH_V_EVENT(__desc,__stats,__comm) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s collective exchangev %s ([%f,%f,%f,%f,%f]) 0x%08x", \ EVENT_TRACE_PREFIX, __desc, __stats[0],__stats[1],__stats[2],__stats[3],__stats[4], __comm); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_COLLECTIVE_EXCH_AAV_EVENT(__desc,__stats1,__stats2,__comm) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[256]; \ sprintf(__tmp, \ "%s collective exchangev %s ([%f,%f,%f,%f,%f],[%f,%f,%f,%f,%f]) 0x%08x", \ EVENT_TRACE_PREFIX, __desc, __stats1[0],__stats1[1],__stats1[2],__stats1[3],__stats1[4], \ __stats2[0],__stats2[1],__stats2[2],__stats2[3],__stats2[4], __comm); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_COMM_SPLIT_EVENT(__comm,__color,__key,__comm_out) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s_Comm_split (%p, %d, %d) 0x%08x", EVENT_TRACE_PREFIX, __comm,__color,__key,__comm_out); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_COMM_DUP_EVENT(__comm,__comm_out) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s_Comm_dup (%p) 0x%08x", EVENT_TRACE_PREFIX, __comm, __comm_out); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_COMM_CREATE_EVENT(__comm,__group,__comm_out) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s_Comm_create (%p, %p) 0x%08x", EVENT_TRACE_PREFIX, __comm, __group, __comm_out); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_COMM_GROUP_EVENT(__comm,__group_addr) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s_Comm_group (%p) %p", EVENT_TRACE_PREFIX, __comm, __group_addr); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} void Tau_sos_group_incl_event(MPI_Group group, int count, int ranks[], MPI_Group new_group) { // assume 128 for letters, and 10 digits for each rank (plus a comma) @@ -142,7 +164,9 @@ void Tau_sos_group_incl_event(MPI_Group group, int count, int ranks[], MPI_Group } #define TAU_SOS_GROUP_INCL_EVENT(__group,__count,__ranks,__group_addr) \ - Tau_sos_group_incl_event(__group, __count, __ranks, __group_addr); +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ + Tau_sos_group_incl_event(__group, __count, __ranks, __group_addr); \ +} void Tau_sos_group_excl_event(MPI_Group group, int count, int ranks[], MPI_Group new_group) { // assume 128 for letters, and 10 digits for each rank (plus a comma) @@ -158,7 +182,9 @@ void Tau_sos_group_excl_event(MPI_Group group, int count, int ranks[], MPI_Group } #define TAU_SOS_GROUP_EXCL_EVENT(__group,__count,__ranks,__group_addr) \ - Tau_sos_group_excl_event(__group, __count, __ranks, __group_addr); +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ + Tau_sos_group_excl_event(__group, __count, __ranks, __group_addr); \ +} void Tau_sos_group_range_incl_event(MPI_Group group, int count, int ranges[][3], MPI_Group new_group) { // assume 128 for letters, and 10 digits for each rank (plus a comma) @@ -174,7 +200,9 @@ void Tau_sos_group_range_incl_event(MPI_Group group, int count, int ranges[][3], } #define TAU_SOS_GROUP_RANGE_INCL_EVENT(__group,__count,__ranges,__newgroup) \ - Tau_sos_group_range_incl_event(__group, __count, __ranges, __newgroup); +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ + Tau_sos_group_range_incl_event(__group, __count, __ranges, __newgroup); \ +} void Tau_sos_group_range_excl_event(MPI_Group group, int count, int ranges[][3], MPI_Group new_group) { // assume 128 for letters, and 10 digits for each rank (plus a comma) @@ -190,7 +218,9 @@ void Tau_sos_group_range_excl_event(MPI_Group group, int count, int ranges[][3], } #define TAU_SOS_GROUP_RANGE_EXCL_EVENT(__group,__count,__ranges,__newgroup) \ - Tau_sos_group_range_excl_event(__group, __count, __ranges, __newgroup); +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ + Tau_sos_group_range_excl_event(__group, __count, __ranges, __newgroup); \ +} void Tau_sos_group_translate_ranks_event(MPI_Group group1, int count, int *ranks1, MPI_Group group2, int *ranks2) { // assume 128 for letters, and 10 digits for each rank (plus a comma) @@ -210,22 +240,30 @@ void Tau_sos_group_translate_ranks_event(MPI_Group group1, int count, int *ranks } #define TAU_SOS_GROUP_TRANSLATE_RANKS_EVENT(__group,__count,__ranks1,__group2,__ranks2) \ - Tau_sos_group_translate_ranks_event(__group, __count, __ranks1, __group2, __ranks2); +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ + Tau_sos_group_translate_ranks_event(__group, __count, __ranks1, __group2, __ranks2); \ +} #define TAU_SOS_GROUP_DIFFERENCE_EVENT(__group1,__group2,__newgroup) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s_Group_difference (%p,%p) %p", EVENT_TRACE_PREFIX, __group1, __group2, __newgroup); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_GROUP_INTERSECTION_EVENT(__group1,__group2,__newgroup) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s_Group_intersection (%p,%p) %p", EVENT_TRACE_PREFIX, __group1, __group2, __newgroup); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} #define TAU_SOS_GROUP_UNION_EVENT(__group1,__group2,__newgroup) \ +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ char __tmp[128]; \ sprintf(__tmp, "%s_Group_union (%p,%p) %p", EVENT_TRACE_PREFIX, __group1, __group2, __newgroup); \ -Tau_plugin_trace_current_timer(__tmp); +Tau_plugin_trace_current_timer(__tmp); \ +} // this is used between cart_create and cart_sub calls... may not be safe, but... static int __cart_dims = 1; @@ -249,7 +287,9 @@ void Tau_sos_cart_create_event(MPI_Comm comm, int ndims, TAU_MPICH3_CONST int * } #define TAU_SOS_CART_CREATE_EVENT(__comm,__ndims,__dims,__periods,__reorder,__comm_out) \ - Tau_sos_cart_create_event(__comm,__ndims,__dims,__periods,__reorder,__comm_out); +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ + Tau_sos_cart_create_event(__comm,__ndims,__dims,__periods,__reorder,__comm_out); \ +} void Tau_sos_cart_coords_event(MPI_Comm comm, int rank, int maxdims, int * coords) { // assume 128 for letters, and 10 digits for each rank (plus a comma) @@ -265,7 +305,9 @@ void Tau_sos_cart_coords_event(MPI_Comm comm, int rank, int maxdims, int * coord } #define TAU_SOS_CART_COORDS_EVENT(__comm,__rank,__maxdims,__coords) \ - Tau_sos_cart_coords_event(__comm,__rank,__maxdims,__coords); +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ + Tau_sos_cart_coords_event(__comm,__rank,__maxdims,__coords); \ +} void Tau_sos_cart_sub_event(MPI_Comm comm, TAU_MPICH3_CONST int * remains, MPI_Comm comm_out) { // assume 128 for letters, and 10 digits for each rank (plus a comma) @@ -281,7 +323,9 @@ void Tau_sos_cart_sub_event(MPI_Comm comm, TAU_MPICH3_CONST int * remains, MPI_C } #define TAU_SOS_CART_SUB_EVENT(__comm,__remains,__comm_out) \ - Tau_sos_cart_sub_event(__comm,__remains,__comm_out); +if(Tau_plugins_enabled.current_timer_exit && TAU_inside_ADIOS() == 0) { \ + Tau_sos_cart_sub_event(__comm,__remains,__comm_out); \ +} #else #define TAU_SOS_COLLECTIVE_SYNC_EVENT(__desc,__comm) @@ -1361,6 +1405,90 @@ MPI_Comm * comm_out; return returnVal; } +void Tau_handle_comm_spawn(MPI_Comm comm, MPI_Comm intercomm) { + static int tau_comm_spawn_num = 0; + tau_comm_spawn_num++; + int comm_rank; + MPI_Comm_rank(comm, &comm_rank); + // Send the generation number to the spawned processes, which + // will join the Bcast in MPI_Init + if(comm_rank == 0) { + PMPI_Bcast(&tau_comm_spawn_num, 1, MPI_INT, MPI_ROOT, intercomm); + } else { + PMPI_Bcast(&tau_comm_spawn_num, 1, MPI_INT, MPI_PROC_NULL, intercomm); + } +} + +int MPI_Comm_spawn(TAU_NONMPC_CONST char *command, char *argv[], int maxprocs, + MPI_Info info, int root, MPI_Comm comm, + MPI_Comm *intercomm, int array_of_errcodes[]) { + int returnVal; + + TAU_PROFILE_TIMER(tautimer, "MPI_Comm_spawn()", " ", TAU_MESSAGE); + TAU_PROFILE_START(tautimer); + + const char * tau_exec_args = TauEnv_get_tau_exec_args(); + const char * tau_exec_path = TauEnv_get_tau_exec_path(); + int allocated_argv = 0; + wordexp_t p; + if(tau_exec_args != NULL && tau_exec_args[0] != '\0') { + // This program was launched through tau_exec + const char * old_command = command; + char ** old_argv = argv; + size_t old_argc = 0; + if(old_argv != NULL) { + char * arg; + for(arg = old_argv[old_argc]; arg != NULL; arg = old_argv[++old_argc]); + } + wordexp(tau_exec_args, &p, WRDE_NOCMD); + argv = malloc((p.we_wordc + old_argc + 2) * sizeof(char*)); + int offset; + for(offset = 0; offset < p.we_wordc; ++offset) { + argv[offset] = p.we_wordv[offset]; + } + argv[offset++] = old_command; + int i; + for(i = 0; i < old_argc; ++i) { + argv[offset++] = old_argv[i]; + } + argv[offset] = NULL; + + command = tau_exec_path; + allocated_argv = 1; + + } + + returnVal = PMPI_Comm_spawn(command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes); + Tau_handle_comm_spawn(comm, *intercomm); + + if(allocated_argv == 1) { + free(argv); + wordfree(&p); + } + + TAU_PROFILE_STOP(tautimer); + + return returnVal; +} + +int MPI_Comm_spawn_multiple(int count, char *array_of_commands[], + char **array_of_argv[], TAU_NONMPC_CONST int array_of_maxprocs[], TAU_NONMPC_CONST MPI_Info + array_of_info[], int root, MPI_Comm comm, MPI_Comm *intercomm, + int array_of_errcodes[]) { + int returnVal; + + TAU_PROFILE_TIMER(tautimer, "MPI_Comm_spawn_multiple()", " ", TAU_MESSAGE); + TAU_PROFILE_START(tautimer); + + returnVal = PMPI_Comm_spawn_multiple(count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm, intercomm, array_of_errcodes); + Tau_handle_comm_spawn(comm, *intercomm); + + TAU_PROFILE_STOP(tautimer); + + return returnVal; +} + + int MPI_Comm_test_inter( comm, flag ) MPI_Comm comm; int * flag; @@ -1793,11 +1921,13 @@ MPI_Errhandler errhandler; return returnVal; } - +#if !defined(TAU_MPC) int tau_mpi_finalized = 0; int TAU_MPI_Finalized() { + //fprintf(stdout, "In TAU_MPI_Finalized(): tau_mpi_finalized=%d\n", tau_mpi_finalized); return tau_mpi_finalized; } +#endif void finalizeCallSites_if_necessary(); int MPI_Finalize( ) @@ -1806,6 +1936,8 @@ int MPI_Finalize( ) char procname[MPI_MAX_PROCESSOR_NAME]; int procnamelength; + TAU_VERBOSE("TAU: Call MPI_Finalize()\n"); + TAU_PROFILE_TIMER(tautimer, "MPI_Finalize()", " ", TAU_MESSAGE); TAU_PROFILE_START(tautimer); @@ -1910,8 +2042,8 @@ int MPI_Finalize( ) /*Invoke plugins only if both plugin path and plugins are specified *Do this first, because the plugin can write TAU_METADATA as recommendations to the user*/ - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_pre_end_of_execution_data plugin_data; + if(Tau_plugins_enabled.pre_end_of_execution) { + Tau_plugin_event_pre_end_of_execution_data_t plugin_data; plugin_data.tid = Tau_get_local_tid(); Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_PRE_END_OF_EXECUTION, &plugin_data); } @@ -1927,7 +2059,7 @@ int MPI_Finalize( ) TAU_PROFILE_STOP(tautimer); Tau_stop_top_level_timer_if_necessary(); - tau_mpi_finalized = 1; + //tau_mpi_finalized = 1; return returnVal; } @@ -1968,6 +2100,59 @@ int Tau_MPI_T_initialization(void) { #endif /* TAU_MPI_T */ } +int mkdirp(const char *path) { + const size_t len = strlen(path); + char _path[4096]; + char *p; + + errno = 0; + + /* Copy string so its mutable */ + if (len > sizeof(_path)-1) { + errno = ENAMETOOLONG; + return -1; + } + strcpy(_path, path); + + /* Iterate the string */ + for (p = _path + 1; *p; p++) { + if (*p == '/') { + /* Temporarily truncate */ + *p = '\0'; + + if (mkdir(_path, S_IRWXU) != 0) { + if (errno != EEXIST) + return -1; + } + + *p = '/'; + } + } + + if (mkdir(_path, S_IRWXU) != 0) { + if (errno != EEXIST) + return -1; + } + + return 0; +} + +void Tau_handle_spawned_init(MPI_Comm intercomm) { + int generation_num; + PMPI_Bcast(&generation_num, 1, MPI_INT, 0, intercomm); + const char * profiledir = TauEnv_get_profiledir(); + const char * tracedir = TauEnv_get_profiledir(); + char new_profiledir[4096]; + char new_tracedir[4096]; + snprintf(new_profiledir, 4096, "%s/spawn-%d", profiledir, generation_num); + snprintf(new_tracedir, 4096, "%s/spawn-%d", tracedir, generation_num); + mkdirp(new_profiledir); + mkdirp(new_tracedir); + TauEnv_set_profiledir(new_profiledir); + TauEnv_set_tracedir(new_tracedir); + TAU_VERBOSE("TAU_INIT: MPI_Comm_spawn generation %d\n", generation_num); +} + int MPI_Init( argc, argv ) int * argc; char *** argv; @@ -2000,16 +2185,16 @@ char *** argv; returnVal = PMPI_Init( argc, argv ); - /*Initialize the plugin system only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - TAU_VERBOSE("TAU INIT: Initializing plugin system...\n"); - if(!Tau_initialize_plugin_system()) { - TAU_VERBOSE("TAU INIT: Successfully Initialized the plugin system.\n"); - } else { - printf("TAU INIT: Error initializing the plugin system\n"); - } + MPI_Comm parent; + PMPI_Comm_get_parent(&parent); + if(parent != MPI_COMM_NULL) { + // This process was created through MPI_Comm_spawn + Tau_handle_spawned_init(parent); } + /* Initialize the plugin system */ + Tau_initialize_plugin_system(); + #ifndef TAU_WINDOWS #ifndef _AIX if (TauEnv_get_ebs_enabled()) { @@ -2073,6 +2258,8 @@ int *provided; int size; char procname[MPI_MAX_PROCESSOR_NAME]; int procnamelength; + + TAU_VERBOSE("call TAU MPI_Init_thread()\n"); TAU_PROFILE_TIMER(tautimer, "MPI_Init_thread()", " ", TAU_MESSAGE); Tau_create_top_level_timer_if_necessary(); @@ -2085,16 +2272,16 @@ int *provided; returnVal = PMPI_Init_thread( argc, argv, required, provided ); - /*Initialize the plugin system only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { - TAU_VERBOSE("TAU INIT: Initializing plugin system...\n"); - if(!Tau_initialize_plugin_system()) { - TAU_VERBOSE("TAU INIT: Successfully Initialized the plugin system.\n"); - } else { - printf("TAU INIT: Error initializing the plugin system\n"); - } + MPI_Comm parent; + MPI_Comm_get_parent(&parent); + if(parent != MPI_COMM_NULL) { + // This process was created through MPI_Comm_spawn + Tau_handle_spawned_init(parent); } + /* Initialize the plugin system */ + Tau_initialize_plugin_system(); + #ifndef TAU_WINDOWS #ifndef _AIX if (TauEnv_get_ebs_enabled()) { diff --git a/src/Profile/TauOMPT.cpp b/src/Profile/TauOMPT.cpp index 9bcf02318..13e89af7a 100644 --- a/src/Profile/TauOMPT.cpp +++ b/src/Profile/TauOMPT.cpp @@ -275,6 +275,7 @@ on_ompt_callback_work( switch(endpoint) { case ompt_scope_begin: + task_data->ptr = NULL; if(TauEnv_get_ompt_resolve_address_eagerly()) { Tau_ompt_resolve_callsite_eagerly(addr, resolved_address); switch(wstype) @@ -342,8 +343,10 @@ on_ompt_callback_work( task_data->ptr = (void*)handle; break; case ompt_scope_end: - TAU_PROFILER_STOP(task_data->ptr); - break; + if(task_data->ptr != NULL) { + TAU_PROFILER_STOP(task_data->ptr); + } + break; } } } diff --git a/src/Profile/TauProfileMerge.cpp b/src/Profile/TauProfileMerge.cpp index cb140942d..242607fa2 100644 --- a/src/Profile/TauProfileMerge.cpp +++ b/src/Profile/TauProfileMerge.cpp @@ -339,6 +339,7 @@ int Tau_mergeProfiles_MPI() } if (TauEnv_get_summary_only()) { /* write only rank one metadata for summary profile */ if (rank == 0) { + TAU_VERBOSE("Tau Profile merge - rank = 0: write meta data block\n"); Tau_snapshot_writeMetaDataBlock(); } } else { diff --git a/src/Profile/TauSampling.cpp b/src/Profile/TauSampling.cpp index 1ab811078..ec839c48e 100644 --- a/src/Profile/TauSampling.cpp +++ b/src/Profile/TauSampling.cpp @@ -121,6 +121,7 @@ using namespace tau; extern FunctionInfo * Tau_create_thread_state_if_necessary(const char* thread_state); extern FunctionInfo * Tau_create_thread_state_if_necessary_string(const string & thread_state); extern "C" void Tau_ompt_resolve_callsite(FunctionInfo &fi, char * resolved_address); +extern "C" int Tau_get_usesMPI(); #if defined(TAU_OPENMP) && !defined (TAU_USE_OMPT_TR6) && (defined(TAU_USE_OMPT) || defined (TAU_IBM_OMPT)) extern "C" int Tau_get_thread_omp_state(int tid); @@ -1869,6 +1870,13 @@ extern "C" void Tau_sampling_init_if_necessary(void) // sanity check - does the user want sampling at all? if (!TauEnv_get_ebs_enabled()) return; + // If this is an MPI configuration of TAU, don't initialize sampling + // if MPI_Init hasn't been called yet. This is necessary to prevent + // problems where the sampling signal interferes with MPI startup. +#ifdef TAU_MPI + if(Tau_get_usesMPI() == 0) return; +#endif + int tid = RtsLayer::localThreadId(); // have we initialized already? if (samplingThrInitialized[tid]) return; diff --git a/src/Profile/TauSnapshot.cpp b/src/Profile/TauSnapshot.cpp index 3c931094a..bb9df9640 100644 --- a/src/Profile/TauSnapshot.cpp +++ b/src/Profile/TauSnapshot.cpp @@ -42,6 +42,8 @@ static Tau_util_outputDevice **Tau_snapshot_getFiles() { snapshotFiles[i] = NULL; } } + + TAU_VERBOSE("Tau_snapshot_getFiles() end: out=%p\n", snapshotFiles); return snapshotFiles; } @@ -118,10 +120,14 @@ extern "C" int Tau_snapshot_writeIntermediate(const char *name) { extern "C" int Tau_snapshot_writeMetaDataBlock() { int tid = RtsLayer::myThread(); - Tau_util_outputDevice *out = Tau_snapshot_getFiles()[tid]; + int totalThreads = RtsLayer::getTotalThreads(); + //Tau_util_outputDevice *out = Tau_snapshot_getFiles()[tid]; + Tau_util_outputDevice *out = Tau_snapshot_getFiles()[0]; char threadid[4096]; sprintf(threadid, "%d.%d.%d.%d", RtsLayer::myNode(), RtsLayer::myContext(), tid, RtsLayer::getPid()); + TAU_VERBOSE("tid=%d, totalThreads=%d\n", tid, totalThreads); + // start of a profile block Tau_util_output (out, "\n"); diff --git a/src/Profile/TauUtil.cpp b/src/Profile/TauUtil.cpp index 0b2baab5e..4bc57714f 100644 --- a/src/Profile/TauUtil.cpp +++ b/src/Profile/TauUtil.cpp @@ -32,6 +32,8 @@ #define strtok_r(a,b,c) strtok(a,b) #endif /* TAU_WINDOWS */ +Tau_plugin_callbacks_active_t Tau_plugins_enabled; + #define TAU_NAME_LENGTH 1024 #ifdef TAU_BFD @@ -329,7 +331,15 @@ PluginManager* Tau_util_get_plugin_manager() { * Initializes the plugin system by loading and registering all plugins ********************************************************************/ int Tau_initialize_plugin_system() { - return(Tau_util_load_and_register_plugins(Tau_util_get_plugin_manager())); + memset(&Tau_plugins_enabled, 0, sizeof(Tau_plugin_callbacks_active_t)); + if(TauEnv_get_plugins_enabled()) { + TAU_VERBOSE("TAU INIT: Initializing plugin system...\n"); + if(!Tau_util_load_and_register_plugins(Tau_util_get_plugin_manager())) { + TAU_VERBOSE("TAU INIT: Successfully Initialized the plugin system.\n"); + } else { + printf("TAU INIT: Error initializing the plugin system\n"); + } + } } /********************************************************************* @@ -560,20 +570,37 @@ void Tau_util_make_callback_copy(Tau_plugin_callbacks * dest, Tau_plugin_callbac extern "C" void Tau_util_plugin_register_callbacks(Tau_plugin_callbacks * cb) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); - Tau_plugin_callback_ * callback = (Tau_plugin_callback_ *)malloc(sizeof(Tau_plugin_callback_)); + Tau_plugin_callback_t * callback = (Tau_plugin_callback_t *)malloc(sizeof(Tau_plugin_callback_t)); Tau_util_make_callback_copy(&(callback->cb), cb); callback->next = (plugin_manager->callback_list)->head; (plugin_manager->callback_list)->head = callback; + + /* Set some flags to make runtime conditional processing more efficient */ + if (cb->FunctionRegistrationComplete != 0) { Tau_plugins_enabled.function_registration = 1; } + if (cb->MetadataRegistrationComplete != 0) { Tau_plugins_enabled.metadata_registration = 1; } + if (cb->PostInit != 0) { Tau_plugins_enabled.post_init = 1; } + if (cb->Dump != 0) { Tau_plugins_enabled.dump = 1; } + if (cb->FunctionEntry != 0) { Tau_plugins_enabled.function_entry = 1; } + if (cb->FunctionExit != 0) { Tau_plugins_enabled.function_exit = 1; } + if (cb->Send != 0) { Tau_plugins_enabled.send = 1; } + if (cb->Recv != 0) { Tau_plugins_enabled.recv = 1; } + if (cb->CurrentTimerExit != 0) { Tau_plugins_enabled.current_timer_exit = 1; } + if (cb->AtomicEventRegistrationComplete != 0) { Tau_plugins_enabled.atomic_event_registration = 1; } + if (cb->AtomicEventTrigger != 0) { Tau_plugins_enabled.atomic_event_trigger = 1; } + if (cb->PreEndOfExecution != 0) { Tau_plugins_enabled.pre_end_of_execution = 1; } + if (cb->EndOfExecution != 0) { Tau_plugins_enabled.end_of_execution = 1; } + if (cb->FunctionFinalize != 0) { Tau_plugins_enabled.function_finalize = 1; } + if (cb->InterruptTrigger != 0) { Tau_plugins_enabled.interrupt_trigger = 1; } } /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the function registration event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_function_registration_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_function_registration_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.FunctionRegistrationComplete != 0) { @@ -586,10 +613,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_function_registration_data data /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the dump event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_dump_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_dump_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.Dump != 0) { @@ -602,10 +629,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_dump_data data) { /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the function entry event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_function_entry_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_function_entry_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.FunctionEntry != 0) { @@ -618,10 +645,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_function_entry_data data) { /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the function exit event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_function_exit_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_function_exit_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.FunctionExit != 0) { @@ -634,10 +661,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_function_exit_data data) { /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the "current timer" exit event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_current_timer_exit_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_current_timer_exit_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.CurrentTimerExit != 0) { @@ -650,10 +677,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_current_timer_exit_data data) { /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the send event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_send_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_send_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.Send != 0) { @@ -666,10 +693,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_send_data data) { /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the recv event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_recv_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_recv_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.Recv != 0) { @@ -682,10 +709,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_recv_data data) { /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the metadata registration event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_metadata_registration_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_metadata_registration_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.MetadataRegistrationComplete != 0) { @@ -698,10 +725,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_metadata_registration_data data /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the post init event ***************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_post_init_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_post_init_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.PostInit != 0) { @@ -714,10 +741,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_post_init_data data) { /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the atomic event registration event ****************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_atomic_event_registration_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_atomic_event_registration_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.AtomicEventRegistrationComplete != 0) { @@ -730,10 +757,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_atomic_event_registration_data /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the atomic event trigger event *****************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_atomic_event_trigger_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_atomic_event_trigger_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.AtomicEventTrigger != 0) { @@ -746,10 +773,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_atomic_event_trigger_data data) /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the pre end of execution event ******************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_pre_end_of_execution_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_pre_end_of_execution_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.PreEndOfExecution != 0) { @@ -762,10 +789,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_pre_end_of_execution_data data) /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for the end of execution event ******************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_end_of_execution_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_end_of_execution_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.EndOfExecution != 0) { @@ -778,10 +805,10 @@ void Tau_util_invoke_callbacks_(Tau_plugin_event_end_of_execution_data data) { /************************************************************************************************************************** * Overloaded function that invokes all registered callbacks for interrupt trigger event *******************************************************************************************************************************/ -void Tau_util_invoke_callbacks_(Tau_plugin_event_interrupt_trigger_data data) { +void Tau_util_invoke_callbacks_(Tau_plugin_event_interrupt_trigger_data_t* data) { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin_callback_list * callback_list = plugin_manager->callback_list; - Tau_plugin_callback_ * callback = callback_list->head; + Tau_plugin_callback_t * callback = callback_list->head; while(callback != NULL) { if(callback->cb.InterruptTrigger != 0) { @@ -798,60 +825,59 @@ extern "C" void Tau_util_invoke_callbacks(Tau_plugin_event event, const void * d switch(event) { case TAU_PLUGIN_EVENT_FUNCTION_REGISTRATION: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_function_registration_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_function_registration_data_t*)data); break; } case TAU_PLUGIN_EVENT_METADATA_REGISTRATION: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_metadata_registration_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_metadata_registration_data_t*)data); break; } case TAU_PLUGIN_EVENT_POST_INIT: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_post_init_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_post_init_data_t*)data); break; } case TAU_PLUGIN_EVENT_DUMP: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_dump_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_dump_data_t*)data); break; } case TAU_PLUGIN_EVENT_FUNCTION_ENTRY: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_function_entry_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_function_entry_data_t*)data); break; } case TAU_PLUGIN_EVENT_FUNCTION_EXIT: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_function_exit_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_function_exit_data_t*)data); break; } case TAU_PLUGIN_EVENT_CURRENT_TIMER_EXIT: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_current_timer_exit_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_current_timer_exit_data_t*)data); break; } case TAU_PLUGIN_EVENT_SEND: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_send_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_send_data_t*)data); break; } case TAU_PLUGIN_EVENT_RECV: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_recv_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_recv_data_t*)data); break; } case TAU_PLUGIN_EVENT_ATOMIC_EVENT_REGISTRATION: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_atomic_event_registration_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_atomic_event_registration_data_t*)data); break; } - case TAU_PLUGIN_EVENT_ATOMIC_EVENT_TRIGGER: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_atomic_event_trigger_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_atomic_event_trigger_data_t*)data); break; } case TAU_PLUGIN_EVENT_PRE_END_OF_EXECUTION: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_pre_end_of_execution_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_pre_end_of_execution_data_t*)data); break; } case TAU_PLUGIN_EVENT_END_OF_EXECUTION: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_end_of_execution_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_end_of_execution_data_t*)data); break; } case TAU_PLUGIN_EVENT_INTERRUPT_TRIGGER: { - Tau_util_invoke_callbacks_(*(Tau_plugin_event_interrupt_trigger_data*)data); + Tau_util_invoke_callbacks_((Tau_plugin_event_interrupt_trigger_data_t*)data); break; } } @@ -865,10 +891,10 @@ int Tau_util_cleanup_all_plugins() { PluginManager* plugin_manager = Tau_util_get_plugin_manager(); Tau_plugin * temp_plugin; - Tau_plugin_callback_ * temp_callback; + Tau_plugin_callback_t * temp_callback; Tau_plugin * plugin = (plugin_manager->plugin_list)->head; - Tau_plugin_callback_ * callback = (plugin_manager->callback_list)->head; + Tau_plugin_callback_t * callback = (plugin_manager->callback_list)->head; /*Two separate while loops to handle the weird case that a plugin is loaded but doesn't register anything*/ while(plugin) { @@ -904,8 +930,6 @@ int Tau_util_cleanup_all_plugins() { /////////////////////////////////////////////////////////////////////////// extern "C" void Tau_plugin_sendmsg(long unsigned int type, long unsigned int destination, long unsigned int length, long unsigned int remoteid) { - /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { Tau_plugin_event_send_data plugin_data; plugin_data.message_tag = type; plugin_data.destination = destination; @@ -915,12 +939,9 @@ extern "C" void Tau_plugin_sendmsg(long unsigned int type, long unsigned int des RtsLayer::getUSecD(plugin_data.tid, timeStamp); plugin_data.timestamp = (unsigned long)(timeStamp[0]); Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_SEND, &plugin_data); - } } /////////////////////////////////////////////////////////////////////////// extern "C" void Tau_plugin_recvmsg(long unsigned int type, long unsigned int source, long unsigned int length, long unsigned int remoteid) { - /*Invoke plugins only if both plugin path and plugins are specified*/ - if(TauEnv_get_plugins_enabled()) { Tau_plugin_event_recv_data plugin_data; plugin_data.message_tag = type; plugin_data.source = source; @@ -930,6 +951,5 @@ extern "C" void Tau_plugin_recvmsg(long unsigned int type, long unsigned int sou RtsLayer::getUSecD(plugin_data.tid, timeStamp); plugin_data.timestamp = (unsigned long)(timeStamp[0]); Tau_util_invoke_callbacks(TAU_PLUGIN_EVENT_RECV, &plugin_data); - } } diff --git a/src/Profile/TracerOTF2.cpp b/src/Profile/TracerOTF2.cpp index d169e75fc..eed409f43 100755 --- a/src/Profile/TracerOTF2.cpp +++ b/src/Profile/TracerOTF2.cpp @@ -549,7 +549,7 @@ void TauTraceOTF2EventWithNodeId(long int ev, x_int64 par, int tid, x_uint64 ts, // The event file for a thread needs to be written by that thread, so we write // the temporary buffers the first time we get an event from that thread after // intialization has completed. - if(!buffers_written[tid]) { + if(!buffers_written[tid] && !otf2_comms_shutdown) { TauTraceOTF2WriteTempBuffer(tid, node_id); } #endif diff --git a/src/Profile/UserEvent.cpp b/src/Profile/UserEvent.cpp index 1a1485d31..173d713c1 100644 --- a/src/Profile/UserEvent.cpp +++ b/src/Profile/UserEvent.cpp @@ -125,8 +125,8 @@ void TauUserEvent::AddEventToDB() DEBUGPROFMSG("Size of eventDB is " << TheEventDB().size() <") == std::string::npos)) { - if(TauEnv_get_plugins_enabled()) { - Tau_plugin_event_atomic_event_trigger_data plugin_data; + Tau_plugin_event_atomic_event_trigger_data_t plugin_data; plugin_data.counter_name = name.c_str(); plugin_data.tid = tid; plugin_data.timestamp = timestamp; @@ -427,36 +427,44 @@ TauSafeString TauContextUserEvent::FormulateContextNameString(Profiler * current buff << userEvent->GetName(); int depth = Tau_get_current_stack_depth(tid); - Profiler ** path = new Profiler*[depth]; - - // Reverse the callpath to avoid string copies - int i=depth-1; - for (; current && i >= 0; --i) { - path[i] = current; - current = current->ParentProfiler; - } - // Now we can construct the name string by appending rather than prepending - buff << " : "; FunctionInfo * fi; - for (++i; i < depth-1; ++i) { - fi = path[i]->ThisFunction; - buff << fi->GetName(); - if (strlen(fi->GetType()) > 0) - buff << " " << fi->GetType(); - buff << " => "; - } - if (depth == 0) { - fi = current->ThisFunction; + if (depth > 0) { + Profiler ** path = new Profiler*[depth]; + + // Reverse the callpath to avoid string copies + int i=depth-1; + for (; current && i >= 0; --i) { + path[i] = current; + current = current->ParentProfiler; + } + // Now we can construct the name string by appending rather than prepending + buff << " : "; + for (++i; i < depth-1; ++i) { + fi = path[i]->ThisFunction; + buff << fi->GetName(); + if (strlen(fi->GetType()) > 0) + buff << " " << fi->GetType(); + buff << " => "; + } + if (depth == 0) { + fi = current->ThisFunction; + } else { + fi = path[i]->ThisFunction; + } + buff << fi->GetName(); + if (strlen(fi->GetType()) > 0) + buff << " " << fi->GetType(); + + delete[] path; } else { - fi = path[i]->ThisFunction; + fi = current->ThisFunction; + buff << " : " << fi->GetName(); + if (strlen(fi->GetType()) > 0) { + buff << " " << fi->GetType(); + } } - buff << fi->GetName(); - if (strlen(fi->GetType()) > 0) - buff << " " << fi->GetType(); - - delete[] path; - // Return a new string object. - // A smart STL implementation will not allocate a new buffer. + // Return a new string object. + // A smart STL implementation will not allocate a new buffer. return buff.str().c_str(); } else { return ""; diff --git a/src/wrappers/mpc_mpi/Makefile b/src/wrappers/mpc_mpi/Makefile index cc980deb2..e1476e878 100644 --- a/src/wrappers/mpc_mpi/Makefile +++ b/src/wrappers/mpc_mpi/Makefile @@ -1,8 +1,12 @@ include ../../../include/Makefile include ../Makefile +OBJS=mpc_mpi_wrap.o gen_prof.o +#OBJS=mpc_mpi_wrap.o gen_trace.o + CC=$(TAU_CC) -CFLAGS=$(TAU_DEFS) $(TAU_INCLUDE) $(TAU_MPI_INCLUDE) -I.. +CXX=$(TAU_CXX) +CFLAGS=$(TAU_DEFS) $(TAU_INCLUDE) $(TAU_MPI_INCLUDE) -I. -I.. -I$(TAUROOT)/include/Profile EXTRA_FLAGS= AR=$(TAU_AR) @@ -17,11 +21,20 @@ install: install-static-mpc install-static-mpc: libmpc_mpi_wrap.a $(TAU_STATIC_INSTALL_CMD) -libmpc_mpi_wrap.a: mpc_mpi_wrap.o - $(AR) $(ARFLAGS) $@ $< +#libmpc_mpi_wrap.a: $(OBJS) +# $(AR) $(ARFLAGS) $@ $< + +libmpc_mpi_wrap.a: $(OBJS) + $(AR) $(ARFLAGS) $@ $(OBJS) mpc_mpi_wrap.o: wr.c $(CC) $(CFLAGS) $(EXTRA_FLAGS) -c $< -o $@ + +gen_prof.o: gen_prof.cpp + $(CXX) $(CFLAGS) $(EXTRA_FLAGS) -c $< -o $@ + +gen_trace.o: gen_trace.c + $(CC) $(CFLAGS) $(EXTRA_FLAGS) -c $< -o $@ clean: - /bin/rm -f mpc_mpi_wrap.o libmpc_mpi_wrap.a + /bin/rm -f mpc_mpi_wrap.o gen_prof.o libmpc_mpi_wrap.a diff --git a/src/wrappers/mpc_mpi/gen_prof.cpp b/src/wrappers/mpc_mpi/gen_prof.cpp new file mode 100644 index 000000000..bce79a26c --- /dev/null +++ b/src/wrappers/mpc_mpi/gen_prof.cpp @@ -0,0 +1,116 @@ +#include +#include +#include + +#include + +#ifdef TAU_MPI +#include +#endif /* TAU_MPI */ +#include +#include + +//#include "gen_prof.h" + + +extern "C" int genProfileFakeExtern() +{ + int rank = 0; + int numRanks; + + PMPI_Comm_rank(MPI_COMM_WORLD, &rank); + PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + TAU_VERBOSE("TAU - genProfileFake Extern C: rank=%d, numRanks=%d\n", rank, numRanks); + + return 0; +} + + +#if 1 +extern "C" int genProfile() +{ + + //int numRanks; + //PMPI_Comm_rank(MPI_COMM_WORLD, &rank); + //PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + //TAU_VERBOSE("TAU - inside genProfile(): rank=%d, numRanks=%d\n", rank, numRanks); + + Tau_metadata_fillMetaData(); + +#if 0 + static int merged = 0; + if (merged == 1) { + return 0; + } + merged = 1; +#endif + + int rank = 0; + +#ifdef TAU_MPI + int numRanks; + //if (TAU_MPI_Finalized()) { + // fprintf(stdout, "TAU_MPI_Finalized() called\n"); + // return 0; + //} + + PMPI_Comm_rank(MPI_COMM_WORLD, &rank); + PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + TAU_VERBOSE("TAU genProfile extern C: rank=%d, numRanks=%d\n", rank, numRanks); +#endif /* TAU_MPI */ + + x_uint64 start, end; + +#if 1 + if (rank == 0) { + + TAU_VERBOSE("TAU: Merging MetaData...\n"); + start = TauMetrics_getTimeOfDay(); + +#if 1 +#ifdef TAU_MPI + Tau_util_outputDevice *out = Tau_metadata_generateMergeBuffer(); + char *defBuf = Tau_util_getOutputBuffer(out); + int defBufSize = Tau_util_getOutputBufferLength(out); + + PMPI_Bcast(&defBufSize, 1, MPI_INT, 0, MPI_COMM_WORLD); + PMPI_Bcast(defBuf, defBufSize, MPI_CHAR, 0, MPI_COMM_WORLD); +#endif /* TAU_MPI */ +#endif + + end = TauMetrics_getTimeOfDay(); + TAU_VERBOSE("TAU: MetaData Merging Complete, duration = %.4G seconds\n", ((double)(end-start))/1000000.0f); + char tmpstr[256]; + sprintf(tmpstr, "%.4G seconds", ((double)(end-start))/1000000.0f); + TAU_METADATA("TAU MetaData Merge Time", tmpstr); + +#if 1 +#ifdef TAU_MPI + Tau_util_destroyOutputDevice(out); +#endif /* TAU_MPI */ +#endif + + } else { + +#if 1 +#ifdef TAU_MPI + TAU_VERBOSE("TAU: Metadata, rank different from 0\n"); + int BufferSize; + PMPI_Bcast(&BufferSize, 1, MPI_INT, 0, MPI_COMM_WORLD); + char *Buffer = (char*) TAU_UTIL_MALLOC(BufferSize); + PMPI_Bcast(Buffer, BufferSize, MPI_CHAR, 0, MPI_COMM_WORLD); + Tau_metadata_removeDuplicates(Buffer, BufferSize); + free(Buffer); +#endif /* TAU_MPI */ +#endif + } +#endif + + return 0; +} +#endif + + diff --git a/src/wrappers/mpc_mpi/link_options.tau b/src/wrappers/mpc_mpi/link_options.tau index 96f20454d..118df6abb 100644 --- a/src/wrappers/mpc_mpi/link_options.tau +++ b/src/wrappers/mpc_mpi/link_options.tau @@ -1 +1 @@ --Wl,-wrap,MPI_Default_error -Wl,-wrap,MPI_Send -Wl,-wrap,MPI_Recv -Wl,-wrap,MPI_Get_count -Wl,-wrap,MPI_Bsend -Wl,-wrap,MPI_Ssend -Wl,-wrap,MPI_Rsend -Wl,-wrap,MPI_Buffer_attach -Wl,-wrap,MPI_Buffer_detach -Wl,-wrap,MPI_Isend -Wl,-wrap,MPI_Ibsend -Wl,-wrap,MPI_Issend -Wl,-wrap,MPI_Irsend -Wl,-wrap,MPI_Irecv -Wl,-wrap,MPI_Wait -Wl,-wrap,MPI_Test -Wl,-wrap,MPI_Request_free -Wl,-wrap,MPI_Waitany -Wl,-wrap,MPI_Testany -Wl,-wrap,MPI_Waitall -Wl,-wrap,MPI_Testall -Wl,-wrap,MPI_Waitsome -Wl,-wrap,MPI_Testsome -Wl,-wrap,MPI_Iprobe -Wl,-wrap,MPI_Probe -Wl,-wrap,MPI_Cancel -Wl,-wrap,MPI_Test_cancelled -Wl,-wrap,MPI_Send_init -Wl,-wrap,MPI_Bsend_init -Wl,-wrap,MPI_Ssend_init -Wl,-wrap,MPI_Rsend_init -Wl,-wrap,MPI_Recv_init -Wl,-wrap,MPI_Start -Wl,-wrap,MPI_Startall -Wl,-wrap,MPI_Sendrecv -Wl,-wrap,MPI_Sendrecv_replace -Wl,-wrap,MPI_Type_contiguous -Wl,-wrap,MPI_Type_vector -Wl,-wrap,MPI_Type_hvector -Wl,-wrap,MPI_Type_indexed -Wl,-wrap,MPI_Type_hindexed -Wl,-wrap,MPI_Type_struct -Wl,-wrap,MPI_Address -Wl,-wrap,MPI_Type_extent -Wl,-wrap,MPI_Type_size -Wl,-wrap,MPI_Type_lb -Wl,-wrap,MPI_Type_ub -Wl,-wrap,MPI_Type_commit -Wl,-wrap,MPI_Type_free -Wl,-wrap,MPI_Get_elements -Wl,-wrap,MPI_Pack -Wl,-wrap,MPI_Unpack -Wl,-wrap,MPI_Pack_size -Wl,-wrap,MPI_Barrier -Wl,-wrap,MPI_Bcast -Wl,-wrap,MPI_Gather -Wl,-wrap,MPI_Gatherv -Wl,-wrap,MPI_Scatter -Wl,-wrap,MPI_Scatterv -Wl,-wrap,MPI_Allgather -Wl,-wrap,MPI_Allgatherv -Wl,-wrap,MPI_Alltoall -Wl,-wrap,MPI_Alltoallv -Wl,-wrap,MPI_Reduce -Wl,-wrap,MPI_Op_create -Wl,-wrap,MPI_Op_free -Wl,-wrap,MPI_Allreduce -Wl,-wrap,MPI_Reduce_scatter -Wl,-wrap,MPI_Scan -Wl,-wrap,MPI_Group_size -Wl,-wrap,MPI_Group_rank -Wl,-wrap,MPI_Group_translate_ranks -Wl,-wrap,MPI_Group_compare -Wl,-wrap,MPI_Comm_group -Wl,-wrap,MPI_Group_union -Wl,-wrap,MPI_Group_intersection -Wl,-wrap,MPI_Group_difference -Wl,-wrap,MPI_Group_incl -Wl,-wrap,MPI_Group_excl -Wl,-wrap,MPI_Group_range_incl -Wl,-wrap,MPI_Group_range_excl -Wl,-wrap,MPI_Group_free -Wl,-wrap,MPI_Comm_size -Wl,-wrap,MPI_Comm_rank -Wl,-wrap,MPI_Comm_compare -Wl,-wrap,MPI_Comm_dup -Wl,-wrap,MPI_Comm_create -Wl,-wrap,MPI_Comm_split -Wl,-wrap,MPI_Comm_free -Wl,-wrap,MPI_Comm_test_inter -Wl,-wrap,MPI_Comm_remote_size -Wl,-wrap,MPI_Comm_remote_group -Wl,-wrap,MPI_Intercomm_create -Wl,-wrap,MPI_Intercomm_merge -Wl,-wrap,MPI_Keyval_create -Wl,-wrap,MPI_Keyval_free -Wl,-wrap,MPI_Attr_put -Wl,-wrap,MPI_Attr_get -Wl,-wrap,MPI_Attr_delete -Wl,-wrap,MPI_Topo_test -Wl,-wrap,MPI_Cart_create -Wl,-wrap,MPI_Dims_create -Wl,-wrap,MPI_Graph_create -Wl,-wrap,MPI_Graphdims_get -Wl,-wrap,MPI_Graph_get -Wl,-wrap,MPI_Cartdim_get -Wl,-wrap,MPI_Cart_get -Wl,-wrap,MPI_Cart_rank -Wl,-wrap,MPI_Cart_coords -Wl,-wrap,MPI_Graph_neighbors_count -Wl,-wrap,MPI_Graph_neighbors -Wl,-wrap,MPI_Cart_shift -Wl,-wrap,MPI_Cart_sub -Wl,-wrap,MPI_Cart_map -Wl,-wrap,MPI_Graph_map -Wl,-wrap,MPI_Get_processor_name -Wl,-wrap,MPI_Get_version -Wl,-wrap,MPI_Errhandler_create -Wl,-wrap,MPI_Errhandler_set -Wl,-wrap,MPI_Errhandler_get -Wl,-wrap,MPI_Errhandler_free -Wl,-wrap,MPI_Error_string -Wl,-wrap,MPI_Error_class -Wl,-wrap,MPI_Wtime -Wl,-wrap,MPI_Wtick -Wl,-wrap,MPI_Init -Wl,-wrap,MPI_Finalize -Wl,-wrap,MPI_Initialized -Wl,-wrap,MPI_Abort -Wl,-wrap,MPI_Comm_get_name -Wl,-wrap,MPI_Comm_set_name -Wl,-wrap,PMPI_Send -Wl,-wrap,PMPI_Recv -Wl,-wrap,PMPI_Get_count -Wl,-wrap,PMPI_Bsend -Wl,-wrap,PMPI_Ssend -Wl,-wrap,PMPI_Rsend -Wl,-wrap,PMPI_Isend -Wl,-wrap,PMPI_Ibsend -Wl,-wrap,PMPI_Issend -Wl,-wrap,PMPI_Irsend -Wl,-wrap,PMPI_Irecv -Wl,-wrap,PMPI_Wait -Wl,-wrap,PMPI_Test -Wl,-wrap,PMPI_Waitany -Wl,-wrap,PMPI_Testany -Wl,-wrap,PMPI_Waitall -Wl,-wrap,PMPI_Testall -Wl,-wrap,PMPI_Waitsome -Wl,-wrap,PMPI_Testsome -Wl,-wrap,PMPI_Iprobe -Wl,-wrap,PMPI_Probe -Wl,-wrap,PMPI_Send_init -Wl,-wrap,PMPI_Bsend_init -Wl,-wrap,PMPI_Ssend_init -Wl,-wrap,PMPI_Rsend_init -Wl,-wrap,PMPI_Recv_init -Wl,-wrap,PMPI_Startall -Wl,-wrap,PMPI_Sendrecv -Wl,-wrap,PMPI_Sendrecv_replace -Wl,-wrap,PMPI_Type_contiguous -Wl,-wrap,PMPI_Type_vector -Wl,-wrap,PMPI_Type_hvector -Wl,-wrap,PMPI_Type_indexed -Wl,-wrap,PMPI_Type_hindexed -Wl,-wrap,PMPI_Type_struct -Wl,-wrap,PMPI_Address -Wl,-wrap,PMPI_Type_extent -Wl,-wrap,PMPI_Type_lb -Wl,-wrap,PMPI_Type_ub -Wl,-wrap,PMPI_Get_elements -Wl,-wrap,PMPI_Pack -Wl,-wrap,PMPI_Unpack -Wl,-wrap,PMPI_Pack_size -Wl,-wrap,PMPI_Bcast -Wl,-wrap,PMPI_Gather -Wl,-wrap,PMPI_Gatherv -Wl,-wrap,PMPI_Scatter -Wl,-wrap,PMPI_Scatterv -Wl,-wrap,PMPI_Allgather -Wl,-wrap,PMPI_Allgatherv -Wl,-wrap,PMPI_Alltoall -Wl,-wrap,PMPI_Alltoallv -Wl,-wrap,PMPI_Reduce -Wl,-wrap,PMPI_Op_create -Wl,-wrap,PMPI_Allreduce -Wl,-wrap,PMPI_Reduce_scatter -Wl,-wrap,PMPI_Scan -Wl,-wrap,PMPI_Group_translate_ranks -Wl,-wrap,PMPI_Group_compare -Wl,-wrap,PMPI_Comm_group -Wl,-wrap,PMPI_Group_union -Wl,-wrap,PMPI_Group_intersection -Wl,-wrap,PMPI_Group_difference -Wl,-wrap,PMPI_Group_incl -Wl,-wrap,PMPI_Group_excl -Wl,-wrap,PMPI_Group_range_incl -Wl,-wrap,PMPI_Group_range_excl -Wl,-wrap,PMPI_Comm_compare -Wl,-wrap,PMPI_Comm_dup -Wl,-wrap,PMPI_Comm_create -Wl,-wrap,PMPI_Comm_split -Wl,-wrap,PMPI_Comm_remote_group -Wl,-wrap,PMPI_Intercomm_create -Wl,-wrap,PMPI_Intercomm_merge -Wl,-wrap,PMPI_Keyval_create -Wl,-wrap,PMPI_Cart_create -Wl,-wrap,PMPI_Graph_create -Wl,-wrap,PMPI_Cart_sub -Wl,-wrap,PMPI_Errhandler_create -Wl,-wrap,PMPI_Errhandler_set -Wl,-wrap,PMPI_Errhandler_get -Wl,-wrap,MPI_Init_thread -lmpc_mpi_wrap +-Wl,-wrap,MPI_Default_error -Wl,-wrap,MPI_Send -Wl,-wrap,MPI_Recv -Wl,-wrap,MPI_Get_count -Wl,-wrap,MPI_Bsend -Wl,-wrap,MPI_Ssend -Wl,-wrap,MPI_Rsend -Wl,-wrap,MPI_Buffer_attach -Wl,-wrap,MPI_Buffer_detach -Wl,-wrap,MPI_Isend -Wl,-wrap,MPI_Ibsend -Wl,-wrap,MPI_Issend -Wl,-wrap,MPI_Irsend -Wl,-wrap,MPI_Irecv -Wl,-wrap,MPI_Wait -Wl,-wrap,MPI_Test -Wl,-wrap,MPI_Request_free -Wl,-wrap,MPI_Waitany -Wl,-wrap,MPI_Testany -Wl,-wrap,MPI_Waitall -Wl,-wrap,MPI_Testall -Wl,-wrap,MPI_Waitsome -Wl,-wrap,MPI_Testsome -Wl,-wrap,MPI_Iprobe -Wl,-wrap,MPI_Probe -Wl,-wrap,MPI_Cancel -Wl,-wrap,MPI_Test_cancelled -Wl,-wrap,MPI_Send_init -Wl,-wrap,MPI_Bsend_init -Wl,-wrap,MPI_Ssend_init -Wl,-wrap,MPI_Rsend_init -Wl,-wrap,MPI_Recv_init -Wl,-wrap,MPI_Start -Wl,-wrap,MPI_Startall -Wl,-wrap,MPI_Sendrecv -Wl,-wrap,MPI_Sendrecv_replace -Wl,-wrap,MPI_Type_contiguous -Wl,-wrap,MPI_Type_vector -Wl,-wrap,MPI_Type_hvector -Wl,-wrap,MPI_Type_indexed -Wl,-wrap,MPI_Type_hindexed -Wl,-wrap,MPI_Type_struct -Wl,-wrap,MPI_Address -Wl,-wrap,MPI_Type_extent -Wl,-wrap,MPI_Type_size -Wl,-wrap,MPI_Type_lb -Wl,-wrap,MPI_Type_ub -Wl,-wrap,MPI_Type_commit -Wl,-wrap,MPI_Type_free -Wl,-wrap,MPI_Get_elements -Wl,-wrap,MPI_Pack -Wl,-wrap,MPI_Unpack -Wl,-wrap,MPI_Pack_size -Wl,-wrap,MPI_Barrier -Wl,-wrap,MPI_Bcast -Wl,-wrap,MPI_Gather -Wl,-wrap,MPI_Gatherv -Wl,-wrap,MPI_Scatter -Wl,-wrap,MPI_Scatterv -Wl,-wrap,MPI_Allgather -Wl,-wrap,MPI_Allgatherv -Wl,-wrap,MPI_Alltoall -Wl,-wrap,MPI_Alltoallv -Wl,-wrap,MPI_Reduce -Wl,-wrap,MPI_Op_create -Wl,-wrap,MPI_Op_free -Wl,-wrap,MPI_Allreduce -Wl,-wrap,MPI_Reduce_scatter -Wl,-wrap,MPI_Scan -Wl,-wrap,MPI_Group_size -Wl,-wrap,MPI_Group_rank -Wl,-wrap,MPI_Group_translate_ranks -Wl,-wrap,MPI_Group_compare -Wl,-wrap,MPI_Comm_group -Wl,-wrap,MPI_Group_union -Wl,-wrap,MPI_Group_intersection -Wl,-wrap,MPI_Group_difference -Wl,-wrap,MPI_Group_incl -Wl,-wrap,MPI_Group_excl -Wl,-wrap,MPI_Group_range_incl -Wl,-wrap,MPI_Group_range_excl -Wl,-wrap,MPI_Group_free -Wl,-wrap,MPI_Comm_size -Wl,-wrap,MPI_Comm_rank -Wl,-wrap,MPI_Comm_compare -Wl,-wrap,MPI_Comm_dup -Wl,-wrap,MPI_Comm_create -Wl,-wrap,MPI_Comm_split -Wl,-wrap,MPI_Comm_free -Wl,-wrap,MPI_Comm_test_inter -Wl,-wrap,MPI_Comm_remote_size -Wl,-wrap,MPI_Comm_remote_group -Wl,-wrap,MPI_Intercomm_create -Wl,-wrap,MPI_Intercomm_merge -Wl,-wrap,MPI_Keyval_create -Wl,-wrap,MPI_Keyval_free -Wl,-wrap,MPI_Attr_put -Wl,-wrap,MPI_Attr_get -Wl,-wrap,MPI_Attr_delete -Wl,-wrap,MPI_Topo_test -Wl,-wrap,MPI_Cart_create -Wl,-wrap,MPI_Dims_create -Wl,-wrap,MPI_Graph_create -Wl,-wrap,MPI_Graphdims_get -Wl,-wrap,MPI_Graph_get -Wl,-wrap,MPI_Cartdim_get -Wl,-wrap,MPI_Cart_get -Wl,-wrap,MPI_Cart_rank -Wl,-wrap,MPI_Cart_coords -Wl,-wrap,MPI_Graph_neighbors_count -Wl,-wrap,MPI_Graph_neighbors -Wl,-wrap,MPI_Cart_shift -Wl,-wrap,MPI_Cart_sub -Wl,-wrap,MPI_Cart_map -Wl,-wrap,MPI_Graph_map -Wl,-wrap,MPI_Get_processor_name -Wl,-wrap,MPI_Get_version -Wl,-wrap,MPI_Errhandler_create -Wl,-wrap,MPI_Errhandler_set -Wl,-wrap,MPI_Errhandler_get -Wl,-wrap,MPI_Errhandler_free -Wl,-wrap,MPI_Error_string -Wl,-wrap,MPI_Error_class -Wl,-wrap,MPI_Wtime -Wl,-wrap,MPI_Wtick -Wl,-wrap,MPI_Init -Wl,-wrap,MPI_Finalize -Wl,-wrap,MPI_Initialized -Wl,-wrap,MPI_Abort -Wl,-wrap,MPI_Comm_get_name -Wl,-wrap,MPI_Comm_set_name -Wl,-wrap,PMPI_Send -Wl,-wrap,PMPI_Recv -Wl,-wrap,PMPI_Get_count -Wl,-wrap,PMPI_Bsend -Wl,-wrap,PMPI_Ssend -Wl,-wrap,PMPI_Rsend -Wl,-wrap,PMPI_Isend -Wl,-wrap,PMPI_Ibsend -Wl,-wrap,PMPI_Issend -Wl,-wrap,PMPI_Irsend -Wl,-wrap,PMPI_Irecv -Wl,-wrap,PMPI_Wait -Wl,-wrap,PMPI_Test -Wl,-wrap,PMPI_Waitany -Wl,-wrap,PMPI_Testany -Wl,-wrap,PMPI_Waitall -Wl,-wrap,PMPI_Testall -Wl,-wrap,PMPI_Waitsome -Wl,-wrap,PMPI_Testsome -Wl,-wrap,PMPI_Iprobe -Wl,-wrap,PMPI_Probe -Wl,-wrap,PMPI_Send_init -Wl,-wrap,PMPI_Bsend_init -Wl,-wrap,PMPI_Ssend_init -Wl,-wrap,PMPI_Rsend_init -Wl,-wrap,PMPI_Recv_init -Wl,-wrap,PMPI_Startall -Wl,-wrap,PMPI_Sendrecv -Wl,-wrap,PMPI_Sendrecv_replace -Wl,-wrap,PMPI_Type_contiguous -Wl,-wrap,PMPI_Type_vector -Wl,-wrap,PMPI_Type_hvector -Wl,-wrap,PMPI_Type_indexed -Wl,-wrap,PMPI_Type_hindexed -Wl,-wrap,PMPI_Type_struct -Wl,-wrap,PMPI_Address -Wl,-wrap,PMPI_Type_extent -Wl,-wrap,PMPI_Type_lb -Wl,-wrap,PMPI_Type_ub -Wl,-wrap,PMPI_Get_elements -Wl,-wrap,PMPI_Pack -Wl,-wrap,PMPI_Unpack -Wl,-wrap,PMPI_Pack_size -Wl,-wrap,PMPI_Bcast -Wl,-wrap,PMPI_Gather -Wl,-wrap,PMPI_Gatherv -Wl,-wrap,PMPI_Scatter -Wl,-wrap,PMPI_Scatterv -Wl,-wrap,PMPI_Allgather -Wl,-wrap,PMPI_Allgatherv -Wl,-wrap,PMPI_Alltoall -Wl,-wrap,PMPI_Alltoallv -Wl,-wrap,PMPI_Reduce -Wl,-wrap,PMPI_Op_create -Wl,-wrap,PMPI_Allreduce -Wl,-wrap,PMPI_Reduce_scatter -Wl,-wrap,PMPI_Scan -Wl,-wrap,PMPI_Group_translate_ranks -Wl,-wrap,PMPI_Group_compare -Wl,-wrap,PMPI_Comm_group -Wl,-wrap,PMPI_Group_union -Wl,-wrap,PMPI_Group_intersection -Wl,-wrap,PMPI_Group_difference -Wl,-wrap,PMPI_Group_incl -Wl,-wrap,PMPI_Group_excl -Wl,-wrap,PMPI_Group_range_incl -Wl,-wrap,PMPI_Group_range_excl -Wl,-wrap,PMPI_Comm_compare -Wl,-wrap,PMPI_Comm_dup -Wl,-wrap,PMPI_Comm_create -Wl,-wrap,PMPI_Comm_split -Wl,-wrap,PMPI_Comm_remote_group -Wl,-wrap,PMPI_Intercomm_create -Wl,-wrap,PMPI_Intercomm_merge -Wl,-wrap,PMPI_Keyval_create -Wl,-wrap,PMPI_Cart_create -Wl,-wrap,PMPI_Graph_create -Wl,-wrap,PMPI_Cart_sub -Wl,-wrap,PMPI_Errhandler_create -Wl,-wrap,PMPI_Errhandler_set -Wl,-wrap,PMPI_Errhandler_get -Wl,-wrap,MPI_Init_thread -lmpc_mpi_wrap diff --git a/src/wrappers/mpc_mpi/wr.c b/src/wrappers/mpc_mpi/wr.c index 0b02fce3e..a837001a3 100644 --- a/src/wrappers/mpc_mpi/wr.c +++ b/src/wrappers/mpc_mpi/wr.c @@ -2,6 +2,17 @@ #include #include +#include + +#ifdef TAU_MPI +#include +#endif /* TAU_MPI */ +//#include "gen_prof.h" +//#include +//#include + + +static int procid_0; /********************************************************** MPI_Default_error @@ -2135,32 +2146,465 @@ double __wrap_MPI_Wtick() { int __real_MPI_Init(int * a1, char *** a2) ; int __wrap_MPI_Init(int * a1, char *** a2) { +#if 0 int retval; + fprintf(stdout, "TAU wrap MPI_Init for MPC\n"); TAU_PROFILE_TIMER(t,"int MPI_Init(int *, char ***) C", "", TAU_USER); TAU_PROFILE_START(t); retval = __real_MPI_Init(a1, a2); TAU_PROFILE_STOP(t); return retval; +#endif + + int returnVal; + int size; + char procname[MPI_MAX_PROCESSOR_NAME]; + int procnamelength; + + if(Tau_get_usesMPI() == 0) + { + + + TAU_PROFILE_TIMER(tautimer, "MPI_Init()", " ", TAU_MESSAGE); + Tau_create_top_level_timer_if_necessary(); + TAU_PROFILE_START(tautimer); + + tau_mpi_init_predefined_constants(); +#ifdef TAU_MPI_T + Tau_MPI_T_initialization(); + Tau_track_mpi_t(); +#endif /* TAU_MPI_T */ + +#ifdef TAU_ADIOS + // this is only here to force the linker to resolve the adiost_tool symbol + // before the weak one in the ADIOS static library gets pulled in, and prevents + // TAU from replacing it. + adiost_tool(); +#endif + +#ifdef TAU_SOS + int provided = 0; + returnVal = PMPI_Init_thread( a1, a2, MPI_THREAD_FUNNELED, &provided ); + if (TauEnv_get_sos_enabled()) { + TAU_SOS_init(argc, argv, true); + } +#else + returnVal = PMPI_Init( a1, a2 ); +#endif + +#ifndef TAU_WINDOWS +#ifndef _AIX + if (TauEnv_get_ebs_enabled()) { + Tau_sampling_init_if_necessary(); + } +#endif /* _AIX */ +#endif /* TAU_WINDOWS */ + + Tau_signal_initialization(); + +#ifdef TAU_MONITORING + Tau_mon_connect(); +#endif /* TAU_MONITORING */ + +#ifdef TAU_BGP + if (TauEnv_get_ibm_bg_hwp_counters()) { + int upcErr; + Tau_Bg_hwp_counters_start(&upcErr); + if (upcErr != 0) { + printf("TAU ERROR: ** Error starting IBM BGP UPC hardware performance counters\n"); + } + PMPI_Barrier(MPI_COMM_WORLD); + } +#endif /* TAU_BGP */ + TAU_PROFILE_STOP(tautimer); + + PMPI_Comm_rank( MPI_COMM_WORLD, &procid_0 ); + TAU_PROFILE_SET_NODE(procid_0 ); + Tau_set_usesMPI(1); + PMPI_Comm_size( MPI_COMM_WORLD, &size ); + tau_totalnodes(1, size); /* Set the totalnodes */ + + PMPI_Get_processor_name(procname, &procnamelength); + TAU_METADATA("MPI Processor Name", procname); + + if (TauEnv_get_synchronize_clocks()) { + TauSyncClocks(); + } + } + else { + returnVal = 0; + } + + writeMetaDataAfterMPI_Init(); + + return returnVal; + +} + +int genProfileFake() +{ + int rank = 0; + int numRanks; + + PMPI_Comm_rank(MPI_COMM_WORLD, &rank); + PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + TAU_VERBOSE("TAU - genProfileFake C: rank=%d, numRanks=%d\n", rank, numRanks); + + return 0; } +#if 0 +int genProfile() +{ + + //int numRanks; + //PMPI_Comm_rank(MPI_COMM_WORLD, &rank); + //PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + //TAU_VERBOSE("TAU - inside genProfile(): rank=%d, numRanks=%d\n", rank, numRanks); + + Tau_metadata_fillMetaData(); + + static int merged = 0; + if (merged == 1) { + return 0; + } + merged = 1; + + int rank = 0; + +#ifdef TAU_MPI + int numRanks; + //if (TAU_MPI_Finalized()) { + // fprintf(stdout, "TAU_MPI_Finalized() called\n"); + // return 0; + //} + + PMPI_Comm_rank(MPI_COMM_WORLD, &rank); + PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + TAU_VERBOSE("TAU: rank=%d, numRanks=%d\n", rank, numRanks); +#endif /* TAU_MPI */ + + x_uint64 start, end; + +#if 1 + if (rank == 0) { + + TAU_VERBOSE("TAU: Merging MetaData...\n"); + start = TauMetrics_getTimeOfDay(); + +#if 1 +#ifdef TAU_MPI + Tau_util_outputDevice *out = Tau_metadata_generateMergeBuffer(); + char *defBuf = Tau_util_getOutputBuffer(out); + int defBufSize = Tau_util_getOutputBufferLength(out); + + PMPI_Bcast(&defBufSize, 1, MPI_INT, 0, MPI_COMM_WORLD); + PMPI_Bcast(defBuf, defBufSize, MPI_CHAR, 0, MPI_COMM_WORLD); +#endif /* TAU_MPI */ +#endif + + end = TauMetrics_getTimeOfDay(); + TAU_VERBOSE("TAU: MetaData Merging Complete, duration = %.4G seconds\n", ((double)(end-start))/1000000.0f); + char tmpstr[256]; + sprintf(tmpstr, "%.4G seconds", ((double)(end-start))/1000000.0f); + TAU_METADATA("TAU MetaData Merge Time", tmpstr); + +#if 1 +#ifdef TAU_MPI + Tau_util_destroyOutputDevice(out); +#endif /* TAU_MPI */ +#endif + + } else { + +#if 1 +#ifdef TAU_MPI + TAU_VERBOSE("TAU: Metadata, rank different from 0\n"); + int BufferSize; + PMPI_Bcast(&BufferSize, 1, MPI_INT, 0, MPI_COMM_WORLD); + char *Buffer = (char*) TAU_UTIL_MALLOC(BufferSize); + PMPI_Bcast(Buffer, BufferSize, MPI_CHAR, 0, MPI_COMM_WORLD); + Tau_metadata_removeDuplicates(Buffer, BufferSize); + free(Buffer); +#endif /* TAU_MPI */ +#endif + } +#endif + + return 0; +} +#endif + + +int tau_mpi_finalized = 0; + +#if 1 +int TAU_MPI_Finalized() { + fprintf(stdout, "In TAU_MPI_Finalized(): tau_mpi_finalized=%d\n", tau_mpi_finalized); + return tau_mpi_finalized; +} +#endif /********************************************************** MPI_Finalize **********************************************************/ + +int __real_MPI_Finalize() ; +int __wrap_MPI_Finalize() { + + + int returnVal; + char procname[MPI_MAX_PROCESSOR_NAME]; + int procnamelength; + + TAU_VERBOSE("TAU: Call MPI_Finalize()\n"); + + TAU_PROFILE_TIMER(tautimer, "MPI_Finalize()", " ", TAU_MESSAGE); + TAU_PROFILE_START(tautimer); + +#ifdef TAU_MPI_T + Tau_track_mpi_t_here(); + + /*Clean up and finalize the MPI_T interface*/ + Tau_mpi_t_cleanup(); + + returnVal = PMPI_T_finalize(); + if (returnVal != MPI_SUCCESS) { + printf("TAU: Call to MPI_T_finalize failed\n"); + } + +#endif /* TAU_MPI_T */ + +#ifdef TAU_SOS + //TAU_SOS_stop_worker(); +#endif + + if (TauEnv_get_synchronize_clocks()) { + TauSyncFinalClocks(); + } + Tau_metadata_writeEndingTimeStamp(); + + PMPI_Get_processor_name(procname, &procnamelength); + TAU_METADATA("MPI Processor Name", procname); + + if (Tau_get_node() < 0) { + /* Grab the node id, we don't always wrap mpi_init */ + PMPI_Comm_rank( MPI_COMM_WORLD, &procid_0 ); + TAU_PROFILE_SET_NODE(procid_0 ); + Tau_set_usesMPI(1); + } + +#ifdef TAU_BGP + /* BGP counters */ + int numCounters, mode, upcErr; + x_uint64 counterVals[1024]; + + if (TauEnv_get_ibm_bg_hwp_counters()) { + PMPI_Barrier(MPI_COMM_WORLD); + Tau_Bg_hwp_counters_stop(&numCounters, counterVals, &mode, &upcErr); + if (upcErr != 0) { + printf(" ** Error stopping UPC performance counters"); + } + + Tau_Bg_hwp_counters_output(&numCounters, counterVals, &mode, &upcErr); + } +#endif /* TAU_BGP */ + +#ifndef TAU_WINDOWS +#ifndef _AIX + /* Shutdown EBS after Finalize to allow Profiles to be written out + correctly. Also allows profile merging (or unification) to be + done correctly. */ + if (TauEnv_get_callsite()) { + finalizeCallSites_if_necessary(); + } +#endif /* _AIX */ +#endif /* TAU_WINDOWS */ + + Tau_MemMgr_finalizeIfNecessary(); + +#ifndef TAU_WINDOWS +#ifndef _AIX + if (TauEnv_get_ebs_enabled()) { + // Tau_sampling_finalizeNode(); + + Tau_sampling_finalize_if_necessary(Tau_get_local_tid()); + } +#endif /* _AIX */ +#endif /* TAU_WINDOWS */ + + /* *CWL* This might be generalized to perform a final monitoring dump. + For now, we should let merging handle the data. +#ifdef TAU_MON_MPI + Tau_collate_writeProfile(); +#else + */ + + // merge TAU metadata + if (TauEnv_get_merge_metadata()) { + Tau_metadataMerge_mergeMetaData(); + } + + /* Create a merged profile if requested */ + if (TauEnv_get_profile_format() == TAU_FORMAT_MERGED) { + /* *CWL* - properly record intermediate values (the same way snapshots work). + Note that we do not want to shut down the timers as yet. There is + still potentially life after MPI_Finalize where TAU is concerned. + */ + /* KAH - NO! this is the wrong time to do this. THis is also done in the + * snapshot writer. If you do it twice, you get double values for main... */ + //TauProfiler_updateAllIntermediateStatistics(); + Tau_mergeProfiles_MPI(); + } + +#ifdef TAU_MONITORING + Tau_mon_disconnect(); +#endif /* TAU_MONITORING */ + +#ifdef TAU_SOS + if (TauEnv_get_sos_enabled()) { + TAU_SOS_finalize(); + } +#endif + +#ifdef TAU_OTF2 + if(TauEnv_get_trace_format() == TAU_TRACE_FORMAT_OTF2) { + TauTraceOTF2ShutdownComms(Tau_get_local_tid()); + } +#endif + + returnVal = __real_MPI_Finalize(); + + TAU_PROFILE_STOP(tautimer); + + Tau_stop_top_level_timer_if_necessary(); + tau_mpi_finalized = 1; + + return returnVal; +} + +#if 0 int __real_MPI_Finalize() ; int __wrap_MPI_Finalize() { int retval; + TAU_VERBOSE("Wrapper to MPI_Finalize() for MPC\n"); TAU_PROFILE_TIMER(t,"int MPI_Finalize() C", "", TAU_USER); - TAU_PROFILE_START(t); + + char procname[MPI_MAX_PROCESSOR_NAME]; + int procnamelength; + + TAU_VERBOSE("TAU: Call MPI_Finalize()\n"); + + TAU_PROFILE_TIMER(tautimer, "MPI_Finalize()", " ", TAU_MESSAGE); + TAU_PROFILE_START(tautimer); + +#ifdef TAU_MPI_T + Tau_track_mpi_t_here(); +#endif /* TAU_MPI_T */ + writeMetaDataAfterMPI_Init(); + + if (TauEnv_get_synchronize_clocks()) { + TauSyncFinalClocks(); + } + + PMPI_Get_processor_name(procname, &procnamelength); + TAU_METADATA("MPI Processor Name", procname); + + if (Tau_get_node() < 0) { + /* Grab the node id, we don't always wrap mpi_init */ + PMPI_Comm_rank( MPI_COMM_WORLD, &procid_0 ); + TAU_PROFILE_SET_NODE(procid_0 ); + Tau_set_usesMPI(1); + } + +#ifdef TAU_BGP + /* BGP counters */ + int numCounters, mode, upcErr; + x_uint64 counterVals[1024]; + + if (TauEnv_get_ibm_bg_hwp_counters()) { + PMPI_Barrier(MPI_COMM_WORLD); + Tau_Bg_hwp_counters_stop(&numCounters, counterVals, &mode, &upcErr); + if (upcErr != 0) { + printf(" ** Error stopping UPC performance counters"); + } + + Tau_Bg_hwp_counters_output(&numCounters, counterVals, &mode, &upcErr); + } +#endif /* TAU_BGP */ + +#ifndef TAU_WINDOWS +#ifndef _AIX + /* Shutdown EBS after Finalize to allow Profiles to be written out + * correctly. Also allows profile merging (or unification) to be + * done correctly. */ + if (TauEnv_get_callsite()) { + finalizeCallSites_if_necessary(); + } +#endif /* _AIX */ +#endif /* TAU_WINDOWS */ + +#ifndef TAU_WINDOWS +#ifndef _AIX + if (TauEnv_get_ebs_enabled()) { + // Tau_sampling_finalizeNode(); + // + Tau_sampling_finalize_if_necessary(Tau_get_local_tid()); + } +#endif /* _AIX */ +#endif /* TAU_WINDOWS */ + +#if 1 + int rank = 0; + int numRanks; + PMPI_Comm_rank(MPI_COMM_WORLD, &rank); + PMPI_Comm_size(MPI_COMM_WORLD, &numRanks); + + TAU_VERBOSE("TAU - inside MPI_Finalize MPC wrapper: rank=%d, numRanks=%d\n", rank, numRanks); + + //Tau_metadataMerge_mergeMetaData_bis(); + Tau_metadataMerge_mergeMetaData(); +#endif + + TAU_VERBOSE("Merge profile files if MERGED format specified\n"); +#if 1 + /* Create a merged profile if requested */ + if (TauEnv_get_profile_format() == TAU_FORMAT_MERGED) { + /* *CWL* - properly record intermediate values (the same way snapshots work). + * Note that we do not want to shut down the timers as yet. There is + * still potentially life after MPI_Finalize where TAU is concerned. + * */ + /* KAH - NO! this is the wrong time to do this. THis is also done in the + * * snapshot writer. If you do it twice, you get double values for main... */ + /* TauProfiler_updateAllIntermediateStatistics(); */ + //fprintf(stdout, "Merge profiles\n"); + Tau_mergeProfiles(); + } +#endif + + TAU_VERBOSE("Call real MPI_Finalize\n"); + + //TAU_PROFILE_START(t); retval = __real_MPI_Finalize(); - TAU_PROFILE_STOP(t); + TAU_PROFILE_STOP(tautimer); + + TAU_VERBOSE("Stop timer\n"); + +#if 1 + Tau_stop_top_level_timer_if_necessary(); + tau_mpi_finalized = 1; +#endif + return retval; } - +#endif /********************************************************** MPI_Initialized diff --git a/tools/src/contrib/CubeReader.jar b/tools/src/contrib/CubeReader.jar index 19785ac92..40ee29214 100644 Binary files a/tools/src/contrib/CubeReader.jar and b/tools/src/contrib/CubeReader.jar differ diff --git a/tools/src/tau_exec b/tools/src/tau_exec index 5b432a3a4..54c83d2ea 100755 --- a/tools/src/tau_exec +++ b/tools/src/tau_exec @@ -56,6 +56,9 @@ usage() echo " -ptts-post Skip application sampling and post-process existing PTTS sample files" echo " -ptts-num= Number of ranks used for ThreadSpotter" echo " -ptts-sample-flags= Flags to pass to PTTS sample_ts command. Overrides TAU_TS_SAMPLE_FLAGS env. var." + echo " -ptts-restart Enable restart support within PTTS, allowing application to continue running and be reinstrumented after stop." + echo " -ptts-start= Address at which to start a PTTS sampling region" + echo " -ptts-stop= Address at which to stop a PTTS sampling region" echo " -ptts-report-flags= Flags to pass to PTTS report_ts command. Overrides TAU_TS_REPORT_FLAGS env. var." echo " -ebs Enable event-based sampling" echo " -ebs_period= Sampling period (default 1000)" @@ -305,6 +308,14 @@ py_interp_args="" ptts_sample_flags="${TAU_TS_SAMPLE_FLAGS:-}" # Set these from environment vars if they exist, don't complain even ptts_report_flags="${TAU_TS_REPORT_FLAGS:-}" # if set -o nounset +# This saves the args to tau_exec so they can be reused later. +# This is used for MPI_Comm_spawn support, in which TAU spawns the child +# through tau_exec, since the child doesn't inherit environment variables. +save_arg() +{ + export TAU_EXEC_ARGS="${TAU_EXEC_ARGS} $@" +} + for arg in "$@" ; do # Thanks to Bernd Mohr for the following that handles quotes and spaces (see configure for explanation) modarg=`echo "x$arg" | sed -e 's/^x//' -e 's/"/\\\"/g' -e s,\',%@%\',g -e 's/%@%/\\\/g' -e 's/ /\\\ /g'` @@ -316,167 +327,220 @@ for arg in "$@" ; do if [ "x$test_arg" != "x$arg" ]; then scorep=true fi + save_arg $arg shift else case $arg in -v|-d|-verbose|--verbose) verbose=true + save_arg $arg shift ;; -h|-help|--help) usage + save_arg $arg ;; -io) track_io=true + save_arg $arg shift ;; -numa) track_numa=true + save_arg $arg shift ;; -memory) track_memory=true + save_arg $arg shift ;; -memory_debug) memory_debug=true + save_arg $arg shift ;; -cuda) track_cuda=true + save_arg $arg shift ;; -ompt) track_ompt=true + save_arg $arg shift ;; -power) track_power=true + save_arg $arg shift ;; -cupti) track_cupti=true + save_arg $arg shift ;; -um | -uvm) unified_memory=true + save_arg $arg shift ;; -sass=*) track_sass=true myarg=`echo $arg | sed 's/-sass=//'` sass_type="$myarg" + save_arg $arg shift ;; -csv) csv_output=true + save_arg $arg shift ;; -opencl) track_opencl=true + save_arg $arg shift ;; -openacc) track_openacc=true + save_arg $arg shift ;; -gomp) track_gomp=true + save_arg $arg shift ;; -armci) track_armci=true + save_arg $arg shift ;; -shmem) track_shmem=true + save_arg $arg shift ;; -pin) use_pin=true + save_arg $arg shift ;; -ptts) use_ptts=true + save_arg $arg shift ;; -ptts-post) use_ptts=true ptts_post=true + save_arg $arg shift ;; -ptts-num=*) myarg=`echo $arg | sed 's/-ptts-num=//'` ptts_num="$myarg" + save_arg $arg shift ;; -ptts-sample-flags=*) ptts_sample_flags="${arg/#-ptts-sample-flags=/}" # bash parameter expansion, bash 3 and up + save_arg $arg + shift + ;; + -ptts-restart) + ptts_restart="true" + save_arg $arg + shift + ;; + -ptts-start=*) + ptts_start="${arg/#-ptts-start=/}" # bash parameter expansion, bash 3 and up + save_arg $arg + shift + ;; + -ptts-stop=*) + ptts_stop="${arg/#-ptts-stop=/}" # bash parameter expansion, bash 3 and up + save_arg $arg shift ;; -ptts-report-flags=*) ptts_report_flags="${arg/#-ptts-report-flags=/}" # Also propper quoting must be used when multiple passed + save_arg $arg shift ;; -ebs) tau_use_ebs=true + save_arg $arg shift ;; -ebs_period=*) tau_use_ebs=true myarg=`echo $arg | sed 's/-ebs_period=//'` tau_ebs_period="$myarg" + save_arg $arg shift ;; -ebs_source=*) tau_use_ebs=true myarg=`echo $arg | sed 's/-ebs_source=//'` tau_ebs_source="$myarg" + save_arg $arg shift ;; -qsub) qsub_mode=true + save_arg $arg shift ;; -s) dryrun=echo + save_arg $arg shift ;; -gdb) use_gdb=true + save_arg $arg shift ;; -T) processT=true + save_arg $arg shift ;; -tau:*) binding_options="$binding_options `echo $arg | sed -e 's/-tau://' -e 's/,/ /g'`" + save_arg $arg shift ;; -loadlib=*) myarg=`echo $arg | sed 's/-loadlib=//'` extraloadlibs="$extraloadlibs:$myarg" + save_arg $arg shift ;; -XrunTAU-*) myarg=`echo $arg | sed 's/-XrunTAU-//'` binding_specified="shared-$myarg" + save_arg $arg shift ;; -XrunTAUsh-*) myarg=`echo $arg | sed 's/-XrunTAUsh-//'` binding_specified="shared-$myarg" + save_arg $arg shift ;; -spark-python) spark_wrapper=true + save_arg $arg shift ;; -tau-python-args=*) if [ $python_wrapper = "true" ] ; then myarg=`echo $arg | sed 's/-tau-python-args=//'` py_interp_args="$myarg" + save_arg $arg shift else echo "Unknown option: $arg" >&2 @@ -485,6 +549,7 @@ for arg in "$@" ; do ;; -c) if [ $python_wrapper = "true" ] ; then + save_arg $arg break else echo "Unknown option: $arg" >&2 @@ -493,6 +558,7 @@ for arg in "$@" ; do ;; -m) if [ $python_wrapper = "true" ] ; then + save_arg $arg shift break else @@ -501,6 +567,7 @@ for arg in "$@" ; do fi ;; --) + save_arg $arg shift break ;; @@ -515,7 +582,21 @@ for arg in "$@" ; do esac fi done +export TAU_EXEC_PATH=${BASH_SOURCE[0]} + +if [ "x$ptts_start" != "x" ]; then + ptts_sample_flags="$ptts_sample_flags --start-at-address $ptts_start" + ptts_restart=true +fi +if [ "x$ptts_stop" != "x" ]; then + ptts_sample_flags="$ptts_sample_flags --stop-at-address $ptts_stop" + ptts_restart=true +fi + +if [ "x$ptts_restart" != "x" ]; then + ptts_sample_flags="$ptts_sample_flags --sample-restart" +fi # choose TAU library new_binding_options="" diff --git a/utils/FixMakefile b/utils/FixMakefile index 98a327100..256266dd3 100755 --- a/utils/FixMakefile +++ b/utils/FixMakefile @@ -2157,6 +2157,10 @@ case $1 in echo "NOTE: IBM xlflang compiler for Linux options used" echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout ;; + ARMFLANG) + echo "NOTE: ARM armflang compiler for Linux options used" + echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout + ;; MPIIFORT) echo "NOTE: Intel mpiifort compiler options used" echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout diff --git a/utils/pprof.cpp b/utils/pprof.cpp index 966b73afa..d8c2a04d5 100644 --- a/utils/pprof.cpp +++ b/utils/pprof.cpp @@ -439,6 +439,13 @@ int FillFunctionDB(int node, int ctx, int thr, char *prefix){ perror("Error: fgets returns NULL in format string "); return 0; }//if + size_t line_len = strlen(line); + if(line[line_len-1] != '\n') { + // Header was too long to read + while(getc(fp) != '\n') { + // skip to next line + } + } if (line[0] == '#') { // new data format sprintf(header,"# Name Calls Subrs Excl Incl "); hlen = strlen(header); @@ -756,6 +763,13 @@ int ProcessFileDynamic(int node, int ctx, int thr, int max, char *prefix){ perror("Error: fgets returns NULL in format string "); return 0; }//if + size_t line_len = strlen(line); + if(line[line_len-1] != '\n') { + // Header was too long to read + while(getc(fp) != '\n') { + // skip to next line + } + } //check to make sure first character is the #. If not, then we //are using the old data format, so note accordingly. if (line[0] != '#') { // Old data format without '#' diff --git a/utils/tau_cupti_avail/Makefile b/utils/tau_cupti_avail/Makefile index 356b521df..bbcc32125 100644 --- a/utils/tau_cupti_avail/Makefile +++ b/utils/tau_cupti_avail/Makefile @@ -13,7 +13,7 @@ all: $(TAU_CUPTI_AVAIL) install: $(INSTALLTAU_CUPTI_AVAIL) $(TAU_CUPTI_AVAIL): tau_cupti_avail.o $(TAU_PREFIX_INSTALL_DIR)/$(CONFIG_ARCH)/lib/libTAUsh$(TAU_CONFIG).so - $(CXX) -o $@ $< -L$(TAU_LIB_DIR) $(TAU_LINKER_RPATH_OPT) $(TAU_SHLIBS) -lcuda + $(CXX) -o $@ $< -L$(TAU_LIB_DIR) $(TAU_LINKER_RPATH_OPT) $(TAU_SHLIBS) $(TAU_OPENMP_OPTION) -lcuda tau_cupti_avail.o: tau_cupti_avail.cpp $(TAU_CUDA_CXX) $(CFLAGS) -I$(TAU_CUDA_INC) -I$(TAU_CUPTI_INC) -I$(TAU_INC_DIR) -c $<