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

JOSS - Remarks #17

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b68f449
Readability improvements: more explicit variable names, added a funct…
JPenuchot Dec 28, 2022
d87aa97
Other readability improvements: explicit variable names and explicit …
JPenuchot Dec 28, 2022
f49cab9
Added clang-tidy checks to clangd config, they should be migrated to …
JPenuchot Dec 28, 2022
35cee46
Removed clang-tidy management from CMake code as checks are now enfor…
JPenuchot Dec 28, 2022
a5abf6e
Added type alias for default scalar type in grapher
JPenuchot Dec 28, 2022
a84a910
More refactoring: function splitting in compare_by plotter code, more…
JPenuchot Dec 28, 2022
a5e18b3
Added new graphs and updated old ones
JPenuchot Jan 9, 2023
145458f
Added figures in practical examples
JPenuchot Jan 9, 2023
19d46bf
Formatting
JPenuchot Jan 9, 2023
95f9144
Added flame graph visualizer screenshot
JPenuchot Jan 9, 2023
835353c
Added flame graph visualization example in the paper
JPenuchot Jan 9, 2023
c2f9ca9
Better figure annotations
JPenuchot Jan 9, 2023
7a0ca1c
Trying to scale up graphs for better readability
JPenuchot Jan 9, 2023
05b192a
Increasing ctbench graph width even more
JPenuchot Jan 9, 2023
305a57c
Stepping back on graph width
JPenuchot Jan 9, 2023
0cbcd16
More clarifications for presented graphs
JPenuchot Jan 9, 2023
4c0fb5b
Typo fix: curve -> curves
JPenuchot Jan 9, 2023
8ad6cba
Fixed poacher citation
JPenuchot Jan 9, 2023
319adc8
Slight updates to the paper: moved statement of interest, split summa…
JPenuchot Jan 11, 2023
5ac33e2
Updated perfetto UI screenshot
JPenuchot Jan 11, 2023
ab5f129
Updated draft with new structure and notes to be reworked
JPenuchot Jan 11, 2023
52c60df
Fixed subtitle
JPenuchot Jan 11, 2023
1c365d7
Reworked functionality text structure
JPenuchot Jan 11, 2023
61b7a69
Indentation for bullet list details
JPenuchot Jan 11, 2023
920648b
Redaction following notetaking with Joel
JPenuchot Jan 12, 2023
10a377a
Added date for metabench citation
JPenuchot Jan 12, 2023
4be157f
Minor changes to the draft
JPenuchot Jan 12, 2023
b762554
Added example benchmark
JPenuchot Jan 16, 2023
799f290
Added reference to time-trace pull request
JPenuchot Jan 16, 2023
ef95e12
Authoring and advancement on paper draft
JPenuchot Jan 16, 2023
b845af8
Fixes and improvements for the benchmarks
JPenuchot Jan 16, 2023
84fd959
Increased repetition number and max benchmark size
JPenuchot Jan 16, 2023
7fc38ff
Added simple benchmark example to the paper
JPenuchot Jan 16, 2023
282ae7a
Updated graphs with provided example
JPenuchot Jan 17, 2023
a6e7b69
Added size zero for baseline
JPenuchot Jan 17, 2023
0525fc4
Config cleanup
JPenuchot Jan 17, 2023
2c3ad99
Support for benchmark size 0, turned benchmark driver into a template…
JPenuchot Jan 17, 2023
d7b224c
Updated draft with benchmark description and graphs
JPenuchot Jan 17, 2023
8947d42
Merge branch 'main' into joss
JPenuchot Jan 17, 2023
6fdc50f
Fixed graphs
JPenuchot Jan 17, 2023
f94ff26
Draft advancement
JPenuchot Jan 18, 2023
cb11128
First 'final' version of the paper
JPenuchot Jan 18, 2023
430189e
Acknowledgements + indent
JPenuchot Jan 18, 2023
99bbee4
Joel's remarks
jfalcou Jan 26, 2023
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
6 changes: 6 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ CompileFlags:
CompilationDatabase: build/
Diagnostics:
UnusedIncludes: Strict
ClangTidy:
Add:
- 'bugprone-*'
- 'readability-*'
- 'clang-analyzer-core.*'
- 'clang-analyzer-security.*'
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ project(ctbench VERSION 1.1.1)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(${CTBENCH_ENABLE_CLANG_TIDY})
set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=-*,readability-*)
endif()

include(cmake/dependencies.cmake)
include(cmake/ctbench-compile-opts.cmake)

Expand Down
3 changes: 1 addition & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_CLANG_TIDY": "clang-tidy;-checks=-*,readability-*"
"CMAKE_C_COMPILER": "clang"
}
},
{
Expand Down
4 changes: 0 additions & 4 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ set(CTBENCH_ENABLE_TESTS
set(CTBENCH_ENABLE_TRACY
OFF
CACHE BOOL "ctbench option: Enable Tracy profiler")

set(CTBENCH_ENABLE_CLANG_TIDY
OFF
CACHE BOOL "ctbench option: Enable clang tidy")
642 changes: 92 additions & 550 deletions docs/images/ExecuteCompiler.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
219 changes: 219 additions & 0 deletions docs/images/InstantiateFunction/foovoid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
234 changes: 234 additions & 0 deletions docs/images/Total_Backend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
219 changes: 219 additions & 0 deletions docs/images/Total_Frontend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
207 changes: 90 additions & 117 deletions docs/images/Total_InstantiateFunction.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/perfetto-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Simple standalone project for compile-time benchmarking using ctbench

# Usage:

# ```sh
# cmake --preset release
# cmake --build --preset release
# ```

# CMake presets use clang/clang++ by default with time-trace enabled.

cmake_minimum_required(VERSION 3.25)
project(example-project)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)

find_package(ctbench REQUIRED)

add_compile_options(
-Wall
-Wextra
-Werror
-Wnull-dereference
-Wold-style-cast
-Wdouble-promotion
-Wshadow)

if(ENABLE_TIME_TRACE)
add_compile_options(-ftime-trace -ftime-trace-granularity=1
-fconstexpr-steps=2147483647 -fbracket-depth=2147483647)
endif()

set(BENCHMARK_START 0 CACHE STRING "Benchmark size minimum")
set(BENCHMARK_STOP 64 CACHE STRING "Benchmark size maximum")
set(BENCHMARK_STEP 1 CACHE STRING "Benchmark size step")
set(BENCHMARK_ITERATIONS 10 CACHE STRING "Number of samples per size")

ctbench_add_benchmark(
variadic_sum.expansion variadic_sum/expansion.cpp ${BENCHMARK_START}
${BENCHMARK_STOP} ${BENCHMARK_STEP} ${BENCHMARK_ITERATIONS})

ctbench_add_benchmark(
variadic_sum.recursive variadic_sum/recursive.cpp ${BENCHMARK_START}
${BENCHMARK_STOP} ${BENCHMARK_STEP} ${BENCHMARK_ITERATIONS})

ctbench_add_graph(variadic_sum-compare-graph compare-all.json
variadic_sum.expansion variadic_sum.recursive)
65 changes: 65 additions & 0 deletions example/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"version" : 4,
"cmakeMinimumRequired" : {
"major" : 3,
"minor" : 25,
"patch" : 0
},
"configurePresets" : [
{
"name" : "dev",
"displayName" : "Dev build",
"description" : "Provides a compile_commands.json file",
"generator" : "Ninja",
"binaryDir" : "${sourceDir}/build",
"cacheVariables" : {
"ENABLE_TIME_TRACE" : "ON",
"CMAKE_CXX_COMPILER" : "clang++",
"CMAKE_C_COMPILER" : "clang",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"CMAKE_BUILD_TYPE" : "RelWithDebInfo"
}
},
{
"name" : "release",
"displayName" : "Release",
"description" : "Release",
"generator" : "Ninja",
"binaryDir" : "${sourceDir}/build/release",
"cacheVariables" : {
"ENABLE_TIME_TRACE" : "ON",
"CMAKE_CXX_COMPILER" : "clang++",
"CMAKE_C_COMPILER" : "clang",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"CMAKE_BUILD_TYPE" : "RelWithDebInfo"
}
},
{
"name" : "debug",
"inherits" : "release",
"displayName" : "Debug",
"description" : "Debug",
"binaryDir" : "${sourceDir}/build/debug",
"cacheVariables" : {
"CMAKE_BUILD_TYPE" : "Debug"
}
}
],
"buildPresets" : [
{
"name" : "release",
"configurePreset" : "release",
"nativeToolOptions" : [
"-j1"
],
"targets" : [
"ctbench-graph-all"
]
},
{
"name" : "debug",
"inherits" : "release",
"configurePreset" : "debug"
}
]
}
14 changes: 14 additions & 0 deletions example/compare-all.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"plotter": "compare_by",
"legend_title": "Timings",
"x_label": "Benchmark size factor",
"y_label": "Time (µs)",
"draw_average": true,
"demangle": false,
"draw_points": false,
"width": 800,
"height": 400,
"key_ptrs": ["/name", "/args/detail"],
"value_ptr": "/dur",
"plot_file_extensions": [".svg"]
}
27 changes: 27 additions & 0 deletions example/variadic_sum/expansion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <utility>

/// Compile-time std::size_t
template <std::size_t N> struct ct_uint_t {
static constexpr std::size_t value = N;
};

/// Expansion compile-time sum implementation
template<typename ... Ts> constexpr auto sum();

template <> constexpr auto sum() { return ct_uint_t<0>{}; }

template <typename... Ts> constexpr auto sum(Ts const &...) {
return ct_uint_t<(Ts::value + ... + 0)>{};
}

// Driver code

template <typename = void> constexpr auto foo() {
return []<std::size_t... Is>(std::index_sequence<Is...>) {
return sum(ct_uint_t<Is>{}...);
}
(std::make_index_sequence<BENCHMARK_SIZE>{});
}

[[maybe_unused]] constexpr std::size_t result =
decltype(foo())::value;
29 changes: 29 additions & 0 deletions example/variadic_sum/recursive.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <utility>

/// Compile-time std::size_t
template <std::size_t N> struct ct_uint_t {
static constexpr std::size_t value = N;
};

/// Recursive compile-time sum implementation
template<typename ... Ts> constexpr auto sum();

template <> constexpr auto sum() { return ct_uint_t<0>{}; }
template <typename T> constexpr auto sum(T const &) { return T{}; }

template <typename T, typename... Ts>
constexpr auto sum(T const &, Ts const &...tl) {
return ct_uint_t<T::value + decltype(sum(tl...))::value>{};
}

// Driver code

template <typename = void> constexpr auto foo() {
return []<std::size_t... Is>(std::index_sequence<Is...>) {
return sum(ct_uint_t<Is>{}...);
}
(std::make_index_sequence<BENCHMARK_SIZE>{});
}

[[maybe_unused]] constexpr std::size_t result =
decltype(foo())::value;
3 changes: 3 additions & 0 deletions grapher/include/grapher/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ using multimap_t =
/// Alias type for JSON objects.
using json_t = nlohmann::basic_json<boost::container::flat_map>;

/// Default type to represent scalar values from benchmark data.
using value_t = unsigned long;

// `time cmake --build --preset bench` results using different containers
// (poacher/brainfuck project, pre-built benchmark targets):
// - boost::container::flat_map -> 78.05 secs
Expand Down
9 changes: 5 additions & 4 deletions grapher/include/grapher/utils/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ namespace grapher {

/// For each instance in entry, returns the sum of the values pointed by
/// value_jptr in the events matching the descriptor's predicates.
std::vector<double> get_values(benchmark_instance_t const &instance,
std::vector<predicate_t> const &predicates,
grapher::json_t::json_pointer value_jptr);
std::vector<grapher::value_t>
get_values(benchmark_instance_t const &instance,
std::vector<predicate_t> const &predicates,
grapher::json_t::json_pointer value_jptr);

/// Generic conversion of a JSON field location to a std::string
template <typename T>
Expand Down Expand Up @@ -172,7 +173,7 @@ grapher::json_t::array_t
write_descriptors(std::vector<group_descriptor_t> const &descriptors);

/// Reads a single descriptor.
group_descriptor_t read_descriptor(grapher::json_t const &j);
group_descriptor_t read_descriptor(grapher::json_t const &descriptor_json);

/// Reads descriptors from a predicate list.
std::vector<group_descriptor_t>
Expand Down
12 changes: 6 additions & 6 deletions grapher/lib/grapher/plotters/compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ void plotter_compare_t::plot(benchmark_set_t const &bset,
std::vector<predicate_t> predicates = get_predicates(descriptor);

for (benchmark_case_t const &bench : bset) {
std::vector<double> x_points;
std::vector<double> y_points;
std::vector<grapher::value_t> x_points;
std::vector<grapher::value_t> y_points;

std::vector<double> x_average;
std::vector<double> y_average;
std::vector<grapher::value_t> x_average;
std::vector<grapher::value_t> y_average;

for (benchmark_instance_t const &instance : bench.instances) {
check(!instance.repetitions.empty(),
fmt::format("No data in benchmark {} for instance size {}.",
bench.name, instance.size),
error_level_t::warning_v);

std::vector<double> const values =
std::vector<grapher::value_t> const values =
get_values(instance, predicates, value_json_pointer);

check(!values.empty(),
Expand All @@ -82,7 +82,7 @@ void plotter_compare_t::plot(benchmark_set_t const &bset,

// Drawing points
if (draw_points) {
for (double value : values) {
for (grapher::value_t value : values) {
x_points.push_back(instance.size);
y_points.push_back(value);
}
Expand Down
Loading