diff --git a/libcxx/cmake/caches/With-pstl.cmake b/libcxx/cmake/caches/With-pstl.cmake new file mode 100644 --- /dev/null +++ b/libcxx/cmake/caches/With-pstl.cmake @@ -0,0 +1,3 @@ +set(LIBCXX_TEST_PARAMS "std=c++17" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") +set(LIBCXX_ENABLE_PARALLEL_ALGORITHMS ON CACHE BOOL "") diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -479,6 +479,10 @@ __numeric/transform_exclusive_scan.h __numeric/transform_inclusive_scan.h __numeric/transform_reduce.h + __pstl_algorithm + __pstl_execution + __pstl_memory + __pstl_numeric __random/bernoulli_distribution.h __random/binomial_distribution.h __random/cauchy_distribution.h @@ -843,6 +847,39 @@ numeric optional ostream + pstl/internal/algorithm_fwd.h + pstl/internal/algorithm_impl.h + pstl/internal/execution_defs.h + pstl/internal/execution_impl.h + pstl/internal/glue_algorithm_defs.h + pstl/internal/glue_algorithm_impl.h + pstl/internal/glue_execution_defs.h + pstl/internal/glue_memory_defs.h + pstl/internal/glue_memory_impl.h + pstl/internal/glue_numeric_defs.h + pstl/internal/glue_numeric_impl.h + pstl/internal/memory_impl.h + pstl/internal/numeric_fwd.h + pstl/internal/numeric_impl.h + pstl/internal/omp/parallel_for.h + pstl/internal/omp/parallel_for_each.h + pstl/internal/omp/parallel_invoke.h + pstl/internal/omp/parallel_merge.h + pstl/internal/omp/parallel_scan.h + pstl/internal/omp/parallel_stable_partial_sort.h + pstl/internal/omp/parallel_stable_sort.h + pstl/internal/omp/parallel_transform_reduce.h + pstl/internal/omp/parallel_transform_scan.h + pstl/internal/omp/util.h + pstl/internal/parallel_backend.h + pstl/internal/parallel_backend_omp.h + pstl/internal/parallel_backend_serial.h + pstl/internal/parallel_backend_tbb.h + pstl/internal/parallel_backend_utils.h + pstl/internal/parallel_impl.h + pstl/internal/pstl_config.h + pstl/internal/unseq_backend_simd.h + pstl/internal/utils.h queue random ranges @@ -895,6 +932,7 @@ endforeach() configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site" @ONLY) +configure_file("__pstl_config_site.in" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__pstl_config_site" @ONLY) configure_file("module.modulemap.in" "${LIBCXX_GENERATED_INCLUDE_DIR}/module.modulemap" @ONLY) set(_all_includes "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site" diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -1918,6 +1918,7 @@ #endif #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 +# include <__functional/not_fn.h> # include <__pstl_algorithm> #endif diff --git a/libcxx/include/pstl/internal/algorithm_impl.h b/libcxx/include/pstl/internal/algorithm_impl.h --- a/libcxx/include/pstl/internal/algorithm_impl.h +++ b/libcxx/include/pstl/internal/algorithm_impl.h @@ -536,7 +536,7 @@ template _ForwardIterator -__pattern_find_if(_Tag __tag, _ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator __last, +__pattern_find_if(_Tag, _ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) noexcept { return __internal::__brick_find_if(__first, __last, __pred, typename _Tag::__is_vector{}); diff --git a/libcxx/include/pstl/internal/pstl_config.h b/libcxx/include/pstl/internal/pstl_config.h --- a/libcxx/include/pstl/internal/pstl_config.h +++ b/libcxx/include/pstl/internal/pstl_config.h @@ -12,6 +12,9 @@ #include <__pstl_config_site> +// TODO: Make this a proper configuration option +#define _PSTL_PAR_BACKEND_SERIAL + // The version is XYYZ, where X is major, YY is minor, and Z is patch (i.e. X.YY.Z) #define _PSTL_VERSION 16000 #define _PSTL_VERSION_MAJOR (_PSTL_VERSION / 1000) diff --git a/libcxx/include/pstl/internal/utils.h b/libcxx/include/pstl/internal/utils.h --- a/libcxx/include/pstl/internal/utils.h +++ b/libcxx/include/pstl/internal/utils.h @@ -12,6 +12,7 @@ #include #include +#include _PSTL_HIDE_FROM_ABI_PUSH @@ -24,9 +25,12 @@ auto __except_handler(_Fp __f) -> decltype(__f()) { +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { +#endif // _LIBCPP_HAS_NO_EXCEPTIONS return __f(); +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (const std::bad_alloc&) { @@ -36,6 +40,7 @@ { std::terminate(); // Good bye according to the standard [algorithms.parallel.exceptions] } +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } template diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -182,16 +182,6 @@ endif() endif() -if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS AND NOT TARGET pstl::ParallelSTL) - message(FATAL_ERROR "Could not find ParallelSTL") -endif() - -function(cxx_set_common_defines name) - if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS) - target_link_libraries(${name} PUBLIC pstl::ParallelSTL) - endif() -endfunction() - split_list(LIBCXX_COMPILE_FLAGS) split_list(LIBCXX_LINK_FLAGS) @@ -211,7 +201,6 @@ DEFINE_SYMBOL "" ) cxx_add_common_build_flags(cxx_shared) - cxx_set_common_defines(cxx_shared) if(ZOS) add_custom_command(TARGET cxx_shared POST_BUILD @@ -303,7 +292,6 @@ OUTPUT_NAME "${LIBCXX_STATIC_OUTPUT_NAME}" ) cxx_add_common_build_flags(cxx_static) - cxx_set_common_defines(cxx_static) if (LIBCXX_HERMETIC_STATIC_LIBRARY) # If the hermetic library doesn't define the operator new/delete functions @@ -412,9 +400,6 @@ if(LIBCXX_INSTALL_HEADERS) set(header_install_target install-cxx-headers) endif() - if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS) - set(pstl_install_target install-pstl) - endif() add_custom_target(install-cxx DEPENDS ${lib_install_target} cxx_experimental diff --git a/libcxx/test/libcxx/clang_tidy.sh.cpp b/libcxx/test/libcxx/clang_tidy.sh.cpp --- a/libcxx/test/libcxx/clang_tidy.sh.cpp +++ b/libcxx/test/libcxx/clang_tidy.sh.cpp @@ -8,6 +8,8 @@ // REQUIRES: has-clang-tidy +// XFAIL: with-pstl + // The GCC compiler flags are not always compatible with clang-tidy. // UNSUPPORTED: gcc diff --git a/libcxx/test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/exception_safety_exceptions_disabled.pass.cpp @@ -8,6 +8,8 @@ // ADDITIONAL_COMPILE_FLAGS: -fno-exceptions +// XFAIL: with-pstl + // UNSUPPORTED: c++03 // diff --git a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp --- a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp +++ b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp @@ -9,6 +9,8 @@ // Test that headers are not tripped up by the surrounding code defining the // min() and max() macros. +// XFAIL: with-pstl + // The system-provided seems to be broken on AIX // XFAIL: LIBCXX-AIX-FIXME diff --git a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp --- a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp +++ b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp @@ -9,6 +9,8 @@ // Test that headers are not tripped up by the surrounding code defining various // alphabetic macros. +// XFAIL: with-pstl + // The system-provided seems to be broken on AIX // XFAIL: LIBCXX-AIX-FIXME diff --git a/libcxx/test/libcxx/transitive_includes.sh.cpp b/libcxx/test/libcxx/transitive_includes.sh.cpp --- a/libcxx/test/libcxx/transitive_includes.sh.cpp +++ b/libcxx/test/libcxx/transitive_includes.sh.cpp @@ -16,6 +16,8 @@ // forever, however we do try to group removals for a couple of releases // to avoid breaking users at every release. +// XFAIL: with-pstl + // This test doesn't support being run when some headers are not available, since we // would need to add significant complexity to make that work. // UNSUPPORTED: no-localization, no-threads, no-wide-characters, no-filesystem, libcpp-has-no-incomplete-format diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -449,6 +449,19 @@ limit: 2 timeout_in_minutes: 120 + - label: "With PSTL support" + command: "libcxx/utils/ci/run-buildbot with-pstl" + artifact_paths: + - "**/test-results.xml" + agents: + queue: "libcxx-builders" + os: "linux" + retry: + automatic: + - exit_status: -1 # Agent was lost + limit: 2 + timeout_in_minutes: 120 + - label: "With LLVM's libunwind" command: "libcxx/utils/ci/run-buildbot generic-with_llvm_unwinder" artifact_paths: diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -448,6 +448,11 @@ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-abi-unstable.cmake" check-runtimes ;; +with-pstl) + clean + generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/With-pstl.cmake" + check-runtimes +;; apple-cxx20) clean generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake" diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -208,6 +208,7 @@ '_LIBCPP_HAS_NO_WIDE_CHARACTERS': 'no-wide-characters', '_LIBCPP_HAS_NO_UNICODE': 'libcpp-has-no-unicode', '_LIBCPP_ENABLE_DEBUG_MODE': 'libcpp-has-debug-mode', + '_LIBCPP_HAS_PARALLEL_ALGORITHMS': 'with-pstl', } for macro, feature in macros.items(): DEFAULT_FEATURES.append(