Initial Implementation: include (#10)

* Initial Implementation: include

* Initial Implementation: lib details (#11)

* Initial Implementation: lib details

* Initial Implementation: lib (#12)

* Initial Implementation: lib

* Initial Implementation: source (#13)

* Initial Implementation: source

* Initial Implementation: samples (#14)

* Initial Implementation: samples

* Initial Implementation: tests (#15)

* Initial Implementation: tests

* Initial Implementation: scripts (#16)

* Initial Implementation: scripts

* Initial Implementation: cmake (#17)

* Initial Implementation: cmake

* Initial Implementation: top-level files (#18)

* Initial Implementation: top-level files

- clang-format
- clang-tidy
- cmake-format
- ignore build and cache directories
- main CMakeLists.txt
- pyproject.toml (python formatting)
- VERSION file

* Initial Implementation: workflow (#19)

* Fix unused variable

- rocprofiler_register_warn_level

[ROCm/rocprofiler-register commit: fa4295db6b]
Dieser Commit ist enthalten in:
Jonathan R. Madsen
2023-08-17 14:59:24 -05:00
committet von GitHub
Ursprung 8ef9cf2642
Commit 7e6e33cfce
68 geänderte Dateien mit 7367 neuen und 0 gelöschten Zeilen
@@ -0,0 +1,465 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(rocprofiler-register-tests LANGUAGES C CXX)
include(CMakeParseArguments)
include(GNUInstallDirs)
if("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
find_package(rocprofiler-register REQUIRED)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_VISIBILITY_PRESET "hidden")
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
enable_testing()
include(CTest)
endif()
function(rocp_register_strip_target)
if(CMAKE_BUILD_TYPE MATCHES "(DEBUG|Debug)")
return()
endif()
cmake_parse_arguments(STRIP "" "" "ARGS" ${ARGN})
list(LENGTH STRIP_UNPARSED_ARGUMENTS NUM_UNPARSED)
if(NUM_UNPARSED EQUAL 1)
set(_TARGET "${STRIP_UNPARSED_ARGUMENTS}")
else()
message(
FATAL_ERROR "rocp_register_strip_target cannot deduce target from \"${ARGN}\""
)
endif()
if(NOT TARGET "${_TARGET}")
message(
FATAL_ERROR
"rocp_register_strip_target not provided valid target: \"${_TARGET}\"")
endif()
if(CMAKE_STRIP)
add_custom_command(
TARGET ${_TARGET}
POST_BUILD
COMMAND ${CMAKE_STRIP} ${STRIP_ARGS} $<TARGET_FILE:${_TARGET}>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Stripping ${_TARGET}...")
else()
message(WARNING "CMAKE_STRIP not set... Not stripping ${_TARGET}")
endif()
endfunction()
#
# mock libraries
#
add_subdirectory(hsa-runtime)
add_subdirectory(amdhip)
add_subdirectory(roctx)
add_subdirectory(rocprofiler)
#
# common to multiple tests
#
find_package(Threads REQUIRED)
add_library(rocprofiler-register-tests-common INTERFACE)
target_include_directories(rocprofiler-register-tests-common
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
target_link_libraries(rocprofiler-register-tests-common INTERFACE Threads::Threads stdc++)
add_library(rocprofiler-register-tests-strong INTERFACE)
target_compile_definitions(rocprofiler-register-tests-strong
INTERFACE ROCP_REG_TEST_WEAK=0)
add_library(rocprofiler-register-tests-weak INTERFACE)
target_compile_definitions(rocprofiler-register-tests-weak INTERFACE ROCP_REG_TEST_WEAK=1)
add_library(rocprofiler-register-tests-rocp INTERFACE)
target_link_options(rocprofiler-register-tests-rocp INTERFACE -Wl,--no-as-needed)
target_link_libraries(rocprofiler-register-tests-rocp INTERFACE rocprofiler::rocprofiler)
add_library(rocprofiler-register::tests-common ALIAS rocprofiler-register-tests-common)
add_library(rocprofiler-register::tests-strong ALIAS rocprofiler-register-tests-strong)
add_library(rocprofiler-register::tests-weak ALIAS rocprofiler-register-tests-weak)
add_library(rocprofiler-register::tests-rocp ALIAS rocprofiler-register-tests-rocp)
#
# test scenarios
#
function(rocp_register_test_executable _NAME)
set(_SV_ARGS)
foreach(_TYPE "CORE" "PRELOAD" "WRAP" "PRELOAD_WRAP")
list(APPEND _SV_ARGS "${_TYPE}_PASS_REGEX" "${_TYPE}_FAIL_REGEX")
endforeach()
cmake_parse_arguments(
RRTE
"" # options
"SECURE;${_SV_ARGS}" # single value args
"SOURCES;LIBRARIES" # multiple value args
${ARGN})
add_executable(${_NAME})
target_sources(${_NAME} PRIVATE ${RRTE_SOURCES})
target_link_libraries(${_NAME} PRIVATE rocprofiler-register::tests-common
${RRTE_LIBRARIES})
function(rocp_register_add_test _TEST_NAME _TARGET _ENV _PASS _FAIL)
if(RRTE_SECURE)
list(APPEND _ENV "ROCPROFILER_REGISTER_SECURE=true")
set(_LABELS "secure")
else()
set(_LABELS "insecure")
endif()
add_test(
NAME ${_TEST_NAME}
COMMAND $<TARGET_FILE:${_TARGET}>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
set_tests_properties(
${_TEST_NAME}
PROPERTIES ENVIRONMENT
"LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY};${_ENV}"
PASS_REGULAR_EXPRESSION
"${_PASS}"
FAIL_REGULAR_EXPRESSION
"${_FAIL}"
LABELS
"${_LABELS}"
${ARGN})
endfunction()
rocp_register_add_test(${_NAME} ${_NAME} "" "${RRTE_CORE_PASS_REGEX}"
"${RRTE_CORE_FAIL_REGEX}")
rocp_register_add_test(${_NAME}-preload ${_NAME} "LD_PRELOAD=librocprofiler64.so"
"${RRTE_PRELOAD_PASS_REGEX}" "${RRTE_PRELOAD_FAIL_REGEX}")
rocp_register_add_test(${_NAME}-wrap ${_NAME} "ROCP_REG_TEST_WRAP=1"
"${RRTE_WRAP_PASS_REGEX}" "${RRTE_WRAP_FAIL_REGEX}")
rocp_register_add_test(
${_NAME}-preload-wrap ${_NAME}
"LD_PRELOAD=librocprofiler64.so;ROCP_REG_TEST_WRAP=1"
"${RRTE_PRELOAD_WRAP_PASS_REGEX}" "${RRTE_PRELOAD_WRAP_FAIL_REGEX}")
endfunction()
# serial
rocp_register_test_executable(
test-amdhip-roctx
SECURE ON
SOURCES test-amdhip-roctx.cpp
LIBRARIES rocprofiler-register::tests-strong amdhip::amdhip roctx::roctx
CORE_PASS_REGEX
".hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
PRELOAD_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
WRAP_PASS_REGEX
".hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
PRELOAD_WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-main\n.rocprofiler.cpp..pop. thread-main\n"
)
rocp_register_test_executable(
test-amdhip-roctx-weak
SOURCES test-amdhip-roctx.cpp
LIBRARIES rocprofiler-register::tests-weak
CORE_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
PRELOAD_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
PRELOAD_WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-main\n.rocprofiler.cpp..pop. thread-main\n"
)
rocp_register_test_executable(
test-amdhip-roctx-rocp
SOURCES test-amdhip-roctx.cpp
LIBRARIES rocprofiler-register::tests-strong amdhip::amdhip roctx::roctx
rocprofiler-register::tests-rocp
CORE_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
PRELOAD_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-main\n.rocprofiler.cpp..pop. thread-main\n"
PRELOAD_WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-main\n.rocprofiler.cpp..pop. thread-main\n"
)
rocp_register_test_executable(
test-amdhip-roctx-weak-rocp
SOURCES test-amdhip-roctx.cpp
LIBRARIES rocprofiler-register::tests-weak rocprofiler-register::tests-rocp
CORE_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
PRELOAD_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-main\n.roctx.cpp..pop. thread-main\n"
WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-main\n.rocprofiler.cpp..pop. thread-main\n"
PRELOAD_WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-main\n.rocprofiler.cpp..pop. thread-main\n"
)
# multithreaded
rocp_register_test_executable(
test-amdhip-roctx-mt
SOURCES test-amdhip-roctx-mt.cpp
LIBRARIES rocprofiler-register::tests-strong amdhip::amdhip roctx::roctx
CORE_PASS_REGEX
".hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
PRELOAD_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
WRAP_PASS_REGEX
".hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
PRELOAD_WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n"
)
rocp_register_test_executable(
test-amdhip-roctx-mt-weak
SOURCES test-amdhip-roctx-mt.cpp
LIBRARIES rocprofiler-register::tests-weak
CORE_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
PRELOAD_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
PRELOAD_WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n"
)
rocp_register_test_executable(
test-amdhip-roctx-mt-rocp
SOURCES test-amdhip-roctx-mt.cpp
LIBRARIES rocprofiler-register::tests-strong amdhip::amdhip roctx::roctx
rocprofiler-register::tests-rocp
CORE_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
PRELOAD_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n"
PRELOAD_WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n"
)
# 29
rocp_register_test_executable(
test-amdhip-roctx-mt-weak-rocp
SOURCES test-amdhip-roctx-mt.cpp
LIBRARIES rocprofiler-register::tests-weak rocprofiler-register::tests-rocp
CORE_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
PRELOAD_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..push. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n.roctx.cpp..pop. thread-[0-3]\n"
WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n"
PRELOAD_WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libroctx64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. roctx :: 40601 :: 0 :: 1\n.roctx.cpp. roctx identifier 16\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..push. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n.rocprofiler.cpp..pop. thread-[0-3]\n"
)
# constructor
rocp_register_test_executable(
test-amdhip-ctor
SOURCES test-amdhip-ctor.cpp
LIBRARIES rocprofiler-register::tests-strong amdhip::amdhip
CORE_PASS_REGEX
".hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n"
PRELOAD_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n"
WRAP_PASS_REGEX
".hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n"
PRELOAD_WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n"
)
rocp_register_test_executable(
test-amdhip-ctor-weak
SOURCES test-amdhip-ctor.cpp
LIBRARIES rocprofiler-register::tests-weak
CORE_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libhsa-runtime64.so, 1\n.hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n"
PRELOAD_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libhsa-runtime64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n"
WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libhsa-runtime64.so, 1\n.hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n"
PRELOAD_WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libhsa-runtime64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n"
)
# 41
rocp_register_test_executable(
test-amdhip-ctor-rocp
SOURCES test-amdhip-ctor.cpp
LIBRARIES rocprofiler-register::tests-strong amdhip::amdhip
rocprofiler-register::tests-rocp
CORE_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n"
PRELOAD_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n"
WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n"
PRELOAD_WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n"
)
rocp_register_test_executable(
test-amdhip-ctor-weak-rocp
SOURCES test-amdhip-ctor.cpp
LIBRARIES rocprofiler-register::tests-weak rocprofiler-register::tests-rocp
CORE_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libhsa-runtime64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n"
PRELOAD_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libhsa-runtime64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n"
WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libhsa-runtime64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n"
PRELOAD_WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.fwd.hpp. dlopen libhsa-runtime64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n"
)
# constructor + mt
rocp_register_test_executable(
test-amdhip-ctor-mt
SOURCES test-amdhip-ctor-mt.cpp
LIBRARIES rocprofiler-register::tests-strong amdhip::amdhip
CORE_PASS_REGEX
".hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
PRELOAD_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
WRAP_PASS_REGEX
".hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
PRELOAD_WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n"
)
rocp_register_test_executable(
test-amdhip-ctor-mt-weak
SOURCES test-amdhip-ctor-mt.cpp
LIBRARIES rocprofiler-register::tests-weak
CORE_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
PRELOAD_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.hsa-runtime.cpp. hsa_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
PRELOAD_WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n"
)
rocp_register_test_executable(
test-amdhip-ctor-mt-rocp
SOURCES test-amdhip-ctor-mt.cpp
LIBRARIES rocprofiler-register::tests-strong amdhip::amdhip
rocprofiler-register::tests-rocp
CORE_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
PRELOAD_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n"
PRELOAD_WRAP_PASS_REGEX
".rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n"
)
rocp_register_test_executable(
test-amdhip-ctor-mt-weak-rocp
SOURCES test-amdhip-ctor-mt.cpp
LIBRARIES rocprofiler-register::tests-weak rocprofiler-register::tests-rocp
CORE_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
PRELOAD_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.hsa-runtime.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n.amdhip.cpp. hip_init\n"
WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n"
PRELOAD_WRAP_PASS_REGEX
".fwd.hpp. dlopen libamdhip64.so, 1\n.rocprofiler.cpp. rocp_ctor\n.rocprofiler.cpp. hsa :: 20100 :: 0 :: 1\n.hsa-runtime.cpp. hsa identifier 0\n.rocprofiler.cpp. hsa_init\n.rocprofiler.cpp. hip :: 60001 :: 0 :: 1\n.amdhip.cpp. hip identifier 8\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n.rocprofiler.cpp. hip_init\n"
)
add_executable(test-invalid-hsa-runtime)
target_sources(test-invalid-hsa-runtime PRIVATE test-amdhip-roctx.cpp)
target_link_libraries(
test-invalid-hsa-runtime PRIVATE rocprofiler-register::tests-common roctx::roctx
amdhip::amdhip-invalid)
add_test(
NAME test-secure-invalid-hsa-runtime
COMMAND $<TARGET_FILE:test-invalid-hsa-runtime>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
set_tests_properties(
test-secure-invalid-hsa-runtime
PROPERTIES
ENVIRONMENT
"LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/invalid:${CMAKE_LIBRARY_OUTPUT_DIRECTORY};ROCPROFILER_REGISTER_SECURE=1"
LABELS
"secure"
WILL_FAIL
ON)
add_test(
NAME test-insecure-invalid-hsa-runtime
COMMAND $<TARGET_FILE:test-invalid-hsa-runtime>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
set_tests_properties(
test-insecure-invalid-hsa-runtime
PROPERTIES
ENVIRONMENT
"LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/invalid:${CMAKE_LIBRARY_OUTPUT_DIRECTORY};ROCPROFILER_REGISTER_SECURE=0"
LABELS
"insecure")
add_executable(test-amdhip-hsart-roctx)
target_sources(test-amdhip-hsart-roctx PRIVATE test-amdhip-hsart-roctx.cpp)
target_link_libraries(
test-amdhip-hsart-roctx PRIVATE rocprofiler-register::tests-common
hsa-runtime::hsa-runtime amdhip::amdhip roctx::roctx)
add_test(
NAME test-force-rocprofiler-dlopen
COMMAND $<TARGET_FILE:test-amdhip-hsart-roctx>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
set_tests_properties(
test-force-rocprofiler-dlopen
PROPERTIES
ENVIRONMENT
"LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY};ROCPROFILER_REGISTER_FORCE_LOAD=1;ROCPROFILER_REGISTER_SECURE=yes;ROCPROFILER_REGISTER_VERBOSE=3"
LABELS
"dlopen;secure")
add_test(
NAME test-rocprofiler-register-library-base-path
COMMAND $<TARGET_FILE:test-amdhip-hsart-roctx>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
set_tests_properties(
test-rocprofiler-register-library-base-path
PROPERTIES
ENVIRONMENT
"LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY};ROCPROFILER_REGISTER_LIBRARY=librocprofiler64.so;ROCPROFILER_REGISTER_SECURE=yes;ROCPROFILER_REGISTER_VERBOSE=3;ROCPROFILER_REGISTER_MONOCHROME=true"
LABELS
"dlopen;secure")
add_test(
NAME test-rocprofiler-register-library-absolute-path
COMMAND $<TARGET_FILE:test-amdhip-hsart-roctx>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
set_tests_properties(
test-rocprofiler-register-library-absolute-path
PROPERTIES
ENVIRONMENT
"LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY};ROCPROFILER_REGISTER_LIBRARY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/librocprofiler64.so;ROCPROFILER_REGISTER_SECURE=yes;ROCPROFILER_REGISTER_VERBOSE=3;ROCPROFILER_REGISTER_MONOCHROME=true"
LABELS
"dlopen;secure")
@@ -0,0 +1,39 @@
#
#
#
if(NOT TARGET rocprofiler-register::rocprofiler-register)
find_package(rocprofiler-register REQUIRED)
endif()
add_library(amdhip SHARED)
add_library(amdhip::amdhip ALIAS amdhip)
target_sources(amdhip PRIVATE amdhip.cpp amdhip.hpp)
target_include_directories(amdhip PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
target_link_libraries(
amdhip
PRIVATE rocprofiler-register::rocprofiler-register
PUBLIC hsa-runtime::hsa-runtime)
set_target_properties(
amdhip
PROPERTIES OUTPUT_NAME amdhip64
SOVERSION 6
VERSION 6.0.1)
rocp_register_strip_target(amdhip)
add_library(amdhip-invalid SHARED)
add_library(amdhip::amdhip-invalid ALIAS amdhip-invalid)
target_sources(amdhip-invalid PRIVATE amdhip.cpp amdhip.hpp)
target_include_directories(amdhip-invalid
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
target_link_libraries(
amdhip-invalid
PRIVATE rocprofiler-register::rocprofiler-register
PUBLIC hsa-runtime::hsa-runtime-invalid)
set_target_properties(
amdhip-invalid
PROPERTIES OUTPUT_NAME amdhip64
SOVERSION 6
VERSION 6.0.1
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/invalid")
rocp_register_strip_target(amdhip-invalid)
@@ -0,0 +1,154 @@
#include "amdhip.hpp"
#include "hsa-runtime.hpp"
#include <rocprofiler-register/rocprofiler-register.h>
#include <atomic>
#include <iostream>
#include <mutex>
#include <string_view>
#define ROCP_REG_VERSION \
ROCPROFILER_REGISTER_COMPUTE_VERSION_3( \
HIP_VERSION_MAJOR, HIP_VERSION_MINOR, HIP_VERSION_PATCH)
ROCPROFILER_REGISTER_DEFINE_IMPORT(hip, ROCP_REG_VERSION)
#ifndef ROCP_REG_FILE_NAME
# define ROCP_REG_FILE_NAME \
::std::string{ __FILE__ } \
.substr(::std::string_view{ __FILE__ }.find_last_of('/') + 1) \
.c_str()
#endif
namespace hip
{
namespace
{
auto&
get_hip_api_table_impl()
{
static auto _table = std::atomic<HipApiTable*>{ nullptr };
return _table;
}
void
register_profiler_impl()
{
static auto _const_api_table = HipApiTable{};
initialize_hip_api_table(&_const_api_table);
// set this before any recursive opportunity arises
get_hip_api_table_impl().exchange(&_const_api_table);
// create a copy of the api table for modification by registration
static auto _profiler_api_table = HipApiTable{};
copy_hip_api_table(&_profiler_api_table, &_const_api_table);
void* _profiler_api_table_v = static_cast<void*>(&_profiler_api_table);
auto lib_id = rocprofiler_register_library_indentifier_t{};
auto success =
rocprofiler_register_library_api_table("hip",
&ROCPROFILER_REGISTER_IMPORT_FUNC(hip),
ROCP_REG_VERSION,
&_profiler_api_table_v,
1,
&lib_id);
if(success == ROCP_REG_SUCCESS)
{
printf("[%s] hip identifier %lu\n", ROCP_REG_FILE_NAME, lib_id.handle);
auto* _api_table = &_const_api_table;
if(!get_hip_api_table_impl().compare_exchange_strong(_api_table,
&_profiler_api_table))
{
// with the current impl, if we ever get here, someone is calling one the
// functions in this anonymous namespace that shouldn't
std::cerr
<< "register_profiler_impl expected the API table to be the internal "
"implementation and yet it is not. something went wrong.\n";
abort();
}
}
else if(success != ROCP_REG_NO_TOOLS)
{
std::cerr << "HIP library failed to register with rocprofiler-register: "
<< rocprofiler_register_error_string(success) << "\n";
exit(EXIT_FAILURE);
}
}
void
register_profiler()
{
// this registration scheme is designed to minimize overhead once
// registered (only pay cost of checking atomic boolean)
// once the profiler is registered. If the library has not
// been registered and two or more threads try to register concurrently
// the first thread to acquire the lock below, will block the
// threads until registration is complete. However,
// if the same thread performing the registration re-enters this function
// i.e. this library's API is called during registration, this function
// will prevent a deadlock by not attempting to re-enter the
// the call-once and not releasing any waiting threads by flipping
// the _is_registered field to true.
static auto _is_registered = std::atomic<bool>{ false };
if(!_is_registered.load(std::memory_order_acquire))
{
using mutex_t = std::recursive_mutex;
using auto_lock_t = std::unique_lock<mutex_t>;
static auto _once = std::once_flag{};
static auto _mutex = mutex_t{};
// defer the lock so we can check for recursion
auto _lk = auto_lock_t{ _mutex, std::defer_lock };
// this will be true if the same thread currently executing the call_once invokes
// the library's API while registering the profiler (e.g. tool which wants to
// instrument HIP API invokes a HIP function while registering with the profiler)
// we allow this thread to proceed and access the "const" API table but
// return so it does not flip _is_registered to true, which would result
// in any subsequent threads not waiting until the library is fully registered,
// resulting in missed callbacks for the tools
if(_lk.owns_lock()) return;
// ensures any subsequent threads wait until the first thread
// finishes registration
_lk.lock();
// call_once to ensure that we only register once
std::call_once(_once, register_profiler_impl);
// the first thread has completed registration and all
// threads waiting on lock will be released and this
// block will not be entered again
_is_registered.exchange(true, std::memory_order_release);
}
}
} // namespace
HipApiTable*
get_hip_api_table()
{
static auto _once = std::once_flag{};
std::call_once(_once, hsa_init);
register_profiler();
return get_hip_api_table_impl().load(std::memory_order_relaxed);
}
void
hip_init()
{
printf("[%s] %s\n", ROCP_REG_FILE_NAME, __FUNCTION__);
}
bool _constructed = true;
} // namespace hip
extern "C" {
void
hip_init(void)
{
if(hip::_constructed) hip::get_hip_api_table()->hip_init_fn();
}
}
@@ -0,0 +1,40 @@
#pragma once
#define HIP_VERSION_MAJOR 6
#define HIP_VERSION_MINOR 0
#define HIP_VERSION_PATCH 1
#include <cstdint>
extern "C" {
// fake hip function
void
hip_init(void) __attribute__((visibility("default")));
}
namespace hip
{
struct HipApiTable
{
uint64_t size = 0;
decltype(::hip_init)* hip_init_fn = nullptr;
};
void
hip_init();
// populates hip api table with function pointers
inline void
initialize_hip_api_table(HipApiTable* dst)
{
dst->size = sizeof(HipApiTable);
dst->hip_init_fn = &::hip::hip_init;
}
// copies the api table from src to dst
inline void
copy_hip_api_table(HipApiTable* dst, const HipApiTable* src)
{
*dst = *src;
}
} // namespace hip
@@ -0,0 +1,31 @@
#pragma once
#include <dlfcn.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(ROCP_REG_TEST_WEAK) && ROCP_REG_TEST_WEAK > 0
# pragma weak hip_init
# pragma weak hsa_init
# pragma weak roctxRangePush
# pragma weak roctxRangePop
#endif
extern void
hip_init(void);
extern void
hsa_init(void);
extern void
roctxRangePush(const char*);
extern void
roctxRangePop(const char*);
#ifdef __cplusplus
}
#endif
@@ -0,0 +1,101 @@
#pragma once
#include "fwd.h"
#include <dlfcn.h>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#ifndef ROCP_REG_FILE_NAME
# define ROCP_REG_FILE_NAME \
::std::string{ __FILE__ } \
.substr(::std::string_view{ __FILE__ }.find_last_of('/') + 1) \
.c_str()
#endif
namespace
{
decltype(hip_init)* hip_init_fn = nullptr;
decltype(hsa_init)* hsa_init_fn = nullptr;
decltype(roctxRangePush)* roctxRangePush_fn = nullptr;
decltype(roctxRangePush)* roctxRangePop_fn = nullptr;
enum rocp_reg_test_modes : uint8_t
{
ROCP_REG_TEST_NONE = 0x0,
ROCP_REG_TEST_HIP = (1 << 0),
ROCP_REG_TEST_HSA = (1 << 1),
ROCP_REG_TEST_ROCTX = (1 << 2),
};
template <uint8_t Idx = ROCP_REG_TEST_NONE>
inline void
resolve_symbols(int _open_mode = RTLD_LOCAL | RTLD_LAZY)
{
auto* _open_mode_env = std::getenv("ROCP_REG_TEST_OPEN_MODE");
if(_open_mode_env)
{
constexpr auto npos = std::string_view::npos;
auto _open_mode_v = std::string_view{ _open_mode_env };
if(_open_mode_v.find("RTLD_GLOBAL") != npos)
_open_mode = RTLD_GLOBAL;
else if(_open_mode_v.find("RTLD_NOLOAD") != npos)
_open_mode = RTLD_NOLOAD;
else
_open_mode = RTLD_LOCAL;
if(_open_mode_v.find("RTLD_NOW") != npos)
_open_mode |= RTLD_NOW;
else
_open_mode |= RTLD_LAZY;
}
auto _resolve_dlopen = [_open_mode](void*& _handle, const char* _lib_name) {
fprintf(
stderr, "[%s] dlopen %s, %i\n", ROCP_REG_FILE_NAME, _lib_name, _open_mode);
_handle = dlopen(_lib_name, _open_mode);
if(!_handle)
{
fprintf(stderr, "Failure opening '%s'\n", _lib_name);
exit(EXIT_FAILURE);
}
};
auto _resolve_dlsym = [](auto& _func, void* _handle, const char* _func_name) {
if(!_func && _handle && _func_name)
{
auto* _func_v = dlsym(_handle, _func_name);
if(_func_v) *(void**) (&_func) = _func_v;
}
};
void* amdhip_handle = nullptr;
void* hsart_handle = nullptr;
void* roctx_handle = nullptr;
if constexpr((Idx & ROCP_REG_TEST_HIP) == ROCP_REG_TEST_HIP)
{
hip_init_fn = hip_init;
if(!hip_init_fn) _resolve_dlopen(amdhip_handle, "libamdhip64.so");
_resolve_dlsym(hip_init_fn, amdhip_handle, "hip_init");
}
if constexpr((Idx & ROCP_REG_TEST_HSA) == ROCP_REG_TEST_HSA)
{
hsa_init_fn = hsa_init;
if(!hsa_init_fn) _resolve_dlopen(hsart_handle, "libhsa-runtime64.so");
_resolve_dlsym(hsa_init_fn, hsart_handle, "hsa_init");
}
if constexpr((Idx & ROCP_REG_TEST_ROCTX) == ROCP_REG_TEST_ROCTX)
{
roctxRangePush_fn = roctxRangePush;
roctxRangePop_fn = roctxRangePop;
if(!roctxRangePush_fn || !roctxRangePop_fn)
_resolve_dlopen(roctx_handle, "libroctx64.so");
_resolve_dlsym(roctxRangePush_fn, roctx_handle, "roctxRangePush");
_resolve_dlsym(roctxRangePop_fn, roctx_handle, "roctxRangePop");
}
}
} // namespace
@@ -0,0 +1,35 @@
#
#
#
if(NOT TARGET rocprofiler-register::rocprofiler-register)
# find_package(rocprofiler-register REQUIRED)
endif()
add_library(hsa-runtime SHARED)
add_library(hsa-runtime::hsa-runtime ALIAS hsa-runtime)
target_sources(hsa-runtime PRIVATE hsa-runtime.cpp hsa-runtime.hpp)
target_include_directories(hsa-runtime
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
target_link_libraries(hsa-runtime PRIVATE rocprofiler-register::rocprofiler-register)
set_target_properties(
hsa-runtime
PROPERTIES OUTPUT_NAME hsa-runtime64
SOVERSION 2
VERSION 2.1.0)
rocp_register_strip_target(hsa-runtime)
add_library(hsa-runtime-invalid SHARED)
add_library(hsa-runtime::hsa-runtime-invalid ALIAS hsa-runtime-invalid)
target_sources(hsa-runtime-invalid PRIVATE hsa-runtime.cpp hsa-runtime.hpp)
target_include_directories(hsa-runtime-invalid
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
target_link_libraries(hsa-runtime-invalid
PRIVATE rocprofiler-register::rocprofiler-register)
set_target_properties(
hsa-runtime-invalid
PROPERTIES OUTPUT_NAME hsa-runtime64
SOVERSION 1
VERSION 1.2.3
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/invalid)
rocp_register_strip_target(hsa-runtime-invalid)
@@ -0,0 +1,149 @@
#include "hsa-runtime.hpp"
#include <rocprofiler-register/rocprofiler-register.h>
#include <atomic>
#include <iostream>
#include <mutex>
#include <string_view>
#define ROCP_REG_VERSION \
ROCPROFILER_REGISTER_COMPUTE_VERSION_3( \
HSA_VERSION_MAJOR, HSA_VERSION_MINOR, HSA_VERSION_PATCH)
ROCPROFILER_REGISTER_DEFINE_IMPORT(hsa, ROCP_REG_VERSION)
#ifndef ROCP_REG_FILE_NAME
# define ROCP_REG_FILE_NAME \
::std::string{ __FILE__ } \
.substr(::std::string_view{ __FILE__ }.find_last_of('/') + 1) \
.c_str()
#endif
namespace hsa
{
namespace
{
auto&
get_hsa_api_table_impl()
{
static auto _table = std::atomic<HsaApiTable*>{ nullptr };
return _table;
}
void
register_profiler_impl()
{
static auto _const_api_table = HsaApiTable{};
initialize_hsa_api_table(&_const_api_table);
// set this before any recursive opportunity arises
get_hsa_api_table_impl().exchange(&_const_api_table);
// create a copy of the api table for modification by registration
static auto _profiler_api_table = HsaApiTable{};
copy_hsa_api_table(&_profiler_api_table, &_const_api_table);
void* _profiler_api_table_v = static_cast<void*>(&_profiler_api_table);
auto lib_id = rocprofiler_register_library_indentifier_t{};
auto success =
rocprofiler_register_library_api_table("hsa",
&ROCPROFILER_REGISTER_IMPORT_FUNC(hsa),
ROCP_REG_VERSION,
&_profiler_api_table_v,
1,
&lib_id);
if(success == 0)
{
printf("[%s] hsa identifier %lu\n", ROCP_REG_FILE_NAME, lib_id.handle);
auto* _api_table = &_const_api_table;
if(!get_hsa_api_table_impl().compare_exchange_strong(_api_table,
&_profiler_api_table))
{
// with the current impl, if we ever get here, someone is calling one the
// functions in this anonymous namespace that shouldn't
std::cerr
<< "register_profiler_impl expected the API table to be the internal "
"implementation and yet it is not. something went wrong.\n";
abort();
}
}
else if(success != ROCP_REG_NO_TOOLS)
{
std::cerr << "HSA library failed to register with rocprofiler-register: "
<< rocprofiler_register_error_string(success) << "\n";
exit(EXIT_FAILURE);
}
}
void
register_profiler()
{
// this registration scheme is designed to minimize overhead once
// registered (only pay cost of checking atomic boolean)
// once the profiler is registered. If the library has not
// been registered and two or more threads try to register concurrently
// the first thread to acquire the lock below, will block the
// threads until registration is complete. However,
// if the same thread performing the registration re-enters this function
// i.e. this library's API is called during registration, this function
// will prevent a deadlock by not attempting to re-enter the
// the call-once and not releasing any waiting threads by flipping
// the _is_registered field to true.
static auto _is_registered = std::atomic<bool>{ false };
if(!_is_registered.load(std::memory_order_acquire))
{
using mutex_t = std::recursive_mutex;
using auto_lock_t = std::unique_lock<mutex_t>;
static auto _once = std::once_flag{};
static auto _mutex = mutex_t{};
// defer the lock so we can check for recursion
auto _lk = auto_lock_t{ _mutex, std::defer_lock };
// this will be true if the same thread currently executing the call_once invokes
// the library's API while registering the profiler (e.g. tool which wants to
// instrument HSA API invokes a HSA function while registering with the profiler)
// we allow this thread to proceed and access the "const" API table but
// return so it does not flip _is_registered to true, which would result
// in any subsequent threads not waiting until the library is fully registered,
// resulting in missed callbacks for the tools
if(_lk.owns_lock()) return;
// ensures any subsequent threads wait until the first thread
// finishes registration
_lk.lock();
// call_once to ensure that we only register once
std::call_once(_once, register_profiler_impl);
// the first thread has completed registration and all
// threads waiting on lock will be released and this
// block will not be entered again
_is_registered.exchange(true, std::memory_order_release);
}
}
} // namespace
HsaApiTable*
get_hsa_api_table()
{
register_profiler();
return get_hsa_api_table_impl().load(std::memory_order_relaxed);
}
void
hsa_init()
{
printf("[%s] %s\n", ROCP_REG_FILE_NAME, __FUNCTION__);
}
} // namespace hsa
extern "C" {
void
hsa_init(void)
{
hsa::get_hsa_api_table()->hsa_init_fn();
}
}
@@ -0,0 +1,40 @@
#pragma once
#define HSA_VERSION_MAJOR 2
#define HSA_VERSION_MINOR 1
#define HSA_VERSION_PATCH 0
#include <cstdint>
extern "C" {
// fake hsa function
void
hsa_init(void) __attribute__((visibility("default")));
}
namespace hsa
{
struct HsaApiTable
{
uint64_t size = 0;
decltype(::hsa_init)* hsa_init_fn = nullptr;
};
void
hsa_init();
// populates hsa api table with function pointers
inline void
initialize_hsa_api_table(HsaApiTable* dst)
{
dst->size = sizeof(HsaApiTable);
dst->hsa_init_fn = &::hsa::hsa_init;
}
// copies the api table from src to dst
inline void
copy_hsa_api_table(HsaApiTable* dst, const HsaApiTable* src)
{
*dst = *src;
}
} // namespace hsa
@@ -0,0 +1,14 @@
#
# mock rocprofiler library
#
add_library(rocprofiler SHARED)
add_library(rocprofiler::rocprofiler ALIAS rocprofiler)
target_sources(rocprofiler PRIVATE rocprofiler.cpp)
target_include_directories(rocprofiler PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>)
set_target_properties(
rocprofiler
PROPERTIES OUTPUT_NAME rocprofiler64
SOVERSION 2
VERSION 2.0.0)
rocp_register_strip_target(rocprofiler)
@@ -0,0 +1,135 @@
#include <amdhip/amdhip.hpp>
#include <hsa-runtime/hsa-runtime.hpp>
#include <roctx/roctx.hpp>
#include <pthread.h>
#include <stdexcept>
#include <string_view>
#ifndef ROCP_REG_FILE_NAME
# define ROCP_REG_FILE_NAME \
::std::string{ __FILE__ } \
.substr(::std::string_view{ __FILE__ }.find_last_of('/') + 1) \
.c_str()
#endif
namespace rocprofiler
{
void
hip_init()
{
printf("[%s] %s\n", ROCP_REG_FILE_NAME, __FUNCTION__);
}
void
hsa_init()
{
printf("[%s] %s\n", ROCP_REG_FILE_NAME, __FUNCTION__);
}
void
roctx_range_push(const char* name)
{
printf("[%s][push] %s\n", ROCP_REG_FILE_NAME, name);
}
void
roctx_range_pop(const char* name)
{
printf("[%s][pop] %s\n", ROCP_REG_FILE_NAME, name);
}
} // namespace rocprofiler
extern "C" {
struct rocprofiler_configure_result_t
{
int (*initialize)(void*) = nullptr;
int (*finalize)(void*) = nullptr;
void* data = nullptr;
};
rocprofiler_configure_result_t*
rocprofiler_configure(uint32_t, const char*, uint32_t, uint32_t)
__attribute__((visibility("default")));
int
rocprofiler_set_api_table(const char*, uint64_t, uint64_t, void**, uint64_t)
__attribute__((visibility("default")));
rocprofiler_configure_result_t*
rocprofiler_configure(uint32_t version,
const char* runtime_version,
uint32_t priority,
uint32_t tool_id)
{
(void) version;
(void) runtime_version;
(void) priority;
(void) tool_id;
return nullptr;
}
int
rocprofiler_set_api_table(const char* name,
uint64_t lib_version,
uint64_t lib_instance,
void** tables,
uint64_t num_tables)
{
printf("[%s] %s :: %lu :: %lu :: %lu\n",
ROCP_REG_FILE_NAME,
name,
lib_version,
lib_instance,
num_tables);
using hip_table_t = hip::HipApiTable;
using hsa_table_t = hsa::HsaApiTable;
using roctx_table_t = roctx::ROCTxApiTable;
auto* _wrap_v = std::getenv("ROCP_REG_TEST_WRAP");
bool _wrap = (_wrap_v != nullptr && std::stoi(_wrap_v) != 0);
if(_wrap)
{
if(num_tables != 1)
throw std::runtime_error{ std::string{ "unexpected number of tables: " } +
std::to_string(num_tables) };
if(tables == nullptr) throw std::runtime_error{ "nullptr to tables" };
if(tables[0] == nullptr) throw std::runtime_error{ "nullptr to tables[0]" };
if(std::string_view{ name } == "hip")
{
hip_table_t* _table = static_cast<hip_table_t*>(tables[0]);
_table->hip_init_fn = &rocprofiler::hip_init;
}
else if(std::string_view{ name } == "hsa")
{
hsa_table_t* _table = static_cast<hsa_table_t*>(tables[0]);
_table->hsa_init_fn = &rocprofiler::hsa_init;
}
else if(std::string_view{ name } == "roctx")
{
roctx_table_t* _table = static_cast<roctx_table_t*>(tables[0]);
_table->roctxRangePush_fn = &rocprofiler::roctx_range_push;
_table->roctxRangePop_fn = &rocprofiler::roctx_range_pop;
}
}
return 0;
}
}
void
rocp_ctor(void) __attribute__((constructor));
bool rocprofiler_test_lib_link = false;
void
rocp_ctor()
{
rocprofiler_test_lib_link = true;
printf("[%s] %s\n", ROCP_REG_FILE_NAME, __FUNCTION__);
}
@@ -0,0 +1,19 @@
#
#
#
if(NOT TARGET rocprofiler-register::rocprofiler-register)
find_package(rocprofiler-register REQUIRED)
endif()
add_library(roctx SHARED)
add_library(roctx::roctx ALIAS roctx)
target_sources(roctx PRIVATE roctx.cpp roctx.hpp)
target_include_directories(roctx PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
target_link_libraries(roctx PRIVATE rocprofiler-register::rocprofiler-register)
set_target_properties(
roctx
PROPERTIES OUTPUT_NAME roctx64
SOVERSION 4
VERSION 4.6.1)
rocp_register_strip_target(roctx)
@@ -0,0 +1,170 @@
#ifdef NDEBUG
# undef NDEBUG
#endif
#include "roctx.hpp"
#include <rocprofiler-register/rocprofiler-register.h>
#include <atomic>
#include <cassert>
#include <iostream>
#include <mutex>
#include <string_view>
#define ROCP_REG_VERSION \
ROCPROFILER_REGISTER_COMPUTE_VERSION_3( \
ROCTX_VERSION_MAJOR, ROCTX_VERSION_MINOR, ROCTX_VERSION_PATCH)
ROCPROFILER_REGISTER_DEFINE_IMPORT(roctx, ROCP_REG_VERSION)
#ifndef ROCP_REG_FILE_NAME
# define ROCP_REG_FILE_NAME \
::std::string{ __FILE__ } \
.substr(::std::string_view{ __FILE__ }.find_last_of('/') + 1) \
.c_str()
#endif
namespace roctx
{
namespace
{
auto&
get_roctx_api_table_impl()
{
static auto _table = std::atomic<ROCTxApiTable*>{ nullptr };
return _table;
}
void
register_profiler_impl()
{
static auto _const_api_table = ROCTxApiTable{};
initialize_roctx_api_table(&_const_api_table);
// set this before any recursive opportunity arises
get_roctx_api_table_impl().exchange(&_const_api_table);
// create a copy of the api table for modification by registration
static auto _profiler_api_table = ROCTxApiTable{};
copy_roctx_api_table(&_profiler_api_table, &_const_api_table);
void* _profiler_api_table_v = static_cast<void*>(&_profiler_api_table);
auto lib_id = rocprofiler_register_library_indentifier_t{};
auto success =
rocprofiler_register_library_api_table("roctx",
&ROCPROFILER_REGISTER_IMPORT_FUNC(roctx),
ROCP_REG_VERSION,
&_profiler_api_table_v,
1,
&lib_id);
if(success == 0)
{
printf("[%s] roctx identifier %lu\n", ROCP_REG_FILE_NAME, lib_id.handle);
auto* _api_table = &_const_api_table;
if(!get_roctx_api_table_impl().compare_exchange_strong(_api_table,
&_profiler_api_table))
{
// with the current impl, if we ever get here, someone is calling one the
// functions in this anonymous namespace that shouldn't
std::cerr
<< "register_profiler_impl expected the API table to be the internal "
"implementation and yet it is not. something went wrong.\n";
abort();
}
}
else if(success != ROCP_REG_NO_TOOLS)
{
std::cerr << "ROCTx library failed to register with rocprofiler-register: "
<< rocprofiler_register_error_string(success) << "\n";
exit(EXIT_FAILURE);
}
}
void
register_profiler()
{
// this registration scheme is designed to minimize overhead once
// registered (only pay cost of checking atomic boolean)
// once the profiler is registered. If the library has not
// been registered and two or more threads try to register concurrently
// the first thread to acquire the lock below, will block the
// threads until registration is complete. However,
// if the same thread performing the registration re-enters this function
// i.e. this library's API is called during registration, this function
// will prevent a deadlock by not attempting to re-enter the
// the call-once and not releasing any waiting threads by flipping
// the _is_registered field to true.
static auto _is_registered = std::atomic<bool>{ false };
if(!_is_registered.load(std::memory_order_acquire))
{
using mutex_t = std::recursive_mutex;
using auto_lock_t = std::unique_lock<mutex_t>;
static auto _once = std::once_flag{};
static auto _mutex = mutex_t{};
// defer the lock so we can check for recursion
auto _lk = auto_lock_t{ _mutex, std::defer_lock };
// this will be true if the same thread currently executing the call_once invokes
// the library's API while registering the profiler (e.g. tool which wants to
// instrument ROCTX API invokes a ROCTX function while registering with the
// profiler) we allow this thread to proceed and access the "const" API table but
// return so it does not flip _is_registered to true, which would result
// in any subsequent threads not waiting until the library is fully registered,
// resulting in missed callbacks for the tools
if(_lk.owns_lock()) return;
// ensures any subsequent threads wait until the first thread
// finishes registration
_lk.lock();
// call_once to ensure that we only register once
std::call_once(_once, register_profiler_impl);
// the first thread has completed registration and all
// threads waiting on lock will be released and this
// block will not be entered again
_is_registered.exchange(true, std::memory_order_release);
}
}
} // namespace
ROCTxApiTable*
get_roctx_api_table()
{
register_profiler();
return get_roctx_api_table_impl().load(std::memory_order_relaxed);
}
void
roctx_range_push(const char* name)
{
printf("[%s][push] %s\n", ROCP_REG_FILE_NAME, name);
}
void
roctx_range_pop(const char* name)
{
printf("[%s][pop] %s\n", ROCP_REG_FILE_NAME, name);
}
} // namespace roctx
extern "C" {
void
roctxRangePush(const char* name)
{
auto&& _func = roctx::get_roctx_api_table()->roctxRangePush_fn;
assert(_func != nullptr);
_func(name);
}
void
roctxRangePop(const char* name)
{
auto&& _func = roctx::get_roctx_api_table()->roctxRangePop_fn;
if(_func == nullptr) throw std::runtime_error("nullptr");
_func(name);
}
}
@@ -0,0 +1,46 @@
#pragma once
#define ROCTX_VERSION_MAJOR 4
#define ROCTX_VERSION_MINOR 6
#define ROCTX_VERSION_PATCH 1
#include <cstdint>
extern "C" {
void
roctxRangePush(const char*) __attribute__((visibility("default")));
void
roctxRangePop(const char*) __attribute__((visibility("default")));
}
namespace roctx
{
struct ROCTxApiTable
{
uint64_t size = 0;
decltype(::roctxRangePush)* roctxRangePush_fn = nullptr;
decltype(::roctxRangePop)* roctxRangePop_fn = nullptr;
};
void
roctx_range_push(const char*);
void
roctx_range_pop(const char*);
// populates roctx api table with function pointers
inline void
initialize_roctx_api_table(ROCTxApiTable* dst)
{
dst->size = sizeof(ROCTxApiTable);
dst->roctxRangePush_fn = &::roctx::roctx_range_push;
dst->roctxRangePop_fn = &::roctx::roctx_range_pop;
}
// copies the api table from src to dst
inline void
copy_roctx_api_table(ROCTxApiTable* dst, const ROCTxApiTable* src)
{
*dst = *src;
}
} // namespace roctx
@@ -0,0 +1,3 @@
#
#
#
@@ -0,0 +1,72 @@
#include <dlfcn.h>
#include <pthread.h>
#include <cstdlib>
#include <string>
#include <thread>
#include <vector>
#include "common/fwd.hpp"
void
run(const std::string& name, pthread_barrier_t* _barrier)
{
if(_barrier) pthread_barrier_wait(_barrier);
if(hsa_init_fn)
{
if(_barrier) pthread_barrier_wait(_barrier);
hsa_init_fn();
}
if(hip_init_fn)
{
if(_barrier) pthread_barrier_wait(_barrier);
hip_init_fn();
}
if(roctxRangePush_fn)
{
if(_barrier) pthread_barrier_wait(_barrier);
roctxRangePush_fn(name.c_str());
}
if(roctxRangePop_fn)
{
if(_barrier) pthread_barrier_wait(_barrier);
roctxRangePop_fn(name.c_str());
}
}
auto
run_threads(unsigned long n)
{
resolve_symbols<ROCP_REG_TEST_HIP>();
auto threads = std::vector<std::thread>{};
auto names = std::vector<std::string>{};
for(unsigned long i = 0; i < n; ++i)
names.emplace_back(std::string{ "thread-" } + std::to_string(i));
auto _barrier = pthread_barrier_t{};
pthread_barrier_init(&_barrier, nullptr, n);
for(unsigned long i = 0; i < n; ++i)
threads.emplace_back(run, names.at(i), &_barrier);
for(auto& itr : threads)
itr.join();
pthread_barrier_destroy(&_barrier);
return n;
}
auto run_n = run_threads(4);
int
main()
{
return (run_n == 4) ? EXIT_SUCCESS : EXIT_FAILURE;
}
@@ -0,0 +1,42 @@
#include <dlfcn.h>
#include <cstdlib>
#include <string>
#include "common/fwd.hpp"
std::string
run(const std::string& name)
{
resolve_symbols<ROCP_REG_TEST_HSA | ROCP_REG_TEST_HIP>();
if(hsa_init_fn)
{
hsa_init_fn();
}
if(hip_init_fn)
{
hip_init_fn();
}
if(roctxRangePush_fn)
{
roctxRangePush_fn(name.c_str());
}
if(roctxRangePop_fn)
{
roctxRangePop_fn(name.c_str());
}
return name;
}
auto run_name = run("thread-ctor");
int
main()
{
return (run_name == "thread-ctor") ? EXIT_SUCCESS : EXIT_FAILURE;
}
@@ -0,0 +1,43 @@
#include <dlfcn.h>
#include <string>
#include "common/fwd.hpp"
void
run(const std::string& name)
{
if(hip_init_fn)
{
hip_init_fn();
}
if(hsa_init_fn)
{
hsa_init_fn();
}
if(roctxRangePush_fn)
{
roctxRangePush_fn(name.c_str());
}
if(roctxRangePop_fn)
{
roctxRangePop_fn(name.c_str());
}
}
int
main(int argc, char** argv)
{
unsigned long n = 1;
if(argc > 1) n = std::stoul(argv[1]);
resolve_symbols<ROCP_REG_TEST_HSA | ROCP_REG_TEST_HIP | ROCP_REG_TEST_ROCTX>();
for(unsigned long i = 0; i < n; ++i)
run("thread-main");
return 0;
}
@@ -0,0 +1,72 @@
#include <dlfcn.h>
#include <pthread.h>
#include <string>
#include <thread>
#include <vector>
#include "common/fwd.hpp"
void
run(const std::string& name, pthread_barrier_t* _barrier)
{
if(_barrier) pthread_barrier_wait(_barrier);
if(hip_init_fn)
{
if(_barrier) pthread_barrier_wait(_barrier);
hip_init_fn();
}
if(hsa_init_fn)
{
if(_barrier) pthread_barrier_wait(_barrier);
hsa_init_fn();
}
if(roctxRangePush_fn)
{
if(_barrier) pthread_barrier_wait(_barrier);
roctxRangePush_fn(name.c_str());
}
if(roctxRangePop_fn)
{
if(_barrier) pthread_barrier_wait(_barrier);
roctxRangePop_fn(name.c_str());
}
}
void
run_threads(unsigned long n)
{
auto threads = std::vector<std::thread>{};
auto names = std::vector<std::string>{};
for(unsigned long i = 0; i < n; ++i)
names.emplace_back(std::string{ "thread-" } + std::to_string(i));
auto _barrier = pthread_barrier_t{};
pthread_barrier_init(&_barrier, nullptr, n);
for(unsigned long i = 0; i < n; ++i)
threads.emplace_back(run, names.at(i), &_barrier);
for(auto& itr : threads)
itr.join();
pthread_barrier_destroy(&_barrier);
}
int
main(int argc, char** argv)
{
unsigned long n = 4;
if(argc > 1) n = std::stoul(argv[1]);
resolve_symbols<ROCP_REG_TEST_HIP | ROCP_REG_TEST_ROCTX>();
run_threads(n);
return 0;
}
@@ -0,0 +1,43 @@
#include <dlfcn.h>
#include <string>
#include "common/fwd.hpp"
void
run(const std::string& name)
{
if(hip_init_fn)
{
hip_init_fn();
}
if(hsa_init_fn)
{
hsa_init_fn();
}
if(roctxRangePush_fn)
{
roctxRangePush_fn(name.c_str());
}
if(roctxRangePop_fn)
{
roctxRangePop_fn(name.c_str());
}
}
int
main(int argc, char** argv)
{
unsigned long n = 1;
if(argc > 1) n = std::stoul(argv[1]);
resolve_symbols<ROCP_REG_TEST_HIP | ROCP_REG_TEST_ROCTX>();
for(unsigned long i = 0; i < n; ++i)
run("thread-main");
return 0;
}