Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Profiling, main branch (2024.09.22.) #713

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,46 @@ if(${TRACCC_BUILD_HIP} AND ${CMAKE_HIP_STANDARD} LESS 20)
message(SEND_ERROR "CMAKE_HIP_STANDARD=${CMAKE_HIP_STANDARD}, but traccc requires C++>=20")
endif()

# Set up build profiling for the project.
if( CTEST_USE_LAUNCHERS )

# Find the bash and time executables.
find_program( BASH_EXECUTABLE bash REQUIRED )
find_program( TIME_EXECUTABLE time REQUIRED )

# Decide what flag to use with the time executable to make it print verbose
# information.
if( "${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Darwin" )
set( TIME_VERBOSE_FLAG "-l" )
elseif( "${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Linux" )
set( TIME_VERBOSE_FLAG "-v" )
else()
message( WARNING "Build profiling is only supported on Linux and macOS."
"This build will likely fail." )
set( TIME_VERBOSE_FLAG "" )
endif()

# Configure the script that would intercept the build commands and save
# profile logs for them.
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/traccc-ctest.sh.in"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/traccc-ctest.sh"
@ONLY )
set( CMAKE_CTEST_COMMAND
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/traccc-ctest.sh" )

# Clean up.
unset( TIME_VERBOSE_FLAG )

# Remove the performance log during a cleaning step.
set_property( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_BINARY_DIR}/traccc_build_performance.log" )

# Let the user know what happened.
message( STATUS
"Saving traccc build performance logs using: ${CMAKE_CTEST_COMMAND}" )
endif()

# Set up VecMem.
option( TRACCC_SETUP_VECMEM
"Set up the VecMem target(s) explicitly" TRUE )
Expand Down
17 changes: 17 additions & 0 deletions cmake/traccc-ctest.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!@BASH_EXECUTABLE@
#
# TRACCC library, part of the ACTS project (R&D line)
#
# (c) 2024 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

# Propagate errors.
set -e
set -o pipefail

# Run every command through the time command. Recording the time, memory, etc.
# used by each and every build command.
command @TIME_EXECUTABLE@ @TIME_VERBOSE_FLAG@ \
-ao @CMAKE_CURRENT_BINARY_DIR@/traccc_build_performance.log \
@CMAKE_CTEST_COMMAND@ $*
Loading