[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
This commit is contained in:
Louis Dionne 2019-08-13 12:49:00 +00:00
parent 42b957aad7
commit 1b6d6e595b
22 changed files with 94 additions and 0 deletions

View File

@ -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)

View File

@ -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

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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_ */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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__)

View File

@ -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 */

View File

@ -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(_ForwardIterator __a, _ForwardIterator __b, _Compare _
} // namespace __internal
} // namespace __pstl
_PSTL_HIDE_FROM_ABI_POP
#endif /* _PSTL_UTILS_H */