Skip to content

Commit

Permalink
Test on Emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
alugowski committed Jan 25, 2024
1 parent 4b5d15d commit 0566de3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 35 deletions.
84 changes: 50 additions & 34 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,50 @@ jobs:
description: "LLVM 5"
llvm-version: "5"

- os: ubuntu-22.04
# select libc++ as libstdc++ appears to be the default
description: "LLVM 16 libc++"
llvm-version: "16"
cmake-flags: '-DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"'

- os: ubuntu-20.04
description: "GCC 7"
gcc-version: "7"
cmake-version: "3.18"
test-amalgamation: true

- os: ubuntu-20.04
description: "GCC 9"
gcc-version: "9"

- os: ubuntu-latest
description: "GCC 13"
gcc-version: "13"
test-amalgamation: true
# - os: ubuntu-22.04
# # select libc++ as libstdc++ appears to be the default
# description: "LLVM 16 libc++"
# llvm-version: "16"
# cmake-flags: '-DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-lc++abi"'
#
# - os: ubuntu-20.04
# description: "GCC 7"
# gcc-version: "7"
# cmake-version: "3.18"
# test-amalgamation: true
#
# - os: ubuntu-20.04
# description: "GCC 9"
# gcc-version: "9"
#
# - os: ubuntu-latest
# description: "GCC 13"
# gcc-version: "13"
# test-amalgamation: true

- os: ubuntu-latest
# default GCC, which has gcov

- os: macos-latest
# uses Apple Clang

- os: windows-latest
# uses MSVC

- os: windows-latest
mingw-version: "13.2.0"
description: "MinGW 13"
cmake-flags: '-G "MinGW Makefiles"'
description: "Emscripten"
emscripten-version: "3.1.52"
# needs:
# - use emscripten's cmake toolchain file so cmake uses em++ and such
# - must compile with -pthread for C++11 threads to work
# - Consider -DCMAKE_EXE_LINKER_FLAGS="-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency"
# - disable codecov because emscripten does not support it.
cmake-flags: '-DCMAKE_TOOLCHAIN_FILE=$(em-config EMSCRIPTEN_ROOT)/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CXX_FLAGS="-pthread" -DPOOLSTL_TEST_COVERAGE=OFF'

# - os: ubuntu-latest
# # default GCC, which has gcov
#
# - os: macos-latest
# # uses Apple Clang
#
# - os: windows-latest
# # uses MSVC
#
# - os: windows-latest
# mingw-version: "13.2.0"
# description: "MinGW 13"
# cmake-flags: '-G "MinGW Makefiles"'

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -82,6 +92,12 @@ jobs:
version: ${{ matrix.llvm-version }}
env: true

- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v14
if: ${{ matrix.emscripten-version != '' }}
with:
version: ${{ matrix.emscripten-version }}

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1
if: ${{ matrix.cmake-version != '' }}
Expand All @@ -95,7 +111,7 @@ jobs:
cd build/tests
ctest -C Debug --output-on-failure --verbose
echo "Supplement Test:"
./supplement_test || ./Debug/supplement_test.exe
./supplement_test || ./Debug/supplement_test.exe || node supplement_test
shell: bash

- name: Benchmark
Expand All @@ -105,7 +121,7 @@ jobs:
cmake -S . -B bench_build/ -DCMAKE_BUILD_TYPE=Release -DPOOLSTL_BENCH=ON ${{ matrix.cmake-flags }}
cmake --build bench_build/ --config Release
cd bench_build/benchmark/
./poolstl_bench || ./Release/poolstl_bench.exe
./poolstl_bench || ./Release/poolstl_bench.exe || node poolstl_bench
shell: bash

- name: Test Amalgamation
Expand Down
2 changes: 1 addition & 1 deletion include/poolstl/internal/ttp_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ namespace poolstl {
// size. Target approximately twice as many partitions as threads to reduce impact of uneven pivot
// selection.
auto num_threads = task_pool.get_num_threads();
std::ptrdiff_t target_leaf_size = std::max(std::distance(first, last) / (num_threads * 2),
std::ptrdiff_t target_leaf_size = std::max((std::ptrdiff_t)(std::distance(first, last) / (num_threads * 2)),
(std::ptrdiff_t)5);

if (num_threads == 1) {
Expand Down

0 comments on commit 0566de3

Please sign in to comment.