|
| 1 | +# |
| 2 | +# |
| 3 | +# |
| 4 | +cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) |
| 5 | + |
| 6 | +if(NOT CMAKE_HIP_COMPILER) |
| 7 | + find_program( |
| 8 | + amdclangpp_EXECUTABLE |
| 9 | + NAMES amdclang++ |
| 10 | + HINTS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm |
| 11 | + PATHS ${ROCM_PATH} ENV ROCM_PATH /opt/rocm |
| 12 | + PATH_SUFFIXES bin llvm/bin NO_CACHE) |
| 13 | + mark_as_advanced(amdclangpp_EXECUTABLE) |
| 14 | + |
| 15 | + if(amdclangpp_EXECUTABLE) |
| 16 | + set(CMAKE_HIP_COMPILER "${amdclangpp_EXECUTABLE}") |
| 17 | + endif() |
| 18 | +endif() |
| 19 | + |
| 20 | +project(rocprofiler-sdk-samples-spm-counter-collection LANGUAGES CXX HIP) |
| 21 | + |
| 22 | +foreach(_TYPE DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) |
| 23 | + if("${CMAKE_HIP_FLAGS_${_TYPE}}" STREQUAL "") |
| 24 | + set(CMAKE_HIP_FLAGS_${_TYPE} "${CMAKE_CXX_FLAGS_${_TYPE}}") |
| 25 | + endif() |
| 26 | +endforeach() |
| 27 | + |
| 28 | +if(NOT ROCPROFILER_MEMCHECK STREQUAL "") |
| 29 | + set(SANITIZER True) |
| 30 | +else() |
| 31 | + set(SANITIZER False) |
| 32 | +endif() |
| 33 | + |
| 34 | +find_package(rocprofiler-sdk REQUIRED) |
| 35 | + |
| 36 | +rocprofiler_sdk_spm_disabled(IS_SPM_DISABLED) |
| 37 | +if(${SANITIZER}) |
| 38 | + set(IS_SPM_DISABLED True) |
| 39 | +endif() |
| 40 | +set(IS_DISABLED True) |
| 41 | + |
| 42 | +add_library(spm-counter-collection-buffer-client SHARED) |
| 43 | +target_sources(spm-counter-collection-buffer-client PRIVATE buffered_client.cpp |
| 44 | + client.hpp) |
| 45 | +target_link_libraries( |
| 46 | + spm-counter-collection-buffer-client |
| 47 | + PUBLIC rocprofiler-sdk::samples-build-flags |
| 48 | + PRIVATE rocprofiler-sdk::rocprofiler-sdk rocprofiler-sdk::samples-common-library) |
| 49 | + |
| 50 | +set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP) |
| 51 | +add_executable(spm-counter-collection-buffer) |
| 52 | +target_sources(spm-counter-collection-buffer PRIVATE main.cpp) |
| 53 | +target_link_libraries(spm-counter-collection-buffer |
| 54 | + PRIVATE spm-counter-collection-buffer-client Threads::Threads) |
| 55 | + |
| 56 | +rocprofiler_samples_get_ld_library_path_env(LIBRARY_PATH_ENV) |
| 57 | +rocprofiler_samples_get_preload_env(PRELOAD_ENV spm-counter-collection-buffer-client) |
| 58 | + |
| 59 | +set(SPM_ENV ROCPROFILER_SPM_BETA_ENABLED=True) |
| 60 | +set(spm-counter-collection-buffer-env "${SPM_ENV}" "${PRELOAD_ENV}" "${LIBRARY_PATH_ENV}") |
| 61 | + |
| 62 | +add_test(NAME spm-counter-collection-buffer |
| 63 | + COMMAND $<TARGET_FILE:spm-counter-collection-buffer>) |
| 64 | + |
| 65 | +set_tests_properties( |
| 66 | + spm-counter-collection-buffer |
| 67 | + PROPERTIES TIMEOUT |
| 68 | + 120 |
| 69 | + LABELS |
| 70 | + "samples" |
| 71 | + ENVIRONMENT |
| 72 | + "${spm-counter-collection-buffer-env}" |
| 73 | + FAIL_REGULAR_EXPRESSION |
| 74 | + "${ROCPROFILER_DEFAULT_FAIL_REGEX}" |
| 75 | + DISABLED |
| 76 | + ${IS_DISABLED}) |
| 77 | + |
| 78 | +add_library(spm-counter-collection-callback-client SHARED) |
| 79 | +target_sources(spm-counter-collection-callback-client PRIVATE callback_client.cpp |
| 80 | + client.hpp) |
| 81 | +target_link_libraries( |
| 82 | + spm-counter-collection-callback-client |
| 83 | + PUBLIC rocprofiler-sdk::samples-build-flags |
| 84 | + PRIVATE rocprofiler-sdk::rocprofiler-sdk rocprofiler-sdk::samples-common-library) |
| 85 | + |
| 86 | +set_source_files_properties(main.cpp PROPERTIES LANGUAGE HIP) |
| 87 | +add_executable(spm-counter-collection-callback) |
| 88 | +target_sources(spm-counter-collection-callback PRIVATE main.cpp) |
| 89 | +target_link_libraries(spm-counter-collection-callback |
| 90 | + PRIVATE spm-counter-collection-callback-client Threads::Threads) |
| 91 | + |
| 92 | +rocprofiler_samples_get_preload_env(PRELOAD_ENV spm-counter-collection-callback-client) |
| 93 | + |
| 94 | +set(spm-counter-collection-callback-env "${SPM_ENV}" "${PRELOAD_ENV}" |
| 95 | + "${LIBRARY_PATH_ENV}") |
| 96 | + |
| 97 | +add_test(NAME spm-counter-collection-callback |
| 98 | + COMMAND $<TARGET_FILE:spm-counter-collection-callback>) |
| 99 | + |
| 100 | +set_tests_properties( |
| 101 | + spm-counter-collection-callback |
| 102 | + PROPERTIES TIMEOUT |
| 103 | + 120 |
| 104 | + LABELS |
| 105 | + "samples" |
| 106 | + ENVIRONMENT |
| 107 | + "${spm-counter-collection-callback-env}" |
| 108 | + FAIL_REGULAR_EXPRESSION |
| 109 | + "${ROCPROFILER_DEFAULT_FAIL_REGEX}" |
| 110 | + DISABLED |
| 111 | + ${IS_DISABLED}) |
0 commit comments