diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ecb9a5c..a553d06c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,6 +342,13 @@ if (APEX_USE_PEDANTIC) endif(APEX_WITH_CUDA) endif (APEX_USE_PEDANTIC) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM") + set(APEX_STDCXX_LIB "" CACHE STRING "C++ library for linking") + message("IntelLLVM compiler detected, no stdc++ library needed") +else() + set(APEX_STDCXX_LIB stdc++ CACHE STRING "C++ library for linking") +endif() + # PGI and Intel don't like the concurrentqueue code. if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI") if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") diff --git a/src/apex/memory_wrapper.cpp b/src/apex/memory_wrapper.cpp index 1d0a9fcd..fb90b351 100644 --- a/src/apex/memory_wrapper.cpp +++ b/src/apex/memory_wrapper.cpp @@ -17,6 +17,7 @@ #include "apex.hpp" #include #include "address_resolution.hpp" +#include namespace apex { @@ -192,15 +193,16 @@ void apex_report_leaks() { if (once) return; once = true; static book_t& book = getBook(); + book.saved_node_id = apex::apex::instance()->get_node_id(); std::stringstream ss; ss << "memory_report." << book.saved_node_id << ".txt"; - std::string tmp{ss.str()}; - std::ofstream report (tmp); + std::string outfile{ss.str()}; + std::ofstream report (outfile); // Declare vector of pairs std::vector > sorted; if (book.saved_node_id == 0) { - std::cout << "APEX Memory Report: (see " << tmp << ")" << std::endl; + std::cout << "APEX Memory Report: (see " << outfile << ")" << std::endl; std::cout << "sorting " << book.memoryMap.size() << " leaks by size..." << std::endl; } @@ -217,9 +219,10 @@ void apex_report_leaks() { if (book.saved_node_id == 0) { std::cout << "Aggregating leaks by task and writing report..." << std::endl; - if (!apex_options::use_cuda()) { + if (apex_options::use_cuda()) { std::cout << "Ignoring known leaks in CUDA/CUPTI..." << std::endl; } + std::cout << "If there are no leaks, there won't be a file..." << std::endl; } size_t actual_leaks{0}; // Print the sorted value @@ -282,7 +285,12 @@ void apex_report_leaks() { actual_leaks++; } report.close(); - std::cout << "Reported " << actual_leaks << " 'actual' leaks.\nExpect false positives if memory was freed after exit." << std::endl; + if (book.saved_node_id == 0) { + std::cout << "Reported " << actual_leaks << " 'actual' leaks.\nExpect false positives if memory was freed after exit." << std::endl; + } + if (actual_leaks == 0) { + remove(outfile.c_str()); + } /* std::cout << "sorting task leaks by size..." << std::endl; diff --git a/src/examples/DemoC/CMakeLists.txt b/src/examples/DemoC/CMakeLists.txt index 8c43414b..a185066e 100644 --- a/src/examples/DemoC/CMakeLists.txt +++ b/src/examples/DemoC/CMakeLists.txt @@ -1,15 +1,15 @@ -# Make sure the compiler can find include files from our Apex library. -include_directories (${APEX_SOURCE_DIR}/src/apex) +# Make sure the compiler can find include files from our Apex library. +include_directories (${APEX_SOURCE_DIR}/src/apex) -# Make sure the linker can find the Apex library once it is built. -link_directories (${APEX_BINARY_DIR}/src/apex) +# Make sure the linker can find the Apex library once it is built. +link_directories (${APEX_BINARY_DIR}/src/apex) # Add executable called "apexCDemo" that is built from the source file -# "demo.c". The extensions are automatically found. -add_executable (apexCDemo demo.c) +# "demo.c". The extensions are automatically found. +add_executable (apexCDemo demo.c) -# Link the executable to the Apex library. -target_link_libraries (apexCDemo apex ${LIBS} stdc++ m) +# Link the executable to the Apex library. +target_link_libraries (apexCDemo apex ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(apexCDemo PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/LuleshMPI/CMakeLists.txt b/src/examples/LuleshMPI/CMakeLists.txt index 27ab80ff..1af44ff5 100644 --- a/src/examples/LuleshMPI/CMakeLists.txt +++ b/src/examples/LuleshMPI/CMakeLists.txt @@ -20,7 +20,7 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DAPEX_ENABLE_MPI=1") # Link the executable to the Apex library. target_link_libraries (lulesh_MPI_2.0 apex apex_mpi apex_global_mpi -${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} stdc++ m) +${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(lulesh_MPI_2.0 PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/MPIGlobalTest/CMakeLists.txt b/src/examples/MPIGlobalTest/CMakeLists.txt index 5772a94c..7701ac29 100644 --- a/src/examples/MPIGlobalTest/CMakeLists.txt +++ b/src/examples/MPIGlobalTest/CMakeLists.txt @@ -17,7 +17,7 @@ add_dependencies (mpi_global_test apex apex_mpi apex_global_mpi) add_dependencies (examples mpi_global_test) # Link the executable to the Apex library. -target_link_libraries (mpi_global_test apex apex_mpi apex_global_mpi ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} stdc++ m) +target_link_libraries (mpi_global_test apex apex_mpi apex_global_mpi ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(mpi_global_test PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/MPIImbalancePolicy/CMakeLists.txt b/src/examples/MPIImbalancePolicy/CMakeLists.txt index 0b7d3cfc..320632ee 100644 --- a/src/examples/MPIImbalancePolicy/CMakeLists.txt +++ b/src/examples/MPIImbalancePolicy/CMakeLists.txt @@ -17,7 +17,7 @@ add_dependencies (mpi_imbalance_test apex apex_mpi apex_global_mpi) add_dependencies (examples mpi_imbalance_test) # Link the executable to the Apex library. -target_link_libraries (mpi_imbalance_test apex apex_mpi apex_global_mpi ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} stdc++ m) +target_link_libraries (mpi_imbalance_test apex apex_mpi apex_global_mpi ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(mpi_imbalance_test PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/MPITest/CMakeLists.txt b/src/examples/MPITest/CMakeLists.txt index 60484357..aa6d956c 100644 --- a/src/examples/MPITest/CMakeLists.txt +++ b/src/examples/MPITest/CMakeLists.txt @@ -17,7 +17,7 @@ add_dependencies (mpi_test apex) add_dependencies (examples mpi_test) # Link the executable to the Apex library. -target_link_libraries (mpi_test apex apex_mpi ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} stdc++ m) +target_link_libraries (mpi_test apex apex_mpi ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(mpi_test PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/Matmult/CMakeLists.txt b/src/examples/Matmult/CMakeLists.txt index a5652495..1af95e53 100644 --- a/src/examples/Matmult/CMakeLists.txt +++ b/src/examples/Matmult/CMakeLists.txt @@ -1,17 +1,17 @@ -# Make sure the compiler can find include files from our Apex library. -include_directories (. ${APEX_SOURCE_DIR}/src/apex) +# Make sure the compiler can find include files from our Apex library. +include_directories (. ${APEX_SOURCE_DIR}/src/apex) -# Make sure the linker can find the Apex library once it is built. -link_directories (${APEX_BINARY_DIR}/src/apex) +# Make sure the linker can find the Apex library once it is built. +link_directories (${APEX_BINARY_DIR}/src/apex) # Add executable called "apexCDemo" that is built from the source file -# "demo.c". The extensions are automatically found. -add_executable (matmult matmult_initialize.cpp matmult.cpp) +# "demo.c". The extensions are automatically found. +add_executable (matmult matmult_initialize.cpp matmult.cpp) add_dependencies (matmult apex) add_dependencies (examples matmult) -# Link the executable to the Apex library. -target_link_libraries (matmult apex ${LIBS} stdc++ m) +# Link the executable to the Apex library. +target_link_libraries (matmult apex ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(matmult PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/OpenMPOverhead/CMakeLists.txt b/src/examples/OpenMPOverhead/CMakeLists.txt index 8efbe712..5ad701f7 100644 --- a/src/examples/OpenMPOverhead/CMakeLists.txt +++ b/src/examples/OpenMPOverhead/CMakeLists.txt @@ -12,7 +12,7 @@ add_dependencies (examples openmp_overhead) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") # Link the executable to the Apex library. -target_link_libraries (openmp_overhead apex ${LIBS} ${OMPT_LIBRARIES} stdc++) +target_link_libraries (openmp_overhead apex ${LIBS} ${OMPT_LIBRARIES} ${APEX_STDCXX_LIB}) if (BUILD_STATIC_EXECUTABLES) set_target_properties(openmp_overhead PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/PolicyEngineExample/CMakeLists.txt b/src/examples/PolicyEngineExample/CMakeLists.txt index 41f31ed7..20fe5f72 100644 --- a/src/examples/PolicyEngineExample/CMakeLists.txt +++ b/src/examples/PolicyEngineExample/CMakeLists.txt @@ -1,17 +1,17 @@ -# Make sure the compiler can find include files from our Apex library. +# Make sure the compiler can find include files from our Apex library. include_directories (${APEX_SOURCE_DIR}/src/apex) -# Make sure the linker can find the Apex library once it is built. +# Make sure the linker can find the Apex library once it is built. link_directories (${APEX_BINARY_DIR}/src/apex) # Add executable called "testPolicyEngine" that is built from the source file -# "testPolicyEngine.c". The extensions are automatically found. -add_executable (testPolicyEngine testPolicyEngine.c) +# "testPolicyEngine.c". The extensions are automatically found. +add_executable (testPolicyEngine testPolicyEngine.c) add_dependencies (testPolicyEngine apex) add_dependencies (examples testPolicyEngine) -# Link the executable to the Apex library. -target_link_libraries (testPolicyEngine apex ${LIBS} stdc++ m) +# Link the executable to the Apex library. +target_link_libraries (testPolicyEngine apex ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(testPolicyEngine PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/PolicyUnitTest/CMakeLists.txt b/src/examples/PolicyUnitTest/CMakeLists.txt index acb146d6..dca56179 100644 --- a/src/examples/PolicyUnitTest/CMakeLists.txt +++ b/src/examples/PolicyUnitTest/CMakeLists.txt @@ -1,17 +1,17 @@ -# Make sure the compiler can find include files from our Apex library. +# Make sure the compiler can find include files from our Apex library. include_directories (${APEX_SOURCE_DIR}/src/apex) -# Make sure the linker can find the Apex library once it is built. +# Make sure the linker can find the Apex library once it is built. link_directories (${APEX_BINARY_DIR}/src/apex) # Add executable called "policyUnitTest" that is built from the source file -# "policyUnitTest.c". The extensions are automatically found. -add_executable (policyUnitTest policyUnitTest.c) +# "policyUnitTest.c". The extensions are automatically found. +add_executable (policyUnitTest policyUnitTest.c) add_dependencies (policyUnitTest apex) add_dependencies (examples policyUnitTest) -# Link the executable to the Apex library. -target_link_libraries (policyUnitTest apex ${LIBS} stdc++ m) +# Link the executable to the Apex library. +target_link_libraries (policyUnitTest apex ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(policyUnitTest PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/TestOpenMP/CMakeLists.txt b/src/examples/TestOpenMP/CMakeLists.txt index ec56a372..a67f47d8 100644 --- a/src/examples/TestOpenMP/CMakeLists.txt +++ b/src/examples/TestOpenMP/CMakeLists.txt @@ -13,7 +13,7 @@ add_dependencies (examples openmp_test) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") # Link the executable to the Apex library. -target_link_libraries (openmp_test apex ${LIBS} ${OMPT_LIBRARIES} stdc++) +target_link_libraries (openmp_test apex ${LIBS} ${OMPT_LIBRARIES} ${APEX_STDCXX_LIB}) if (BUILD_STATIC_EXECUTABLES) set_target_properties(openmp_test PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/Throttling/CMakeLists.txt b/src/examples/Throttling/CMakeLists.txt index 750f7f24..cd4009dd 100644 --- a/src/examples/Throttling/CMakeLists.txt +++ b/src/examples/Throttling/CMakeLists.txt @@ -1,17 +1,17 @@ -# Make sure the compiler can find include files from our Apex library. +# Make sure the compiler can find include files from our Apex library. include_directories (${APEX_SOURCE_DIR}/src/apex) -# Make sure the linker can find the Apex library once it is built. +# Make sure the linker can find the Apex library once it is built. link_directories (${APEX_BINARY_DIR}/src/apex) # Add executable called "testThrottling" that is built from the source file -# "testThrottling.c". The extensions are automatically found. -add_executable (testThrottling testThrottling.c) +# "testThrottling.c". The extensions are automatically found. +add_executable (testThrottling testThrottling.c) add_dependencies (testThrottling apex) add_dependencies (examples testThrottling) -# Link the executable to the Apex library. -target_link_libraries (testThrottling apex ${LIBS} stdc++ m) +# Link the executable to the Apex library. +target_link_libraries (testThrottling apex ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(testThrottling PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/examples/ThrottlingActiveHarmony/CMakeLists.txt b/src/examples/ThrottlingActiveHarmony/CMakeLists.txt index 663d0db4..b4bfdbf2 100644 --- a/src/examples/ThrottlingActiveHarmony/CMakeLists.txt +++ b/src/examples/ThrottlingActiveHarmony/CMakeLists.txt @@ -1,17 +1,17 @@ -# Make sure the compiler can find include files from our Apex library. +# Make sure the compiler can find include files from our Apex library. include_directories (${APEX_SOURCE_DIR}/src/apex) -# Make sure the linker can find the Apex library once it is built. +# Make sure the linker can find the Apex library once it is built. link_directories (${APEX_BINARY_DIR}/src/apex) # Add executable called "testThrottlingActiveHarmony" that is built from the source file -# "testThrottlingActiveHarmony.c". The extensions are automatically found. -add_executable (testThrottlingActiveHarmony testThrottlingActiveHarmony.c) +# "testThrottlingActiveHarmony.c". The extensions are automatically found. +add_executable (testThrottlingActiveHarmony testThrottlingActiveHarmony.c) add_dependencies (testThrottlingActiveHarmony apex) add_dependencies (examples testThrottlingActiveHarmony) -# Link the executable to the Apex library. -target_link_libraries (testThrottlingActiveHarmony apex ${LIBS} stdc++ m) +# Link the executable to the Apex library. +target_link_libraries (testThrottlingActiveHarmony apex ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(testThrottlingActiveHarmony PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/openmp/CMakeLists.txt b/src/openmp/CMakeLists.txt index c78d8d2f..9e91ed9e 100644 --- a/src/openmp/CMakeLists.txt +++ b/src/openmp/CMakeLists.txt @@ -41,9 +41,9 @@ foreach(example_program ${example_programs}) # Use the tool-enabled OpenMP runtime target_compile_options(${example_program} PRIVATE "-mp=ompt") target_link_options(${example_program} PRIVATE "-mp=ompt") - target_link_libraries (${example_program} apex ${LIBS} stdc++ m) + target_link_libraries (${example_program} apex ${LIBS} ${APEX_STDCXX_LIB} m) else() - target_link_libraries (${example_program} ${OMPT_LIBRARIES} apex ${LIBS} OpenMP::OpenMP_CXX stdc++ m) + target_link_libraries (${example_program} ${OMPT_LIBRARIES} apex ${LIBS} OpenMP::OpenMP_CXX ${APEX_STDCXX_LIB} m) endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "NVHPC") if (BUILD_STATIC_EXECUTABLES) set_target_properties(${example_program} PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) diff --git a/src/scripts/apex_exec b/src/scripts/apex_exec index b30923ad..759224fc 100755 --- a/src/scripts/apex_exec +++ b/src/scripts/apex_exec @@ -649,6 +649,8 @@ fi # and iterate over them, setting different output directories for each. # Print out all APEX environment variables that have been set. +APEX_SAVE_LD_PRELOAD=${LD_PRELOAD} +unset LD_PRELOAD env | while IFS= read -r line; do value=${line#*=} name=${line%%=*} @@ -656,6 +658,7 @@ env | while IFS= read -r line; do echo "$value: $name" fi done +export LD_PRELOAD=${APEX_SAVE_LD_PRELOAD} delim=";" long_metrics=${APEX_PAPI_METRICS} diff --git a/src/unit_tests/C++/CMakeLists.txt b/src/unit_tests/C++/CMakeLists.txt index 0b7207d7..74243cb9 100644 --- a/src/unit_tests/C++/CMakeLists.txt +++ b/src/unit_tests/C++/CMakeLists.txt @@ -135,7 +135,7 @@ add_dependencies (apex_hpx_annotated_functions_mpi apex) add_dependencies (examples apex_hpx_annotated_functions_mpi) # Link the executable to the Apex library. -target_link_libraries (apex_hpx_annotated_functions_mpi apex ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} stdc++ m) +target_link_libraries (apex_hpx_annotated_functions_mpi apex ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(apex_hpx_annotated_functions_mpi PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/unit_tests/C/CMakeLists.txt b/src/unit_tests/C/CMakeLists.txt index 8a5ee8db..fd5cdfc3 100644 --- a/src/unit_tests/C/CMakeLists.txt +++ b/src/unit_tests/C/CMakeLists.txt @@ -71,7 +71,7 @@ foreach(example_program ${example_programs}) source_group("Source Files" FILES ${sources}) add_executable(${example_program} ${sources}) - target_link_libraries (${example_program} apex ${LIBS} stdc++ m) + target_link_libraries (${example_program} apex ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(${example_program} PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/unit_tests/MPI/CMakeLists.txt b/src/unit_tests/MPI/CMakeLists.txt index 4529f503..ccbd061b 100644 --- a/src/unit_tests/MPI/CMakeLists.txt +++ b/src/unit_tests/MPI/CMakeLists.txt @@ -12,7 +12,7 @@ add_dependencies (mpi_cpi apex) add_dependencies (tests mpi_cpi) # Link the executable to the Apex library. -target_link_libraries (mpi_cpi apex ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} stdc++ m) +target_link_libraries (mpi_cpi apex ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES} ${LIBS} ${APEX_STDCXX_LIB} m) if (BUILD_STATIC_EXECUTABLES) set_target_properties(mpi_cpi PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif() diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 694e12d5..00bcb352 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -14,7 +14,7 @@ foreach(util_program ${util_programs}) set(sources ${util_program}.cpp) source_group("Source Files" FILES ${sources}) add_executable("${util_program}" ${sources}) - target_link_libraries ("${util_program}" apex stdc++ ${LIBS}) + target_link_libraries ("${util_program}" apex ${APEX_STDCXX_LIB} ${LIBS}) if (BUILD_STATIC_EXECUTABLES) set_target_properties("${util_program}" PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1) endif()