Files
rocm-systems/projects/rocprofiler-systems/tests/source/CMakeLists.txt
T
David Galiffi 182a750c08 Fix for thread limit tests (#323)
* Fix for thread limit tests. Which are failing due to exceeding the number of threads allowed.

Signed-off-by: Anuj-Kumar Shukla <AnujKumar.Shukla@amd.com>

* Update CMakeLists.txt

* Stopping thread creation after max thread limit

* Adressed review comments

* Update projects/rocprofiler-systems/tests/source/CMakeLists.txt

---------

Signed-off-by: Anuj-Kumar Shukla <AnujKumar.Shukla@amd.com>
Co-authored-by: anujshuk-amd <anujshuk@amd.com>
2025-10-09 19:07:14 -04:00

87 lines
3.3 KiB
CMake

# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
set(CMAKE_BUILD_TYPE "Release")
find_package(Threads REQUIRED)
add_library(tests-compile-options INTERFACE)
target_compile_options(tests-compile-options INTERFACE -g)
add_executable(thread-limit thread-limit.cpp)
target_compile_definitions(thread-limit PRIVATE MAX_THREADS=${ROCPROFSYS_MAX_THREADS})
target_link_libraries(thread-limit PRIVATE Threads::Threads tests-compile-options)
set(_thread_limit_environment
"${_base_environment}"
"ROCPROFSYS_TRACE=ON"
"ROCPROFSYS_PROFILE=ON"
"ROCPROFSYS_COUT_OUTPUT=ON"
"ROCPROFSYS_USE_SAMPLING=ON"
"ROCPROFSYS_SAMPLING_FREQ=250"
"ROCPROFSYS_VERBOSE=2"
"ROCPROFSYS_TIMEMORY_COMPONENTS=wall_clock,peak_rss,page_rss"
)
# Maximum allowed threads
set(ALLOWED_MAX_THREADS 4096)
math(EXPR THREAD_VAL_1 "${ROCPROFSYS_MAX_THREADS} + 24")
math(EXPR THREAD_VAL_2 "${ALLOWED_MAX_THREADS} + 1")
set(THREAD_VALUES ${THREAD_VAL_1} ${THREAD_VAL_2})
# Loop over thread values
foreach(THREADS IN LISTS THREAD_VALUES)
set(THREAD_PASS_VALUE ${THREADS})
math(EXPR THREAD_FAIL_VALUE "${THREADS} + 1")
if(${THREADS} GREATER_EQUAL ${ALLOWED_MAX_THREADS})
math(EXPR THREAD_PASS_VALUE "${ALLOWED_MAX_THREADS} - 1")
math(EXPR THREAD_FAIL_VALUE "${THREADS}")
endif()
set(_thread_limit_pass_regex "\\|${THREAD_PASS_VALUE}>>>")
set(_thread_limit_fail_regex "\\|${THREAD_FAIL_VALUE}>>>|ROCPROFSYS_ABORT_FAIL_REGEX")
# Unique test name
set(_test_name thread-limit-${THREADS})
# Add test
rocprofiler_systems_add_test(
SKIP_BASELINE
NAME ${_test_name}
TARGET thread-limit
LABELS "max-threads"
REWRITE_ARGS -e -v 2 -i 1024 --label return args
RUNTIME_ARGS -e -v 1 -i 1024 --label return args
RUN_ARGS 35 2 ${THREADS}
SAMPLING_TIMEOUT 180
REWRITE_TIMEOUT 180
RUNTIME_TIMEOUT 360
RUNTIME_PASS_REGEX "${_thread_limit_pass_regex}"
SAMPLING_PASS_REGEX "${_thread_limit_pass_regex}"
REWRITE_RUN_PASS_REGEX "${_thread_limit_pass_regex}"
RUNTIME_FAIL_REGEX "${_thread_limit_fail_regex}"
SAMPLING_FAIL_REGEX "${_thread_limit_fail_regex}"
REWRITE_RUN_FAIL_REGEX "${_thread_limit_fail_regex}"
ENVIRONMENT "${_thread_limit_environment}"
)
endforeach()