[libcxx-commits] [pstl] r368684 - [pstl] Allow customizing whether per-TU insulation is provided

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 13 05:49:00 PDT 2019


Author: ldionne
Date: Tue Aug 13 05:49:00 2019
New Revision: 368684

URL: http://llvm.org/viewvc/llvm-project?rev=368684&view=rev
Log:
[pstl] Allow customizing whether per-TU insulation is provided

Like we do in libc++, PSTL needs the ability to constrain
ABI-unstable symbols to each translation unit. This is OFF by
default (like for libc++), because most people don't care about
this and there is a cost associated to enabling the option (code
bloat because templates are not deduped across TUs).

I'm using '#pragma clang attribute push' to avoid marking each
declaration with an attribute, which quickly becomes difficult
to maintain.

Modified:
    pstl/trunk/CMakeLists.txt
    pstl/trunk/include/__pstl_config_site.in
    pstl/trunk/include/pstl/internal/algorithm_fwd.h
    pstl/trunk/include/pstl/internal/algorithm_impl.h
    pstl/trunk/include/pstl/internal/execution_defs.h
    pstl/trunk/include/pstl/internal/execution_impl.h
    pstl/trunk/include/pstl/internal/glue_algorithm_defs.h
    pstl/trunk/include/pstl/internal/glue_algorithm_impl.h
    pstl/trunk/include/pstl/internal/glue_memory_defs.h
    pstl/trunk/include/pstl/internal/glue_memory_impl.h
    pstl/trunk/include/pstl/internal/glue_numeric_defs.h
    pstl/trunk/include/pstl/internal/glue_numeric_impl.h
    pstl/trunk/include/pstl/internal/memory_impl.h
    pstl/trunk/include/pstl/internal/numeric_fwd.h
    pstl/trunk/include/pstl/internal/numeric_impl.h
    pstl/trunk/include/pstl/internal/parallel_backend_serial.h
    pstl/trunk/include/pstl/internal/parallel_backend_tbb.h
    pstl/trunk/include/pstl/internal/parallel_backend_utils.h
    pstl/trunk/include/pstl/internal/parallel_impl.h
    pstl/trunk/include/pstl/internal/pstl_config.h
    pstl/trunk/include/pstl/internal/unseq_backend_simd.h
    pstl/trunk/include/pstl/internal/utils.h

Modified: pstl/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/CMakeLists.txt?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/CMakeLists.txt (original)
+++ pstl/trunk/CMakeLists.txt Tue Aug 13 05:49:00 2019
@@ -17,6 +17,8 @@ math(EXPR VERSION_PATCH "(${PARALLELSTL_
 project(ParallelSTL VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES CXX)
 
 set(PSTL_PARALLEL_BACKEND "serial" CACHE STRING "Threading backend to use. Valid choices are 'serial' and 'tbb'. The default is 'serial'.")
+set(PSTL_HIDE_FROM_ABI_PER_TU OFF CACHE BOOL "Whether to constrain ABI-unstable symbols to each translation unit (basically, mark them with C's static keyword).")
+set(_PSTL_HIDE_FROM_ABI_PER_TU ${PSTL_HIDE_FROM_ABI_PER_TU}) # For __pstl_config_site
 
 if (NOT TBB_DIR)
     get_filename_component(PSTL_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)

Modified: pstl/trunk/include/__pstl_config_site.in
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/__pstl_config_site.in?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/__pstl_config_site.in (original)
+++ pstl/trunk/include/__pstl_config_site.in Tue Aug 13 05:49:00 2019
@@ -11,5 +11,6 @@
 
 #cmakedefine _PSTL_PAR_BACKEND_SERIAL
 #cmakedefine _PSTL_PAR_BACKEND_TBB
+#cmakedefine _PSTL_HIDE_FROM_ABI_PER_TU
 
 #endif // __PSTL_CONFIG_SITE

Modified: pstl/trunk/include/pstl/internal/algorithm_fwd.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/algorithm_fwd.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/algorithm_fwd.h (original)
+++ pstl/trunk/include/pstl/internal/algorithm_fwd.h Tue Aug 13 05:49:00 2019
@@ -16,6 +16,8 @@
 
 #include "pstl_config.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __internal
@@ -1254,4 +1256,7 @@ __pattern_lexicographical_compare(_Execu
 
 } // namespace __internal
 } // namespace __pstl
+
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_ALGORITHM_FWD_H */

Modified: pstl/trunk/include/pstl/internal/algorithm_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/algorithm_impl.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/algorithm_impl.h (original)
+++ pstl/trunk/include/pstl/internal/algorithm_impl.h Tue Aug 13 05:49:00 2019
@@ -24,6 +24,8 @@
 #include "pstl_config.h"
 #include "unseq_backend_simd.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __internal
@@ -3620,4 +3622,6 @@ __pattern_lexicographical_compare(_Execu
 } // namespace __internal
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_ALGORITHM_IMPL_H */

Modified: pstl/trunk/include/pstl/internal/execution_defs.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/execution_defs.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/execution_defs.h (original)
+++ pstl/trunk/include/pstl/internal/execution_defs.h Tue Aug 13 05:49:00 2019
@@ -14,6 +14,8 @@
 
 #include "pstl_config.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace execution
@@ -155,4 +157,6 @@ using __enable_if_execution_policy =
 
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_EXECUTION_POLICY_DEFS_H */

Modified: pstl/trunk/include/pstl/internal/execution_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/execution_impl.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/execution_impl.h (original)
+++ pstl/trunk/include/pstl/internal/execution_impl.h Tue Aug 13 05:49:00 2019
@@ -16,6 +16,8 @@
 #include "pstl_config.h"
 #include "execution_defs.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __internal
@@ -159,4 +161,6 @@ struct __prefer_parallel_tag
 } // namespace __internal
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_EXECUTION_IMPL_H */

Modified: pstl/trunk/include/pstl/internal/glue_algorithm_defs.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/glue_algorithm_defs.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/glue_algorithm_defs.h (original)
+++ pstl/trunk/include/pstl/internal/glue_algorithm_defs.h Tue Aug 13 05:49:00 2019
@@ -16,6 +16,8 @@
 #include "execution_defs.h"
 #include "pstl_config.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace std
 {
 
@@ -550,4 +552,7 @@ lexicographical_compare(_ExecutionPolicy
                         _ForwardIterator2 __first2, _ForwardIterator2 __last2);
 
 } // namespace std
+
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_GLUE_ALGORITHM_DEFS_H */

Modified: pstl/trunk/include/pstl/internal/glue_algorithm_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/glue_algorithm_impl.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/glue_algorithm_impl.h (original)
+++ pstl/trunk/include/pstl/internal/glue_algorithm_impl.h Tue Aug 13 05:49:00 2019
@@ -21,6 +21,8 @@
 
 #include "execution_impl.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace std
 {
 
@@ -1160,4 +1162,6 @@ lexicographical_compare(_ExecutionPolicy
 
 } // namespace std
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_GLUE_ALGORITHM_IMPL_H */

Modified: pstl/trunk/include/pstl/internal/glue_memory_defs.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/glue_memory_defs.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/glue_memory_defs.h (original)
+++ pstl/trunk/include/pstl/internal/glue_memory_defs.h Tue Aug 13 05:49:00 2019
@@ -13,6 +13,8 @@
 #include "execution_defs.h"
 #include "pstl_config.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace std
 {
 
@@ -77,4 +79,7 @@ __pstl::__internal::__enable_if_executio
 uninitialized_value_construct_n(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Size __n);
 
 } //  namespace std
+
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_GLUE_MEMORY_DEFS_H */

Modified: pstl/trunk/include/pstl/internal/glue_memory_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/glue_memory_impl.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/glue_memory_impl.h (original)
+++ pstl/trunk/include/pstl/internal/glue_memory_impl.h Tue Aug 13 05:49:00 2019
@@ -18,6 +18,8 @@
 
 #include "execution_impl.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace std
 {
 
@@ -368,4 +370,6 @@ uninitialized_value_construct_n(_Executi
 
 } // namespace std
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_GLUE_MEMORY_IMPL_H */

Modified: pstl/trunk/include/pstl/internal/glue_numeric_defs.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/glue_numeric_defs.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/glue_numeric_defs.h (original)
+++ pstl/trunk/include/pstl/internal/glue_numeric_defs.h Tue Aug 13 05:49:00 2019
@@ -15,6 +15,8 @@
 #include "execution_defs.h"
 #include "pstl_config.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace std
 {
 // [reduce]
@@ -116,4 +118,7 @@ adjacent_difference(_ExecutionPolicy&& _
                     _ForwardIterator2 __d_first);
 
 } // namespace std
+
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_GLUE_NUMERIC_DEFS_H */

Modified: pstl/trunk/include/pstl/internal/glue_numeric_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/glue_numeric_impl.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/glue_numeric_impl.h (original)
+++ pstl/trunk/include/pstl/internal/glue_numeric_impl.h Tue Aug 13 05:49:00 2019
@@ -18,6 +18,8 @@
 #include "numeric_fwd.h"
 #include "execution_impl.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace std
 {
 
@@ -228,4 +230,6 @@ adjacent_difference(_ExecutionPolicy&& _
 
 } // namespace std
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_GLUE_NUMERIC_IMPL_H_ */

Modified: pstl/trunk/include/pstl/internal/memory_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/memory_impl.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/memory_impl.h (original)
+++ pstl/trunk/include/pstl/internal/memory_impl.h Tue Aug 13 05:49:00 2019
@@ -15,6 +15,8 @@
 #include "pstl_config.h"
 #include "unseq_backend_simd.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __internal
@@ -54,4 +56,6 @@ __brick_uninitialized_move(_ForwardItera
 } // namespace __internal
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_MEMORY_IMPL_H */

Modified: pstl/trunk/include/pstl/internal/numeric_fwd.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/numeric_fwd.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/numeric_fwd.h (original)
+++ pstl/trunk/include/pstl/internal/numeric_fwd.h Tue Aug 13 05:49:00 2019
@@ -15,6 +15,8 @@
 
 #include "pstl_config.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __internal
@@ -135,4 +137,7 @@ __pattern_adjacent_difference(_Execution
 
 } // namespace __internal
 } // namespace __pstl
+
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_NUMERIC_FWD_H */

Modified: pstl/trunk/include/pstl/internal/numeric_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/numeric_impl.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/numeric_impl.h (original)
+++ pstl/trunk/include/pstl/internal/numeric_impl.h Tue Aug 13 05:49:00 2019
@@ -20,6 +20,8 @@
 #include "unseq_backend_simd.h"
 #include "algorithm_fwd.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __internal
@@ -351,4 +353,6 @@ __pattern_adjacent_difference(_Execution
 } // namespace __internal
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_NUMERIC_IMPL_H */

Modified: pstl/trunk/include/pstl/internal/parallel_backend_serial.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend_serial.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend_serial.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend_serial.h Tue Aug 13 05:49:00 2019
@@ -18,6 +18,8 @@
 
 #include "pstl_config.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __serial_backend
@@ -129,4 +131,6 @@ __parallel_invoke(_ExecutionPolicy&&, _F
 } // namespace __serial_backend
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_PARALLEL_BACKEND_SERIAL_H */

Modified: pstl/trunk/include/pstl/internal/parallel_backend_tbb.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend_tbb.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend_tbb.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend_tbb.h Tue Aug 13 05:49:00 2019
@@ -30,6 +30,8 @@
 #    error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
 #endif
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __tbb_backend
@@ -1052,4 +1054,6 @@ __parallel_invoke(_ExecutionPolicy&&, _F
 } // namespace __tbb_backend
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_PARALLEL_BACKEND_TBB_H */

Modified: pstl/trunk/include/pstl/internal/parallel_backend_utils.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_backend_utils.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_backend_utils.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_backend_utils.h Tue Aug 13 05:49:00 2019
@@ -17,6 +17,8 @@
 
 #include "pstl_config.h"
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 
@@ -139,4 +141,6 @@ struct __serial_move_merge
 } // namespace __utils
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_PARALLEL_BACKEND_UTILS_H */

Modified: pstl/trunk/include/pstl/internal/parallel_impl.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/parallel_impl.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/parallel_impl.h (original)
+++ pstl/trunk/include/pstl/internal/parallel_impl.h Tue Aug 13 05:49:00 2019
@@ -16,6 +16,8 @@
 // This header defines the minimum set of parallel routines required to support Parallel STL,
 // implemented on top of Intel(R) Threading Building Blocks (Intel(R) TBB) library
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __internal
@@ -80,4 +82,6 @@ __parallel_or(_ExecutionPolicy&& __exec,
 } // namespace __internal
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_PARALLEL_IMPL_H */

Modified: pstl/trunk/include/pstl/internal/pstl_config.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/pstl_config.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/pstl_config.h (original)
+++ pstl/trunk/include/pstl/internal/pstl_config.h Tue Aug 13 05:49:00 2019
@@ -42,6 +42,15 @@
 #define _PSTL_STRING(x) _PSTL_STRING_AUX(x)
 #define _PSTL_STRING_CONCAT(x, y) x #y
 
+#ifdef _PSTL_HIDE_FROM_ABI_PER_TU
+#    define _PSTL_HIDE_FROM_ABI_PUSH                                                                                   \
+        _Pragma("clang attribute push(__attribute__((internal_linkage)), apply_to=any(function,record))")
+#    define _PSTL_HIDE_FROM_ABI_POP _Pragma("clang attribute pop")
+#else
+#    define _PSTL_HIDE_FROM_ABI_PUSH /* nothing */
+#    define _PSTL_HIDE_FROM_ABI_POP  /* nothing */
+#endif
+
 // note that when ICC or Clang is in use, _PSTL_GCC_VERSION might not fully match
 // the actual GCC version on the system.
 #define _PSTL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)

Modified: pstl/trunk/include/pstl/internal/unseq_backend_simd.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/unseq_backend_simd.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/unseq_backend_simd.h (original)
+++ pstl/trunk/include/pstl/internal/unseq_backend_simd.h Tue Aug 13 05:49:00 2019
@@ -17,6 +17,9 @@
 
 // This header defines the minimum set of vector routines required
 // to support parallel STL.
+
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __unseq_backend
@@ -854,4 +857,6 @@ __simd_remove_if(_RandomAccessIterator _
 } // namespace __unseq_backend
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_UNSEQ_BACKEND_SIMD_H */

Modified: pstl/trunk/include/pstl/internal/utils.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/utils.h?rev=368684&r1=368683&r2=368684&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/utils.h (original)
+++ pstl/trunk/include/pstl/internal/utils.h Tue Aug 13 05:49:00 2019
@@ -13,6 +13,8 @@
 #include <new>
 #include <iterator>
 
+_PSTL_HIDE_FROM_ABI_PUSH
+
 namespace __pstl
 {
 namespace __internal
@@ -170,4 +172,6 @@ __cmp_iterators_by_values(_ForwardIterat
 } // namespace __internal
 } // namespace __pstl
 
+_PSTL_HIDE_FROM_ABI_POP
+
 #endif /* _PSTL_UTILS_H */




More information about the libcxx-commits mailing list