Skip to content

Commit

Permalink
CI now builds in windows too
Browse files Browse the repository at this point in the history
* made Abseil & Boost optional
* minor warning fixes in svector
* Updated unit tests so it compiles with strict warnings
* Bump version to 1.0.3
  • Loading branch information
martinus committed Mar 28, 2023
1 parent 63ea333 commit cbeced4
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 74 deletions.
40 changes: 30 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: ./scripts/lint/lint-all.py

linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install dependencies boost
run: sudo apt-get install -yq libboost-dev
- uses: actions/checkout@v3
- run: sudo apt-get install -yq libboost-dev
- uses: hendrikmuhs/[email protected]
- uses: actions/setup-python@v1
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: pip install meson ninja
- run: meson setup builddir/
env:
CXX: ccache c++
- run: meson test -C builddir/ -v
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
if: failure()
with:
name: Linux_Meson_Testlog
Expand All @@ -38,17 +37,38 @@ jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: brew install gcc boost ccache meson ninja
- run: meson setup builddir/
env:
CXX: ccache c++
- run: meson test -C builddir/ -v
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
if: failure()
with:
name: MacOS_Meson_Testlog
path: builddir/meson-logs/testlog.txt

windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: BSFishy/pip-action@v1
with:
packages: ninja meson
- uses: ilammy/msvc-dev-cmd@v1
- run: meson setup builddir
- run: meson test -C builddir -v
- uses: actions/upload-artifact@v3
if: failure()
with:
name: Windows_Meson_Testlog
path: |
builddir/meson-logs/testlog.txt
builddir/test/test-svector.exe
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)
project("svector"
VERSION 1.0.2
VERSION 1.0.3
DESCRIPTION " Compact SVO optimized vector for C++17 or higher"
HOMEPAGE_URL "https://github.com/martinus/svector")

Expand Down
14 changes: 7 additions & 7 deletions include/ankerl/svector.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// ┌─┐┬ ┬┌─┐┌─┐┌┬┐┌─┐┬─┐ Compact SVO optimized vector C++17 or higher
// └─┐└┐┌┘├┤ │ │ │ │├┬┘ Version 1.0.2
// └─┐└┐┌┘├┤ │ │ │ │├┬┘ Version 1.0.3
// └─┘ └┘ └─┘└─┘ ┴ └─┘┴└─ https://github.com/martinus/svector
//
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
// SPDX-License-Identifier: MIT
// Copyright (c) 2022 Martin Leitner-Ankerl <[email protected]>
// Copyright (c) 2022-2023 Martin Leitner-Ankerl <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -30,7 +30,7 @@
// see https://semver.org/spec/v2.0.0.html
#define ANKERL_SVECTOR_VERSION_MAJOR 1 // incompatible API changes
#define ANKERL_SVECTOR_VERSION_MINOR 0 // add functionality in a backwards compatible manner
#define ANKERL_SVECTOR_VERSION_PATCH 2 // backwards compatible bug fixes
#define ANKERL_SVECTOR_VERSION_PATCH 3 // backwards compatible bug fixes

// API versioning with inline namespace, see https://www.foonathan.net/2018/11/inline-namespaces/
#define ANKERL_SVECTOR_VERSION_CONCAT1(major, minor, patch) v##major##_##minor##_##patch
Expand Down Expand Up @@ -211,7 +211,7 @@ class svector {

// sets size of direct mode and mode to direct too.
constexpr void set_direct_and_size(size_t s) {
m_data[0] = (s << 1U) | 1U;
m_data[0] = static_cast<uint8_t>((s << 1U) | 1U);
}

[[nodiscard]] auto direct_data() -> T* {
Expand Down Expand Up @@ -285,9 +285,9 @@ class svector {
// indirect -> indirect
uninitialized_move_and_destroy(data<direction::indirect>(), storage->data(), size<direction::indirect>());
storage->size(size<direction::indirect>());
auto* storage = indirect();
std::destroy_at(storage);
::operator delete(storage);
auto* storage_direct = indirect();
std::destroy_at(storage_direct);
::operator delete(storage_direct);
}
set_indirect(storage);
}
Expand Down
9 changes: 7 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
#

project('svector', 'cpp',
version: '1.0.2',
version: '1.0.3',
license: 'MIT',
default_options : ['cpp_std=c++17', 'warning_level=3', 'werror=true'])
default_options : [
'cpp_std=c++17',
'warning_level=3',
'werror=true',
'b_ndebug=true', # otherwise absl is really slow!
])

incdir = include_directories('include')
subdir('test')
Expand Down
19 changes: 11 additions & 8 deletions subprojects/abseil-cpp.wrap
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
[wrap-file]
directory = abseil-cpp-20211102.0
source_url = https://github.com/abseil/abseil-cpp/archive/20211102.0.tar.gz
source_filename = abseil-cpp-20211102.0.tar.gz
source_hash = dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4
patch_filename = abseil-cpp_20211102.0-3_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/abseil-cpp_20211102.0-3/get_patch
patch_hash = 3b49ff46df64414bac034b58bf36a07457375b6f8d8b5158e341157c6f9efad2
directory = abseil-cpp-20230125.1
source_url = https://github.com/abseil/abseil-cpp/archive/20230125.1.tar.gz
source_filename = abseil-cpp-20230125.1.tar.gz
source_hash = 81311c17599b3712069ded20cca09a62ab0bf2a89dfa16993786c8782b7ed145
patch_filename = abseil-cpp_20230125.1-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/abseil-cpp_20230125.1-1/get_patch
patch_hash = a920ab28067e433d7ead2d564a4f511628f498f0723f7f94d19317877787ef39
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/abseil-cpp_20230125.1-1/abseil-cpp-20230125.1.tar.gz
wrapdb_version = 20230125.1-1

[provide]
absl_base = absl_base_dep
absl_container = absl_container_dep
absl_debugging = absl_debugging_dep
absl_log = absl_log_dep
absl_flags = absl_flags_dep
absl_hash = absl_hash_dep
absl_crc = absl_crc_dep
absl_numeric = absl_numeric_dep
absl_random = absl_random_dep
absl_status = absl_status_dep
absl_strings = absl_strings_dep
absl_synchronization = absl_synchronization_dep
absl_time = absl_time_dep
absl_types = absl_types_dep

10 changes: 5 additions & 5 deletions subprojects/doctest.wrap
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[wrap-file]
directory = doctest-2.4.8
source_url = https://github.com/doctest/doctest/archive/refs/tags/v2.4.8.tar.gz
source_filename = doctest-2.4.8.tar.gz
source_hash = f52763630aa17bd9772b54e14b6cdd632c87adf0169455a86a49bd94abf2cd83
directory = doctest-2.4.9
source_url = https://github.com/doctest/doctest/archive/refs/tags/v2.4.9.tar.gz
source_filename = doctest-2.4.9.tar.gz
source_hash = 19b2df757f2f3703a5e63cee553d85596875f06d91a3333acd80a969ef210856
wrapdb_version = 2.4.9-1

[provide]
dependency_names = doctest

16 changes: 8 additions & 8 deletions subprojects/fmt.wrap
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[wrap-file]
directory = fmt-8.1.1
source_url = https://github.com/fmtlib/fmt/archive/8.1.1.tar.gz
source_filename = fmt-8.1.1.tar.gz
source_hash = 3d794d3cf67633b34b2771eb9f073bde87e846e0d395d254df7b211ef1ec7346
patch_filename = fmt_8.1.1-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_8.1.1-1/get_patch
patch_hash = 6035a67c7a8c90bed74c293c7265c769f47a69816125f7566bccb8e2543cee5e
directory = fmt-9.1.0
source_url = https://github.com/fmtlib/fmt/archive/9.1.0.tar.gz
source_filename = fmt-9.1.0.tar.gz
source_hash = 5dea48d1fcddc3ec571ce2058e13910a0d4a6bab4cc09a809d8b1dd1c88ae6f2
patch_filename = fmt_9.1.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_9.1.0-1/get_patch
patch_hash = 4557b9ba87b3eb63694ed9b21d1a2117d4a97ca56b91085b10288e9a5294adf8
wrapdb_version = 9.1.0-1

[provide]
fmt = fmt_dep

15 changes: 15 additions & 0 deletions test/app/boost_absl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#if __has_include(<absl/container/inlined_vector.h>)
# define ANKERL_SVECTOR_HAS_ABSL() 1
# include <absl/container/inlined_vector.h>
#else
# define ANKERL_SVECTOR_HAS_ABSL() 0
#endif

#if __has_include(<boost/container/small_vector.hpp>)
# define ANKERL_SVECTOR_HAS_BOOST() 1
# include <boost/container/small_vector.hpp>
#else
# define ANKERL_SVECTOR_HAS_BOOST() 0
#endif
7 changes: 5 additions & 2 deletions test/bench/bench_accumulate.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <ankerl/svector.h>
#include <app/boost_absl.h>
#include <app/name_of_type.h>
#include <app/nanobench.h>

#include <doctest.h>

#include <absl/container/inlined_vector.h>
#include <boost/container/small_vector.hpp>
#include <fmt/format.h>

#include <fstream>
Expand Down Expand Up @@ -35,8 +34,12 @@ TEST_CASE("bench_accumulate_numeric" * doctest::skip() * doctest::test_suite("be
bench.epochs(100);

accumulate_numeric<std::vector<uint64_t>>(num_items, bench);
#if ANKERL_SVECTOR_HAS_ABSL()
accumulate_numeric<absl::InlinedVector<uint64_t, 7>>(num_items, bench);
#endif
#if ANKERL_SVECTOR_HAS_BOOST()
accumulate_numeric<boost::container::small_vector<uint64_t, 7>>(num_items, bench);
#endif
accumulate_numeric<ankerl::svector<uint64_t, 7>>(num_items, bench);

auto f = std::ofstream("bench_accumulate_numeric.html");
Expand Down
11 changes: 9 additions & 2 deletions test/bench/bench_emplace_back.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <ankerl/svector.h>
#include <app/boost_absl.h>
#include <app/name_of_type.h>
#include <app/nanobench.h>

#include <doctest.h>

#include <absl/container/inlined_vector.h>
#include <boost/container/small_vector.hpp>
#include <fmt/format.h>

#include <fstream>
Expand All @@ -31,8 +30,12 @@ TEST_CASE("bench_emplace_back_int" * doctest::skip() * doctest::test_suite("benc
bench.epochs(100);

emplace_back<std::vector<int>>(bench, num_items);
#if ANKERL_SVECTOR_HAS_ABSL()
emplace_back<absl::InlinedVector<int, 4>>(bench, num_items);
#endif
#if ANKERL_SVECTOR_HAS_BOOST()
emplace_back<boost::container::small_vector<int, 4>>(bench, num_items);
#endif
emplace_back<ankerl::svector<int, 4>>(bench, num_items);

auto f = std::ofstream("bench_emplace_back_int.html");
Expand All @@ -46,8 +49,12 @@ TEST_CASE("bench_emplace_back_string" * doctest::skip() * doctest::test_suite("b
bench.epochs(100);

emplace_back<std::vector<std::string>>(bench, num_items, "hello");
#if ANKERL_SVECTOR_HAS_ABSL()
emplace_back<absl::InlinedVector<std::string, 7>>(bench, num_items, "hello");
#endif
#if ANKERL_SVECTOR_HAS_BOOST()
emplace_back<boost::container::small_vector<std::string, 7>>(bench, num_items, "hello");
#endif
emplace_back<ankerl::svector<std::string, 7>>(bench, num_items, "hello");

auto f = std::ofstream("bench_emplace_back_string.html");
Expand Down
11 changes: 9 additions & 2 deletions test/bench/bench_fill_front.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <ankerl/svector.h>
#include <app/boost_absl.h>
#include <app/name_of_type.h>
#include <app/nanobench.h>

#include <doctest.h>

#include <absl/container/inlined_vector.h>
#include <boost/container/small_vector.hpp>
#include <fmt/format.h>

#include <fstream>
Expand All @@ -32,8 +31,12 @@ TEST_CASE("bench_fill_front_int" * doctest::skip() * doctest::test_suite("bench"
bench.title("emplace(vec.begin(), ...)");

fill_front<std::vector<int>>(bench, num_items);
#if ANKERL_SVECTOR_HAS_ABSL()
fill_front<absl::InlinedVector<int, 7>>(bench, num_items);
#endif
#if ANKERL_SVECTOR_HAS_BOOST()
fill_front<boost::container::small_vector<int, 7>>(bench, num_items);
#endif
fill_front<ankerl::svector<int, 7>>(bench, num_items);

auto f = std::ofstream("bench_fill_front_int.html");
Expand All @@ -47,8 +50,12 @@ TEST_CASE("bench_fill_front_string" * doctest::skip() * doctest::test_suite("ben

fill_front<std::vector<std::string>>(bench, num_items, "hello");
fill_front<ankerl::svector<std::string, 7>>(bench, num_items, "hello");
#if ANKERL_SVECTOR_HAS_ABSL()
fill_front<absl::InlinedVector<std::string, 7>>(bench, num_items, "hello");
#endif
#if ANKERL_SVECTOR_HAS_BOOST()
fill_front<boost::container::small_vector<std::string, 7>>(bench, num_items, "hello");
#endif

auto f = std::ofstream("bench_fill_front_string.html");
bench.render(ankerl::nanobench::templates::htmlBoxplot(), f);
Expand Down
14 changes: 11 additions & 3 deletions test/bench/bench_fill_random.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <ankerl/svector.h>
#include <app/boost_absl.h>
#include <app/name_of_type.h>
#include <app/nanobench.h>

#include <doctest.h>

#include <absl/container/inlined_vector.h>
#include <boost/container/small_vector.hpp>
#include <fmt/format.h>

#include <fstream>
Expand All @@ -18,7 +17,7 @@ void fill_random(ankerl::nanobench::Bench& bench, size_t num_items) {
auto rng = ankerl::nanobench::Rng(1234);
auto vec = Vec();
for (size_t i = 0; i < num_items; ++i) {
auto it = vec.begin() + rng.bounded(vec.size());
auto it = vec.begin() + rng.bounded(static_cast<uint32_t>(vec.size()));
if constexpr (std::is_same_v<typename Vec::value_type, std::string>) {
vec.emplace(it, "hello");
} else {
Expand All @@ -36,8 +35,12 @@ TEST_CASE("bench_fill_random_uint64_t" * doctest::skip() * doctest::test_suite("
bench.epochs(100);

fill_random<std::vector<uint64_t>>(bench, num_items);
#if ANKERL_SVECTOR_HAS_ABSL()
fill_random<absl::InlinedVector<uint64_t, 7>>(bench, num_items);
#endif
#if ANKERL_SVECTOR_HAS_BOOST()
fill_random<boost::container::small_vector<uint64_t, 7>>(bench, num_items);
#endif
fill_random<ankerl::svector<uint64_t, 7>>(bench, num_items);

auto f = std::ofstream("bench_fill_random_uint64_t.html");
Expand All @@ -51,8 +54,13 @@ TEST_CASE("bench_fill_random_string" * doctest::skip() * doctest::test_suite("be
bench.epochs(100);

fill_random<std::vector<std::string>>(bench, num_items);
#if ANKERL_SVECTOR_HAS_ABSL()
fill_random<absl::InlinedVector<std::string, 7>>(bench, num_items);
#endif
#if ANKERL_SVECTOR_HAS_BOOST()
fill_random<boost::container::small_vector<std::string, 7>>(bench, num_items);

#endif
fill_random<ankerl::svector<std::string, 7>>(bench, num_items);

auto f = std::ofstream("bench_fill_random_string.html");
Expand Down
Loading

0 comments on commit cbeced4

Please sign in to comment.