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

0.1.0 update #12

Merged
merged 59 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
39c9174
Added internal JSON alias type
JPenuchot Apr 15, 2022
97defd4
Updated code to use grapher::json_t alias type instead oh nlohmann::json
JPenuchot Apr 15, 2022
c7f763d
Using boost::container::flat_map instead of std::map for JSON objects…
JPenuchot Apr 15, 2022
d5d0614
Added reference to CPPP 2021 presentation
JPenuchot Apr 19, 2022
039942b
Patch version bump
JPenuchot Apr 19, 2022
dc7e548
Fix readme link to example configs
JPenuchot Apr 19, 2022
055ed66
Added error management code
JPenuchot Apr 27, 2022
ebb0e2a
Linking against fmt
JPenuchot Apr 27, 2022
720f6bf
Error management cleanup thanks to new check() and warn() functions
JPenuchot Apr 27, 2022
e4bf5fa
Slight refactoring
JPenuchot Apr 27, 2022
30eb023
Improved json_value: reference support, better type handling (uses gr…
JPenuchot May 5, 2022
c799417
Removed unnecessary copies
JPenuchot May 5, 2022
6c6997b
Added new core types for maps and multimaps, based on boost containers
JPenuchot May 10, 2022
007a3b0
JSON value access improvements: refactoring, added support for more t…
JPenuchot May 10, 2022
5decd88
Replaced JSON value and reference access with json_at and json_at_ref…
JPenuchot May 10, 2022
98c3aab
Bump to v0.1.0
JPenuchot May 10, 2022
0eae4cb
Added partial implementation for compare_all
JPenuchot May 10, 2022
aabe4a4
Replaced .get_ref with json_at_ref
JPenuchot May 10, 2022
de213d1
Made json_at an inline function
JPenuchot May 10, 2022
3f31cee
compare_all progress: data wrangling and curve vector building now fi…
JPenuchot May 10, 2022
d128fb2
Added plot drawing, to be improved by adding legends and so on
JPenuchot May 11, 2022
6459ce3
Added compare_all to exposed plotters, disabled grouped_histogram
JPenuchot May 11, 2022
fdbbaae
Fixed json_pointer constructions and split curve vector declarations …
JPenuchot May 11, 2022
c021c0e
Added fallback return statement in to_string
JPenuchot May 11, 2022
99c9f62
Added CMakePresets.json file, three presets are available including o…
JPenuchot May 11, 2022
8959d76
Added git exception for builds where non-dev builds are compiled
JPenuchot May 11, 2022
616c78c
Generating one plot per feature instead of one plot per feature+bench…
JPenuchot May 12, 2022
e8f51b4
Added exception for CMakeUserPresets.json
JPenuchot May 12, 2022
0930d22
Error management fix: warning no longer terminates execution. Conditi…
JPenuchot May 12, 2022
5ac2d47
compare_all renamed to compare_by, error reporting improved
JPenuchot May 12, 2022
979561f
release/debug builds are now inside of build instead of builds
JPenuchot May 12, 2022
4898a21
Added log error level (like info but will be enabled with a verbose f…
JPenuchot May 12, 2022
0998187
JSON dump format is now a single line for more compact info reports
JPenuchot May 12, 2022
87bc748
Error message simplification
JPenuchot May 12, 2022
7d84267
clang-format
JPenuchot May 12, 2022
1fe7e7d
Added plot saving helper function to manage multiple extensions more …
JPenuchot May 12, 2022
dacac45
Using new save_plot function across all plotters
JPenuchot May 12, 2022
962eca2
Changed x/ylabel to x_/y_label for parameter name style consistency, …
JPenuchot May 13, 2022
1ad344a
get_help() return type is now std::string instead of std::string_view
JPenuchot May 16, 2022
1e76b0a
Changed return type of get_help to std::string
JPenuchot May 16, 2022
2b76d9f
Changed return type of get_help to std::string
JPenuchot May 16, 2022
0c91fca
Max filename limit made a tiny bit cleaner (just a tiny bit)
JPenuchot May 16, 2022
027a880
Refactoring, added C++ symbol name demangling, more comments, more he…
JPenuchot May 16, 2022
90458d5
Added getter for default plot options explainer
JPenuchot May 16, 2022
b306cc4
Small refactoring, better explainer
JPenuchot May 16, 2022
b78198a
Removed llvm-timescopes documentation as the file will likely remain …
JPenuchot May 16, 2022
16888da
ENABLE_DOCS is now a cache variable
JPenuchot May 16, 2022
a689173
Removed get_help, plotter documentation will be moved to doxygen
JPenuchot May 16, 2022
6403b29
Removed help command from grapher-utils
JPenuchot May 16, 2022
862ea43
Removed get_help declarations from plotter declarations
JPenuchot May 16, 2022
93acc98
Replaced get_help functions with doxygen paragraphs
JPenuchot May 16, 2022
1f1ea64
Renamed plotter_i to plotter_base_t
JPenuchot May 16, 2022
5857044
Fused utils/config and utils/plot into utils/json, improved documenta…
JPenuchot May 17, 2022
c40a05e
Improved debug messages for json ref getter
JPenuchot Jun 23, 2022
8cdcb1b
Removed useless header
JPenuchot Jun 23, 2022
3864960
Fix ref type for value computation
JPenuchot Jun 23, 2022
e0e8224
Fixed y_label value getting for plot config
JPenuchot Jun 24, 2022
a671230
Adapted to new Sciplot API
JPenuchot Aug 3, 2022
f13fe7c
Adapted to other Sciplot and Nlohmann JSON API changes
JPenuchot Aug 3, 2022
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.cache/
generated-docs/
build/
builds/
CMakeUserPresets.json
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
cmake_minimum_required(VERSION 3.21)
project(ctbench VERSION 0.0.1)
project(ctbench VERSION 0.1.0)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)

set(ENABLE_DOCS ON CACHE BOOL "Enable documentation target")

if(${ENABLE_CLANG_TIDY})
set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=-*,readability-*)
endif()
Expand Down
57 changes: 57 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "dev",
"displayName": "Development",
"description": "Development build, provides compile_commands.json",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"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-*"
}
},
{
"name": "release",
"displayName": "Release",
"description": "Release build",
"binaryDir": "${sourceDir}/build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "debug",
"inherits": "release",
"displayName": "Debug",
"description": "Debug build",
"binaryDir": "${sourceDir}/build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
}
],
"buildPresets": [
{
"name": "dev",
"configurePreset": "dev"
},
{
"name": "release",
"configurePreset": "release"
},
{
"name": "debug",
"configurePreset": "debug"
}
]
}
55 changes: 0 additions & 55 deletions docs/llvm-timescopes.md

This file was deleted.

4 changes: 3 additions & 1 deletion grapher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
find_package(nlohmann_json 3.9.1 REQUIRED)
find_package(sciplot REQUIRED)
find_package(LLVM REQUIRED CONFIG)
find_package(fmt)

# Declaring the grapher library
file(GLOB_RECURSE GRAPHER_SOURCES lib/*.cpp)
add_library(grapher STATIC ${GRAPHER_SOURCES})

target_link_libraries(grapher PUBLIC ctbench-compile-opts)
target_include_directories(grapher PUBLIC include)

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})
sciplot::sciplot stdc++fs tbb fmt::fmt ${llvm_libs})

target_compile_options(grapher PUBLIC -DJSON_NOEXCEPTION)

Expand Down
39 changes: 0 additions & 39 deletions grapher/configs/readme.md

This file was deleted.

5 changes: 3 additions & 2 deletions grapher/grapher-plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main(int argc, char const *argv[]) {
llvm::cl::ParseCommandLineOptions(argc, argv);

// Get configed
nlohmann::json config;
grapher::json_t config;
{
std::ifstream config_file(cli::config_opt.getValue());
if (!config_file) {
Expand All @@ -47,7 +47,8 @@ int main(int argc, char const *argv[]) {
// Acquire plotter
grapher::plotter_t plotter =
grapher::plotter_type_to_plotter(grapher::string_to_plotter_type(
grapher::json_value<std::string>(config, "plotter")));
grapher::json_at_ref<grapher::json_t::string_t const &>(config,
"plotter")));

// Build cats
grapher::benchmark_set_t bset =
Expand Down
17 changes: 5 additions & 12 deletions grapher/grapher-utils.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/raw_ostream.h>

#include "grapher/plotters/plotter_i.hpp"
#include "grapher/plotters/plotters.hpp"

namespace cli {
Expand All @@ -14,16 +13,13 @@ lc::opt<grapher::plotter_type_t> plotter_opt("plotter", lc::Required,

enum command_enum_t {
generate_config_v,
help_v,
};

lc::opt<command_enum_t> command_opt(
"command", lc::Required, lc::desc("Command:"),
lc::values(lc::OptionEnumValue{"get-help", command_enum_t::help_v,
"Get plotter help."},
lc::OptionEnumValue{"get-default-config",
command_enum_t::generate_config_v,
"Output plotter default config."}));
lc::opt<command_enum_t>
command_opt("command", lc::Required, lc::desc("Command:"),
lc::values(lc::OptionEnumValue{
"get-default-config", command_enum_t::generate_config_v,
"Output plotter default config."}));

} // namespace cli

Expand All @@ -38,9 +34,6 @@ int main(int argc, char const *argv[]) {
case cli::generate_config_v:
llvm::outs() << plotter->get_default_config().dump(2) << '\n';
break;
case cli::help_v:
llvm::outs() << plotter->get_help() << '\n';
break;
}

return 0;
Expand Down
23 changes: 22 additions & 1 deletion grapher/include/grapher/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@

#include <filesystem>
#include <string>
#include <tuple>

#include <nlohmann/json.hpp>

#include <boost/container/flat_map.hpp>

namespace grapher {

// Basic container types

template <typename KeyType, typename ValueType,
typename CompareType = std::less<KeyType>>
using map_t = boost::container::flat_map<KeyType, ValueType, CompareType>;

template <typename KeyType, typename ValueType,
typename CompareType = std::less<KeyType>>
using multimap_t =
boost::container::flat_multimap<KeyType, ValueType, CompareType>;

/// Alias type for JSON objects.
using json_t = nlohmann::basic_json<boost::container::flat_map>;

// `time cmake --build --preset bench` results using different containers
// (poacher/brainfuck project, pre-built benchmark targets):
// - boost::container::flat_map -> 78.05 secs
// - std::map -> 87.08 secs
// - boost::container::map -> 80.16 secs

/// Set of results for a benchmark case iteration of a given size.
struct benchmark_iteration_t {
/// Size of the benchmark instance
Expand Down
53 changes: 46 additions & 7 deletions grapher/include/grapher/plotters/compare.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,57 @@
#pragma once

#include "grapher/plotters/plotter_i.hpp"
#include "grapher/plotters/plotter_base.hpp"

namespace grapher::plotters {

/// \ingroup plotters
/// For each group descriptor, generates a graph comparing all benchmark cases
/// in the set.
///
/// Plotter-specific JSON parameters:
/// - `value_json_pointer` (`string`): pointer to JSON value to measure
/// - `draw_average` (`bool`): enable average curve drawing
/// - `draw_points` (`bool`): enable point value drawing
/// - `group_descriptors` (group descriptors): see group_descriptor_t
/// documentation
///
/// \copydetails base_default_config
///
/// Example config:
/// \code{.json}
/// {
/// "draw_average": true,
/// "draw_points": true,
/// "group_descriptors": [
/// {
/// "name": "All",
/// "predicates": [
/// {
/// "pointer": "/name",
/// "regex": "*",
/// "type": "regex"
/// }
/// ]
/// }
/// ],
/// "height": 500,
/// "legend_title": "Timings",
/// "plot_file_extensions": [
/// ".svg",
/// ".png"
/// ],
/// "plotter": "compare",
/// "value_json_pointer": "/dur",
/// "width": 1500,
/// "x_label": "Benchmark size factor",
/// "y_label": "Time (µs)"
/// }
/// \endcode

struct plotter_compare_t : plotter_i {
struct plotter_compare_t : plotter_base_t {
void plot(benchmark_set_t const &bset, std::filesystem::path const &dest,
nlohmann::json const &config) const override;
grapher::json_t const &config) const override;

std::string_view get_help() const override;

nlohmann::json get_default_config() const override;
grapher::json_t get_default_config() const override;
};

} // namespace grapher::plotters
Loading