From 1b6d6e595b5e27566579c03923667aaab58bd3cd Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 13 Aug 2019 12:49:00 +0000 Subject: [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. llvm-svn: 368684 --- pstl/CMakeLists.txt | 2 ++ pstl/include/__pstl_config_site.in | 1 + pstl/include/pstl/internal/algorithm_fwd.h | 5 +++++ pstl/include/pstl/internal/algorithm_impl.h | 4 ++++ pstl/include/pstl/internal/execution_defs.h | 4 ++++ pstl/include/pstl/internal/execution_impl.h | 4 ++++ pstl/include/pstl/internal/glue_algorithm_defs.h | 5 +++++ pstl/include/pstl/internal/glue_algorithm_impl.h | 4 ++++ pstl/include/pstl/internal/glue_memory_defs.h | 5 +++++ pstl/include/pstl/internal/glue_memory_impl.h | 4 ++++ pstl/include/pstl/internal/glue_numeric_defs.h | 5 +++++ pstl/include/pstl/internal/glue_numeric_impl.h | 4 ++++ pstl/include/pstl/internal/memory_impl.h | 4 ++++ pstl/include/pstl/internal/numeric_fwd.h | 5 +++++ pstl/include/pstl/internal/numeric_impl.h | 4 ++++ pstl/include/pstl/internal/parallel_backend_serial.h | 4 ++++ pstl/include/pstl/internal/parallel_backend_tbb.h | 4 ++++ pstl/include/pstl/internal/parallel_backend_utils.h | 4 ++++ pstl/include/pstl/internal/parallel_impl.h | 4 ++++ pstl/include/pstl/internal/pstl_config.h | 9 +++++++++ pstl/include/pstl/internal/unseq_backend_simd.h | 5 +++++ pstl/include/pstl/internal/utils.h | 4 ++++ 22 files changed, 94 insertions(+) (limited to 'pstl') diff --git a/pstl/CMakeLists.txt b/pstl/CMakeLists.txt index 62451b2..dd601bc 100644 --- a/pstl/CMakeLists.txt +++ b/pstl/CMakeLists.txt @@ -17,6 +17,8 @@ math(EXPR VERSION_PATCH "(${PARALLELSTL_VERSION_SOURCE} % 10)") 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) diff --git a/pstl/include/__pstl_config_site.in b/pstl/include/__pstl_config_site.in index f92c695..7bfdb74 100644 --- a/pstl/include/__pstl_config_site.in +++ b/pstl/include/__pstl_config_site.in @@ -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 diff --git a/pstl/include/pstl/internal/algorithm_fwd.h b/pstl/include/pstl/internal/algorithm_fwd.h index 2f9f13e..d3986de 100644 --- a/pstl/include/pstl/internal/algorithm_fwd.h +++ b/pstl/include/pstl/internal/algorithm_fwd.h @@ -16,6 +16,8 @@ #include "pstl_config.h" +_PSTL_HIDE_FROM_ABI_PUSH + namespace __pstl { namespace __internal @@ -1254,4 +1256,7 @@ __pattern_lexicographical_compare(_ExecutionPolicy&&, _ForwardIterator1, _Forwar } // namespace __internal } // namespace __pstl + +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_ALGORITHM_FWD_H */ diff --git a/pstl/include/pstl/internal/algorithm_impl.h b/pstl/include/pstl/internal/algorithm_impl.h index 883f03d..5bfa8ee 100644 --- a/pstl/include/pstl/internal/algorithm_impl.h +++ b/pstl/include/pstl/internal/algorithm_impl.h @@ -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(_ExecutionPolicy&& __exec, _ForwardIterator1 _ } // namespace __internal } // namespace __pstl +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_ALGORITHM_IMPL_H */ diff --git a/pstl/include/pstl/internal/execution_defs.h b/pstl/include/pstl/internal/execution_defs.h index cb9cf69..28e89f5 100644 --- a/pstl/include/pstl/internal/execution_defs.h +++ b/pstl/include/pstl/internal/execution_defs.h @@ -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 */ diff --git a/pstl/include/pstl/internal/execution_impl.h b/pstl/include/pstl/internal/execution_impl.h index 26f4c7d..af3b083 100644 --- a/pstl/include/pstl/internal/execution_impl.h +++ b/pstl/include/pstl/internal/execution_impl.h @@ -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 */ diff --git a/pstl/include/pstl/internal/glue_algorithm_defs.h b/pstl/include/pstl/internal/glue_algorithm_defs.h index d5e4d4a..28a7f92 100644 --- a/pstl/include/pstl/internal/glue_algorithm_defs.h +++ b/pstl/include/pstl/internal/glue_algorithm_defs.h @@ -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&& __exec, _ForwardIterator1 __first1, _ _ForwardIterator2 __first2, _ForwardIterator2 __last2); } // namespace std + +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_GLUE_ALGORITHM_DEFS_H */ diff --git a/pstl/include/pstl/internal/glue_algorithm_impl.h b/pstl/include/pstl/internal/glue_algorithm_impl.h index 47c39a5..9b4c56c 100644 --- a/pstl/include/pstl/internal/glue_algorithm_impl.h +++ b/pstl/include/pstl/internal/glue_algorithm_impl.h @@ -21,6 +21,8 @@ #include "execution_impl.h" +_PSTL_HIDE_FROM_ABI_PUSH + namespace std { @@ -1160,4 +1162,6 @@ lexicographical_compare(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ } // namespace std +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_GLUE_ALGORITHM_IMPL_H */ diff --git a/pstl/include/pstl/internal/glue_memory_defs.h b/pstl/include/pstl/internal/glue_memory_defs.h index bf32c92..ae52333 100644 --- a/pstl/include/pstl/internal/glue_memory_defs.h +++ b/pstl/include/pstl/internal/glue_memory_defs.h @@ -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_execution_policy<_ExecutionPolicy, _ForwardItera uninitialized_value_construct_n(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Size __n); } // namespace std + +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_GLUE_MEMORY_DEFS_H */ diff --git a/pstl/include/pstl/internal/glue_memory_impl.h b/pstl/include/pstl/internal/glue_memory_impl.h index 5401690..5c96e30 100644 --- a/pstl/include/pstl/internal/glue_memory_impl.h +++ b/pstl/include/pstl/internal/glue_memory_impl.h @@ -18,6 +18,8 @@ #include "execution_impl.h" +_PSTL_HIDE_FROM_ABI_PUSH + namespace std { @@ -368,4 +370,6 @@ uninitialized_value_construct_n(_ExecutionPolicy&& __exec, _ForwardIterator __fi } // namespace std +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_GLUE_MEMORY_IMPL_H */ diff --git a/pstl/include/pstl/internal/glue_numeric_defs.h b/pstl/include/pstl/internal/glue_numeric_defs.h index 1a9cd07..f997b54 100644 --- a/pstl/include/pstl/internal/glue_numeric_defs.h +++ b/pstl/include/pstl/internal/glue_numeric_defs.h @@ -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&& __exec, _ForwardIterator1 __first, _Forwa _ForwardIterator2 __d_first); } // namespace std + +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_GLUE_NUMERIC_DEFS_H */ diff --git a/pstl/include/pstl/internal/glue_numeric_impl.h b/pstl/include/pstl/internal/glue_numeric_impl.h index 2b3bf73..18b3371 100644 --- a/pstl/include/pstl/internal/glue_numeric_impl.h +++ b/pstl/include/pstl/internal/glue_numeric_impl.h @@ -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&& __exec, _ForwardIterator1 __first, _Forwa } // namespace std +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_GLUE_NUMERIC_IMPL_H_ */ diff --git a/pstl/include/pstl/internal/memory_impl.h b/pstl/include/pstl/internal/memory_impl.h index 2140ba9..241f00a 100644 --- a/pstl/include/pstl/internal/memory_impl.h +++ b/pstl/include/pstl/internal/memory_impl.h @@ -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(_ForwardIterator __first, _ForwardIterator __last, _O } // namespace __internal } // namespace __pstl +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_MEMORY_IMPL_H */ diff --git a/pstl/include/pstl/internal/numeric_fwd.h b/pstl/include/pstl/internal/numeric_fwd.h index 4d52164..07d7f07 100644 --- a/pstl/include/pstl/internal/numeric_fwd.h +++ b/pstl/include/pstl/internal/numeric_fwd.h @@ -15,6 +15,8 @@ #include "pstl_config.h" +_PSTL_HIDE_FROM_ABI_PUSH + namespace __pstl { namespace __internal @@ -135,4 +137,7 @@ __pattern_adjacent_difference(_ExecutionPolicy&&, _ForwardIterator, _ForwardIter } // namespace __internal } // namespace __pstl + +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_NUMERIC_FWD_H */ diff --git a/pstl/include/pstl/internal/numeric_impl.h b/pstl/include/pstl/internal/numeric_impl.h index fe1f222..c288111 100644 --- a/pstl/include/pstl/internal/numeric_impl.h +++ b/pstl/include/pstl/internal/numeric_impl.h @@ -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(_ExecutionPolicy&& __exec, _ForwardIterator1 __fir } // namespace __internal } // namespace __pstl +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_NUMERIC_IMPL_H */ diff --git a/pstl/include/pstl/internal/parallel_backend_serial.h b/pstl/include/pstl/internal/parallel_backend_serial.h index 969f199..65033c9 100644 --- a/pstl/include/pstl/internal/parallel_backend_serial.h +++ b/pstl/include/pstl/internal/parallel_backend_serial.h @@ -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&&, _F1&& __f1, _F2&& __f2) } // namespace __serial_backend } // namespace __pstl +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_PARALLEL_BACKEND_SERIAL_H */ diff --git a/pstl/include/pstl/internal/parallel_backend_tbb.h b/pstl/include/pstl/internal/parallel_backend_tbb.h index 6e7cb66..244ab4c 100644 --- a/pstl/include/pstl/internal/parallel_backend_tbb.h +++ b/pstl/include/pstl/internal/parallel_backend_tbb.h @@ -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&&, _F1&& __f1, _F2&& __f2) } // namespace __tbb_backend } // namespace __pstl +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_PARALLEL_BACKEND_TBB_H */ diff --git a/pstl/include/pstl/internal/parallel_backend_utils.h b/pstl/include/pstl/internal/parallel_backend_utils.h index c94cdc4..5728b48 100644 --- a/pstl/include/pstl/internal/parallel_backend_utils.h +++ b/pstl/include/pstl/internal/parallel_backend_utils.h @@ -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 */ diff --git a/pstl/include/pstl/internal/parallel_impl.h b/pstl/include/pstl/internal/parallel_impl.h index 523b925..247ff44 100644 --- a/pstl/include/pstl/internal/parallel_impl.h +++ b/pstl/include/pstl/internal/parallel_impl.h @@ -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, _Index __first, _Index __last, _Brick _ } // namespace __internal } // namespace __pstl +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_PARALLEL_IMPL_H */ diff --git a/pstl/include/pstl/internal/pstl_config.h b/pstl/include/pstl/internal/pstl_config.h index c2a737b..5346929 100644 --- a/pstl/include/pstl/internal/pstl_config.h +++ b/pstl/include/pstl/internal/pstl_config.h @@ -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__) diff --git a/pstl/include/pstl/internal/unseq_backend_simd.h b/pstl/include/pstl/internal/unseq_backend_simd.h index 96e099c..7916d80 100644 --- a/pstl/include/pstl/internal/unseq_backend_simd.h +++ b/pstl/include/pstl/internal/unseq_backend_simd.h @@ -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 __first, _DifferenceType __n, _UnaryPredi } // namespace __unseq_backend } // namespace __pstl +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_UNSEQ_BACKEND_SIMD_H */ diff --git a/pstl/include/pstl/internal/utils.h b/pstl/include/pstl/internal/utils.h index 0f5b834..4911165 100644 --- a/pstl/include/pstl/internal/utils.h +++ b/pstl/include/pstl/internal/utils.h @@ -13,6 +13,8 @@ #include #include +_PSTL_HIDE_FROM_ABI_PUSH + namespace __pstl { namespace __internal @@ -170,4 +172,6 @@ __cmp_iterators_by_values(_ForwardIterator __a, _ForwardIterator __b, _Compare _ } // namespace __internal } // namespace __pstl +_PSTL_HIDE_FROM_ABI_POP + #endif /* _PSTL_UTILS_H */ -- cgit v1.1