Skip to content

Commit 65a422c

Browse files
committed
[pstl] Make the default backend be the serial backend and always provide parallel policies
Summary: Before this change, the default backend was TBB but one could disable anything related to TBB by removing the parallel policies. This change uses the serial backend by default and removes the ability to disable parallel policies, which is not useful anymore. Reviewers: rodgert, MikeDvorskiy Subscribers: mgorny, jkorous, dexonsmith, jdoerfert, libcxx-commits Differential Revision: https://reviews.llvm.org/D59792 llvm-svn: 359134
1 parent 0ddd12e commit 65a422c

File tree

11 files changed

+20
-287
lines changed

11 files changed

+20
-287
lines changed

pstl/CMakeLists.txt

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ math(EXPR VERSION_PATCH "(${PARALLELSTL_VERSION_SOURCE} % 10)")
1616

1717
project(ParallelSTL VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES CXX)
1818

19-
option(PARALLELSTL_USE_PARALLEL_POLICIES "Enable parallel policies" OFF)
20-
set(PARALLELSTL_BACKEND "tbb" CACHE STRING "Threading backend; defaults to TBB")
19+
set(PARALLELSTL_BACKEND "serial" CACHE STRING "Threading backend to use. Valid choices are 'serial' and 'tbb'. The default is 'serial'.")
2120

2221
if (NOT TBB_DIR)
2322
get_filename_component(PSTL_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
@@ -34,20 +33,16 @@ add_library(ParallelSTL INTERFACE)
3433
add_library(pstl::ParallelSTL ALIAS ParallelSTL)
3534
target_compile_features(ParallelSTL INTERFACE cxx_std_17)
3635

37-
if (PARALLELSTL_USE_PARALLEL_POLICIES)
38-
if (PARALLELSTL_BACKEND STREQUAL "serial")
39-
message(STATUS "Parallel STL uses the serial backend")
40-
target_compile_definitions(ParallelSTL INTERFACE -D_PSTL_PAR_BACKEND_SERIAL)
41-
elseif (PARALLELSTL_BACKEND STREQUAL "tbb")
42-
find_package(TBB 2018 REQUIRED tbb OPTIONAL_COMPONENTS tbbmalloc)
43-
message(STATUS "Parallel STL uses TBB ${TBB_VERSION} (interface version: ${TBB_INTERFACE_VERSION})")
44-
target_link_libraries(ParallelSTL INTERFACE TBB::tbb)
45-
target_compile_definitions(ParallelSTL INTERFACE -D_PSTL_PAR_BACKEND_TBB)
46-
else()
47-
message(FATAL_ERROR "Requested unknown Parallel STL backend '${PARALLELSTL_BACKEND}'.")
48-
endif()
36+
if (PARALLELSTL_BACKEND STREQUAL "serial")
37+
message(STATUS "Parallel STL uses the serial backend")
38+
target_compile_definitions(ParallelSTL INTERFACE -D_PSTL_PAR_BACKEND_SERIAL)
39+
elseif (PARALLELSTL_BACKEND STREQUAL "tbb")
40+
find_package(TBB 2018 REQUIRED tbb OPTIONAL_COMPONENTS tbbmalloc)
41+
message(STATUS "Parallel STL uses TBB ${TBB_VERSION} (interface version: ${TBB_INTERFACE_VERSION})")
42+
target_link_libraries(ParallelSTL INTERFACE TBB::tbb)
43+
target_compile_definitions(ParallelSTL INTERFACE -D_PSTL_PAR_BACKEND_TBB)
4944
else()
50-
target_compile_definitions(ParallelSTL INTERFACE PSTL_USE_PARALLEL_POLICIES=0)
45+
message(FATAL_ERROR "Requested unknown Parallel STL backend '${PARALLELSTL_BACKEND}'.")
5146
endif()
5247

5348
target_include_directories(ParallelSTL

pstl/include/pstl/internal/algorithm_fwd.h

Lines changed: 0 additions & 104 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)