Skip to content

Commit

Permalink
Merge branch 'master' into service-fetch-rti
Browse files Browse the repository at this point in the history
  • Loading branch information
UNEXENU authored Feb 21, 2025
2 parents 35cbcaa + 36cdbd4 commit fc64268
Show file tree
Hide file tree
Showing 263 changed files with 6,782 additions and 4,156 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ LineEnding: LF
InsertNewlineAtEOF: true
RequiresClausePosition: SingleLine
IndentRequiresClause: false
AttributeMacros: [CPP_member, CPP_auto_member, CPP_fun, CPP_auto_fun]
# TODO<joka921> Update to Clang-format-17 and then we can have much nicer CPP_... macros.
#Macros:
# - CPP_template_2(x)=template<x> requires
...
3 changes: 2 additions & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
- name: Install coverage tools
run: |
sudo apt install -y llvm-16
sudo apt install mold
- name: Show path
run: |
which llvm-profdata-16
Expand All @@ -60,7 +61,7 @@ jobs:
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build ${{env.cmake-flags}} -DCMAKE_BUILD_TYPE=${{env.build-type}} -DLOGLEVEL=TIMING -DADDITIONAL_COMPILER_FLAGS="${{env.warnings}} ${{env.asan-flags}} ${{env.ubsan-flags}} ${{env.coverage-flags}}" -DADDITIONAL_LINKER_FLAGS="${{env.coverage-flags}}" -DUSE_PARALLEL=false -DRUN_EXPENSIVE_TESTS=false -DSINGLE_TEST_BINARY=ON -DENABLE_EXPENSIVE_CHECKS=true
run: cmake -B ${{github.workspace}}/build ${{env.cmake-flags}} -DCMAKE_BUILD_TYPE=${{env.build-type}} -DLOGLEVEL=TIMING -DADDITIONAL_COMPILER_FLAGS="${{env.warnings}} ${{env.asan-flags}} ${{env.ubsan-flags}} ${{env.coverage-flags}}" -DADDITIONAL_LINKER_FLAGS="${{env.coverage-flags}}" -DUSE_PARALLEL=false -DRUN_EXPENSIVE_TESTS=false -DSINGLE_TEST_BINARY=ON -DENABLE_EXPENSIVE_CHECKS=true -DADDITIONAL_LINKER_FLAGS="-fuse-ld=mold"

- name: Build
# Build your program with the given configuration
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
run: |
pip3 install pyaml pyicu
- name: Install conan
run: |
brew install conan@2
- name: Install dependencies
run: |
brew install llvm@16
Expand All @@ -46,27 +49,34 @@ jobs:
echo 'export LDFLAGS="-L/usr/local/opt/llvm@16/lib -L/usr/local/opt/llvm@16/lib/c++ -Wl,-rpath,/usr/local/opt/llvm@16/lib/c++"' >> ~/.bash_profile
echo LDFLAGS="-L/usr/local/opt/llvm@16/lib -L/usr/local/opt/llvm@16/lib/c++ -Wl,-rpath,/usr/local/opt/llvm@16/lib/c++" >> $GITHUB_ENV
echo 'export CPPFLAGS="-I/usr/local/opt/llvm@16/include"' >> ~/.bash_profile
echo CPPFLAGS="/usr/local/opt/llvm@16/include" >> $GITHUB_ENV
echo CPPFLAGS="-I/usr/local/opt/llvm@16/include" >> $GITHUB_ENV
echo 'export CFLAGS="-I/usr/local/opt/llvm@16/include"' >> ~/.bash_profile
echo CFLAGS="-I/usr/local/opt/llvm@16/include" >> $GITHUB_ENV
echo 'export CC="/usr/local/opt/llvm@16/bin/clang"' >> ~/.bash_profile
echo CC="/usr/local/opt/llvm@16/bin/clang" >> $GITHUB_ENV
echo 'export CXX="/usr/local/opt/llvm@16/bin/clang++"' >> ~/.bash_profile
echo CXX="/usr/local/opt/llvm@16/bin/clang++" >> $GITHUB_ENV
source ~/.bash_profile
- name: Print clang version
run: clang++ --version

- name: Cache for conan
uses: actions/cache@v3
env:
cache-name: cache-conan-modules
cache-name: cache-conan-modules-macos-13
with:
path: ~/.conan2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('conanfile.txt') }}
- name: Create build directory
run: mkdir ${{github.workspace}}/build
- name: Install and run conan
working-directory: ${{github.workspace}}/build
run: >
conan install .. -pr:b=../conanprofiles/clang-16-macos -pr:h=../conanprofiles/clang-16-macos -of=. --build=missing;
run: |
conan install .. -pr:b=../conanprofiles/clang-16-macos -pr:h=../conanprofiles/clang-16-macos -of=. --build=missing
- name: Configure CMake
# For std::ranges::join_view we need the -fexperimental-library flag on libc++16, which on Mac requires to manually tinker with the linking flags.
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DCMAKE_TOOLCHAIN_FILE="$(pwd)/build/conan_toolchain.cmake" -DUSE_PARALLEL=true -DRUN_EXPENSIVE_TESTS=false -DENABLE_EXPENSIVE_CHECKS=true -DCMAKE_CXX_COMPILER=clang++ -DADDITIONAL_COMPILER_FLAGS="-fexperimental-library" -D_NO_TIMING_TESTS=ON -DADDITIONAL_LINKER_FLAGS="-L$(brew --prefix llvm)/lib/c++"
# We currently cannot use the parallel algorithms, as the parallel sort requires a GNU-extension, and we build with `libc++`.
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DCMAKE_TOOLCHAIN_FILE="$(pwd)/build/conan_toolchain.cmake" -DUSE_PARALLEL=false -DRUN_EXPENSIVE_TESTS=false -DENABLE_EXPENSIVE_CHECKS=true -DCMAKE_CXX_COMPILER=clang++ -DADDITIONAL_COMPILER_FLAGS="-fexperimental-library" -D_NO_TIMING_TESTS=ON -DADDITIONAL_LINKER_FLAGS="-L$(brew --prefix llvm)/lib/c++"

- name: Build
# Build your program with the given configuration
Expand Down
71 changes: 36 additions & 35 deletions benchmark/JoinAlgorithmBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ static constexpr bool isValuePreservingCast(const Source& source) {
/*
@brief Return biggest possible value for the given arithmetic type.
*/
template <ad_utility::Arithmetic Type>
consteval Type getMaxValue() {
CPP_template(typename Type)(
requires ad_utility::Arithmetic<Type>) consteval Type getMaxValue() {
return std::numeric_limits<Type>::max();
}

Expand Down Expand Up @@ -408,10 +408,10 @@ static double calculateNextWholeExponent(const T& base,
@brief Generate a sorted, inclusive interval of exponents $base^x$, with $x$
always a natural number.
*/
template <ad_utility::Arithmetic T>
requires std::convertible_to<T, double>
static std::vector<T> generateExponentInterval(T base, T inclusiveLowerBound,
T inclusiveUpperBound) {
CPP_template(typename T)(requires ad_utility::Arithmetic<T> CPP_and
std::convertible_to<T, double>) static std::
vector<T> generateExponentInterval(T base, T inclusiveLowerBound,
T inclusiveUpperBound) {
std::vector<T> elements{};

/*
Expand Down Expand Up @@ -440,9 +440,9 @@ static std::vector<T> generateExponentInterval(T base, T inclusiveLowerBound,
@brief Generate a sorted,inclusive interval of all natural numbers inside
`[inclusiveLowerBound, inclusiveUpperBound]`.
*/
template <ad_utility::Arithmetic T>
static std::vector<T> generateNaturalNumberSequenceInterval(
T inclusiveLowerBound, T inclusiveUpperBound) {
CPP_template(typename T)(requires ad_utility::Arithmetic<T>) static std::vector<
T> generateNaturalNumberSequenceInterval(T inclusiveLowerBound,
T inclusiveUpperBound) {
if constexpr (std::floating_point<T>) {
inclusiveLowerBound = std::ceil(inclusiveLowerBound);
inclusiveUpperBound = std::floor(inclusiveUpperBound);
Expand All @@ -459,9 +459,8 @@ static std::vector<T> generateNaturalNumberSequenceInterval(

// Merge multiple sorted vectors into one sorted vector, where every element is
// unique.
template <ad_utility::Arithmetic T>
static std::vector<T> mergeSortedVectors(
const std::vector<std::vector<T>>& intervals) {
CPP_template(typename T)(requires ad_utility::Arithmetic<T>) static std::vector<
T> mergeSortedVectors(const std::vector<std::vector<T>>& intervals) {
std::vector<T> mergedVector{};

// Merge.
Expand Down Expand Up @@ -770,27 +769,29 @@ class GeneralInterfaceImplementation : public BenchmarkInterface {
};
};
auto generateBiggerEqualLambdaDesc =
[](const ad_utility::isInstantiation<
ad_utility::ConstConfigOptionProxy> auto& option,
const auto& minimumValue, bool canBeEqual) {
return absl::StrCat("'", option.getConfigOption().getIdentifier(),
"' must be bigger than",
canBeEqual ? ", or equal to," : "", " ",
minimumValue, ".");
};
[]<typename OptionType,
typename = std::enable_if_t<ad_utility::isInstantiation<
OptionType, ad_utility::ConstConfigOptionProxy>>>(
const OptionType& option, const auto& minimumValue,
bool canBeEqual) {
return absl::StrCat("'", option.getConfigOption().getIdentifier(),
"' must be bigger than",
canBeEqual ? ", or equal to," : "", " ", minimumValue,
".");
};

// Object with a `operator()` for the `<=` operator.
auto lessEqualLambda = std::less_equal<size_t>{};
auto generateLessEqualLambdaDesc =
[](const ad_utility::isInstantiation<
ad_utility::ConstConfigOptionProxy> auto& lhs,
const ad_utility::isInstantiation<
ad_utility::ConstConfigOptionProxy> auto& rhs) {
return absl::StrCat("'", lhs.getConfigOption().getIdentifier(),
"' must be smaller than, or equal to, "
"'",
rhs.getConfigOption().getIdentifier(), "'.");
};
[]<typename OptionType,
typename = std::enable_if_t<ad_utility::isInstantiation<
OptionType, ad_utility::ConstConfigOptionProxy>>>(
const OptionType& lhs, const OptionType& rhs) {
return absl::StrCat("'", lhs.getConfigOption().getIdentifier(),
"' must be smaller than, or equal to, "
"'",
rhs.getConfigOption().getIdentifier(), "'.");
};

// Adding the validators.

Expand Down Expand Up @@ -1163,9 +1164,9 @@ class GeneralInterfaceImplementation : public BenchmarkInterface {
chance to be picked.) This adjusts the number of elements in the sample size
to `Amount of rows * ratio`, which affects the possibility of duplicates.
*/
template <ad_utility::InvocableWithExactReturnType<
bool, float, size_t, size_t, size_t, size_t, float, float>
StopFunction,
template <QL_CONCEPT_OR_TYPENAME(ad_utility::InvocableWithExactReturnType<
bool, float, size_t, size_t, size_t, size_t,
float, float>) StopFunction,
isTypeOrGrowthFunction<float> T1, isTypeOrGrowthFunction<float> T2,
isTypeOrGrowthFunction<size_t> T3,
isTypeOrGrowthFunction<size_t> T4,
Expand Down Expand Up @@ -1330,9 +1331,9 @@ class GeneralInterfaceImplementation : public BenchmarkInterface {
ResultTable* table,
const QL_CONCEPT_OR_NOTHING(
ad_utility::SameAsAny<float, size_t>) auto changingParameterValue,
ad_utility::InvocableWithExactReturnType<bool, float, size_t, size_t,
size_t, size_t, float,
float> auto stopFunction,
QL_CONCEPT_OR_NOTHING(ad_utility::InvocableWithExactReturnType<
bool, float, size_t, size_t, size_t, size_t, float,
float>) auto stopFunction,
const float overlap, const std::optional<size_t>& resultTableNumRows,
ad_utility::RandomSeed randomSeed, const bool smallerTableSorted,
const bool biggerTableSorted, const float& ratioRows,
Expand Down
4 changes: 2 additions & 2 deletions benchmark/infrastructure/BenchmarkMeasurementContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ class ResultTable : public BenchmarkMetadataGetter {
@param row, column Which table entry to read. Starts with `(0,0)`.
*/
template <ad_utility::SameAsAnyTypeIn<EntryType> T>
T getEntry(const size_t row, const size_t column) const {
CPP_template(typename T)(requires ad_utility::SameAsAnyTypeIn<T, EntryType>) T
getEntry(const size_t row, const size_t column) const {
AD_CONTRACT_CHECK(row < numRows() && column < numColumns());
static_assert(!ad_utility::isSimilar<T, std::monostate>);

Expand Down
12 changes: 6 additions & 6 deletions benchmark/infrastructure/BenchmarkToJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ provided translation function for the vector entries.
@tparam TranslationFunction Has to be a function, that takes `VectorType`
and returns a `nlohmann:json` object.
*/
template <typename VectorType, ad_utility::InvocableWithExactReturnType<
nlohmann::ordered_json, VectorType>
TranslationFunction>
static nlohmann::json transformIntoJsonArray(
const std::vector<VectorType>& vec,
TranslationFunction translationFunction) {
CPP_template(typename VectorType, typename TranslationFunction)(
requires ad_utility::InvocableWithExactReturnType<
TranslationFunction, nlohmann::ordered_json,
VectorType>) static nlohmann::json
transformIntoJsonArray(const std::vector<VectorType>& vec,
TranslationFunction translationFunction) {
/*
Without explicit instantiation, `nlohmann::nlohmann::ordered_json` is not
guaranteed, to always interpret a `push_back` correctly. For instance,
Expand Down
10 changes: 6 additions & 4 deletions benchmark/util/ResultTableColumnOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ Column number together with the type of value, that can be found inside the
column. Note, that **all** entries in the column must have the same type,
because of `ResultTable::getEntry`.
*/
template <ad_utility::SameAsAnyTypeIn<ResultTable::EntryType> Type>
struct ColumnNumWithType {
CPP_template(typename Type)(
requires ad_utility::SameAsAnyTypeIn<
Type, ResultTable::EntryType>) struct ColumnNumWithType {
using ColumnType = Type;
const size_t columnNum_;
};

template <typename ColumnReturnType, typename... ColumnInputTypes>
requires(sizeof...(ColumnInputTypes) > 0) void generateColumnWithColumnInput(
ResultTable* const table,
ad_utility::InvocableWithSimilarReturnType<
ColumnReturnType, const ColumnInputTypes&...> auto&& generator,
QL_CONCEPT_OR_NOTHING(
ad_utility::InvocableWithSimilarReturnType<
ColumnReturnType, const ColumnInputTypes&...>) auto&& generator,
const ColumnNumWithType<ColumnReturnType>& columnToPutResultIn,
const ColumnNumWithType<ColumnInputTypes>&... inputColumns) {
// Using a column more than once is the sign of an error.
Expand Down
2 changes: 1 addition & 1 deletion conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[requires]
boost/1.81.0
icu/73.1
icu/76.1
openssl/3.1.1
zstd/1.5.5
# The jemalloc recipe for Conan2 is currently broken, uncomment this line as soon as this is fixed.
Expand Down
3 changes: 3 additions & 0 deletions conanprofiles/clang-16-macos
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=16
os=Macos

[conf]
tools.build:compiler_executables={ "c": "clang", "cpp": "clang++"}
52 changes: 48 additions & 4 deletions src/backports/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#pragma once

#include <concepts/concepts.hpp>

#include "backports/cppTemplate2.h"
#ifndef QLEVER_CPP_17
#include <concepts>
#endif
Expand All @@ -19,6 +21,19 @@
// `QL_CONCEPT_OR_TYPENAME(arg)`: expands to `arg` in C++20 mode, and to
// `typename` in C++17 mode. Example usage:
//
// `CPP_lambda(capture)(arg)(requires ...)`: Expands lambda to use
// `requires` in C++20 mode and `std::enable_if_t` in C++17 mode.
//
// `CPP_lambda_mut(capture)(arg)(requires ...)`: Same as
// `CPP_lambda` but for mutable lambdas.
//
// `CPP_template_lambda(capture)(typenames...)(arg)(requires ...)`: Expands
// lambda with (C++20) explicit template parameters to use
// `requires` in C++20 mode and `std::enable_if_t` in C++17 mode.
//
// `CPP_template_lambda_mut(capture)(typenames...)(arg)(requires ...)`: Same as
// `CPP_template_lambda` but for mutable lambdas.
//
// Example usages:
//
// `QL_CONCEPT_OR_NOTHING(std::view) auto x = someFunction();`
Expand All @@ -29,27 +44,56 @@
//
// `template <QL_CONCEPT_OR_TYPENAME(ql::same_as<int>) T> void f(){...}`
//
// `auto myLambda = CPP_lambda(someCapture)(someArg)(requires
// ranges::same_as<decltype(someArg), int>) {...}`
//
// `auto myLambda2 = CPP_lambda(someCapture)(typename F)(F arg)(requires
// ranges::same_as<F, int>) {...}`
//
// NOTE: The macros are variadic to allow for commas in the argument, like in
// the second example above.

// Additionally define the macros `CPP_template_2` and `CPP_and_2` that can
// be used to constrain member functions of classes where the outer class
// has already been constrained with `CPP_template`. For a detailed example, see
// the `test/backports/ConceptsTest.cpp` file.

#ifdef QLEVER_CPP_17
#define QL_CONCEPT_OR_NOTHING(...)
#define QL_CONCEPT_OR_TYPENAME(...) typename
#define CPP_template_2 CPP_template_2_SFINAE
#define CPP_and_2 CPP_and_2_sfinae
#define CPP_and_def CPP_and_sfinae_def
#define CPP_and_2_def CPP_and_2_def_sfinae
#define CPP_variadic_template CPP_template_NO_DEFAULT_SFINAE
#define CPP_member_def CPP_member_def_sfinae
#define CPP_lambda CPP_lambda_sfinae
#define CPP_template_lambda CPP_template_lambda_sfinae
#define CPP_lambda_mut CPP_lambda_mut_sfinae
#define CPP_template_lambda_mut CPP_template_lambda_mut_sfinae
#else
#define QL_CONCEPT_OR_NOTHING(...) __VA_ARGS__
#define QL_CONCEPT_OR_TYPENAME(...) __VA_ARGS__
#define CPP_template_2 CPP_template
#define CPP_and_2 CPP_and
#define CPP_and_def CPP_and
#define CPP_and_2_def CPP_and
#define CPP_variadic_template CPP_template
#define CPP_member_def CPP_member
#define CPP_lambda CPP_LAMBDA_20
#define CPP_template_lambda CPP_TEMPLATE_LAMBDA_20
#define CPP_lambda_mut CPP_lambda_mut_20
#define CPP_template_lambda_mut CPP_TEMPLATE_LAMBDA_MUT_20
#endif

// The namespace `ql::concepts` includes concepts that are contained in the
// C++20 standard as well as in `range-v3`.
namespace ql {
namespace concepts {
namespace ql::concepts {

#ifdef QLEVER_CPP_17
using namespace ::concepts;
#else
using namespace std;
#endif

} // namespace concepts
} // namespace ql
} // namespace ql::concepts
Loading

0 comments on commit fc64268

Please sign in to comment.