[libcxx-commits] [libcxx] r367903 - [libc++] Take 2: Integrate the PSTL into libc++
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 5 11:29:14 PDT 2019
Author: ldionne
Date: Mon Aug 5 11:29:14 2019
New Revision: 367903
URL: http://llvm.org/viewvc/llvm-project?rev=367903&view=rev
Log:
[libc++] Take 2: Integrate the PSTL into libc++
Summary:
This commit allows specifying LIBCXX_ENABLE_PARALLEL_ALGORITHMS when
configuring libc++ in CMake. When that option is enabled, libc++ will
assume that the PSTL can be found somewhere on the CMake module path,
and it will provide the C++17 parallel algorithms based on the PSTL
(that is assumed to be available).
The commit also adds support for running the PSTL tests as part of
the libc++ test suite.
The first attempt to commit this failed because it exposed a bug in the
tests for modules. Now that this has been fixed, it should be safe to
commit this.
Reviewers: EricWF
Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF
Tags: #libc
Differential Revision: https://reviews.llvm.org/D60480
Added:
libcxx/trunk/include/execution
libcxx/trunk/test/std/pstl (with props)
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/include/CMakeLists.txt
libcxx/trunk/include/__config_site.in
libcxx/trunk/include/algorithm
libcxx/trunk/include/memory
libcxx/trunk/include/module.modulemap
libcxx/trunk/include/numeric
libcxx/trunk/src/CMakeLists.txt
libcxx/trunk/test/CMakeLists.txt
libcxx/trunk/test/libcxx/double_include.sh.cpp
libcxx/trunk/test/lit.site.cfg.in
libcxx/trunk/utils/libcxx/test/config.py
Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Aug 5 11:29:14 2019
@@ -80,6 +80,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)
# Benchmark options -----------------------------------------------------------
option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON)
@@ -745,6 +746,7 @@ config_define_if(LIBCXX_HAS_WIN32_THREAD
config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
+config_define_if(LIBCXX_ENABLE_PARALLEL_ALGORITHMS _LIBCPP_HAS_PARALLEL_ALGORITHMS)
if (LIBCXX_ABI_DEFINES)
set(abi_defines)
Modified: libcxx/trunk/include/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Mon Aug 5 11:29:14 2019
@@ -62,6 +62,7 @@ set(files
deque
errno.h
exception
+ execution
experimental/__config
experimental/__memory
experimental/algorithm
Modified: libcxx/trunk/include/__config_site.in
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config_site.in?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/include/__config_site.in (original)
+++ libcxx/trunk/include/__config_site.in Mon Aug 5 11:29:14 2019
@@ -29,6 +29,7 @@
#cmakedefine _LIBCPP_NO_VCRUNTIME
#cmakedefine01 _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT
#cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@
+#cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS
@_LIBCPP_ABI_DEFINES@
Modified: libcxx/trunk/include/algorithm
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Aug 5 11:29:14 2019
@@ -5678,4 +5678,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
+# include <pstl/internal/glue_algorithm_impl.h>
+#endif
+
#endif // _LIBCPP_ALGORITHM
Added: libcxx/trunk/include/execution
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/execution?rev=367903&view=auto
==============================================================================
--- libcxx/trunk/include/execution (added)
+++ libcxx/trunk/include/execution Mon Aug 5 11:29:14 2019
@@ -0,0 +1,19 @@
+// -*- C++ -*-
+//===------------------------- execution ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXECUTION
+#define _LIBCPP_EXECUTION
+
+#include <__config>
+
+#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
+# include <pstl/internal/glue_execution_defs.h>
+#endif
+
+#endif // _LIBCPP_EXECUTION
Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Mon Aug 5 11:29:14 2019
@@ -5590,4 +5590,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
+# include <pstl/internal/glue_memory_impl.h>
+#endif
+
#endif // _LIBCPP_MEMORY
Modified: libcxx/trunk/include/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/module.modulemap?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/include/module.modulemap (original)
+++ libcxx/trunk/include/module.modulemap Mon Aug 5 11:29:14 2019
@@ -275,6 +275,10 @@ module std [system] {
header "exception"
export *
}
+ module execution {
+ header "execution"
+ export *
+ }
module filesystem {
header "filesystem"
export *
Modified: libcxx/trunk/include/numeric
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/numeric?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/include/numeric (original)
+++ libcxx/trunk/include/numeric Mon Aug 5 11:29:14 2019
@@ -586,4 +586,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
+# include <pstl/internal/glue_numeric_impl.h>
+#endif
+
#endif // _LIBCPP_NUMERIC
Modified: libcxx/trunk/src/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/CMakeLists.txt?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/src/CMakeLists.txt (original)
+++ libcxx/trunk/src/CMakeLists.txt Mon Aug 5 11:29:14 2019
@@ -196,6 +196,10 @@ function(cxx_link_system_libraries targe
endif()
endfunction()
+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_CXX_ABI_HEADER_TARGET)
add_dependencies(${name} ${LIBCXX_CXX_ABI_HEADER_TARGET})
@@ -222,6 +226,10 @@ function(cxx_set_common_defines name)
# in printf, scanf.
_CRT_STDIO_ISO_WIDE_SPECIFIERS)
endif()
+
+ if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
+ target_link_libraries(${name} PUBLIC pstl::ParallelSTL)
+ endif()
endfunction()
split_list(LIBCXX_COMPILE_FLAGS)
Modified: libcxx/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Mon Aug 5 11:29:14 2019
@@ -40,6 +40,7 @@ pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
pythonize_bool(LIBCXX_DEBUG_BUILD)
+pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
# By default, for non-standalone builds, libcxx and libcxxabi share a library
# directory.
Modified: libcxx/trunk/test/libcxx/double_include.sh.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/double_include.sh.cpp?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/double_include.sh.cpp (original)
+++ libcxx/trunk/test/libcxx/double_include.sh.cpp Mon Aug 5 11:29:14 2019
@@ -63,6 +63,7 @@
#include <deque>
#include <errno.h>
#include <exception>
+#include <execution>
#include <fenv.h>
#include <filesystem>
#include <float.h>
Modified: libcxx/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.site.cfg.in?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/test/lit.site.cfg.in (original)
+++ libcxx/trunk/test/lit.site.cfg.in Mon Aug 5 11:29:14 2019
@@ -33,6 +33,7 @@ config.use_libatomic = @LIBCX
config.debug_build = @LIBCXX_DEBUG_BUILD@
config.libcxxabi_shared = @LIBCXXABI_ENABLE_SHARED@
config.cxx_ext_threads = @LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY@
+config.pstl_root = "@ParallelSTL_SOURCE_DIR@" if @LIBCXX_ENABLE_PARALLEL_ALGORITHMS@ else None
# Let the main config do the real work.
config.loaded_site_config = True
Added: libcxx/trunk/test/std/pstl
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/pstl?rev=367903&view=auto
==============================================================================
--- libcxx/trunk/test/std/pstl (added)
+++ libcxx/trunk/test/std/pstl Mon Aug 5 11:29:14 2019
@@ -0,0 +1 @@
+link ../../../pstl/test/std
\ No newline at end of file
Propchange: libcxx/trunk/test/std/pstl
------------------------------------------------------------------------------
svn:special = *
Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=367903&r1=367902&r2=367903&view=diff
==============================================================================
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Mon Aug 5 11:29:14 2019
@@ -581,6 +581,13 @@ class Configuration(object):
support_path = os.path.join(self.libcxx_src_root, 'test/support')
self.cxx.compile_flags += ['-I' + support_path]
+ # Add includes for the PSTL headers
+ pstl_root = self.get_lit_conf('pstl_root')
+ if pstl_root is not None:
+ self.cxx.compile_flags += ['-I' + os.path.join(pstl_root, 'include')]
+ self.cxx.compile_flags += ['-I' + os.path.join(pstl_root, 'test')]
+ self.config.available_features.add('parallel-algorithms')
+
# FIXME(EricWF): variant_size.pass.cpp requires a slightly larger
# template depth with older Clang versions.
self.cxx.addFlagIfSupported('-ftemplate-depth=270')
More information about the libcxx-commits
mailing list