Skip to content

Commit

Permalink
Word smithing
Browse files Browse the repository at this point in the history
  • Loading branch information
alugowski committed Nov 29, 2023
1 parent af237b0 commit 1b230c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ Unfortunately compiler support [varies](https://en.cppreference.com/w/cpp/compil
| | Linux | macOS | Windows |
|:------------------|:------------:|:------------:|:------------:|
| GCC 8- | ❌ | ❌ | ❌ |
| GCC 9+ | TBB Required | TBB Required | TBB Required |
| Clang (libstdc++) | TBB Required | TBB Required | TBB Required |
| GCC 8- | ❌ | ❌ | ❌ |
| Clang (libc++) | ❌ | ❌ | ❌ |
| Clang (libstdc++) | TBB Required | TBB Required | TBB Required |
| Apple Clang | | ❌ | |
| MSVC 15.7+ (2017) | | | ✅ |
| [Parallel STL](https://www.intel.com/content/www/us/en/developer/articles/guide/get-started-with-parallel-stl.html) | TBB Required | TBB Required | TBB Required |
| **poolSTL** | ✅ | ✅ | ✅ |
| **poolSTL** | ✅* | ✅* | ✅* |
PoolSTL is a *supplement* to fill in the support gaps. It is small, easy to integrate, and has no external dependencies.
Note that poolSTL is not a full implementation; only the basics are covered.
PoolSTL is a *supplement* to fill in the support gaps. It is not a full implementation; only the basics are covered.
However, it is small, easy to integrate, and has no external dependencies. A good backup to the other options.
Use poolSTL exclusively, or only on platforms lacking native support,
or only if [TBB](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb.html) is not present.
Expand Down Expand Up @@ -228,7 +228,6 @@ PoolSTL will fill in automatically on GCC <9 and Apple Clang.

**Example use case 2:** You'd *prefer* to use the TBB version, but don't want to fail on systems that don't have it.
Simply use the supplement as above, but have your build system (CMake, meson, etc.) check for TBB.
If not found define `POOLSTL_STD_SUPPLEMENT_NO_INCLUDE`.

If defined, the supplement will not `#include <execution>` (and neither should your code!),
thus dropping the TBB link requirement. The poolSTL supplement fills in. See the supplement section of [tests/CMakeLists.txt](tests/CMakeLists.txt) for an example.
If not found, define `POOLSTL_STD_SUPPLEMENT_NO_INCLUDE` and the supplement will not `#include <execution>` (and neither should your code!),
thus dropping the TBB link requirement. The poolSTL supplement fills in.
See the supplement section of [tests/CMakeLists.txt](tests/CMakeLists.txt) for an example.
8 changes: 5 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,25 @@ target_compile_features(cpp11_test PUBLIC cxx_std_11)

# Test std::execution supplementation.
# The test code uses only std::execution::par, seq, and par_unseq.
# On compilers with support poolSTL does nothing, else poolSTL creates a fallback using poolstl::par.
# On compilers with support poolSTL does nothing, else poolSTL aliases poolstl::par to the std::execution policies.
# This way users may write code using standard std::execution and still support platforms lacking support.
add_executable(supplement_test supplement_test.cpp)
target_link_libraries(supplement_test PUBLIC poolSTL::poolSTL)
target_compile_features(supplement_test PUBLIC cxx_std_17)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# GCC and Clang require TBB for std::execution::par.
# MinGW will compile std::execution::par without TBB, but performance is sequential.
# MinGW will compile std::execution::par without TBB, but performance is sequential. (Verified as of MinGW 13).
find_package(TBB)
if (TBB_FOUND)
target_link_libraries(supplement_test PUBLIC TBB::tbb)
else()
message("No TBB")
# Prevent including <execution>, as doing that requires linking against TBB on newer GCC/Clang.
# User code must not #include <execution> either.
target_compile_definitions(supplement_test PUBLIC POOLSTL_STD_SUPPLEMENT_NO_INCLUDE)
if (MINGW)
# extra hack!
# MinGW declares support, so must override poolSTL's auto-detection to enable the supplement.
# MinGW declares support, so override poolSTL's auto-detection to enable the supplement.
target_compile_definitions(supplement_test PUBLIC POOLSTL_STD_SUPPLEMENT_FORCE)
endif()
endif()
Expand Down

0 comments on commit 1b230c1

Please sign in to comment.