[libcxx-commits] [libcxx] 2445603 - [libc++][PSTL] Integrate the headers and add a CI job

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 26 13:11:31 PDT 2023


Author: Nikolas Klauser
Date: 2023-04-26T13:11:25-07:00
New Revision: 244560329603e8e1b1c6e72654b4292fec52ed8b

URL: https://github.com/llvm/llvm-project/commit/244560329603e8e1b1c6e72654b4292fec52ed8b
DIFF: https://github.com/llvm/llvm-project/commit/244560329603e8e1b1c6e72654b4292fec52ed8b.diff

LOG: [libc++][PSTL] Integrate the headers and add a CI job

Reviewed By: ldionne, #libc

Spies: libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D141780

Added: 
    libcxx/cmake/caches/With-pstl.cmake

Modified: 
    libcxx/CMakeLists.txt
    libcxx/include/CMakeLists.txt
    libcxx/include/pstl/internal/algorithm_impl.h
    libcxx/include/pstl/internal/pstl_config.h
    libcxx/include/pstl/internal/utils.h
    libcxx/test/libcxx/clang_tidy.sh.cpp
    libcxx/utils/ci/buildkite-pipeline.yml
    libcxx/utils/ci/run-buildbot
    libcxx/utils/libcxx/test/features.py

Removed: 
    


################################################################################
diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 2b6f9987c6750..cf572af74bd13 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -68,6 +68,7 @@ endif()
 option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ library"
     ${ENABLE_FILESYSTEM_DEFAULT})
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
+option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF)
 option(LIBCXX_ENABLE_DEBUG_MODE
   "Whether to build libc++ with the debug mode enabled.
    By default, this is turned off. Turning it on results in a 
diff erent ABI (additional

diff  --git a/libcxx/cmake/caches/With-pstl.cmake b/libcxx/cmake/caches/With-pstl.cmake
new file mode 100644
index 0000000000000..82dd90f968cb6
--- /dev/null
+++ b/libcxx/cmake/caches/With-pstl.cmake
@@ -0,0 +1,4 @@
+# TODO: Remove this cache file once the PSTL is under `-fexperimental-library`
+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
index a28f8c1e8a035..fa7ff67394ec1 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -494,6 +494,10 @@ set(files
   __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
@@ -862,6 +866,39 @@ set(files
   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

diff  --git a/libcxx/include/pstl/internal/algorithm_impl.h b/libcxx/include/pstl/internal/algorithm_impl.h
index 2b505d94611f6..3cc50c8f504bd 100644
--- a/libcxx/include/pstl/internal/algorithm_impl.h
+++ b/libcxx/include/pstl/internal/algorithm_impl.h
@@ -536,7 +536,7 @@ __brick_find_if(_RandomAccessIterator __first, _RandomAccessIterator __last, _Pr
 
 template <class _Tag, class _ExecutionPolicy, class _ForwardIterator, class _Predicate>
 _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
index de89e7bd977e7..fbc3acaca10e6 100644
--- a/libcxx/include/pstl/internal/pstl_config.h
+++ b/libcxx/include/pstl/internal/pstl_config.h
@@ -10,7 +10,8 @@
 #ifndef _PSTL_CONFIG_H
 #define _PSTL_CONFIG_H
 
-#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

diff  --git a/libcxx/include/pstl/internal/utils.h b/libcxx/include/pstl/internal/utils.h
index ec9d46713a682..f52eb6650cd99 100644
--- a/libcxx/include/pstl/internal/utils.h
+++ b/libcxx/include/pstl/internal/utils.h
@@ -12,6 +12,7 @@
 
 #include <new>
 #include <iterator>
+#include <utility>
 
 _PSTL_HIDE_FROM_ABI_PUSH
 
@@ -24,9 +25,12 @@ template <typename _Fp>
 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 @@ __except_handler(_Fp __f) -> decltype(__f())
     {
         std::terminate(); // Good bye according to the standard [algorithms.parallel.exceptions]
     }
+#endif // _LIBCPP_HAS_NO_EXCEPTIONS
 }
 
 template <typename _Fp>

diff  --git a/libcxx/test/libcxx/clang_tidy.sh.cpp b/libcxx/test/libcxx/clang_tidy.sh.cpp
index 74df7af5c191b..f04b6a5b3a504 100644
--- a/libcxx/test/libcxx/clang_tidy.sh.cpp
+++ b/libcxx/test/libcxx/clang_tidy.sh.cpp
@@ -8,6 +8,9 @@
 
 // REQUIRES: has-clang-tidy
 
+// FIXME: This should pass with the PSTL enables
+// XFAIL: with-pstl
+
 // The GCC compiler flags are not always compatible with clang-tidy.
 // UNSUPPORTED: gcc
 

diff  --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml
index 474138d21f4f0..f489302a55700 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -463,6 +463,22 @@ steps:
           limit: 2
     timeout_in_minutes: 120
 
+  - label: "With PSTL support"
+    command: "libcxx/utils/ci/run-buildbot with-pstl"
+    artifact_paths:
+      - "**/test-results.xml"
+    env:
+      CC: "clang-${LLVM_HEAD_VERSION}"
+      CXX: "clang++-${LLVM_HEAD_VERSION}"
+    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
index cd70d73a52f5d..34e3792efd5d4 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -448,6 +448,11 @@ generic-abi-unstable)
     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-system)
     clean
 

diff  --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index dd5163f844453..49f5e70334327 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -209,6 +209,7 @@ def _getSuitableClangTidy(cfg):
   '_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(


        


More information about the libcxx-commits mailing list