Skip to content

Commit

Permalink
Merge pull request #12 from JPenuchot/dev
Browse files Browse the repository at this point in the history
0.1.0 update
  • Loading branch information
JPenuchot authored Aug 3, 2022
2 parents bfeda57 + f13fe7c commit db83ff6
Show file tree
Hide file tree
Showing 35 changed files with 1,058 additions and 649 deletions.
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

0 comments on commit db83ff6

Please sign in to comment.