From a92fa8f0712cca9db148eca048ae2cb0db4bdad9 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Tue, 22 Oct 2024 05:54:16 -0500 Subject: [PATCH] Miscellaneous Testing Fixes + CMake find_package include guard (#1106) * Improve ROCPROFILER_DEFAULT_FAIL_REGEX * Support find_package called twice * Skip iteration of ROCPROFILER_AGENT_TYPE_CPU * Relax tests/rocprofv3/summary * Tweak to rocprofiler-sdk-tool/tool.cpp * Move rocprofv3-trigger-list-metrics to libexec * Remove PC_SAMPLING_TESTS_REGEX from CI workflow * Update packaging - core component depends on roctx component * Increase verbosity for failing tests * Fix RPATH of rocprofv3-trigger-list-metrics --------- Co-authored-by: Gopesh Bhardwaj --- .github/workflows/continuous_integration.yml | 19 ----------------- .../rocprofiler-sdk-roctx/config.cmake.in | 3 +++ .../Templates/rocprofiler-sdk/config.cmake.in | 3 +++ cmake/rocprofiler_config_packaging.cmake | 1 + cmake/rocprofiler_options.cmake | 4 ++-- source/CMakeLists.txt | 1 + source/bin/rocprofv3.py | 2 +- .../lib/rocprofiler-sdk-tool/CMakeLists.txt | 17 --------------- source/lib/rocprofiler-sdk-tool/helper.hpp | 11 +++------- source/lib/rocprofiler-sdk-tool/tool.cpp | 7 +++---- source/libexec/CMakeLists.txt | 5 +++++ .../CMakeLists.txt | 21 +++++++++++++++++++ .../rocprofv3_trigger_list_metrics.cpp | 0 tests/rocprofv3/summary/conftest.py | 7 ++++--- tests/rocprofv3/summary/validate.py | 2 +- 15 files changed, 48 insertions(+), 55 deletions(-) create mode 100644 source/libexec/CMakeLists.txt create mode 100644 source/libexec/rocprofv3-trigger-list-metrics/CMakeLists.txt rename source/{lib/rocprofiler-sdk-tool => libexec/rocprofv3-trigger-list-metrics}/rocprofv3_trigger_list_metrics.cpp (100%) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 6178ea2e..670372f0 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -23,7 +23,6 @@ env: ROCM_PATH: "/opt/rocm" GPU_TARGETS: "gfx900 gfx906 gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030 gfx1100 gfx1101 gfx1102" PATH: "/usr/bin:$PATH" - PC_SAMPLING_TESTS_REGEX: ".*pc-sampling.*" jobs: core-deb: @@ -67,12 +66,6 @@ jobs: cat /opt/rocm/.info/version ls -la - - name: Exclude PC Sampling Tests - if: ${{ !contains(matrix.runner, 'mi200') && !contains(matrix.runner, 'mi300') }} - shell: bash - run: | - echo 'EXCLUDED_TESTS=${{ env.PC_SAMPLING_TESTS_REGEX }}' >> $GITHUB_ENV - - name: Enable PC Sampling if: ${{ contains(matrix.runner, 'mi200') }} shell: bash @@ -195,12 +188,6 @@ jobs: cat /opt/rocm/.info/version ls -la - - name: Exclude PC Sampling Tests - if: ${{ !contains(matrix.runner, 'mi200') && !contains(matrix.runner, 'mi300') }} - shell: bash - run: | - echo 'EXCLUDED_TESTS=${{ env.PC_SAMPLING_TESTS_REGEX }}' >> $GITHUB_ENV - - name: Enable PC Sampling if: ${{ contains(matrix.runner, 'mi200') }} shell: bash @@ -564,12 +551,6 @@ jobs: cat /opt/rocm/.info/version ls -la - - name: Exclude PC Sampling Tests - if: ${{ !contains(matrix.runner, 'mi200') && !contains(matrix.runner, 'mi300') }} - shell: bash - run: | - echo 'EXCLUDED_TESTS=${{ env.PC_SAMPLING_TESTS_REGEX }}' >> $GITHUB_ENV - - name: Enable PC Sampling if: ${{ contains(matrix.runner, 'mi200') }} shell: bash diff --git a/cmake/Templates/rocprofiler-sdk-roctx/config.cmake.in b/cmake/Templates/rocprofiler-sdk-roctx/config.cmake.in index 86ccea0d..f5b998a0 100644 --- a/cmake/Templates/rocprofiler-sdk-roctx/config.cmake.in +++ b/cmake/Templates/rocprofiler-sdk-roctx/config.cmake.in @@ -11,6 +11,9 @@ # @PACKAGE_NAME@::@PACKAGE_NAME@ # +# prevent "target already exists" error +include_guard(DIRECTORY) + # compute paths get_filename_component(@PACKAGE_NAME@_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/cmake/Templates/rocprofiler-sdk/config.cmake.in b/cmake/Templates/rocprofiler-sdk/config.cmake.in index 1a580c39..49178408 100644 --- a/cmake/Templates/rocprofiler-sdk/config.cmake.in +++ b/cmake/Templates/rocprofiler-sdk/config.cmake.in @@ -12,6 +12,9 @@ # @PACKAGE_NAME@::@PACKAGE_NAME@ # +# prevent "target already exists" error +include_guard(DIRECTORY) + # compute paths get_filename_component(@PACKAGE_NAME@_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/cmake/rocprofiler_config_packaging.cmake b/cmake/rocprofiler_config_packaging.cmake index ee4072e2..1830b8fb 100644 --- a/cmake/rocprofiler_config_packaging.cmake +++ b/cmake/rocprofiler_config_packaging.cmake @@ -141,6 +141,7 @@ endforeach() set(CPACK_DEBIAN_PACKAGE_EPOCH 0) set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON CACHE BOOL "") # auto-generate deps based on shared libs diff --git a/cmake/rocprofiler_options.cmake b/cmake/rocprofiler_options.cmake index b49d9130..414c161f 100644 --- a/cmake/rocprofiler_options.cmake +++ b/cmake/rocprofiler_options.cmake @@ -134,5 +134,5 @@ include(rocprofiler_memcheck) # default FAIL_REGULAR_EXPRESSION for tests set(ROCPROFILER_DEFAULT_FAIL_REGEX - "threw an exception|Permission denied|Could not create logging file" - CACHE STRING "Default FAIL_REGULAR_EXPRESSION for tests") + "threw an exception|Permission denied|Could not create logging file|failed with error code" + CACHE INTERNAL "Default FAIL_REGULAR_EXPRESSION for tests" FORCE) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 4d280dab..4b945f28 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -7,5 +7,6 @@ endif() add_subdirectory(include) add_subdirectory(lib) +add_subdirectory(libexec) add_subdirectory(bin) add_subdirectory(docs) diff --git a/source/bin/rocprofv3.py b/source/bin/rocprofv3.py index e361be5d..9499f624 100755 --- a/source/bin/rocprofv3.py +++ b/source/bin/rocprofv3.py @@ -830,7 +830,7 @@ def log_config(_env): sys.stderr.flush() if args.list_metrics: - app_args = [f"{ROCM_DIR}/lib/rocprofiler-sdk/rocprofv3-trigger-list-metrics"] + app_args = [f"{ROCM_DIR}/libexec/rocprofv3-trigger-list-metrics"] elif not app_args: log_config(app_env) diff --git a/source/lib/rocprofiler-sdk-tool/CMakeLists.txt b/source/lib/rocprofiler-sdk-tool/CMakeLists.txt index d6f1e7e5..ccdce026 100644 --- a/source/lib/rocprofiler-sdk-tool/CMakeLists.txt +++ b/source/lib/rocprofiler-sdk-tool/CMakeLists.txt @@ -65,21 +65,4 @@ install( COMPONENT tools EXPORT rocprofiler-sdk-tool-targets) -add_executable(rocprofv3-trigger-list-metrics) -target_sources(rocprofv3-trigger-list-metrics PRIVATE rocprofv3_trigger_list_metrics.cpp) -target_link_libraries(rocprofv3-trigger-list-metrics - PRIVATE rocprofiler-sdk::rocprofiler-hsa-runtime) -set_target_properties( - rocprofv3-trigger-list-metrics - PROPERTIES RUNTIME_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/rocprofiler-sdk - BUILD_RPATH "\$ORIGIN:\$ORIGIN/.." - INSTALL_RPATH "\$ORIGIN:\$ORIGIN/..") - -install( - TARGETS rocprofv3-trigger-list-metrics - DESTINATION ${CMAKE_INSTALL_LIBDIR}/rocprofiler-sdk - COMPONENT tools - EXPORT rocprofiler-sdk-tool-targets) - add_subdirectory(kokkosp) diff --git a/source/lib/rocprofiler-sdk-tool/helper.hpp b/source/lib/rocprofiler-sdk-tool/helper.hpp index 79f3441b..c1be8748 100644 --- a/source/lib/rocprofiler-sdk-tool/helper.hpp +++ b/source/lib/rocprofiler-sdk-tool/helper.hpp @@ -71,14 +71,9 @@ { \ std::string status_msg = \ rocprofiler_get_status_string(ROCPROFILER_VARIABLE(CHECKSTATUS, __LINE__)); \ - std::cerr << "[" #result "][" << __FILE__ << ":" << __LINE__ << "] " << msg \ - << " failed with error code " << ROCPROFILER_VARIABLE(CHECKSTATUS, __LINE__) \ - << ": " << status_msg << "\n" \ - << std::flush; \ - std::stringstream errmsg{}; \ - errmsg << "[" #result "][" << __FILE__ << ":" << __LINE__ << "] " << msg " failure (" \ - << status_msg << ")"; \ - throw std::runtime_error(errmsg.str()); \ + ROCP_FATAL << " :: [" << __FILE__ << ":" << __LINE__ << "]\n\t" << #result << "\n\n" \ + << msg << " failed with error code " \ + << ROCPROFILER_VARIABLE(CHECKSTATUS, __LINE__) << ": " << status_msg; \ } \ } diff --git a/source/lib/rocprofiler-sdk-tool/tool.cpp b/source/lib/rocprofiler-sdk-tool/tool.cpp index acba07fa..c13a415a 100644 --- a/source/lib/rocprofiler-sdk-tool/tool.cpp +++ b/source/lib/rocprofiler-sdk-tool/tool.cpp @@ -1181,10 +1181,9 @@ list_metrics_iterate_agents(rocprofiler_agent_version_t, return ROCPROFILER_STATUS_SUCCESS; }, reinterpret_cast(&node_id)); - if(status != ROCPROFILER_STATUS_SUCCESS) - { - ROCP_ERROR << "Failed to iterate counters for agent " << node_id; - } + + ROCP_ERROR_IF(status != ROCPROFILER_STATUS_SUCCESS) + << "Failed to iterate counters for agent " << node_id << " (" << agent->name << ")"; } return ROCPROFILER_STATUS_SUCCESS; } diff --git a/source/libexec/CMakeLists.txt b/source/libexec/CMakeLists.txt new file mode 100644 index 00000000..38c96dae --- /dev/null +++ b/source/libexec/CMakeLists.txt @@ -0,0 +1,5 @@ +# +# +# + +add_subdirectory(rocprofv3-trigger-list-metrics) diff --git a/source/libexec/rocprofv3-trigger-list-metrics/CMakeLists.txt b/source/libexec/rocprofv3-trigger-list-metrics/CMakeLists.txt new file mode 100644 index 00000000..a8b65bb9 --- /dev/null +++ b/source/libexec/rocprofv3-trigger-list-metrics/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# +# + +set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "tools") + +add_executable(rocprofv3-trigger-list-metrics) +target_sources(rocprofv3-trigger-list-metrics PRIVATE rocprofv3_trigger_list_metrics.cpp) +target_link_libraries(rocprofv3-trigger-list-metrics + PRIVATE rocprofiler-sdk::rocprofiler-hsa-runtime) +set_target_properties( + rocprofv3-trigger-list-metrics + PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBEXECDIR} + BUILD_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" + INSTALL_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + +install( + TARGETS rocprofv3-trigger-list-metrics + DESTINATION ${CMAKE_INSTALL_LIBEXECDIR} + COMPONENT tools + EXPORT rocprofiler-sdk-tool-targets) diff --git a/source/lib/rocprofiler-sdk-tool/rocprofv3_trigger_list_metrics.cpp b/source/libexec/rocprofv3-trigger-list-metrics/rocprofv3_trigger_list_metrics.cpp similarity index 100% rename from source/lib/rocprofiler-sdk-tool/rocprofv3_trigger_list_metrics.cpp rename to source/libexec/rocprofv3-trigger-list-metrics/rocprofv3_trigger_list_metrics.cpp diff --git a/tests/rocprofv3/summary/conftest.py b/tests/rocprofv3/summary/conftest.py index 945d5cbf..a371aff6 100644 --- a/tests/rocprofv3/summary/conftest.py +++ b/tests/rocprofv3/summary/conftest.py @@ -33,10 +33,11 @@ def pytest_addoption(parser): action="store", help="Path to summary markdown file.", ) - pd.set_option("display.max_rows", None) - pd.set_option("display.max_columns", None) + pd.set_option("display.width", 2000) - pd.set_option("display.max_colwidth", None) + # increase debug display of pandas dataframes + for itr in ["rows", "columns", "colwidth"]: + pd.set_option(f"display.max_{itr}", None) @pytest.fixture diff --git a/tests/rocprofv3/summary/validate.py b/tests/rocprofv3/summary/validate.py index c8e39dd1..56bd6268 100644 --- a/tests/rocprofv3/summary/validate.py +++ b/tests/rocprofv3/summary/validate.py @@ -185,7 +185,7 @@ def test_summary_data(json_data): ) assert oitr.value.count == 2 elif itr.domain == "HIP_API": - assert itr.stats.count >= 2130 and itr.stats.count <= 2140 + assert itr.stats.count >= 2130 and itr.stats.count <= 2150 elif itr.domain == "MEMORY_COPY": assert itr.stats.count == 12 elif itr.domain == "MARKER_API":