Skip to content

Commit

Permalink
Fixed gcc & emscripten actions. TODO clang.
Browse files Browse the repository at this point in the history
  • Loading branch information
WillisMedwell committed Jan 22, 2024
1 parent baeb891 commit b221cf5
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 61 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Clang

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
container:
image: medwellwillis/clang-gcc-cmake-vcpkg-git:0.2

steps:
- uses: actions/checkout@v2

- name: Build With Clang
run: |
cmake --preset clang-ninja
cmake --build ./build/clang-ninja --config Release
22 changes: 22 additions & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Emscripten

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
container:
image: emscripten/emsdk

steps:
- uses: actions/checkout@v2

- name: Get Ninja
run: |
python3 -m pip install ninja
- name: Build With Emscripten
run: |
mkdir -p build/emscripten-ninja
emcmake cmake --preset emscripten-ninja -DCMAKE_SUPPRESS_DEVELOPER_WARNINGS=ON
cmake --build build/emscripten-ninja --config Release
22 changes: 22 additions & 0 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: GCC

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
container:
image: medwellwillis/clang-gcc-cmake-vcpkg-git:0.2

steps:
- uses: actions/checkout@v2

- name: Build With GCC
run: |
cmake --preset gcc-ninja
cmake --build ./build/gcc-ninja --config Release
- name: Run Tests
run: |
./build/gcc-ninja/UtilyTest
./build/gcc-ninja/UtilyBenchmark
22 changes: 0 additions & 22 deletions .github/workflows/native-build.yml

This file was deleted.

6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy DESTINATION ${CMAKE_CURRENT_BI
if(DEFINED EMSCRIPTEN)
message(STATUS "For Emscripten SIMD use flags: \"-msimd128 -mrelaxed-simd -msse -msse2 -mavx\"")
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)
message(STATUS "For Native SIMD use flags: \"-mavx2 -mavx512bw\"")
endif()

Expand Down Expand Up @@ -74,12 +71,15 @@ 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
)

set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable Google Benchmark tests" FORCE)
FetchContent_MakeAvailable(benchmark)
endif()
add_executable(UtilyBenchmark ${UTILY_BENCHMARK_SOURCES})
Expand Down
35 changes: 33 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_UTILY_TESTS": "ON",
"BUILD_UTILY_BENCHMARKS": "ON"
"BUILD_UTILY_BENCHMARKS": "ON",
"HAVE_STEADY_CLOCK": "0",
"HAVE_POSIX_REGEX": "0",
"HAVE_STD_REGEX": "0",
"HAVE_THREAD_SAFETY_ATTRIBUTES": "0"
},
"environment": {
"CC": "gcc",
Expand All @@ -29,12 +33,35 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_UTILY_TESTS": "ON",
"BUILD_UTILY_BENCHMARKS": "ON"
"BUILD_UTILY_BENCHMARKS": "ON",
"HAVE_STEADY_CLOCK": "0",
"HAVE_POSIX_REGEX": "0",
"HAVE_STD_REGEX": "0",
"HAVE_THREAD_SAFETY_ATTRIBUTES": "0"
},
"environment": {
"CC": "clang",
"CXX": "clang++"
}
},
{
"name": "emscripten-ninja",
"description": "Build with Emscripten SDK",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/emscripten-ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_UTILY_TESTS": "ON",
"BUILD_UTILY_BENCHMARKS": "ON",
"HAVE_STEADY_CLOCK": "0",
"HAVE_POSIX_REGEX": "0",
"HAVE_STD_REGEX": "0",
"HAVE_THREAD_SAFETY_ATTRIBUTES": "0"
},
"environment": {
"CC": "emcc",
"CXX": "em++"
}
}
],
"buildPresets": [
Expand All @@ -45,6 +72,10 @@
{
"name": "clang-ninja",
"configurePreset": "clang-ninja"
},
{
"name": "emscripten-ninja",
"configurePreset": "emscripten-ninja"
}
]
}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Start from Ubuntu base image
FROM ubuntu:latest

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y curl
RUN apt-get install -y git
RUN apt-get install -y unzip
RUN apt-get install -y tar
RUN apt-get install -y gcc g++
RUN apt-get install -y wget
RUN apt-get install -y cmake
RUN apt-get install -y ninja-build
RUN apt-get install -y build-essential
RUN apt-get install -y clang=1:14.0-55~exp2
RUN apt-get autoremove -y
RUN apt-get clean
RUN dpkg --configure -a
RUN apt-get install -y --no-install-recommends clang++=1:14.0-55~exp2
RUN apt-get autoremove -y
RUN apt-get clean
RUN apt-get install -y zip
RUN git clone https://github.com/microsoft/vcpkg.git && ./vcpkg/bootstrap-vcpkg.sh -disableMetrics

WORKDIR /workspace
COPY . .
18 changes: 12 additions & 6 deletions benchmark/BenchSimd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@
// #define UTY_USE_SIMD_128
// #define UTY_USE_SIMD_256
// #define UTY_USE_SIMD_512

#include "Utily/Utily.hpp"

#include <benchmark/benchmark.h>

#include <algorithm>
#include <array>
#include <ranges>
#include <numeric>
#include <ranges>

constexpr static std::string_view LONG_STRING = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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);
std::fill(v.begin(), v.end(), 'a');
v.append("a");
return v;
}
const static std::string LONG_STRING = all_a(10000);

auto iota(int32_t max) -> std::vector<int32_t>
{
auto iota(size_t max) -> std::vector<int32_t> {
std::vector<int32_t> v;
v.resize(max);
std::iota(v.begin(), v.end(), 0);
return v;
}

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

static void BM_Utily_Simd_find_char(benchmark::State& state) {
Expand Down
19 changes: 10 additions & 9 deletions benchmark/BenchSplit.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@

#include <benchmark/benchmark.h>
#include "Utily/Utily.hpp"
#include <benchmark/benchmark.h>

#include <ranges>

#if 1
constexpr static std::string_view LONG_STRING = "The quick brown fox jumps over the lazy dog while the energetic and spirited puppies, intrigued by the sudden burst of activity, start chasing their own tails, causing a delightful commotion in the serene and peaceful meadow that has, until now, been undisturbed by such playful endeavors";

// Apparently gcc's implementation of std::views::split is not compatible with const strings...
static std::string LONG_STRING = "The quick brown fox jumps over the lazy dog while the energetic and spirited puppies, intrigued by the sudden burst of activity, start chasing their own tails, causing a delightful commotion in the serene and peaceful meadow that has, until now, been undisturbed by such playful endeavors";

static void BM_Utily_SplitByElement(benchmark::State& state) {
for (auto _ : state) {
for(auto word : Utily::split(LONG_STRING, ' ')) {
benchmark::DoNotOptimize(word);
for (auto word : Utily::split(LONG_STRING, ' ')) {
benchmark::DoNotOptimize(word);
}
}
}
BENCHMARK(BM_Utily_SplitByElement);

static void BM_Utily_SplitByElements(benchmark::State& state) {
for (auto _ : state) {
for(auto word : Utily::split(LONG_STRING, ' ', 't')) {
benchmark::DoNotOptimize(word);
for (auto word : Utily::split(LONG_STRING, ' ', 't')) {
benchmark::DoNotOptimize(word);
}
}
}
Expand All @@ -28,10 +30,9 @@ BENCHMARK(BM_Utily_SplitByElements);
static void BM_Std_SplitByElement(benchmark::State& state) {
for (auto _ : state) {
auto splitter = LONG_STRING | std::views::split(' ');
for(auto word : splitter) {
benchmark::DoNotOptimize(word);
for (auto&& word : splitter) {
benchmark::DoNotOptimize(word);
}
benchmark::DoNotOptimize(splitter);
}
}
BENCHMARK(BM_Std_SplitByElement);
Expand Down
4 changes: 1 addition & 3 deletions build-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ call cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release
call cmake --build . --config Release
cd ..


@REM WEB
if not exist "build-web\" (
mkdir build-web
)
cd build-web
call emcmake cmake .. -DCMAKE_TOOLCHAIN_FILE=%VCPKG_PATH%/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DEMSCRIPTEN=1 -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=%EMSCRIPTEN%cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release
call emcmake cmake .. -DEMSCRIPTEN=1 -DCMAKE_BUILD_TYPE=Release
call cmake --build . --config Release
cd ..


cd build-native
call UtilyTest.exe
call UtilyBenchmark.exe
8 changes: 7 additions & 1 deletion include/Utily/Concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <list>
#include <memory>
#include <string>
#include <ranges>

namespace Utily {
namespace Concepts {
Expand Down Expand Up @@ -44,7 +45,7 @@ namespace Utily {
std::ranges::contiguous_range<T> && std::ranges::sized_range<T> && requires(T a) {
{ std::ranges::data(a) } -> std::contiguous_iterator;
};

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

Expand All @@ -63,6 +64,11 @@ namespace Utily {
t(param...)
};
};

template <typename Iter>
concept SubrangeCompatible = std::contiguous_iterator<Iter> && requires(Iter a, Iter b) {
{ std::ranges::subrange(a, b) } -> std::convertible_to<std::ranges::subrange<Iter>>;
};
}

} // namespace Utily
2 changes: 1 addition & 1 deletion include/Utily/InlineArrays.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Utily {
template <typename T>
static auto is_aligned(auto* ptr) {
return reinterpret_cast<std::uintptr_t>(ptr) % alignof(T) == 0;
};
}

template <typename... Types, std::integral... Size>
requires(sizeof...(Size) == sizeof...(Types))
Expand Down
6 changes: 3 additions & 3 deletions include/Utily/Simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ namespace Utily::Simd::Details {

const size_t max_i_clamped = src_size - (src_size % chars_per_vec);

std::array<__m128i, max_values> vs;
__m128i vs[max_values];
for (size_t i = 0; i < value_size; ++i) {
vs[i] = _mm_set1_epi8(value_begin[i]);
}

for (size_t i = 0; i < max_i_clamped; i += chars_per_vec) {
const __m128i c = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(src_begin + i));
std::array<__m128i, max_values> eqs;
__m128i eqs[max_values];
for (size_t ii = 0; ii < value_size; ++ii) {
eqs[ii] = _mm_cmpeq_epi8(c, vs[ii]);
}
Expand All @@ -251,7 +251,7 @@ namespace Utily::Simd::Details {

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

std::array<__m128i, max_values> eqs;
__m128i eqs[max_values];
for (size_t i = 0; i < value_size; ++i) {
eqs[i] = _mm_cmpeq_epi8(c, vs[i]);
}
Expand Down
Loading

0 comments on commit b221cf5

Please sign in to comment.