Skip to content

Commit

Permalink
added CI/CD; Added opt-in bench and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
WillisMedwell committed Jan 22, 2024
1 parent c80bb66 commit baeb891
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 38 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/native-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: C++ CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
container:
image: ardupilot/ardupilot-dev-clang:latest

steps:
- uses: actions/checkout@v2

- name: Build Clang
run: |
cmake --preset clang-ninja
cmake --build build/clang-ninja
- name: Build GCC
run: |
cmake --preset gcc-ninja
cmake --build build/gcc-ninja
47 changes: 36 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.11)

project(
Utily
Expand All @@ -23,7 +23,7 @@ elseif(NOT MSVC)
# Enable all the warnings.
target_compile_options(Utily_Utily PRIVATE "-Wall" "-Wextra" "-Wpedantic" "-Wcast-align" "-Wcast-qual" "-Wctor-dtor-privacy" "-Wformat=2" "-Winit-self" "-Wmissing-declarations" "-Wmissing-include-dirs" "-Wold-style-cast" "-Woverloaded-virtual" "-Wredundant-decls" "-Wshadow" "-Wsign-conversion" "-Wsign-promo" "-Wstrict-overflow=5" "-Wswitch-default" "-Wundef" "-Wno-unused" "-Wconversion" "-Wsign-compare")
# For std::format.
target_compile_options(Utily_Utily PRIVATE -fexperimental-library)
# target_compile_options(Utily_Utily PRIVATE -fexperimental-library)
message(STATUS "For Native SIMD use flags: \"-mavx2 -mavx512bw\"")
endif()

Expand All @@ -32,9 +32,27 @@ set_property(TARGET Utily_Utily PROPERTY EXPORT_NAME Utily)
target_compile_features(Utily_Utily PUBLIC cxx_std_20)
target_include_directories(Utily_Utily PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

option(BUILD_UTILY_TESTS "Build Utily test suite" OFF)
option(BUILD_UTILY_BENCHMARKS "Build Utily benchmarks" OFF)

if(BUILD_UTILY_TESTS OR BUILD_UTILY_BENCHMARKS)
include(FetchContent)
endif()

# Test Setup
find_package(GTest CONFIG)
if(GTest_FOUND)
if(BUILD_UTILY_TESTS)
find_package(GTest CONFIG)
if(NOT GTest_FOUND)
message(STATUS "Downloading GTest...")
FetchContent_Declare(
GTest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG main
GIT_SHALLOW FALSE
)
FetchContent_MakeAvailable(GTest)
endif()

add_executable(UtilyTest ${UTILY_TEST_SOURCES})
if(DEFINED EMSCRIPTEN)
target_compile_options(UtilyTest PRIVATE "-Wdeprecated-declarations")
Expand All @@ -44,17 +62,26 @@ if(GTest_FOUND)
target_compile_options(UtilyTest PRIVATE "-Wall" "-Wextra" "-Wpedantic" "-Wcast-align" "-Wcast-qual" "-Wctor-dtor-privacy" "-Wformat=2" "-Winit-self" "-Wmissing-declarations" "-Wmissing-include-dirs" "-Wold-style-cast" "-Woverloaded-virtual" "-Wredundant-decls" "-Wshadow" "-Wsign-conversion" "-Wsign-promo" "-Wstrict-overflow=5" "-Wswitch-default" "-Wundef" "-Wno-unused" "-Wconversion" "-Wsign-compare")
target_compile_options(UtilyTest PRIVATE -mavx2 -mavx512bw)
endif()

target_link_libraries(UtilyTest PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main Utily::Utily)
enable_testing()
add_test(NAME AllTestsInUtilyTest COMMAND UtilyTest)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
else()
message(STATUS "Package \"GTest\" not found, not building tests.")
endif()

# Benchmark Setup
find_package(benchmark CONFIG)
if(benchmark_FOUND)
if(BUILD_UTILY_BENCHMARKS)
find_package(benchmark CONFIG)
if(NOT benchmark_FOUND)
message(STATUS "Downloading Benchmark...")
FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark
GIT_TAG main
GIT_SHALLOW FALSE
)
FetchContent_MakeAvailable(benchmark)
endif()
add_executable(UtilyBenchmark ${UTILY_BENCHMARK_SOURCES})

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
Expand All @@ -75,7 +102,5 @@ if(benchmark_FOUND)
target_compile_options(UtilyBenchmark PRIVATE -mavx2 -mavx512bw)
endif()
target_link_libraries(UtilyBenchmark PRIVATE benchmark::benchmark benchmark::benchmark_main Utily::Utily)
else()
message(STATUS "Package \"benchmark\" not found, not building benchmarks.")
endif()

50 changes: 50 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 11,
"patch": 0
},
"configurePresets": [
{
"name": "gcc-ninja",
"description": "Build with GCC and Ninja",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/gcc-ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_UTILY_TESTS": "ON",
"BUILD_UTILY_BENCHMARKS": "ON"
},
"environment": {
"CC": "gcc",
"CXX": "g++"
}
},
{
"name": "clang-ninja",
"description": "Build with Clang and Ninja",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/clang-ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_UTILY_TESTS": "ON",
"BUILD_UTILY_BENCHMARKS": "ON"
},
"environment": {
"CC": "clang",
"CXX": "clang++"
}
}
],
"buildPresets": [
{
"name": "gcc-ninja",
"configurePreset": "gcc-ninja"
},
{
"name": "clang-ninja",
"configurePreset": "clang-ninja"
}
]
}
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ constexpr auto to_array(Args&&... args)
Using Modern cmake features means that we can use CMake as a dependency manager relatively easily.

```CMake
include(FetchContent)
FetchContent_Declare(
Utily
GIT_REPOSITORY https://github.com/WillisMedwell/Utily.git
Expand All @@ -308,6 +310,18 @@ In the future, I would like to have Utily:: supported by package managers like v

</details>

<details><summary><b>Building Tests and Benchmarks</b></summary>

I don't want my users to be wasting time by building the tests and benchmarks.

As such, to build these tests and benchmarks you will need to have both [benchmark](https://github.com/google/benchmark) & [gtest](https://github.com/google/googletest) as 'findable' packages using cmake's `find_package`


---

</details>


<details><summary><b>Conditions</b></summary>

I think its fair to recognise the use of other people's libraries and code; I strive to do my best to recognise other people's contribution and work.
Expand Down
11 changes: 9 additions & 2 deletions benchmark/BenchSimd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
#include <algorithm>
#include <array>
#include <ranges>
#include <numeric>

constexpr static std::string_view LONG_STRING = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz";
// constexpr static std::string_view LONG_STRING = "this is my testing zone";

const static auto iota_view = std::views::iota(0, 10000);
const static std::vector<int32_t> NUMS = { iota_view.begin(), iota_view.end() };
auto iota(int32_t max) -> std::vector<int32_t>
{
std::vector<int32_t> v;
v.resize(max);
std::iota(v.begin(), v.end(), 0);
}

const static std::vector<int32_t> NUMS = iota(10000);

static void BM_Utily_Simd_find_char(benchmark::State& state) {
for (auto _ : state) {
Expand Down
6 changes: 4 additions & 2 deletions include/Utily/AsyncFileReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Utily/Error.hpp"
#include "Utily/Result.hpp"


#if 0

namespace Utily {
class AsyncFileReader
Expand All @@ -37,4 +37,6 @@ namespace Utily {
static void wait_for_all();
static auto wait_pop(std::filesystem::path file_path) -> Utily::Result<std::vector<char>, Utily::Error>;
};
}
}

#endif
15 changes: 4 additions & 11 deletions include/Utily/Concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace Utily {
};
static_assert(HasMoveOperator<std::string>);


template <typename T>
concept HasCopyConstructor = requires(const T& t) {
{
Expand All @@ -41,17 +40,11 @@ namespace Utily {
static_assert(HasCopyOperator<std::string>);

template <typename T>
concept IsContiguousRange = requires(T t) {
{
t.begin()
};
{
t.end()
concept IsContiguousRange =
std::ranges::contiguous_range<T> && std::ranges::sized_range<T> && requires(T a) {
{ std::ranges::data(a) } -> std::contiguous_iterator;
};
{
t.data()
};
};

static_assert(IsContiguousRange<std::string>);
static_assert(!IsContiguousRange<std::list<int>>);

Expand Down
13 changes: 7 additions & 6 deletions include/Utily/Simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <array>
#include <cassert>
#include <cstring>
#include <iostream>

// Check for SSE support
Expand Down Expand Up @@ -77,7 +78,7 @@ namespace Utily::Simd::Details {
}

__m512i c = v;
std::memcpy(&c, (src_begin + max_i_clamped), src_size - max_i_clamped);
memcpy(reinterpret_cast<void*>(&c), (src_begin + max_i_clamped), src_size - max_i_clamped);
uint64_t eq_bits = std::bit_cast<uint64_t>(_mm512_cmpeq_epi8_mask(c, v));
return static_cast<std::ptrdiff_t>(max_i_clamped) + std::countr_zero(eq_bits);
}
Expand All @@ -100,7 +101,7 @@ namespace Utily::Simd::Details {
}

__m256i c = v;
std::memcpy(&c, (src_begin + max_i_clamped), src_size - max_i_clamped);
memcpy(reinterpret_cast<void*>(&c), (src_begin + max_i_clamped), src_size - max_i_clamped);
const __m256i eq = _mm256_cmpeq_epi8(c, v);
uint32_t eq_bits = std::bit_cast<uint32_t>(_mm256_movemask_epi8(eq));
return static_cast<std::ptrdiff_t>(max_i_clamped) + std::countr_zero(eq_bits);
Expand All @@ -125,7 +126,7 @@ namespace Utily::Simd::Details {
}

__m128i c = v;
std::memcpy(&c, (src_begin + max_i_clamped), src_size - max_i_clamped);
memcpy(reinterpret_cast<void*>(&c), (src_begin + max_i_clamped), src_size - max_i_clamped);
uint32_t eq_bits = std::bit_cast<uint32_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(c, v)));
return static_cast<std::ptrdiff_t>(max_i_clamped) + std::countr_zero(eq_bits);
}
Expand Down Expand Up @@ -165,7 +166,7 @@ namespace Utily::Simd::Details {
}
}
Vec c = v;
std::memcpy(&c, (src_begin + max_i_clamped), src_size - max_i_clamped);
memcpy(reinterpret_cast<void*>(&c), (src_begin + max_i_clamped), src_size - max_i_clamped);
uint16_t eq_bits = std::bit_cast<uint16_t>(_mm512_cmpeq_epi32_mask(c, v));
return static_cast<std::ptrdiff_t>(max_i_clamped) + std::countr_zero(eq_bits);
}
Expand All @@ -191,7 +192,7 @@ namespace Utily::Simd::Details {
}

Vec c = v;
std::memcpy(&c, (src_begin + max_i_clamped), src_size - max_i_clamped);
memcpy(reinterpret_cast<void*>(&c), (src_begin + max_i_clamped), src_size - max_i_clamped);
auto eqi = _mm_cmpeq_epi32(c, v);
auto eq = _mm_castsi128_ps(eqi);
uint32_t eq_bits = std::bit_cast<uint32_t>(_mm_movemask_ps(eq));
Expand Down Expand Up @@ -248,7 +249,7 @@ namespace Utily::Simd::Details {

__m128i c = vs[0];

std::memcpy(&c, (src_begin + max_i_clamped), src_size - max_i_clamped);
memcpy(reinterpret_cast<void*>(&c), (src_begin + max_i_clamped), src_size - max_i_clamped);

std::array<__m128i, max_values> eqs;
for (size_t i = 0; i < value_size; ++i) {
Expand Down
9 changes: 6 additions & 3 deletions include/Utily/Split.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <algorithm>
#include <cstring>
#include <array>
#include <bit>
#include <bitset>
Expand All @@ -25,7 +26,7 @@ namespace Utily {
requires std::equality_comparable_with<Delim, std::ranges::range_value_t<Container>> && (!std::is_reference_v<Container>)
class ByElement
{
using ContainerIter = Container::const_iterator;
using ContainerIter = typename Container::const_iterator;
using ContainerValue = std::ranges::range_value_t<Container>;

const Container& _container;
Expand Down Expand Up @@ -101,12 +102,14 @@ namespace Utily {
using const_iterator = Iterator;

[[nodiscard]] constexpr auto begin() const noexcept {
return ++Iterator {
Iterator iter {
.current_begin = _container.cbegin(),
.current_end = _container.cbegin(),
.end = _container.cend(),
.delim = _delim
};
++iter;
return iter;
}
[[nodiscard]] constexpr auto end() const noexcept {
return Iterator {
Expand All @@ -132,7 +135,7 @@ namespace Utily {
class ByElements
{
private:
using ContainerIter = Container::const_iterator;
using ContainerIter = typename Container::const_iterator;
using ContainerValue = std::ranges::range_value_t<Container>;
using Delims = std::array<Delim, S>;
const Container& _container;
Expand Down
8 changes: 7 additions & 1 deletion src/AsyncFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
#include <iostream>
#include <span>



#elif defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
#error "not implemented unix/apple system"
//#error "not implemented unix/apple system"
#endif

#if 0

namespace Utily {
#if defined(_WIN32)
using FileHandle = HANDLE;
Expand Down Expand Up @@ -239,3 +243,5 @@ namespace Utily {
#endif

}

#endif
Loading

0 comments on commit baeb891

Please sign in to comment.