diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ea0c6a0c5..84ce03e7af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,7 +139,7 @@ add_subdirectory(src) if(${LIBRARY_TYPE} STREQUAL SHARED) ## Build samples - #add_subdirectory(samples) + add_subdirectory(samples) ## Build tests add_subdirectory(tests) @@ -340,8 +340,8 @@ set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/ string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_DOCS_PACKAGE_DEPENDS ${CPACK_DEBIAN_DOCS_PACKAGE_DEPENDS}) string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PLUGINS_PACKAGE_DEPENDS ${CPACK_DEBIAN_PLUGINS_PACKAGE_DEPENDS}) endif() - - set(CPACK_COMPONENTS_ALL runtime dev tests docs plugins) + + set(CPACK_COMPONENTS_ALL runtime dev tests docs plugins samples) include(CPack) cpack_add_component(runtime diff --git a/cmake_modules/env.cmake b/cmake_modules/env.cmake index 0e89ed2b47..e7e0dec376 100644 --- a/cmake_modules/env.cmake +++ b/cmake_modules/env.cmake @@ -55,15 +55,6 @@ if ( NOT DEFINED CMAKE_PREFIX_PATH AND DEFINED ENV{CMAKE_PREFIX_PATH} ) set ( CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH} ) endif() -## Extend Compiler flags based on build type -string ( TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE ) -if ( "${CMAKE_BUILD_TYPE}" STREQUAL debug ) - set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb" ) - set ( CMAKE_BUILD_TYPE "debug" ) -else () - set ( CMAKE_BUILD_TYPE "release" ) -endif () - ## Find hsa-runtime find_package(hsa-runtime64 CONFIG REQUIRED HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm PATH_SUFFIXES lib/cmake/hsa-runtime64 ) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index b0ae391312..9c8e29610e 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -1,5 +1,4 @@ include (CheckCSourceCompiles) - # ############################################################################################################################################ # ############################################################################################################################################ # General Requirements @@ -54,6 +53,7 @@ set_source_files_properties(profiler/application_replay_sample.cpp PROPERTIES HI hip_add_executable(profiler_application_replay profiler/application_replay_sample.cpp ${ROCPROFILER_UTIL_SRC_FILES}) target_include_directories(profiler_application_replay PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/common) target_link_libraries(profiler_application_replay PRIVATE ${ROCPROFILER_TARGET} systemd amd_comgr) +target_link_options(profiler_application_replay PRIVATE "-Wl,--build-id=md5") add_dependencies(samples profiler_application_replay) install(TARGETS profiler_application_replay RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) @@ -62,6 +62,7 @@ set_source_files_properties(profiler/kernel_replay_sample.cpp PROPERTIES HIP_SOU hip_add_executable(profiler_kernel_replay profiler/kernel_replay_sample.cpp ${ROCPROFILER_UTIL_SRC_FILES}) target_include_directories(profiler_kernel_replay PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/common) target_link_libraries(profiler_kernel_replay PRIVATE ${ROCPROFILER_TARGET} systemd amd_comgr) +target_link_options(profiler_kernel_replay PRIVATE "-Wl,--build-id=md5") add_dependencies(samples profiler_kernel_replay) install(TARGETS profiler_kernel_replay RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) @@ -69,6 +70,7 @@ install(TARGETS profiler_kernel_replay RUNTIME DESTINATION ${CMAKE_INSTALL_DATAR set_source_files_properties(profiler/user_replay_sample.cpp PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) hip_add_executable(profiler_user_replay profiler/user_replay_sample.cpp ${ROCPROFILER_UTIL_SRC_FILES}) target_include_directories(profiler_user_replay PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/common) +target_link_options(profiler_user_replay PRIVATE "-Wl,--build-id=md5") target_link_libraries(profiler_user_replay PRIVATE ${ROCPROFILER_TARGET} systemd amd_comgr) add_dependencies(samples profiler_user_replay) install(TARGETS profiler_user_replay RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) @@ -78,6 +80,7 @@ set_source_files_properties(profiler/device_profiling_sample.cpp PROPERTIES HIP_ hip_add_executable(profiler_device_profiling profiler/device_profiling_sample.cpp ${ROCPROFILER_UTIL_SRC_FILES}) target_include_directories(profiler_device_profiling PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/common) target_link_libraries(profiler_device_profiling PRIVATE ${ROCPROFILER_TARGET} systemd amd_comgr) +target_link_options(profiler_device_profiling PRIVATE "-Wl,--build-id=md5") add_dependencies(samples profiler_device_profiling) install(TARGETS profiler_device_profiling RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) @@ -90,6 +93,7 @@ set_source_files_properties(tracer/sample.cpp PROPERTIES HIP_SOURCE_PROPERTY_FOR hip_add_executable(tracer_hip_hsa tracer/sample.cpp ${ROCPROFILER_UTIL_SRC_FILES}) target_include_directories(tracer_hip_hsa PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/common) target_link_libraries(tracer_hip_hsa PRIVATE ${ROCPROFILER_TARGET} systemd amd_comgr) +target_link_options(tracer_hip_hsa PRIVATE "-Wl,--build-id=md5") add_dependencies(samples tracer_hip_hsa) install(TARGETS tracer_hip_hsa RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) @@ -97,40 +101,41 @@ install(TARGETS tracer_hip_hsa RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ # PC Sampling Samples # ############################################################################################################################################ -#set(CODE_PRINTING_SAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/pcsampler/code_printing_sample) -#file(GLOB PC_SAMPLING_CODE_PRINTING_FILES ${CODE_PRINTING_SAMPLE_DIR}/*.cpp) -#set_source_files_properties(${PC_SAMPLING_CODE_PRINTING_FILES} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) -#hip_add_executable(pc_sampling_code_printing ${PC_SAMPLING_CODE_PRINTING_FILES} -# HIPCC_OPTIONS -# -std=c++17 +set(CODE_PRINTING_SAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/pcsampler/code_printing_sample) +file(GLOB PC_SAMPLING_CODE_PRINTING_FILES ${CODE_PRINTING_SAMPLE_DIR}/*.cpp) +set_source_files_properties(${PC_SAMPLING_CODE_PRINTING_FILES} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) +hip_add_executable(pc_sampling_code_printing ${PC_SAMPLING_CODE_PRINTING_FILES} + HIPCC_OPTIONS + -std=c++17 # Include debugging symbols and source for the contextual disassembly -# -gdwarf-4) + -gdwarf-4) -#check_c_source_compiles(" +check_c_source_compiles(" #define _GNU_SOURCE #include - # int main() { return memfd_create (\"cmake_test\", 0); } - #" HAVE_MEMFD_CREATE) - #if (HAVE_MEMFD_CREATE) - #target_compile_definitions(pc_sampling_code_printing PRIVATE HAVE_MEMFD_CREATE) - #endif() + int main() { return memfd_create (\"cmake_test\", 0); } + " HAVE_MEMFD_CREATE) + if (HAVE_MEMFD_CREATE) + target_compile_definitions(pc_sampling_code_printing PRIVATE HAVE_MEMFD_CREATE) + endif() - #target_link_libraries(pc_sampling_code_printing - #PRIVATE - #${ROCPROFILER_TARGET} - #rocm-dbgapi - #${LIBELF_LIBRARIES} - #${LIBDW_LIBRARIES} - #hsa-runtime64::hsa-runtime64 Threads::Threads dl) - #target_include_directories(pc_sampling_code_printing - #PRIVATE - # INTERFACE_INCLUDE_DIRECTORIES - #${TEST_DIR} - #${ROOT_DIR} - #${HSA_RUNTIME_INC_PATH} - #${PROJECT_SOURCE_DIR}) - #add_dependencies(samples pc_sampling_code_printing) -# install(TARGETS pc_sampling_code_printing RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) + target_link_libraries(pc_sampling_code_printing + PRIVATE + ${ROCPROFILER_TARGET} + rocm-dbgapi + ${LIBELF_LIBRARIES} + ${LIBDW_LIBRARIES} + hsa-runtime64::hsa-runtime64 Threads::Threads dl) + target_include_directories(pc_sampling_code_printing + PRIVATE + INTERFACE_INCLUDE_DIRECTORIES + ${TEST_DIR} + ${ROOT_DIR} + ${HSA_RUNTIME_INC_PATH} + ${PROJECT_SOURCE_DIR}) + target_link_options(pc_sampling_code_printing PRIVATE "-Wl,--build-id=md5") + add_dependencies(samples pc_sampling_code_printing) + install(TARGETS pc_sampling_code_printing RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) # ############################################################################################################################################ # Scripts to run samples