Files
rocm-systems/source/lib/rocprofiler-sdk/counters/tests/CMakeLists.txt
T
Madsen, Jonathan 640ca55ac0 [CI] Testing stability (#486)
* [CI] Testing Stability

- CMake option ROCPROFILER_DISABLE_UNSTABLE_CTESTS
  - used for tests which periodically fail around 1 out of every 10 runs
  - set to ON while instability remains, this needs to set to OFF in ROCm 7.1 or, ideally, ROCm 7.0.1
- Use FIXTURES_SETUP and FIXTURES_REQUIRED for some tests
- replace "threw an exception" with "${ROCPROFILER_DEFAULT_FAIL_REGEX}" for misc FAIL_REGULAR_EXPRESSIONS

* Remove contents of all EXCLUDE_{TESTS,LABEL}_REGEX from CI workflow

* Disable patch git step in code-coverage run

* Tweak spin time of reproducible runtime

* Removed patch git step in code-coverage run

* Update ROCPROFILER_DEFAULT_FAIL_REGEX

* Mark test-counter-collection tests as unstable

- add fixtures setup/required

* Remove ATTACHED_FILES_ON_FAIL

- CDash doesn't store enable downloading these properly anyway

* Relax collection-period fuzzing window

* Disable unstable collection-period test

- too unstable

* formatting

* Disable unstable device_counting_service_test.async_counters

* Suppress perfetto internal data race errors

* Switch code-coverage CI jobs to mi300 runner

* Timeout increases

* rocprofv3-test-rocpd updates

- add fixtures
- switch executable
- redefine input/output paths

* Revert code-coverage job to mi300a runner

* Update rocprofv3-test-rocpd-execute-multiproc

- reduce problem size

* disable multiproc rocpd

* Split code-coverage into separate workflow

- network issues cause this job to fail frequently
- when in a separate workflow, it can be restarted easily

* Fixtures for rocprofv3-test-trace-hip-in-libraries

* Disable unstable device_counting_service_test.sync_counters

* Potential fix for code scanning alert no. 171: Workflow does not contain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Switch code-coverage to run on rocprof-azure

- mi300a EMU runner set is unstable (network issues)

* tests/rocprofv3/pc-sampling SKIP_REGULAR_EXPRESSION

* Update rocprofv3-test-list-avail-trace-execute

- reduce log level and increase timeout

* rocprofv3: Prevent recursive call to rocprofv3_error_signal_handler + log chaining

* rocprofv3: Use ROCP_ERROR + std::exit instead of ROCP_FATAL

- should help with SKIP_REGULAR_EXPRESSION

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-06-30 15:07:37 -05:00

125 rindas
4.6 KiB
CMake

rocprofiler_deactivate_clang_tidy()
include(GoogleTest)
find_program(
amdclangpp_EXECUTABLE REQUIRED
NAMES amdclang++
HINTS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm
PATHS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm
PATH_SUFFIXES bin llvm/bin NO_CACHE)
function(generate_hsaco TARGET_ID INPUT_FILE OUTPUT_FILE)
separate_arguments(
CLANG_ARG_LIST
UNIX_COMMAND
"-O2 -x cl -Xclang -finclude-default-header -cl-denorms-are-zero -cl-std=CL2.0 -Wl,--build-id=sha1
-target amdgcn-amd-amdhsa -mcpu=${TARGET_ID} -o ${OUTPUT_FILE} ${INPUT_FILE}")
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/${OUTPUT_FILE}
COMMAND ${amdclangpp_EXECUTABLE} ${CLANG_ARG_LIST}
COMMAND
${CMAKE_COMMAND} -E copy
${PROJECT_BINARY_DIR}/source/lib/rocprofiler-sdk/counters/tests/${OUTPUT_FILE}
${CMAKE_BINARY_DIR}/bin/${OUTPUT_FILE}
OUTPUT ${CMAKE_BINARY_DIR}/bin/${OUTPUT_FILE}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/${OUTPUT_FILE}
${CMAKE_BINARY_DIR}/bin/${OUTPUT_FILE}
COMMENT "Building ${OUTPUT_FILE}...")
set(HSACO_TARGET_LIST
${HSACO_TARGET_LIST} ${PROJECT_BINARY_DIR}/${OUTPUT_FILE}
PARENT_SCOPE)
endfunction(generate_hsaco)
foreach(target_id ${GPU_TARGETS})
# generate kernel bitcodes
generate_hsaco(${target_id} ${CMAKE_CURRENT_SOURCE_DIR}/agent_kernels.cl
${target_id}_agent_kernels.hsaco)
endforeach()
add_custom_target(agent_hasco_targets DEPENDS ${HSACO_TARGET_LIST})
add_library(counter_test_constants OBJECT)
add_library(rocprofiler-sdk::counter-test-constants ALIAS counter_test_constants)
set(ROCPROFILER_LIB_COUNTER_TEST_CONSTANTS_SOURCES hsa_tables.cpp)
set(ROCPROFILER_LIB_COUNTER_TEST_CONSTANTS_HEADERS hsa_tables.hpp)
target_sources(
counter_test_constants
PUBLIC ${ROCPROFILER_LIB_COUNTER_TEST_CONSTANTS_HEADERS}
PRIVATE ${ROCPROFILER_LIB_COUNTER_TEST_CONSTANTS_SOURCES})
target_link_libraries(
counter_test_constants
PRIVATE rocprofiler-sdk::rocprofiler-sdk-common-library
rocprofiler-sdk::rocprofiler-sdk-static-library
rocprofiler-sdk::rocprofiler-sdk-hip
rocprofiler-sdk::rocprofiler-sdk-hsa-runtime)
set(ROCPROFILER_LIB_COUNTER_TEST_SOURCES
metrics_test.cpp evaluate_ast_test.cpp dimension.cpp core.cpp code_object_loader.cpp
device_counting.cpp)
set(ROCPROFILER_LIB_COUNTER_TEST_HEADERS code_object_loader.hpp device_counting.hpp)
add_executable(counter-test)
target_sources(counter-test PRIVATE ${ROCPROFILER_LIB_COUNTER_TEST_SOURCES}
${ROCPROFILER_LIB_COUNTER_TEST_HEADERS})
add_dependencies(counter-test agent_hasco_targets)
target_link_libraries(
counter-test
PRIVATE rocprofiler-sdk::counter-test-constants
rocprofiler-sdk::rocprofiler-sdk-hsa-runtime
rocprofiler-sdk::rocprofiler-sdk-hip
rocprofiler-sdk::rocprofiler-sdk-common-library
rocprofiler-sdk::rocprofiler-sdk-static-library
GTest::gtest
GTest::gtest_main)
gtest_add_tests(
TARGET counter-test
SOURCES ${ROCPROFILER_LIB_COUNTER_TEST_SOURCES}
TEST_LIST counter-tests_TESTS
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(
${counter-tests_TESTS}
PROPERTIES
TIMEOUT
45
LABELS
"unittests"
FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}"
SKIP_REGULAR_EXPRESSION
"Running non-intercept test(.*)could not be locked for profiling due to lack of permissions.*"
)
# unstable counter collection test: Generates HW exception leading to GPU hang or memory
# access fault
set_tests_properties(
device_counting_service_test.sync_counters device_counting_service_test.async_counters
PROPERTIES DISABLED "${ROCPROFILER_DISABLE_UNSTABLE_CTESTS}")
set(ROCPROFILER_LIB_CONSUMER_TEST_SOURCES consumer_test.cpp)
add_executable(consumer-test)
target_sources(consumer-test PRIVATE ${ROCPROFILER_LIB_CONSUMER_TEST_SOURCES})
target_link_libraries(
consumer-test rocprofiler-sdk::rocprofiler-sdk-hsa-runtime
rocprofiler-sdk::rocprofiler-sdk-hip rocprofiler-sdk::rocprofiler-sdk-common-library
rocprofiler-sdk::rocprofiler-sdk-static-library GTest::gtest GTest::gtest_main)
gtest_add_tests(
TARGET consumer-test
SOURCES ${ROCPROFILER_LIB_CONSUMER_TEST_SOURCES}
TEST_LIST consumer-tests_TESTS
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(
${consumer-tests_TESTS}
PROPERTIES TIMEOUT 45 LABELS "unittests" FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")