From 79852fe22a549090447e3dffc2357e2f2e6ced1a Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 15:26:02 +0200 Subject: [PATCH 01/26] Bump DAC version --- cmake/docs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/docs.cmake b/cmake/docs.cmake index 6be5340..3f2f789 100644 --- a/cmake/docs.cmake +++ b/cmake/docs.cmake @@ -17,7 +17,7 @@ include(FetchContent) FetchContent_Declare( dac_content GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css.git - GIT_TAG v1.6.1 + GIT_TAG v2.0.3 GIT_SHALLOW) FetchContent_GetProperties(dac_content) From 5400a5bd0be256058293485896fb4a9fa66733c6 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 15:26:35 +0200 Subject: [PATCH 02/26] Moved internal API into benchmarking.cmake --- benchmarking.cmake | 51 ++++++++++++++++++++++++++++++++++++++------ cmake/internal.cmake | 30 -------------------------- 2 files changed, 45 insertions(+), 36 deletions(-) delete mode 100644 cmake/internal.cmake diff --git a/benchmarking.cmake b/benchmarking.cmake index c165fe4..fac9903 100644 --- a/benchmarking.cmake +++ b/benchmarking.cmake @@ -1,5 +1,46 @@ +#! ctbench - CMake documentation + +## ============================================================================= +#@ +#@ ## Internal API +#@ +## ============================================================================= + +## ============================================================================= +#@ +#@ _ctbench_internal_add_compile_benchmark +#@ +#@ Creates a library target for a file and extracts the compilation time trace +#@ file. +#@ +#@ - `target_name`: Name of the benchmark target +#@ - `output`: Time trace output path +#@ - `file`: Source file +#@ - `size`: Sets BENCHMARK_SIZE define (can be something else than a number) +#@ - `options`: Options passed to the compiler + +function(_ctbench_internal_add_compile_benchmark target_name output source + options) + + add_library(${target_name} OBJECT EXCLUDE_FROM_ALL ${source}) + target_include_directories(${target_name} PUBLIC "../include") + + # Setting time-trace-wrapper as a compiler launcher + set_target_properties( + ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER + "${CTBENCH_TIME_TRACE_WRAPPER_EXEC};${output}") + + # Adding dependency because CMake won't + add_dependencies(${target_name} time-trace-wrapper) + + # Pass benchmark size + target_compile_options(${target_name} PRIVATE ${options}) + +endfunction(_ctbench_internal_add_compile_benchmark) + ## ============================================================================= -#! # CMake API +#! +#! ## Public API #! #! Functions for automated benchmark declarations. #! @@ -14,9 +55,8 @@ add_custom_target(ctbench-graph-all) -include(cmake/internal.cmake) - ## ============================================================================= +#! #! ## ctbench_add_benchmark #! #! Add a benchmark for a given source, with a given size range. @@ -25,7 +65,6 @@ include(cmake/internal.cmake) #! - `source`: Source file #! - `begin, end, step`: Iteration parameters #! - `samples`: Number of samples per iteration -#! function( ctbench_add_benchmark @@ -57,6 +96,7 @@ function( endfunction(ctbench_add_benchmark) ## ============================================================================= +#! #! ## ctbench_add_custom_benchmark #! #! Add a benchmark for a given source with a given size range @@ -68,7 +108,6 @@ endfunction(ctbench_add_benchmark) #! - `iterations`: Number of benchmark iterations for a given size #! - `generator`: Compile option generator. Takes a size and an output #! variable name as parameters. -#! function( ctbench_add_custom_benchmark @@ -101,6 +140,7 @@ function( endfunction(ctbench_add_custom_benchmark) ## ============================================================================= +#! #! ## ctbench_add_graph #! #! Adds a graph target for a set of benchmarks, @@ -110,7 +150,6 @@ endfunction(ctbench_add_custom_benchmark) #! target, and the folder where the graphs will be saved. #! - `config`: Config file for plotting #! - `benchmarks`: List of benchmark names -#! function(ctbench_add_graph category config) set(config_path ${CMAKE_CURRENT_SOURCE_DIR}/${config}) diff --git a/cmake/internal.cmake b/cmake/internal.cmake deleted file mode 100644 index c924bdd..0000000 --- a/cmake/internal.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# Creates a library target for a file and extracts the compilation time trace -# file. -# -# * target_name: Name of the benchmark target -# * output: Time trace output path -# * file: Source file -# * size: Sets BENCHMARK_SIZE define (can be something else than a number) -# * options: Options passed to the compiler - -function(_ctbench_internal_add_compile_benchmark target_name output source - options) - - add_library(${target_name} OBJECT EXCLUDE_FROM_ALL ${source}) - target_include_directories(${target_name} PUBLIC "../include") - - # Setting time-trace-wrapper as a compiler launcher - set_target_properties( - ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER - "${CTBENCH_TIME_TRACE_WRAPPER_EXEC};${output}") - - # Adding dependency because CMake won't - add_dependencies(${target_name} time-trace-wrapper) - - # Pass benchmark size - target_compile_options(${target_name} PRIVATE ${options}) - - # Boost Preprocessor - target_include_directories(${target_name} PUBLIC Boost_INCLUDE_DIRS) - -endfunction(_ctbench_internal_add_compile_benchmark) From c59ad087922426453b959e3a835450c0fef32299 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 16:21:19 +0200 Subject: [PATCH 03/26] Shiny docs --- benchmarking.cmake | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/benchmarking.cmake b/benchmarking.cmake index fac9903..ea8e6bc 100644 --- a/benchmarking.cmake +++ b/benchmarking.cmake @@ -1,4 +1,4 @@ -#! ctbench - CMake documentation +#! # CMake documentation ## ============================================================================= #@ @@ -15,8 +15,7 @@ #@ #@ - `target_name`: Name of the benchmark target #@ - `output`: Time trace output path -#@ - `file`: Source file -#@ - `size`: Sets BENCHMARK_SIZE define (can be something else than a number) +#@ - `source`: Source file #@ - `options`: Options passed to the compiler function(_ctbench_internal_add_compile_benchmark target_name output source @@ -25,13 +24,13 @@ function(_ctbench_internal_add_compile_benchmark target_name output source add_library(${target_name} OBJECT EXCLUDE_FROM_ALL ${source}) target_include_directories(${target_name} PUBLIC "../include") - # Setting time-trace-wrapper as a compiler launcher + # Setting ctbench-ttw as a compiler launcher set_target_properties( ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER "${CTBENCH_TIME_TRACE_WRAPPER_EXEC};${output}") # Adding dependency because CMake won't - add_dependencies(${target_name} time-trace-wrapper) + add_dependencies(${target_name} ctbench-ttw) # Pass benchmark size target_compile_options(${target_name} PRIVATE ${options}) @@ -47,17 +46,20 @@ endfunction(_ctbench_internal_add_compile_benchmark) ## ============================================================================= ## ============================================================================= -#! ## ctbench-graph-all target +#! +#! ### ctbench-graph-all target #! #! `ctbench-graph-all` is a ctbench-provided target to generate all graphs #! at once. -#! add_custom_target(ctbench-graph-all) +#! +#! -- + ## ============================================================================= #! -#! ## ctbench_add_benchmark +#! ### ctbench_add_benchmark(name source begin end step samples) #! #! Add a benchmark for a given source, with a given size range. #! @@ -95,9 +97,12 @@ function( endfunction(ctbench_add_benchmark) +#! +#! -- + ## ============================================================================= #! -#! ## ctbench_add_custom_benchmark +#! ### ctbench_add_custom_benchmark(name source begin end step iterations generator) #! #! Add a benchmark for a given source with a given size range #! using a custom compile options generator. @@ -139,9 +144,12 @@ function( endfunction(ctbench_add_custom_benchmark) +#! +#! -- + ## ============================================================================= #! -#! ## ctbench_add_graph +#! ### ctbench_add_graph(category config benchmarks...) #! #! Adds a graph target for a set of benchmarks, #! and adds the target to ctbench-graph-all. @@ -149,7 +157,7 @@ endfunction(ctbench_add_custom_benchmark) #! - `category`: Name of the category. This is also the name of the graph #! target, and the folder where the graphs will be saved. #! - `config`: Config file for plotting -#! - `benchmarks`: List of benchmark names +#! - `benchmarks...`: List of benchmark names function(ctbench_add_graph category config) set(config_path ${CMAKE_CURRENT_SOURCE_DIR}/${config}) @@ -160,3 +168,5 @@ function(ctbench_add_graph category config) WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_dependencies(ctbench-graph-all ${category}) endfunction(ctbench_add_graph) +#! +#! -- From 8a7e089ae7e9f172783d5bf33bdfd3a47c572302 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 16:52:35 +0200 Subject: [PATCH 04/26] Major CMake overhaul in preparation for an installable ctbench first version --- CMakeLists.txt | 16 +----- grapher/CMakeLists.txt | 34 ++++++------ grapher/cmake/libraries_fetch.cmake | 53 ------------------- grapher/cmake/libraries_local.cmake | 16 ------ .../src/main.cpp => grapher-plot.cpp} | 0 grapher/grapher-plot/CMakeLists.txt | 6 --- .../src/main.cpp => grapher-utils.cpp} | 0 grapher/grapher-utils/CMakeLists.txt | 6 --- time-trace-wrapper/CMakeLists.txt | 22 +++----- 9 files changed, 25 insertions(+), 128 deletions(-) delete mode 100644 grapher/cmake/libraries_fetch.cmake delete mode 100644 grapher/cmake/libraries_local.cmake rename grapher/{grapher-plot/src/main.cpp => grapher-plot.cpp} (100%) delete mode 100644 grapher/grapher-plot/CMakeLists.txt rename grapher/{grapher-utils/src/main.cpp => grapher-utils.cpp} (100%) delete mode 100644 grapher/grapher-utils/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2152738..e1e950a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,6 @@ project(ctbench) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_STANDARD 20) -# Project options -option(CTBENCH_ENABLE_TESTING "Enable testing for ctbench components." OFF) - -option(CTBENCH_FETCH_LIBRARIES - "Fetch libraries instead of using the ones installed locally." OFF) - add_compile_options( -Wall -Wextra @@ -21,21 +15,13 @@ add_compile_options( add_compile_options(-fno-rtti -fno-exceptions) -add_subdirectory(time-trace-wrapper) - # Docs if(${PROJECT_IS_TOP_LEVEL}) add_subdirectory(cmake-doc-extractor) include(cmake/docs.cmake) endif() -# Exporting time-trace-wrapper exec path to parent scope if needed -if(NOT ${PROJECT_IS_TOP_LEVEL}) - set(CTBENCH_TIME_TRACE_WRAPPER_EXEC - ${CTBENCH_TIME_TRACE_WRAPPER_EXEC} - PARENT_SCOPE) -endif() - +add_subdirectory(time-trace-wrapper) add_subdirectory(grapher) include(benchmarking.cmake) diff --git a/grapher/CMakeLists.txt b/grapher/CMakeLists.txt index 13434d2..1ccf794 100644 --- a/grapher/CMakeLists.txt +++ b/grapher/CMakeLists.txt @@ -1,19 +1,16 @@ -# Creating the grapher library +# Declaring the grapher library + file(GLOB_RECURSE GRAPHER_SOURCES lib/*.cpp) add_library(grapher STATIC ${GRAPHER_SOURCES}) target_include_directories(grapher PUBLIC include) -if(CTBENCH_FETCH_LIBRARIES) - include(cmake/libraries_fetch.cmake) -else() - include(cmake/libraries_local.cmake) -endif() - -# LLVM +find_package(nlohmann_json 3.9.1 REQUIRED) +find_package(sciplot REQUIRED) find_package(LLVM REQUIRED CONFIG) + llvm_map_components_to_libnames(llvm_libs core support) -#target_compile_options(grapher PUBLIC -fno-rtti) -target_link_libraries(grapher PUBLIC ${llvm_libs}) + +target_link_libraries(grapher PUBLIC nlohmann_json::nlohmann_json sciplot::sciplot stdc++fs tbb ${llvm_libs}) target_compile_options( grapher @@ -23,16 +20,17 @@ target_compile_options( -Wnull-dereference -Wold-style-cast -Wdouble-promotion - -Wshadow) + -Wshadow + -fno-rtti) + +# Adding executables -# Old libstdc++ compatibility -target_link_libraries(grapher PUBLIC stdc++fs) -target_link_libraries(grapher PUBLIC tbb) +add_executable(ctbench-grapher-plot grapher-plot.cpp) +target_link_libraries(ctbench-grapher-plot PRIVATE grapher) -# Adding executable subdirectories -add_subdirectory(grapher-plot) -add_subdirectory(grapher-utils) +add_executable(ctbench-grapher-utils grapher-utils.cpp) +target_link_libraries(ctbench-grapher-utils PRIVATE grapher) -if(CTBENCH_ENABLE_TESTING) +if(BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/grapher/cmake/libraries_fetch.cmake b/grapher/cmake/libraries_fetch.cmake deleted file mode 100644 index 9ef3e27..0000000 --- a/grapher/cmake/libraries_fetch.cmake +++ /dev/null @@ -1,53 +0,0 @@ -# ============================================================================== -# nlohmann::json - -set(JSON_BuildTests OFF) -set(JSON_Install OFF) -set(JSON_MultipleHeaders ON) -set(JSON_ImplicitConversions ON) -set(JSON_Diagnostics ON) -set(JSON_CI OFF) - -FetchContent_Declare( - json_content - GIT_REPOSITORY https://github.com/nlohmann/json.git - GIT_TAG v3.9.1 - GIT_SHALLOW) - -FetchContent_MakeAvailable(json_content) - -target_link_libraries(grapher PUBLIC nlohmann_json::nlohmann_json) - -# ============================================================================== -# Sciplot - -FetchContent_Declare( - sciplot_content - GIT_REPOSITORY https://github.com/sciplot/sciplot.git - GIT_TAG master - GIT_SHALLOW) - -FetchContent_GetProperties(sciplot_content) -if(NOT sciplot_content_POPULATED) - FetchContent_Populate(sciplot_content) -endif() - -target_include_directories(grapher PUBLIC ${sciplot_content_SOURCE_DIR}) - -# ============================================================================== -# TTS - -if(CTBENCH_ENABLE_TESTING) - FetchContent_Declare( - tts_content - GIT_REPOSITORY https://github.com/jfalcou/tts.git - GIT_TAG 1.0 - GIT_SHALLOW) - - FetchContent_GetProperties(tts_content) - if(NOT tts_content_POPULATED) - FetchContent_Populate(tts_content) - endif() - - target_include_directories(grapher PUBLIC ${tts_content_SOURCE_DIR}/include) -endif() diff --git a/grapher/cmake/libraries_local.cmake b/grapher/cmake/libraries_local.cmake deleted file mode 100644 index 9fb1a46..0000000 --- a/grapher/cmake/libraries_local.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# ============================================================================== -# nlohmann::json - -find_package(nlohmann_json 3.9.1 REQUIRED) -target_link_libraries(grapher PUBLIC nlohmann_json::nlohmann_json) - -# ============================================================================== -# Sciplot - -find_package(sciplot REQUIRED) -target_link_libraries(grapher PUBLIC sciplot::sciplot) - -# ============================================================================== -# TTS - -# https://jfalcou.github.io/tts/index.html#buildandsetup diff --git a/grapher/grapher-plot/src/main.cpp b/grapher/grapher-plot.cpp similarity index 100% rename from grapher/grapher-plot/src/main.cpp rename to grapher/grapher-plot.cpp diff --git a/grapher/grapher-plot/CMakeLists.txt b/grapher/grapher-plot/CMakeLists.txt deleted file mode 100644 index 779edf0..0000000 --- a/grapher/grapher-plot/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB_RECURSE GRAPHER_PLOT_SOURCES src/*.cpp) - -add_executable(grapher-plot ${GRAPHER_PLOT_SOURCES}) - -target_link_libraries(grapher-plot PRIVATE grapher) -target_include_directories(grapher-plot PRIVATE include) diff --git a/grapher/grapher-utils/src/main.cpp b/grapher/grapher-utils.cpp similarity index 100% rename from grapher/grapher-utils/src/main.cpp rename to grapher/grapher-utils.cpp diff --git a/grapher/grapher-utils/CMakeLists.txt b/grapher/grapher-utils/CMakeLists.txt deleted file mode 100644 index 024b92f..0000000 --- a/grapher/grapher-utils/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB_RECURSE GRAPHER_UTILS_SOURCES src/*.cpp) - -add_executable(grapher-utils ${GRAPHER_UTILS_SOURCES}) - -target_link_libraries(grapher-utils PRIVATE grapher) -target_include_directories(grapher-utils PRIVATE include) diff --git a/time-trace-wrapper/CMakeLists.txt b/time-trace-wrapper/CMakeLists.txt index 0e1d8e7..c6a00c6 100644 --- a/time-trace-wrapper/CMakeLists.txt +++ b/time-trace-wrapper/CMakeLists.txt @@ -1,18 +1,12 @@ -cmake_minimum_required(VERSION 3.18) -project(time-trace-wrapper) - -set(CMAKE_CXX_STANDARD 20) - -# time-trace-wrapper -add_executable(time-trace-wrapper time-trace-wrapper.cpp) -target_include_directories(time-trace-wrapper PUBLIC include/) +add_executable(ctbench-ttw time-trace-wrapper.cpp) +target_include_directories(ctbench-ttw PUBLIC include) set(CTBENCH_TIME_TRACE_WRAPPER_EXEC - "${PROJECT_BINARY_DIR}/time-trace-wrapper" + "${PROJECT_BINARY_DIR}/ctbench-ttw" PARENT_SCOPE) -if(CTBENCH_ENABLE_TESTING) - add_executable(time-trace-wrapper-test-exec tests/time-trace-wrapper.cpp) - add_test(NAME time-trace-wrapper-test COMMAND time-trace-wrapper-test-exec) - target_include_directories(time-trace-wrapper-test-exec PUBLIC include/) -endif(CTBENCH_ENABLE_TESTING) +if(BUILD_TESTING) + add_executable(ctbench-ttw-test-exec tests/time-trace-wrapper.cpp) + target_include_directories(ctbench-ttw-test-exec PUBLIC include) + add_test(NAME ctbench-ttw-test COMMAND ctbench-ttw-test-exec) +endif(BUILD_TESTING) From b3a3c173bace511ecabd0b199f0a2782508937fe Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 16:53:51 +0200 Subject: [PATCH 05/26] Command name change --- benchmarking.cmake | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/benchmarking.cmake b/benchmarking.cmake index ea8e6bc..8af57e7 100644 --- a/benchmarking.cmake +++ b/benchmarking.cmake @@ -38,11 +38,9 @@ function(_ctbench_internal_add_compile_benchmark target_name output source endfunction(_ctbench_internal_add_compile_benchmark) ## ============================================================================= -#! -#! ## Public API -#! -#! Functions for automated benchmark declarations. -#! +#@ +#@ ## Public API +#@ ## ============================================================================= ## ============================================================================= @@ -163,10 +161,11 @@ function(ctbench_add_graph category config) set(config_path ${CMAKE_CURRENT_SOURCE_DIR}/${config}) add_custom_target( ${category} - COMMAND grapher-plot --output=${category} --config=${config_path} ${ARGN} + COMMAND ctbench-grapher-plot --output=${category} --config=${config_path} ${ARGN} DEPENDS ${config_path} ${ARGN} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_dependencies(ctbench-graph-all ${category}) endfunction(ctbench_add_graph) + #! #! -- From c6260485a77116a2c6c5d48099265b4ca0468572 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 17:05:23 +0200 Subject: [PATCH 06/26] Temporarily restored CTBENCH_TIME_TRACE_WRAPPER_EXEC variable export --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1e950a..40d2005 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,3 +25,7 @@ add_subdirectory(time-trace-wrapper) add_subdirectory(grapher) include(benchmarking.cmake) + +set(CTBENCH_TIME_TRACE_WRAPPER_EXEC + "${PROJECT_BINARY_DIR}/ctbench-ttw" + PARENT_SCOPE) From 44fd30f40a94226abe286b11e73b68a3c1141b41 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 17:06:49 +0200 Subject: [PATCH 07/26] Fixed CTBENCH_TIME_TRACE_WRAPPER_EXEC export --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40d2005..b6466ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,4 @@ add_subdirectory(grapher) include(benchmarking.cmake) -set(CTBENCH_TIME_TRACE_WRAPPER_EXEC - "${PROJECT_BINARY_DIR}/ctbench-ttw" - PARENT_SCOPE) +set(CTBENCH_TIME_TRACE_WRAPPER_EXEC ${CTBENCH_TIME_TRACE_WRAPPER_EXEC} PARENT_SCOPE) From 801201618366a3e0d0867a08d995d28b2816e201 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 23:38:45 +0200 Subject: [PATCH 08/26] CMake overhaul: target exports and install targets --- CMakeLists.txt | 11 +++++++---- benchmarking.cmake => cmake/benchmarking.cmake | 5 +++-- cmake/docs.cmake | 6 +++--- grapher/CMakeLists.txt | 18 ++++++------------ time-trace-wrapper/CMakeLists.txt | 17 +++++++++-------- 5 files changed, 28 insertions(+), 29 deletions(-) rename benchmarking.cmake => cmake/benchmarking.cmake (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6466ad..2025f23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,6 @@ add_compile_options( -Wdouble-promotion -Wshadow) -add_compile_options(-fno-rtti -fno-exceptions) - # Docs if(${PROJECT_IS_TOP_LEVEL}) add_subdirectory(cmake-doc-extractor) @@ -24,6 +22,11 @@ endif() add_subdirectory(time-trace-wrapper) add_subdirectory(grapher) -include(benchmarking.cmake) +export( + EXPORT ctbench-targets + NAMESPACE ctbench:: + FILE CtbenchTargets.cmake) + +install(EXPORT ctbench-targets DESTINATION ctbench) -set(CTBENCH_TIME_TRACE_WRAPPER_EXEC ${CTBENCH_TIME_TRACE_WRAPPER_EXEC} PARENT_SCOPE) +include(cmake/benchmarking.cmake) diff --git a/benchmarking.cmake b/cmake/benchmarking.cmake similarity index 96% rename from benchmarking.cmake rename to cmake/benchmarking.cmake index 8af57e7..de0236a 100644 --- a/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -27,7 +27,7 @@ function(_ctbench_internal_add_compile_benchmark target_name output source # Setting ctbench-ttw as a compiler launcher set_target_properties( ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER - "${CTBENCH_TIME_TRACE_WRAPPER_EXEC};${output}") + "ctbench::ctbench-time-trace-wrapper;${output}") # Adding dependency because CMake won't add_dependencies(${target_name} ctbench-ttw) @@ -161,7 +161,8 @@ function(ctbench_add_graph category config) set(config_path ${CMAKE_CURRENT_SOURCE_DIR}/${config}) add_custom_target( ${category} - COMMAND ctbench-grapher-plot --output=${category} --config=${config_path} ${ARGN} + COMMAND ctbench::ctbench-grapher-plot --output=${category} --config=${config_path} + ${ARGN} DEPENDS ${config_path} ${ARGN} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_dependencies(ctbench-graph-all ${category}) diff --git a/cmake/docs.cmake b/cmake/docs.cmake index 3f2f789..667b522 100644 --- a/cmake/docs.cmake +++ b/cmake/docs.cmake @@ -33,8 +33,8 @@ doxygen_add_docs(docs ALL) add_custom_target( extract-api-doc - cmake-doc-extractor --input ${CMAKE_SOURCE_DIR}/benchmarking.cmake --output - ${CMAKE_SOURCE_DIR}/generated-docs/benchmarking.md - DEPENDS ${CMAKE_SOURCE_DIR}/benchmarking.cmake) + cmake-doc-extractor --input ${CMAKE_SOURCE_DIR}/cmake/benchmarking.cmake + --output ${CMAKE_SOURCE_DIR}/generated-docs/benchmarking.md + DEPENDS ${CMAKE_SOURCE_DIR}/cmake/benchmarking.cmake) add_dependencies(docs extract-api-doc) diff --git a/grapher/CMakeLists.txt b/grapher/CMakeLists.txt index 1ccf794..1c3a898 100644 --- a/grapher/CMakeLists.txt +++ b/grapher/CMakeLists.txt @@ -10,18 +10,10 @@ find_package(LLVM REQUIRED CONFIG) llvm_map_components_to_libnames(llvm_libs core support) -target_link_libraries(grapher PUBLIC nlohmann_json::nlohmann_json sciplot::sciplot stdc++fs tbb ${llvm_libs}) - -target_compile_options( - grapher - PUBLIC -Wall - -Wextra - -Werror - -Wnull-dereference - -Wold-style-cast - -Wdouble-promotion - -Wshadow - -fno-rtti) +target_link_libraries(grapher PUBLIC nlohmann_json::nlohmann_json + sciplot::sciplot stdc++fs tbb ${llvm_libs}) + +target_compile_options(grapher PUBLIC -fno-rtti -fno-exceptions) # Adding executables @@ -31,6 +23,8 @@ target_link_libraries(ctbench-grapher-plot PRIVATE grapher) add_executable(ctbench-grapher-utils grapher-utils.cpp) target_link_libraries(ctbench-grapher-utils PRIVATE grapher) +install(TARGETS ctbench-grapher-plot ctbench-grapher-utils EXPORT ctbench-targets) + if(BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/time-trace-wrapper/CMakeLists.txt b/time-trace-wrapper/CMakeLists.txt index c6a00c6..db50610 100644 --- a/time-trace-wrapper/CMakeLists.txt +++ b/time-trace-wrapper/CMakeLists.txt @@ -1,12 +1,13 @@ -add_executable(ctbench-ttw time-trace-wrapper.cpp) -target_include_directories(ctbench-ttw PUBLIC include) +add_executable(ctbench-time-trace-wrapper time-trace-wrapper.cpp) +target_include_directories(ctbench-time-trace-wrapper PRIVATE include) -set(CTBENCH_TIME_TRACE_WRAPPER_EXEC - "${PROJECT_BINARY_DIR}/ctbench-ttw" - PARENT_SCOPE) +install(TARGETS ctbench-time-trace-wrapper EXPORT ctbench-targets) if(BUILD_TESTING) - add_executable(ctbench-ttw-test-exec tests/time-trace-wrapper.cpp) - target_include_directories(ctbench-ttw-test-exec PUBLIC include) - add_test(NAME ctbench-ttw-test COMMAND ctbench-ttw-test-exec) + add_executable(ctbench-time-trace-wrapper-test-exec + tests/time-trace-wrapper.cpp) + target_include_directories(ctbench-time-trace-wrapper-test-exec + PUBLIC include) + add_test(NAME ctbench-time-trace-wrapper-test + COMMAND ctbench-time-trace-wrapper-test-exec) endif(BUILD_TESTING) From 2779569419ffe00906c8cd8ff1756d38e2a60151 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Tue, 29 Mar 2022 23:40:29 +0200 Subject: [PATCH 09/26] Updated target dependency --- cmake/benchmarking.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index de0236a..62d5fdf 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -30,7 +30,7 @@ function(_ctbench_internal_add_compile_benchmark target_name output source "ctbench::ctbench-time-trace-wrapper;${output}") # Adding dependency because CMake won't - add_dependencies(${target_name} ctbench-ttw) + add_dependencies(${target_name} ctbench::ctbench-time-trace-wrapper) # Pass benchmark size target_compile_options(${target_name} PRIVATE ${options}) From 3a4196bdc47ab039dce23adfd17fba14841250b3 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:39:54 +0200 Subject: [PATCH 10/26] Renamed time-trace-wrapper as ttw --- ttw/CMakeLists.txt | 13 ++++++++++++ ttw/include/ttw.hpp | 50 +++++++++++++++++++++++++++++++++++++++++++ ttw/tests/ttw.cpp | 19 +++++++++++++++++ ttw/ttw.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 ttw/CMakeLists.txt create mode 100644 ttw/include/ttw.hpp create mode 100644 ttw/tests/ttw.cpp create mode 100644 ttw/ttw.cpp diff --git a/ttw/CMakeLists.txt b/ttw/CMakeLists.txt new file mode 100644 index 0000000..c38ad5d --- /dev/null +++ b/ttw/CMakeLists.txt @@ -0,0 +1,13 @@ +add_executable(ctbench-ttw ttw.cpp) +target_include_directories(ctbench-ttw PRIVATE include) + +install(TARGETS ctbench-ttw EXPORT ctbench-targets) + +if(BUILD_TESTING) + add_executable(ctbench-ttw-test-exec + tests/ttw.cpp) + target_include_directories(ctbench-ttw-test-exec + PUBLIC include) + add_test(NAME ctbench-ttw-test + COMMAND ctbench-ttw-test-exec) +endif(BUILD_TESTING) diff --git a/ttw/include/ttw.hpp b/ttw/include/ttw.hpp new file mode 100644 index 0000000..3bd36cd --- /dev/null +++ b/ttw/include/ttw.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include + +inline int get_timetrace_file(std::filesystem::path const out, std::string cmd, + std::filesystem::path obj_path) { + namespace fs = std::filesystem; + + // Run program + std::system(cmd.c_str()); + if (auto const out_parent = out.parent_path(); !out_parent.empty()) { + fs::create_directories(out.parent_path()); + } + + fs::copy_file(obj_path.replace_extension(".json"), out, + fs::copy_options::overwrite_existing); + + return 0; +} + +inline auto parse_args(int argc, char const *argv[]) { + namespace fs = std::filesystem; + + constexpr int args_begin = 2; + + std::ostringstream cmd_builder; + fs::path obj_path; + bool has_time_trace_flag = false; + + cmd_builder << argv[args_begin]; + for (auto beg = argv + args_begin + 1, end = argv + argc; beg < end; beg++) { + // Object path finding + if (*beg == std::string_view("-o") && (beg + 1) != end) { + obj_path = *(beg + 1); + } + + if (*beg == std::string_view("-ftime-trace") || + *beg == std::string_view("--ftime-trace")) { + has_time_trace_flag = true; + } + + cmd_builder << ' ' << *beg; + } + + if (!has_time_trace_flag) { + cmd_builder << " -ftime-trace"; + } + + return std::tuple(cmd_builder.str(), obj_path); +} diff --git a/ttw/tests/ttw.cpp b/ttw/tests/ttw.cpp new file mode 100644 index 0000000..f943224 --- /dev/null +++ b/ttw/tests/ttw.cpp @@ -0,0 +1,19 @@ +#include + +// auto parse_args(int argc, char const *argv[]) +void test_parse_args() { + // TODO +} + +// int get_timetrace_file(std::filesystem::path const out, std::string cmd, +// std::filesystem::path obj_path) +void test_get_timetrace_file() { + // TODO +} + +void test_all() { + test_parse_args(); + test_get_timetrace_file(); +} + +int main(int /*argc*/, char const * /*argv*/[]) { test_all(); } diff --git a/ttw/ttw.cpp b/ttw/ttw.cpp new file mode 100644 index 0000000..991e669 --- /dev/null +++ b/ttw/ttw.cpp @@ -0,0 +1,52 @@ +/// -ftime-trace wrapper for clang. + +#include +#include +#include +#include +#include + +#include + +/// Wrapper for a given clang command. + +int main(int argc, char const *argv[]) { + namespace fs = std::filesystem; + + constexpr int exec_id = 0; + constexpr int path_id = 1; + constexpr int cmd_start_id = 2; + + if (argc < 3) { + std::cout << "Usage: " << argv[exec_id] + << "time_trace_export_path.json COMMAND [ARGS]...\n"; + return 1; + } + + // Building path and finding obj_path + std::ostringstream cmd_builder; + fs::path obj_path; + bool has_time_trace_flag = false; + + cmd_builder << argv[cmd_start_id]; + for (auto beg = &argv[cmd_start_id + 1], end = &argv[argc]; beg < end; + beg++) { + // Object path finding + if (*beg == std::string_view("-o") && (beg + 1) != end) { + obj_path = *(beg + 1); + } + + if (*beg == std::string_view("-ftime-trace") || + *beg == std::string_view("--ftime-trace")) { + has_time_trace_flag = true; + } + cmd_builder << ' ' << *beg; + } + + if (!has_time_trace_flag) { + cmd_builder << " -ftime-trace"; + } + + return get_timetrace_file(argv[path_id], cmd_builder.str(), + std::move(obj_path)); +} From 3360a021260f66e6f9e595ced0c985edcf4c5aa6 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:40:02 +0200 Subject: [PATCH 11/26] Renamed time-trace-wrapper as ttw --- time-trace-wrapper/CMakeLists.txt | 13 ----- .../include/time-trace-wrapper.hpp | 50 ------------------ .../tests/time-trace-wrapper.cpp | 19 ------- time-trace-wrapper/time-trace-wrapper.cpp | 52 ------------------- 4 files changed, 134 deletions(-) delete mode 100644 time-trace-wrapper/CMakeLists.txt delete mode 100644 time-trace-wrapper/include/time-trace-wrapper.hpp delete mode 100644 time-trace-wrapper/tests/time-trace-wrapper.cpp delete mode 100644 time-trace-wrapper/time-trace-wrapper.cpp diff --git a/time-trace-wrapper/CMakeLists.txt b/time-trace-wrapper/CMakeLists.txt deleted file mode 100644 index db50610..0000000 --- a/time-trace-wrapper/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -add_executable(ctbench-time-trace-wrapper time-trace-wrapper.cpp) -target_include_directories(ctbench-time-trace-wrapper PRIVATE include) - -install(TARGETS ctbench-time-trace-wrapper EXPORT ctbench-targets) - -if(BUILD_TESTING) - add_executable(ctbench-time-trace-wrapper-test-exec - tests/time-trace-wrapper.cpp) - target_include_directories(ctbench-time-trace-wrapper-test-exec - PUBLIC include) - add_test(NAME ctbench-time-trace-wrapper-test - COMMAND ctbench-time-trace-wrapper-test-exec) -endif(BUILD_TESTING) diff --git a/time-trace-wrapper/include/time-trace-wrapper.hpp b/time-trace-wrapper/include/time-trace-wrapper.hpp deleted file mode 100644 index 3bd36cd..0000000 --- a/time-trace-wrapper/include/time-trace-wrapper.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include - -inline int get_timetrace_file(std::filesystem::path const out, std::string cmd, - std::filesystem::path obj_path) { - namespace fs = std::filesystem; - - // Run program - std::system(cmd.c_str()); - if (auto const out_parent = out.parent_path(); !out_parent.empty()) { - fs::create_directories(out.parent_path()); - } - - fs::copy_file(obj_path.replace_extension(".json"), out, - fs::copy_options::overwrite_existing); - - return 0; -} - -inline auto parse_args(int argc, char const *argv[]) { - namespace fs = std::filesystem; - - constexpr int args_begin = 2; - - std::ostringstream cmd_builder; - fs::path obj_path; - bool has_time_trace_flag = false; - - cmd_builder << argv[args_begin]; - for (auto beg = argv + args_begin + 1, end = argv + argc; beg < end; beg++) { - // Object path finding - if (*beg == std::string_view("-o") && (beg + 1) != end) { - obj_path = *(beg + 1); - } - - if (*beg == std::string_view("-ftime-trace") || - *beg == std::string_view("--ftime-trace")) { - has_time_trace_flag = true; - } - - cmd_builder << ' ' << *beg; - } - - if (!has_time_trace_flag) { - cmd_builder << " -ftime-trace"; - } - - return std::tuple(cmd_builder.str(), obj_path); -} diff --git a/time-trace-wrapper/tests/time-trace-wrapper.cpp b/time-trace-wrapper/tests/time-trace-wrapper.cpp deleted file mode 100644 index a95cd69..0000000 --- a/time-trace-wrapper/tests/time-trace-wrapper.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include - -// auto parse_args(int argc, char const *argv[]) -void test_parse_args() { - // TODO -} - -// int get_timetrace_file(std::filesystem::path const out, std::string cmd, -// std::filesystem::path obj_path) -void test_get_timetrace_file() { - // TODO -} - -void test_all() { - test_parse_args(); - test_get_timetrace_file(); -} - -int main(int argc, char const *argv[]) { test_all(); } diff --git a/time-trace-wrapper/time-trace-wrapper.cpp b/time-trace-wrapper/time-trace-wrapper.cpp deleted file mode 100644 index 5a8b8dc..0000000 --- a/time-trace-wrapper/time-trace-wrapper.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/// -ftime-trace wrapper for clang. - -#include -#include -#include -#include -#include - -#include - -/// Wrapper for a given clang command. - -int main(int argc, char const *argv[]) { - namespace fs = std::filesystem; - - constexpr int exec_id = 0; - constexpr int path_id = 1; - constexpr int cmd_start_id = 2; - - if (argc < 3) { - std::cout << "Usage: " << argv[exec_id] - << "time_trace_export_path.json COMMAND [ARGS]...\n"; - return 1; - } - - // Building path and finding obj_path - std::ostringstream cmd_builder; - fs::path obj_path; - bool has_time_trace_flag = false; - - cmd_builder << argv[cmd_start_id]; - for (auto beg = &argv[cmd_start_id + 1], end = &argv[argc]; beg < end; - beg++) { - // Object path finding - if (*beg == std::string_view("-o") && (beg + 1) != end) { - obj_path = *(beg + 1); - } - - if (*beg == std::string_view("-ftime-trace") || - *beg == std::string_view("--ftime-trace")) { - has_time_trace_flag = true; - } - cmd_builder << ' ' << *beg; - } - - if (!has_time_trace_flag) { - cmd_builder << " -ftime-trace"; - } - - return get_timetrace_file(argv[path_id], cmd_builder.str(), - std::move(obj_path)); -} From a87d038664368c37d2395227482d90fee451a649 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:40:51 +0200 Subject: [PATCH 12/26] Format + set include to private for test target --- ttw/CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ttw/CMakeLists.txt b/ttw/CMakeLists.txt index c38ad5d..d7de904 100644 --- a/ttw/CMakeLists.txt +++ b/ttw/CMakeLists.txt @@ -4,10 +4,7 @@ target_include_directories(ctbench-ttw PRIVATE include) install(TARGETS ctbench-ttw EXPORT ctbench-targets) if(BUILD_TESTING) - add_executable(ctbench-ttw-test-exec - tests/ttw.cpp) - target_include_directories(ctbench-ttw-test-exec - PUBLIC include) - add_test(NAME ctbench-ttw-test - COMMAND ctbench-ttw-test-exec) + add_executable(ctbench-ttw-test-exec tests/ttw.cpp) + target_include_directories(ctbench-ttw-test-exec PRIVATE include) + add_test(NAME ctbench-ttw-test COMMAND ctbench-ttw-test-exec) endif(BUILD_TESTING) From f0a5b2d1e34c9acc8f72e58097536a0c73f60b0c Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:43:01 +0200 Subject: [PATCH 13/26] Changed subdir path to ttw, added subdir folder definitions for benchmarking API file --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2025f23..1cfcf38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if(${PROJECT_IS_TOP_LEVEL}) include(cmake/docs.cmake) endif() -add_subdirectory(time-trace-wrapper) +add_subdirectory(ttw) add_subdirectory(grapher) export( @@ -29,4 +29,7 @@ export( install(EXPORT ctbench-targets DESTINATION ctbench) +set(GRAPHER_FOLDER ${CMAKE_BINARY_DIR}/grapher/) +set(TIME_TRACE_WRAPPER_FOLDER ${CMAKE_BINARY_DIR}/ttw/) + include(cmake/benchmarking.cmake) From 1276aef48ad905e94cce19e16a41d654c0cb8588 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:43:48 +0200 Subject: [PATCH 14/26] cmake-format --- grapher/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grapher/CMakeLists.txt b/grapher/CMakeLists.txt index 1c3a898..87d17d3 100644 --- a/grapher/CMakeLists.txt +++ b/grapher/CMakeLists.txt @@ -23,7 +23,8 @@ target_link_libraries(ctbench-grapher-plot PRIVATE grapher) add_executable(ctbench-grapher-utils grapher-utils.cpp) target_link_libraries(ctbench-grapher-utils PRIVATE grapher) -install(TARGETS ctbench-grapher-plot ctbench-grapher-utils EXPORT ctbench-targets) +install(TARGETS ctbench-grapher-plot ctbench-grapher-utils + EXPORT ctbench-targets) if(BUILD_TESTING) add_subdirectory(tests) From 89d34a2d51fe59b0a92935705267bb1e1a95a57c Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:45:52 +0200 Subject: [PATCH 15/26] Added ttw and ctbench prefixes to exec paths --- cmake/benchmarking.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index 62d5fdf..4c3c175 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -27,10 +27,10 @@ function(_ctbench_internal_add_compile_benchmark target_name output source # Setting ctbench-ttw as a compiler launcher set_target_properties( ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER - "ctbench::ctbench-time-trace-wrapper;${output}") + "${GRAPHER_FOLDER}ctbench-ttw;${output}") # Adding dependency because CMake won't - add_dependencies(${target_name} ctbench::ctbench-time-trace-wrapper) + # add_dependencies(${target_name} ctbench::ctbench-time-trace-wrapper) # Pass benchmark size target_compile_options(${target_name} PRIVATE ${options}) @@ -161,8 +161,8 @@ function(ctbench_add_graph category config) set(config_path ${CMAKE_CURRENT_SOURCE_DIR}/${config}) add_custom_target( ${category} - COMMAND ctbench::ctbench-grapher-plot --output=${category} --config=${config_path} - ${ARGN} + COMMAND ${CTBENCH_FOLDER}ctbench-grapher-plot --output=${category} + --config=${config_path} ${ARGN} DEPENDS ${config_path} ${ARGN} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_dependencies(ctbench-graph-all ${category}) From 827edeb3aefc4879e1c08c0ea01f7cfa48094734 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:46:23 +0200 Subject: [PATCH 16/26] Changed TIME_TRACE_WRAPPER_FOLDER to TTW_FOLDER --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cfcf38..9b01d00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,6 @@ export( install(EXPORT ctbench-targets DESTINATION ctbench) set(GRAPHER_FOLDER ${CMAKE_BINARY_DIR}/grapher/) -set(TIME_TRACE_WRAPPER_FOLDER ${CMAKE_BINARY_DIR}/ttw/) +set(TTW_FOLDER ${CMAKE_BINARY_DIR}/ttw/) include(cmake/benchmarking.cmake) From 45c744dc69426761804c992ef1c262eea02ee7e6 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:48:52 +0200 Subject: [PATCH 17/26] Propagate folder prefixes to parent scope --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b01d00..0b332e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ export( install(EXPORT ctbench-targets DESTINATION ctbench) -set(GRAPHER_FOLDER ${CMAKE_BINARY_DIR}/grapher/) -set(TTW_FOLDER ${CMAKE_BINARY_DIR}/ttw/) +set(GRAPHER_FOLDER ${CMAKE_BINARY_DIR}/grapher/ PARENT_SCOPE) +set(TTW_FOLDER ${CMAKE_BINARY_DIR}/ttw/ PARENT_SCOPE) include(cmake/benchmarking.cmake) From d8b9b928ad1e82181cf8dd8abb65942400bc1609 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 00:50:45 +0200 Subject: [PATCH 18/26] Added benchmark dependency to ctbench-ttw --- cmake/benchmarking.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index 4c3c175..046201c 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -30,7 +30,7 @@ function(_ctbench_internal_add_compile_benchmark target_name output source "${GRAPHER_FOLDER}ctbench-ttw;${output}") # Adding dependency because CMake won't - # add_dependencies(${target_name} ctbench::ctbench-time-trace-wrapper) + add_dependencies(${target_name} ctbench::ctbench-ttw) # Pass benchmark size target_compile_options(${target_name} PRIVATE ${options}) From 7750a088f819fba40c4a78a5c92984e74aaefeb5 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 01:00:18 +0200 Subject: [PATCH 19/26] Added CTBENCH_PORTABLE variable, defined only when ctbench is imported as a subproject and not through installation --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b332e0..dc9da87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,6 @@ export( install(EXPORT ctbench-targets DESTINATION ctbench) -set(GRAPHER_FOLDER ${CMAKE_BINARY_DIR}/grapher/ PARENT_SCOPE) -set(TTW_FOLDER ${CMAKE_BINARY_DIR}/ttw/ PARENT_SCOPE) +set(CTBENCH_PORTABLE ON PARENT_SCOPE) include(cmake/benchmarking.cmake) From 8fd9421902776f29302982fe4f2bd1c5f0b761b7 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 01:00:46 +0200 Subject: [PATCH 20/26] Moved prefix definitions inside benchmarking.cmake --- cmake/benchmarking.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index 046201c..1db0efe 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -6,6 +6,11 @@ #@ ## ============================================================================= +if(CTBENCH_PORTABLE) + set(GRAPHER_FOLDER ${CMAKE_BINARY_DIR}/grapher/ PARENT_SCOPE) + set(TTW_FOLDER ${CMAKE_BINARY_DIR}/ttw/ PARENT_SCOPE) +endif() + ## ============================================================================= #@ #@ _ctbench_internal_add_compile_benchmark @@ -29,8 +34,9 @@ function(_ctbench_internal_add_compile_benchmark target_name output source ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER "${GRAPHER_FOLDER}ctbench-ttw;${output}") - # Adding dependency because CMake won't - add_dependencies(${target_name} ctbench::ctbench-ttw) + if(CTBENCH_PORTABLE) + add_dependencies(${target_name} ctbench-ttw) + endif() # Pass benchmark size target_compile_options(${target_name} PRIVATE ${options}) From 085a85c115a79968f64d843614241096cda91bc5 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 01:03:01 +0200 Subject: [PATCH 21/26] Fixed prefix names --- cmake/benchmarking.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index 1db0efe..c6f7fd0 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -32,7 +32,7 @@ function(_ctbench_internal_add_compile_benchmark target_name output source # Setting ctbench-ttw as a compiler launcher set_target_properties( ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER - "${GRAPHER_FOLDER}ctbench-ttw;${output}") + "${TTW_FOLDER}ctbench-ttw;${output}") if(CTBENCH_PORTABLE) add_dependencies(${target_name} ctbench-ttw) @@ -167,7 +167,7 @@ function(ctbench_add_graph category config) set(config_path ${CMAKE_CURRENT_SOURCE_DIR}/${config}) add_custom_target( ${category} - COMMAND ${CTBENCH_FOLDER}ctbench-grapher-plot --output=${category} + COMMAND ${GRAPHER_FOLDER}ctbench-grapher-plot --output=${category} --config=${config_path} ${ARGN} DEPENDS ${config_path} ${ARGN} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) From 9b8d56f601cbb46ba216c26ef1526687bc92454c Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 01:05:39 +0200 Subject: [PATCH 22/26] Added debug lines for executable prefixes in portable mode --- cmake/benchmarking.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index c6f7fd0..1f523ff 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -7,8 +7,12 @@ ## ============================================================================= if(CTBENCH_PORTABLE) - set(GRAPHER_FOLDER ${CMAKE_BINARY_DIR}/grapher/ PARENT_SCOPE) - set(TTW_FOLDER ${CMAKE_BINARY_DIR}/ttw/ PARENT_SCOPE) + set(GRAPHER_PREFIX ${CMAKE_BINARY_DIR}/grapher/ PARENT_SCOPE) + set(TTW_PREFIX ${CMAKE_BINARY_DIR}/ttw/ PARENT_SCOPE) + + message(ctbench was imported) + message(GRAPHER_PREFIX: ${GRAPHER_PREFIX}) + message(TTW_PREFIX: ${TTW_PREFIX}) endif() ## ============================================================================= @@ -32,7 +36,7 @@ function(_ctbench_internal_add_compile_benchmark target_name output source # Setting ctbench-ttw as a compiler launcher set_target_properties( ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER - "${TTW_FOLDER}ctbench-ttw;${output}") + "${TTW_PREFIX}ctbench-ttw;${output}") if(CTBENCH_PORTABLE) add_dependencies(${target_name} ctbench-ttw) @@ -167,7 +171,7 @@ function(ctbench_add_graph category config) set(config_path ${CMAKE_CURRENT_SOURCE_DIR}/${config}) add_custom_target( ${category} - COMMAND ${GRAPHER_FOLDER}ctbench-grapher-plot --output=${category} + COMMAND ${GRAPHER_PREFIX}ctbench-grapher-plot --output=${category} --config=${config_path} ${ARGN} DEPENDS ${config_path} ${ARGN} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) From 8fe997784c3a8cee0dfb2808d8d1693e7ab09834 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 01:11:09 +0200 Subject: [PATCH 23/26] Removed CTBENCH_PORTABLE, now relying on ctbench_FOUND to find out whether the project was imported or not --- CMakeLists.txt | 2 -- cmake/benchmarking.cmake | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc9da87..9e2f28b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,4 @@ export( install(EXPORT ctbench-targets DESTINATION ctbench) -set(CTBENCH_PORTABLE ON PARENT_SCOPE) - include(cmake/benchmarking.cmake) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index 1f523ff..c67fb7b 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -6,7 +6,7 @@ #@ ## ============================================================================= -if(CTBENCH_PORTABLE) +if(NOT ctbench_FOUND) set(GRAPHER_PREFIX ${CMAKE_BINARY_DIR}/grapher/ PARENT_SCOPE) set(TTW_PREFIX ${CMAKE_BINARY_DIR}/ttw/ PARENT_SCOPE) @@ -38,7 +38,7 @@ function(_ctbench_internal_add_compile_benchmark target_name output source ${target_name} PROPERTIES CXX_COMPILER_LAUNCHER "${TTW_PREFIX}ctbench-ttw;${output}") - if(CTBENCH_PORTABLE) + if(NOT ctbench_FOUND) add_dependencies(${target_name} ctbench-ttw) endif() From f0d134b1715f420105356cc717f0f60983ec325b Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 01:13:17 +0200 Subject: [PATCH 24/26] Fixed prefix setting --- cmake/benchmarking.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index c67fb7b..f3cfe53 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -7,8 +7,8 @@ ## ============================================================================= if(NOT ctbench_FOUND) - set(GRAPHER_PREFIX ${CMAKE_BINARY_DIR}/grapher/ PARENT_SCOPE) - set(TTW_PREFIX ${CMAKE_BINARY_DIR}/ttw/ PARENT_SCOPE) + set(GRAPHER_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/grapher/ PARENT_SCOPE) + set(TTW_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ttw/ PARENT_SCOPE) message(ctbench was imported) message(GRAPHER_PREFIX: ${GRAPHER_PREFIX}) From f25572cbde534f7330264a30729e46f945dd58d8 Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 11:17:11 +0200 Subject: [PATCH 25/26] Added info regarding folder/target prefixes, and added dependency to grapher-plot for graph generation --- cmake/benchmarking.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index f3cfe53..17ce23f 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -6,13 +6,15 @@ #@ ## ============================================================================= +# Setting executable/target prefix. +# ctbench_FOUND being false means ctbench was imported inside of the tree. +# ctbench_FOUND being true means ctbench found through find_package. if(NOT ctbench_FOUND) set(GRAPHER_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/grapher/ PARENT_SCOPE) set(TTW_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ttw/ PARENT_SCOPE) - - message(ctbench was imported) - message(GRAPHER_PREFIX: ${GRAPHER_PREFIX}) - message(TTW_PREFIX: ${TTW_PREFIX}) +else() + set(GRAPHER_PREFIX ctbench:: PARENT_SCOPE) + set(TTW_PREFIX ctbench:: PARENT_SCOPE) endif() ## ============================================================================= @@ -176,6 +178,10 @@ function(ctbench_add_graph category config) DEPENDS ${config_path} ${ARGN} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_dependencies(ctbench-graph-all ${category}) + + if(NOT ctbench_FOUND) + add_dependencies(${target_name} ctbench-grapher-plot) + endif() endfunction(ctbench_add_graph) #! From 4c4a94a24955a0584382f16d1f49927e9b4bff5c Mon Sep 17 00:00:00 2001 From: Jules P?nuchot Date: Wed, 30 Mar 2022 11:18:50 +0200 Subject: [PATCH 26/26] Fixed add_dependencies call in ctbench_add_graph --- cmake/benchmarking.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/benchmarking.cmake b/cmake/benchmarking.cmake index 17ce23f..05e417e 100644 --- a/cmake/benchmarking.cmake +++ b/cmake/benchmarking.cmake @@ -180,7 +180,7 @@ function(ctbench_add_graph category config) add_dependencies(ctbench-graph-all ${category}) if(NOT ctbench_FOUND) - add_dependencies(${target_name} ctbench-grapher-plot) + add_dependencies(${category} ctbench-grapher-plot) endif() endfunction(ctbench_add_graph)