From da93eda751797ab01768db7b3ff895dde5fdc781 Mon Sep 17 00:00:00 2001 From: Kevin Huck Date: Wed, 25 Oct 2023 18:21:39 -0400 Subject: [PATCH] Reporting tcmalloc preload error when detected. We could probably automatically detect that tcmalloc is a dependency and preload it automatically... --- src/apex/CMakeLists_standalone.cmake | 6 +++++- src/scripts/apex_exec | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/apex/CMakeLists_standalone.cmake b/src/apex/CMakeLists_standalone.cmake index 805eb8aa..147e2dfc 100644 --- a/src/apex/CMakeLists_standalone.cmake +++ b/src/apex/CMakeLists_standalone.cmake @@ -58,6 +58,10 @@ if(APEX_WITH_PERFETTO) include_directories(${APEX_SOURCE_DIR}/src/perfetto_sdk) endif() +if(APEX_WITH_TCMALLOC) + set(TCMALLOC_SOURCE tcmalloc_hooks.cpp) +endif(APEX_WITH_TCMALLOC) + # Try to keep this in alphabetical order SET(all_SOURCE apex_preload.cpp @@ -92,7 +96,7 @@ random.cpp ${SENSOR_SOURCE} simulated_annealing.cpp task_identifier.cpp -tcmalloc_hooks.cpp +${TCMALLOC_SOURCE} ${tau_SOURCE} thread_instance.cpp threadpool.cpp diff --git a/src/scripts/apex_exec b/src/scripts/apex_exec index 98998939..8336aee0 100755 --- a/src/scripts/apex_exec +++ b/src/scripts/apex_exec @@ -536,6 +536,7 @@ if [ $mpi = yes ]; then testme=${BASEDIR}/${LIBDIR}/${APEX_LIBRARY_NAME}_mpi${SHLIBX} if [ -f ${testme} ]; then export MPI_LIB=:${testme} + export MPI_LIB2=${testme} fi fi if [ $cuda = yes ] || [ $monitor_gpu = yes ]; then @@ -702,6 +703,12 @@ else unset DYLD_INSERT_LIBRARIES rm -f ./.gdbcmds if [ ${retval} != 0 ] ; then + echo "Error ${retval}!" + count=`ldd ${MPI_LIB2} | grep -c tcmalloc` + if [ ${count} -eq 1 ] ; then + preloadme=`ldd ${MPI_LIB2} | grep tcmalloc | awk '{ print $3 }'` + echo "If you got some kind of tcmalloc error, please preload the dependent tcmalloc shared object library with '--apex:preload ${preloadme}'" + fi exit ${retval} fi fi