Initial skeleton (revised) (#16)

* [0/N] git submodules

* [1/N] Update cmake, gitignore, external

- clang-tidy file
- update .gitignore
- update main CMakeLists.txt
- update external/CMakeLists.txt
- update rocprofiler_config_interfaces.cmake
- update rocprofiler_formatting.cmake
- update rocprofiler_interfaces.cmake
- update rocprofiler_linting.cmake
- update rocprofiler_options.cmake
- update rocprofiler_utilities.cmake

* [2/N] Update rocprofiler/config.h

- update to work with new rocprofiler.h

* [3/N] Update source/lib/rocprofiler/hsa

- hsa-types.h: static asserts
- hsa.cpp: copyTables scope
- hsa.gen.cpp: ACTIVITY_DOMAIN_HSA_API -> ROCPROFILER_TRACER_ACTIVITY_DOMAIN_HSA_API
- rename some files
- add rocprofiler_ prefix to types and enums
- HSA_API_TABLE_LOOKUP_DEFINITION macro
- get_saved_table() -> get_table()

* [4/N] Update source/lib/common

- CMake: change target_link_libraries
- defines.hpp: remove ppdefs defined in include/rocprofiler/defines.h

* [5/N] Update source/lib/rocprofiler

- updates due to changes in rocprofiler.h
- rocprofiler_config.cpp: remove unions which are now defined in include/rocprofiler
- CMakeLists.txt: rocprofiler.cpp and public hsa-runtime and hip libraries
- rocprofiler.cpp: dummy implementations for:
  - rocprofiler_query_available_agents
  - rocprofiler_create_context
  - rocprofiler_start_context
  - rocprofiler_stop_context
  - rocprofiler_flush_buffer
  - rocprofiler_destroy_buffer

* [6/N] Update license

- replace stale LBNL license

* [7/N] CMake format
This commit is contained in:
Jonathan R. Madsen
2023-08-22 13:29:11 -05:00
committed by GitHub
parent 527aa71f5a
commit 351d825a8d
38 changed files with 937 additions and 5686 deletions
+7 -3
View File
@@ -9,12 +9,16 @@ include_guard(DIRECTORY)
target_include_directories(
rocprofiler-headers
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source/include>
INTERFACE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/source/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# include threading because of rooflines
target_link_libraries(rocprofiler-headers INTERFACE rocprofiler::rocprofiler-threading)
target_compile_definitions(
rocprofiler-headers
INTERFACE $<BUILD_INTERFACE:AMD_INTERNAL_BUILD=1> $<BUILD_INTERFACE:PROF_API_IMPL=1>
$<BUILD_INTERFACE:HIP_PROF_HIP_API_STRING=1>
$<BUILD_INTERFACE:__HIP_PLATFORM_AMD__=1>)
# ensure the env overrides the appending /opt/rocm later
string(REPLACE ":" ";" CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH};${CMAKE_PREFIX_PATH}")
+8 -6
View File
@@ -42,12 +42,14 @@ if(ROCPROFILER_CLANG_FORMAT_EXE
set(${_TYPE})
endforeach()
file(GLOB_RECURSE header_files ${PROJECT_SOURCE_DIR}/${_DIR}/*.h
${PROJECT_SOURCE_DIR}/${_DIR}/*.hpp)
${PROJECT_SOURCE_DIR}/${_DIR}/*.hpp ${PROJECT_SOURCE_DIR}/${_DIR}/*.h.in
${PROJECT_SOURCE_DIR}/${_DIR}/*.hpp.in)
file(GLOB_RECURSE source_files ${PROJECT_SOURCE_DIR}/${_DIR}/*.c
${PROJECT_SOURCE_DIR}/${_DIR}/*.cpp)
file(GLOB_RECURSE cmake_files ${PROJECT_SOURCE_DIR}/${_DIR}/*CMakeLists.txt
${PROJECT_SOURCE_DIR}/${_DIR}/*.cmake)
file(GLOB_RECURSE python_files ${PROJECT_SOURCE_DIR}/${_DIR}/*.py)
file(GLOB_RECURSE python_files ${PROJECT_SOURCE_DIR}/${_DIR}/*.py
${PROJECT_SOURCE_DIR}/${_DIR}/*.py.in)
foreach(_TYPE header_files source_files cmake_files python_files)
list(APPEND rocp_${_TYPE} ${${_TYPE}})
endforeach()
@@ -69,12 +71,12 @@ if(ROCPROFILER_CLANG_FORMAT_EXE
)
endif()
if(ROCPROFILER_BLACK_FORMAT_EXE)
if(ROCPROFILER_BLACK_FORMAT_EXE AND rocp_python_files)
add_custom_target(
format-rocprofiler-python
${ROCPROFILER_BLACK_FORMAT_EXE} -q ${rocp_python_files}
COMMENT
"[rocprofiler] Running Python formatter ${ROCPROFILER_BLACK_FORMAT_EXE}..."
"[rocprofiler] Running python formatter ${ROCPROFILER_BLACK_FORMAT_EXE}..."
)
endif()
@@ -83,7 +85,7 @@ if(ROCPROFILER_CLANG_FORMAT_EXE
format-rocprofiler-cmake
${ROCPROFILER_CMAKE_FORMAT_EXE} -i ${rocp_cmake_files}
COMMENT
"[rocprofiler] Running CMake formatter ${ROCPROFILER_CMAKE_FORMAT_EXE}..."
"[rocprofiler] Running cmake formatter ${ROCPROFILER_CMAKE_FORMAT_EXE}..."
)
endif()
@@ -94,7 +96,7 @@ if(ROCPROFILER_CLANG_FORMAT_EXE
endif()
endforeach()
foreach(_TYPE source python)
foreach(_TYPE source python cmake)
if(TARGET format-rocprofiler-${_TYPE})
add_dependencies(format format-rocprofiler-${_TYPE})
endif()
+26 -19
View File
@@ -12,33 +12,40 @@ include(rocprofiler_utilities)
rocprofiler_add_interface_library(
rocprofiler-headers
"Provides minimal set of include flags to compile with rocprofiler")
rocprofiler_add_interface_library(rocprofiler-build-flags
"Provides generalized build flags for rocprofiler")
rocprofiler_add_interface_library(rocprofiler-threading "Enables multithreading support")
rocprofiler_add_interface_library(rocprofiler-perfetto "Enables Perfetto support")
rocprofiler_add_interface_library(rocprofiler-compile-definitions "Compile definitions")
rocprofiler_add_interface_library(
rocprofiler-build-flags "Provides generalized build flags for rocprofiler" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-threading "Enables multithreading support"
INTERNAL)
rocprofiler_add_interface_library(rocprofiler-perfetto "Enables Perfetto support"
INTERNAL)
rocprofiler_add_interface_library(rocprofiler-compile-definitions "Compile definitions"
INTERNAL)
rocprofiler_add_interface_library(rocprofiler-static-libgcc
"Link to static version of libgcc")
"Link to static version of libgcc" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-static-libstdcxx
"Link to static version of libstdc++")
rocprofiler_add_interface_library(rocprofiler-developer-flags
"Compiler flags for developers (more warnings, etc.)")
"Link to static version of libstdc++" INTERNAL)
rocprofiler_add_interface_library(
rocprofiler-developer-flags "Compiler flags for developers (more warnings, etc.)"
INTERNAL)
rocprofiler_add_interface_library(rocprofiler-debug-flags
"Compiler flags for more debug info")
"Compiler flags for more debug info" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-release-flags
"Compiler flags for more debug info")
"Compiler flags for more debug info" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-stack-protector
"Adds stack-protector compiler flags")
rocprofiler_add_interface_library(rocprofiler-memcheck INTERFACE)
"Adds stack-protector compiler flags" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-memcheck INTERFACE INTERNAL)
#
# interfaces for libraries
#
rocprofiler_add_interface_library(rocprofiler-dl
"Build flags for dynamic linking library")
rocprofiler_add_interface_library(rocprofiler-rt "Build flags for runtime library")
rocprofiler_add_interface_library(rocprofiler-hip "HIP library")
rocprofiler_add_interface_library(rocprofiler-hsa-runtime "HSA runtime library")
rocprofiler_add_interface_library(rocprofiler-amd-comgr "AMD comgr library")
rocprofiler_add_interface_library(rocprofiler-googletest "Google Test library" INTERNAL)
"Build flags for dynamic linking library" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-rt "Build flags for runtime library"
INTERNAL)
rocprofiler_add_interface_library(rocprofiler-hip "HIP library" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-hsa-runtime "HSA runtime library" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-amd-comgr "AMD comgr library" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-gtest "Google Test library" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-glog "Google Log library" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-fmt "C++ format string library" INTERNAL)
rocprofiler_add_interface_library(rocprofiler-stdcxxfs "C++ filesystem library" INTERNAL)
+15 -3
View File
@@ -6,7 +6,17 @@ include_guard(GLOBAL)
#
# ----------------------------------------------------------------------------------------#
find_program(ROCPROFILER_CLANG_TIDY_COMMAND NAMES clang-tidy)
find_program(
ROCPROFILER_CLANG_TIDY_COMMAND
NAMES clang-tidy-18
clang-tidy-17
clang-tidy-16
clang-tidy-15
clang-tidy-14
clang-tidy-13
clang-tidy-12
clang-tidy-11
clang-tidy)
macro(ROCPROFILER_ACTIVATE_CLANG_TIDY)
if(ROCPROFILER_ENABLE_CLANG_TIDY)
@@ -16,8 +26,10 @@ macro(ROCPROFILER_ACTIVATE_CLANG_TIDY)
"ROCPROFILER_ENABLE_CLANG_TIDY is ON but clang-tidy is not found!")
endif()
set(CMAKE_CXX_CLANG_TIDY ${ROCPROFILER_CLANG_TIDY_COMMAND}
-header-filter=${PROJECT_SOURCE_DIR}/.*)
set(CMAKE_CXX_CLANG_TIDY
${ROCPROFILER_CLANG_TIDY_COMMAND}
-header-filter=${PROJECT_SOURCE_DIR}/source/.*
--warnings-as-errors=*,-misc-header-include-cycle)
# Create a preprocessor definition that depends on .clang-tidy content so the
# compile command will change when .clang-tidy changes. This ensures that a
+39 -14
View File
@@ -3,23 +3,41 @@
#
# Configure miscellaneous settings
#
# standard cmake options
rocprofiler_add_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
rocprofiler_add_option(BUILD_STATIC_LIBS "Build static libraries" OFF)
rocprofiler_add_option(CMAKE_POSITION_INDEPENDENT_CODE "Build position independent code"
ON)
include_guard(GLOBAL)
# export compile commands in the project
# export compile commands of the project. Many IDEs want the compile_commands.json in root
# directory so run ln -s <build>/compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# C settings
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_VISIBILITY_PRESET "hidden")
# C++ settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
# general settings affecting build
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
set(CMAKE_UNITY_BUILD OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
rocprofiler_add_option(ROCPROFILER_BUILD_TESTS "Enable building the tests" OFF)
rocprofiler_add_option(ROCPROFILER_BUILD_SAMPLES "Enable building the code samples" OFF)
rocprofiler_add_feature(CMAKE_BUILD_TYPE "Build type")
rocprofiler_add_feature(CMAKE_INSTALL_PREFIX "Install prefix")
# standard cmake options
rocprofiler_add_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
# rocprofiler_add_option(BUILD_STATIC_LIBS "Build static libraries" OFF)
rocprofiler_add_option(
ROCPROFILER_BUILD_CI "Enable continuous integration default values for options" OFF
ADVANCED)
rocprofiler_add_option(ROCPROFILER_BUILD_TESTS "Enable building the tests"
${ROCPROFILER_BUILD_CI})
rocprofiler_add_option(ROCPROFILER_BUILD_SAMPLES "Enable building the code samples"
${ROCPROFILER_BUILD_CI})
# CLI and FILE plugins are always built
foreach(_PLUGIN "ATT" "CTF" "PERFETTO")
@@ -27,19 +45,26 @@ foreach(_PLUGIN "ATT" "CTF" "PERFETTO")
"Enable building the ${_PLUGIN} plugin" ON)
endforeach()
rocprofiler_add_option(ROCPROFILER_BUILD_FMT "Enable building fmt library internally" ON)
rocprofiler_add_option(ROCPROFILER_BUILD_GLOG
"Enable building glog (Google logging) library internally" ON)
if(ROCPROFILER_BUILD_TESTS)
rocprofiler_add_option(
ROCPROFILER_BUILD_GTEST
"Enable building gtest (Google testing) library internally" ON ADVANCED)
endif()
rocprofiler_add_option(ROCPROFILER_DEBUG_TRACE "Enable debug tracing" OFF ADVANCED)
rocprofiler_add_option(ROCPROFILER_LD_AQLPROFILE
"Enable direct loading of AQL-profile HSA extension" OFF ADVANCED)
rocprofiler_add_option(ROCPROFILER_BUILD_CI "Enable continuous integration additions" OFF
ADVANCED)
rocprofiler_add_option(ROCPROFILER_ENABLE_CLANG_TIDY "Enable clang-tidy checks" OFF
ADVANCED)
rocprofiler_add_option(ROCPROFILER_BUILD_WERROR "Any compiler warnings are errors" OFF
ADVANCED)
rocprofiler_add_option(
ROCPROFILER_BUILD_DEVELOPER "Extra build flags for development like -Werror"
${ROCPROFILER_BUILD_CI} ADVANCED)
rocprofiler_add_option(ROCPROFILER_BUILD_WERROR "Any compiler warnings are errors"
${ROCPROFILER_BUILD_CI} ADVANCED)
rocprofiler_add_option(ROCPROFILER_BUILD_RELEASE "Build with minimal debug info" OFF
ADVANCED)
rocprofiler_add_option(ROCPROFILER_BUILD_DEBUG "Build with extra debug info" OFF ADVANCED)
@@ -48,10 +73,10 @@ rocprofiler_add_option(ROCPROFILER_BUILD_STATIC_LIBGCC
rocprofiler_add_option(ROCPROFILER_BUILD_STATIC_LIBSTDCXX
"Build with -static-libstdc++ if possible" OFF ADVANCED)
rocprofiler_add_option(ROCPROFILER_BUILD_STACK_PROTECTOR "Build with -fstack-protector"
OFF ADVANCED)
ON ADVANCED)
# In the future, we will do this even with clang-tidy enabled
if(ROCPROFILER_BUILD_CI AND NOT ROCPROFILER_ENABLE_CLANG_TIDY)
if(ROCPROFILER_BUILD_CI AND NOT ROCPROFILER_BUILD_WERROR)
message(STATUS "Forcing ROCPROFILER_BUILD_WERROR=ON because ROCPROFILER_BUILD_CI=ON")
set(ROCPROFILER_BUILD_WERROR
ON
+38 -23
View File
@@ -204,11 +204,6 @@ function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE)
set(CHECKOUT_TEST_FILE "CMakeLists.txt")
endif()
# default assumption
if(NOT CHECKOUT_REPO_BRANCH)
set(CHECKOUT_REPO_BRANCH "master")
endif()
find_package(Git)
set(_DIR "${CHECKOUT_WORKING_DIRECTORY}/${CHECKOUT_RELATIVE_PATH}")
# ensure the (possibly empty) directory exists
@@ -267,7 +262,9 @@ function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE)
if(NOT _TEST_FILE_EXISTS AND _HAS_REPO_URL)
message(
STATUS "Checking out '${CHECKOUT_REPO_URL}' @ '${CHECKOUT_REPO_BRANCH}'...")
STATUS
"Cloning '${CHECKOUT_REPO_URL}' into ${CHECKOUT_WORKING_DIRECTORY}/${CHECKOUT_RELATIVE_PATH}..."
)
# remove the existing directory
if(EXISTS "${_DIR}")
@@ -276,11 +273,33 @@ function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE)
# perform the checkout
execute_process(
COMMAND
${GIT_EXECUTABLE} clone -b ${CHECKOUT_REPO_BRANCH}
${CHECKOUT_ADDITIONAL_CMDS} ${CHECKOUT_REPO_URL} ${CHECKOUT_RELATIVE_PATH}
COMMAND ${GIT_EXECUTABLE} clone ${CHECKOUT_ADDITIONAL_CMDS}
${CHECKOUT_REPO_URL} ${CHECKOUT_RELATIVE_PATH}
WORKING_DIRECTORY ${CHECKOUT_WORKING_DIRECTORY}
RESULT_VARIABLE RET)
RESULT_VARIABLE RET_CLONE)
if(NOT RET_CLONE EQUAL 0)
message(
SEND_ERROR
"Failed to clone ${CHECKOUT_REPO_URL} into ${CHECKOUT_WORKING_DIRECTORY}/${CHECKOUT_RELATIVE_PATH}"
)
return()
endif()
if(CHECKOUT_REPO_BRANCH)
execute_process(
COMMAND ${GIT_EXECUTABLE} checkout ${CHECKOUT_REPO_BRANCH}
WORKING_DIRECTORY ${CHECKOUT_WORKING_DIRECTORY}/${CHECKOUT_RELATIVE_PATH}
RESULT_VARIABLE RET_BRANCH)
if(NOT RET_BRANCH EQUAL 0)
message(
SEND_ERROR
"Failed to checkout '${CHECKOUT_REPO_BRANCH}' for ${CHECKOUT_REPO_URL} in ${CHECKOUT_WORKING_DIRECTORY}/${CHECKOUT_RELATIVE_PATH}"
)
return()
endif()
endif()
# perform the submodule update
if(CHECKOUT_RECURSIVE
@@ -289,20 +308,17 @@ function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init ${_RECURSE}
WORKING_DIRECTORY ${_DIR}
RESULT_VARIABLE RET)
RESULT_VARIABLE RET_RECURSIVE)
if(NOT RET_RECURSIVE EQUAL 0)
message(
SEND_ERROR
"Failed to update submodules for ${CHECKOUT_REPO_URL} in ${CHECKOUT_WORKING_DIRECTORY}/${CHECKOUT_RELATIVE_PATH}"
)
return()
endif()
endif()
# check the return code
if(RET GREATER 0)
set(_CMD
"${GIT_EXECUTABLE} clone -b ${CHECKOUT_REPO_BRANCH}
${CHECKOUT_ADDITIONAL_CMDS} ${CHECKOUT_REPO_URL} ${CHECKOUT_RELATIVE_PATH}"
)
message(STATUS "function(rocprofiler_checkout_git_submodule) failed.")
message(FATAL_ERROR "Command: \"${_CMD}\"")
else()
set(_TEST_FILE_EXISTS ON)
endif()
set(_TEST_FILE_EXISTS ON)
endif()
if(NOT EXISTS "${_TEST_FILE}" OR NOT _TEST_FILE_EXISTS)
@@ -310,7 +326,6 @@ function(ROCPROFILER_CHECKOUT_GIT_SUBMODULE)
FATAL_ERROR
"Error checking out submodule: '${CHECKOUT_RELATIVE_PATH}' to '${_DIR}'")
endif()
endfunction()
# ----------------------------------------------------------------------------------------#