Skip to content

Commit a986167

Browse files
committed
Test on Emscripten
1 parent 4b5d15d commit a986167

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

.github/workflows/tests.yml

+33-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ jobs:
3838
gcc-version: "13"
3939
test-amalgamation: true
4040

41+
- os: ubuntu-latest
42+
description: "Emscripten"
43+
emscripten-version: "3.1.52"
44+
# needs:
45+
# - use emscripten's cmake toolchain file so cmake uses em++ and such
46+
# - must compile with -pthread for C++11 threads to work
47+
#
48+
# See https://emscripten.org/docs/porting/pthreads.html
49+
#
50+
# poolSTL test-suite specific options:
51+
# - using -sNO_DISABLE_EXCEPTION_CATCHING because some tests throw
52+
# - using high -sTOTAL_MEMORY because our benchmarks use large arrays
53+
# - disable codecov because emscripten does not support it.
54+
# - Consider -DCMAKE_EXE_LINKER_FLAGS="-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency"
55+
cmake-flags: '-DCMAKE_TOOLCHAIN_FILE=$(em-config EMSCRIPTEN_ROOT)/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CXX_FLAGS="-pthread -sNO_DISABLE_EXCEPTION_CATCHING" -DCMAKE_EXE_LINKER_FLAGS="-sTOTAL_MEMORY=2048MB" -DPOOLSTL_TEST_COVERAGE=OFF'
56+
4157
- os: ubuntu-latest
4258
# default GCC, which has gcov
4359

@@ -82,6 +98,21 @@ jobs:
8298
version: ${{ matrix.llvm-version }}
8399
env: true
84100

101+
- name: Setup Emscripten
102+
uses: mymindstorm/setup-emsdk@v14
103+
if: ${{ matrix.emscripten-version != '' }}
104+
with:
105+
version: ${{ matrix.emscripten-version }}
106+
107+
# Default node.js (v18) does not support threads well.
108+
# It might work with --experimental-wasm-threads --experimental-wasm-bulk-memory
109+
# but newer node just works out of the box.
110+
- name: Setup node.js for running Emscripten builds
111+
uses: actions/setup-node@v4
112+
if: ${{ matrix.emscripten-version != '' }}
113+
with:
114+
node-version: 21
115+
85116
- name: Setup cmake
86117
uses: jwlawson/actions-setup-cmake@v1
87118
if: ${{ matrix.cmake-version != '' }}
@@ -95,7 +126,7 @@ jobs:
95126
cd build/tests
96127
ctest -C Debug --output-on-failure --verbose
97128
echo "Supplement Test:"
98-
./supplement_test || ./Debug/supplement_test.exe
129+
./supplement_test || ./Debug/supplement_test.exe || node supplement_test
99130
shell: bash
100131

101132
- name: Benchmark
@@ -105,7 +136,7 @@ jobs:
105136
cmake -S . -B bench_build/ -DCMAKE_BUILD_TYPE=Release -DPOOLSTL_BENCH=ON ${{ matrix.cmake-flags }}
106137
cmake --build bench_build/ --config Release
107138
cd bench_build/benchmark/
108-
./poolstl_bench || ./Release/poolstl_bench.exe
139+
./poolstl_bench || ./Release/poolstl_bench.exe || node poolstl_bench
109140
shell: bash
110141

111142
- name: Test Amalgamation

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ However, it is small, easy to integrate, and has no external dependencies. A goo
3333
Use poolSTL exclusively, or only on platforms lacking native support,
3434
or only if [TBB](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb.html) is not present.
3535
36-
Supports C++11 and higher, C++17 preferred.
37-
Tested in CI on GCC 7+, Clang/LLVM 5+, Apple Clang, MSVC.
36+
Supports C++11 and higher. Algorithms introduced in C++17 require C++17 or higher.
37+
Tested in CI on GCC 7+, Clang/LLVM 5+, Apple Clang, MSVC, MinGW, and Emscripten.
3838
3939
## Implemented Algorithms
4040
Algorithms are added on an as-needed basis. If you need one [open an issue](https://github.com/alugowski/poolSTL/issues) or contribute a PR.

include/poolstl/internal/ttp_impl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ namespace poolstl {
270270
// size. Target approximately twice as many partitions as threads to reduce impact of uneven pivot
271271
// selection.
272272
auto num_threads = task_pool.get_num_threads();
273-
std::ptrdiff_t target_leaf_size = std::max(std::distance(first, last) / (num_threads * 2),
273+
std::ptrdiff_t target_leaf_size = std::max((std::ptrdiff_t)(std::distance(first, last) / (num_threads * 2)),
274274
(std::ptrdiff_t)5);
275275

276276
if (num_threads == 1) {

0 commit comments

Comments
 (0)