diff --git a/projects/rocprofiler-sdk/cmake/rocprofiler_memcheck.cmake b/projects/rocprofiler-sdk/cmake/rocprofiler_memcheck.cmake index 9484ad5d10..b3d311631d 100644 --- a/projects/rocprofiler-sdk/cmake/rocprofiler_memcheck.cmake +++ b/projects/rocprofiler-sdk/cmake/rocprofiler_memcheck.cmake @@ -66,11 +66,15 @@ function(rocprofiler_set_memcheck_env _TYPE _LIB_BASE) set(ROCPROFILER_MEMCHECK_PRELOAD_ENV "LD_PRELOAD=${${_TYPE}_LIBRARY}" CACHE INTERNAL "LD_PRELOAD env variable for tests " FORCE) + set(ROCPROFILER_MEMCHECK_PRELOAD_ENV_VALUE + "${${_TYPE}_LIBRARY}" + CACHE INTERNAL "Library to LD_PRELOAD for tests " FORCE) endif() endfunction() # always unset so that it doesn't preload if memcheck disabled unset(ROCPROFILER_MEMCHECK_PRELOAD_ENV CACHE) +unset(ROCPROFILER_MEMCHECK_PRELOAD_ENV_VALUE CACHE) # the soversions below are fallbacks in case deduce-sanitizer-lib.sh fails if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION diff --git a/projects/rocprofiler-sdk/samples/advanced_thread_trace/CMakeLists.txt b/projects/rocprofiler-sdk/samples/advanced_thread_trace/CMakeLists.txt index 3bfd9a8d91..aded15bd51 100644 --- a/projects/rocprofiler-sdk/samples/advanced_thread_trace/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/advanced_thread_trace/CMakeLists.txt @@ -44,16 +44,11 @@ target_link_libraries( advanced-thread-trace PRIVATE advanced-thread-trace-client Threads::Threads rocprofiler::samples-build-flags) +rocprofiler_samples_get_preload_env(PRELOAD_ENV advanced-thread-trace-client) + add_test(NAME advanced-thread-trace COMMAND $) set_tests_properties( advanced-thread-trace - PROPERTIES - TIMEOUT - 45 - LABELS - "samples" - ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - FAIL_REGULAR_EXPRESSION - "threw an exception") + PROPERTIES TIMEOUT 45 LABELS "samples" ENVIRONMENT "${PRELOAD_ENV}" + FAIL_REGULAR_EXPRESSION "threw an exception") diff --git a/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt b/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt index ab6a8034af..293eb479bc 100644 --- a/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/api_buffered_tracing/CMakeLists.txt @@ -43,16 +43,14 @@ target_link_libraries( buffered-api-tracing PRIVATE buffered-api-tracing-client Threads::Threads rocprofiler::samples-build-flags) +rocprofiler_samples_get_preload_env(PRELOAD_ENV buffered-api-tracing-client) +rocprofiler_samples_get_ld_library_path_env(LIBRARY_PATH_ENV) + +set(buffered-api-tracing-env ${PRELOAD_ENV} ${LIBRARY_PATH_ENV}) + add_test(NAME buffered-api-tracing COMMAND $) set_tests_properties( buffered-api-tracing - PROPERTIES - TIMEOUT - 45 - LABELS - "samples" - ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - FAIL_REGULAR_EXPRESSION - "${ROCPROFILER_DEFAULT_FAIL_REGEX}") + PROPERTIES TIMEOUT 45 LABELS "samples" ENVIRONMENT "${buffered-api-tracing-env}" + FAIL_REGULAR_EXPRESSION "${ROCPROFILER_DEFAULT_FAIL_REGEX}") diff --git a/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt b/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt index 9b5c77ba95..1c16335f29 100644 --- a/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/api_callback_tracing/CMakeLists.txt @@ -46,13 +46,13 @@ target_link_libraries( PRIVATE callback-api-tracing-client Threads::Threads rocprofiler-sdk-roctx::rocprofiler-sdk-roctx rocprofiler::samples-build-flags) -add_test(NAME callback-api-tracing COMMAND $) +rocprofiler_samples_get_preload_env(PRELOAD_ENV callback-api-tracing-client) +rocprofiler_samples_get_ld_library_path_env( + LIBRARY_PATH_ENV rocprofiler-sdk-roctx::rocprofiler-sdk-roctx-shared-library) -set(callback-api-tracing-env - ${ROCPROFILER_MEMCHECK_PRELOAD_ENV} - "HSA_TOOLS_LIB=$" - "LD_LIBRARY_PATH=$:$ENV{LD_LIBRARY_PATH}" - ) +set(callback-api-tracing-env ${PRELOAD_ENV} ${LIBRARY_PATH_ENV}) + +add_test(NAME callback-api-tracing COMMAND $) set_tests_properties( callback-api-tracing diff --git a/projects/rocprofiler-sdk/samples/code_object_isa_decode/CMakeLists.txt b/projects/rocprofiler-sdk/samples/code_object_isa_decode/CMakeLists.txt index ffc4bae201..1a380d2b77 100644 --- a/projects/rocprofiler-sdk/samples/code_object_isa_decode/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/code_object_isa_decode/CMakeLists.txt @@ -41,12 +41,6 @@ add_test(NAME code-object-isa-decode COMMAND $" - FAIL_REGULAR_EXPRESSION - "threw an exception") + PROPERTIES TIMEOUT 45 LABELS "samples" ENVIRONMENT + "${ROCPROFILER_MEMCHECK_PRELOAD_ENV}" FAIL_REGULAR_EXPRESSION + "threw an exception") diff --git a/projects/rocprofiler-sdk/samples/code_object_tracing/CMakeLists.txt b/projects/rocprofiler-sdk/samples/code_object_tracing/CMakeLists.txt index 2f41af72b1..bbf69b7404 100644 --- a/projects/rocprofiler-sdk/samples/code_object_tracing/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/code_object_tracing/CMakeLists.txt @@ -47,12 +47,6 @@ add_test(NAME code-object-tracing COMMAND $) set_tests_properties( code-object-tracing - PROPERTIES - TIMEOUT - 45 - LABELS - "samples" - ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - FAIL_REGULAR_EXPRESSION - "${ROCPROFILER_DEFAULT_FAIL_REGEX}") + PROPERTIES TIMEOUT 45 LABELS "samples" ENVIRONMENT + "${ROCPROFILER_MEMCHECK_PRELOAD_ENV}" FAIL_REGULAR_EXPRESSION + "${ROCPROFILER_DEFAULT_FAIL_REGEX}") diff --git a/projects/rocprofiler-sdk/samples/common/CMakeLists.txt b/projects/rocprofiler-sdk/samples/common/CMakeLists.txt index edae86f2e6..b8480695fc 100644 --- a/projects/rocprofiler-sdk/samples/common/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/common/CMakeLists.txt @@ -40,3 +40,47 @@ if(EXISTS ${EXTERNAL_SUBMODULE_DIR}/filesystem/include/ghc/filesystem.hpp) rocprofiler-samples-common-library SYSTEM INTERFACE $) endif() + +# function for getting the LD_PRELOAD environment variable +function(rocprofiler_samples_get_preload_env _VAR) + set(_PRELOAD_ENV_LIBS ${ROCPROFILER_MEMCHECK_PRELOAD_ENV_VALUE} $ENV{LD_PRELOAD}) + + foreach(_TARG ${ARGN}) + if(NOT TARGET ${_TARG}) + message( + FATAL_ERROR + "rocprofiler_samples_get_preload_env: '${_TARG}' is not a valid target" + ) + endif() + list(APPEND _PRELOAD_ENV_LIBS $) + endforeach() + + if(_PRELOAD_ENV_LIBS) + string(REPLACE ";" ":" _PRELOAD_ENV "LD_PRELOAD=${_PRELOAD_ENV_LIBS}") + endif() + + set(${_VAR} + "${_PRELOAD_ENV}" + PARENT_SCOPE) +endfunction() + +# function for getting the LD_LIBRARY_PATH environment variable +function(rocprofiler_samples_get_ld_library_path_env _VAR) + + set(_LDLIB_PATH "LD_LIBRARY_PATH=") + foreach(_TARG ${ARGN}) + if(NOT TARGET ${_TARG}) + message( + FATAL_ERROR + "rocprofiler_samples_get_ld_library_path_env: '${_TARG}' is not a valid target" + ) + endif() + string(APPEND _LDLIB_PATH "$:") + endforeach() + # append the environments current LD_LIBRARY_PATH + string(APPEND _LDLIB_PATH "$ENV{LD_LIBRARY_PATH}") + + set(${_VAR} + "${_LDLIB_PATH}" + PARENT_SCOPE) +endfunction() diff --git a/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt b/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt index 91a9053ebe..bb2631b755 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt @@ -40,19 +40,18 @@ target_sources(counter-collection-buffer PRIVATE main.cpp) target_link_libraries(counter-collection-buffer PRIVATE counter-collection-buffer-client Threads::Threads) +rocprofiler_samples_get_ld_library_path_env(LIBRARY_PATH_ENV) +rocprofiler_samples_get_preload_env(PRELOAD_ENV counter-collection-buffer-client) + +set(counter-collection-buffer-env "${PRELOAD_ENV}" "${LIBRARY_PATH_ENV}") + add_test(NAME counter-collection-buffer COMMAND $) set_tests_properties( counter-collection-buffer - PROPERTIES - TIMEOUT - 120 - LABELS - "samples" - ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - FAIL_REGULAR_EXPRESSION - "${ROCPROFILER_DEFAULT_FAIL_REGEX}") + PROPERTIES TIMEOUT 120 LABELS "samples" ENVIRONMENT + "${counter-collection-buffer-env}" FAIL_REGULAR_EXPRESSION + "${ROCPROFILER_DEFAULT_FAIL_REGEX}") add_library(counter-collection-callback-client SHARED) target_sources(counter-collection-callback-client PRIVATE callback_client.cpp client.hpp) @@ -67,20 +66,18 @@ target_sources(counter-collection-callback PRIVATE main.cpp) target_link_libraries(counter-collection-callback PRIVATE counter-collection-callback-client Threads::Threads) +rocprofiler_samples_get_preload_env(PRELOAD_ENV counter-collection-callback-client) + +set(counter-collection-callback-env "${PRELOAD_ENV}" "${LIBRARY_PATH_ENV}") + add_test(NAME counter-collection-callback COMMAND $) set_tests_properties( counter-collection-callback - PROPERTIES - TIMEOUT - 120 - LABELS - "samples" - ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - FAIL_REGULAR_EXPRESSION - "${ROCPROFILER_DEFAULT_FAIL_REGEX}") + PROPERTIES TIMEOUT 120 LABELS "samples" ENVIRONMENT + "${counter-collection-callback-env}" FAIL_REGULAR_EXPRESSION + "${ROCPROFILER_DEFAULT_FAIL_REGEX}") add_library(counter-collection-functional-counter-client SHARED) target_sources(counter-collection-functional-counter-client @@ -96,17 +93,16 @@ target_link_libraries( counter-collection-print-functional-counters PRIVATE counter-collection-functional-counter-client Threads::Threads) +rocprofiler_samples_get_preload_env(PRELOAD_ENV + counter-collection-functional-counter-client) + +set(counter-collection-functional-counter-env "${PRELOAD_ENV}" "${LIBRARY_PATH_ENV}") + add_test(NAME counter-collection-print-functional-counters COMMAND $) set_tests_properties( counter-collection-print-functional-counters - PROPERTIES - TIMEOUT - 120 - LABELS - "samples" - ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - FAIL_REGULAR_EXPRESSION - "${ROCPROFILER_DEFAULT_FAIL_REGEX}") + PROPERTIES TIMEOUT 120 LABELS "samples" ENVIRONMENT + "${counter-collection-functional-counter-env}" FAIL_REGULAR_EXPRESSION + "${ROCPROFILER_DEFAULT_FAIL_REGEX}") diff --git a/projects/rocprofiler-sdk/samples/intercept_table/CMakeLists.txt b/projects/rocprofiler-sdk/samples/intercept_table/CMakeLists.txt index 4289ad56c0..61ef5f647b 100644 --- a/projects/rocprofiler-sdk/samples/intercept_table/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/intercept_table/CMakeLists.txt @@ -42,16 +42,14 @@ target_sources(intercept-table PRIVATE main.cpp) target_link_libraries(intercept-table PRIVATE intercept-table-client Threads::Threads rocprofiler::samples-build-flags) +rocprofiler_samples_get_preload_env(PRELOAD_ENV intercept-table-client) +rocprofiler_samples_get_ld_library_path_env(LIBRARY_PATH_ENV) + +set(intercept-table-env ${PRELOAD_ENV} ${LIBRARY_PATH_ENV}) + add_test(NAME intercept-table COMMAND $) set_tests_properties( intercept-table - PROPERTIES - TIMEOUT - 45 - LABELS - "samples" - ENVIRONMENT - "${ROCPROFILER_MEMCHECK_PRELOAD_ENV};HSA_TOOLS_LIB=$" - FAIL_REGULAR_EXPRESSION - "${ROCPROFILER_DEFAULT_FAIL_REGEX}") + PROPERTIES TIMEOUT 45 LABELS "samples" ENVIRONMENT "${intercept-table-env}" + FAIL_REGULAR_EXPRESSION "${ROCPROFILER_DEFAULT_FAIL_REGEX}") diff --git a/projects/rocprofiler-sdk/source/scripts/run-ci.py b/projects/rocprofiler-sdk/source/scripts/run-ci.py index 334731a75e..d4ac23c890 100755 --- a/projects/rocprofiler-sdk/source/scripts/run-ci.py +++ b/projects/rocprofiler-sdk/source/scripts/run-ci.py @@ -12,6 +12,8 @@ import multiprocessing # this constant is used to define CTEST_PROJECT_NAME # and default value for CTEST_SUBMIT_URL +# _PROJECT_NAME = "rocprofiler-v2-internal" +# _BASE_URL = "10.194.116.31/cdash" _PROJECT_NAME = "rocprofiler-sdk-internal" _BASE_URL = "cdash.mariadb.svc.cluster.local" _GCOVR_GENERATE_CMD = None diff --git a/projects/rocprofiler-sdk/tests/rocprofv3/hsa-queue-dependency/CMakeLists.txt b/projects/rocprofiler-sdk/tests/rocprofv3/hsa-queue-dependency/CMakeLists.txt index 833868ec86..59d8b0bd00 100644 --- a/projects/rocprofiler-sdk/tests/rocprofv3/hsa-queue-dependency/CMakeLists.txt +++ b/projects/rocprofiler-sdk/tests/rocprofv3/hsa-queue-dependency/CMakeLists.txt @@ -17,10 +17,8 @@ else() set(LOG_LEVEL "info") endif() -set(tracing-env - "${PRELOAD_ENV}" "ROCPROF_LOG_LEVEL=${LOG_LEVEL}" - "ROCPROFILER_LOG_LEVEL=${LOG_LEVEL}" - "HSA_TOOLS_LIB=$") +set(tracing-env "${PRELOAD_ENV}" "ROCPROF_LOG_LEVEL=${LOG_LEVEL}" + "ROCPROFILER_LOG_LEVEL=${LOG_LEVEL}") foreach(FILENAME validate.py conftest.py) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME} diff --git a/projects/rocprofiler-sdk/tests/scratch-memory-tracing/CMakeLists.txt b/projects/rocprofiler-sdk/tests/scratch-memory-tracing/CMakeLists.txt index f24871a0e5..56eb4b14a6 100644 --- a/projects/rocprofiler-sdk/tests/scratch-memory-tracing/CMakeLists.txt +++ b/projects/rocprofiler-sdk/tests/scratch-memory-tracing/CMakeLists.txt @@ -21,7 +21,6 @@ add_test(NAME test-scratch-memory-tracing-execute COMMAND $" "ROCPROFILER_TOOL_OUTPUT_FILE=scratch-memory-tracing-test.json" "LD_LIBRARY_PATH=$:$ENV{LD_LIBRARY_PATH}" ) diff --git a/projects/rocprofiler-sdk/tests/tools/json-tool.cpp b/projects/rocprofiler-sdk/tests/tools/json-tool.cpp index bfdfb4cb9e..b0d75c1a36 100644 --- a/projects/rocprofiler-sdk/tests/tools/json-tool.cpp +++ b/projects/rocprofiler-sdk/tests/tools/json-tool.cpp @@ -1343,7 +1343,7 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data) } } - push_external_correlation(getpid()); + push_external_correlation(getppid()); start(); @@ -1910,13 +1910,13 @@ pop_external_correlation() auto _data = rocprofiler_user_data_t{.value = 0}; ROCPROFILER_CALL(rocprofiler_pop_external_correlation_id(*itr.second, tid, &_data), "push external correlation"); - if(_data.value != static_cast(getpid())) + if(_data.value != static_cast(getppid())) { auto _msg = std::stringstream{}; _msg << "rocprofiler_pop_external_correlation_id(context.handle=" << itr.second->handle << ", tid=" << tid << ", ...) returned external correlation id value of " << _data.value - << ". expected: " << getpid(); + << ". expected: " << getppid(); throw std::runtime_error{_msg.str()}; } }