[pstl] Indent preprocessor directives as part of the clang-format rules
Summary: Indenting preprocessor directives provides a significant gain in readability. We do it for normal if statements, and it makes sense to do it for preprocessor ifs too. Reviewers: rodgert, MikeDvorskiy Subscribers: jkorous, dexonsmith, jdoerfert, libcxx-commits Differential Revision: https://reviews.llvm.org/D59767 llvm-svn: 357401
This commit is contained in:
parent
0a30f33ce2
commit
95c585e258
|
@ -15,3 +15,6 @@ BreakBeforeBraces: Allman
|
|||
# Disable formatting options which may break tests.
|
||||
SortIncludes: false
|
||||
ReflowComments: false
|
||||
|
||||
# Indent preprocessor directives
|
||||
IndentPPDirectives: AfterHash
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
#if __PSTL_EXECUTION_POLICIES_DEFINED
|
||||
// If <execution> has already been included, pull in implementations
|
||||
#include "internal/glue_algorithm_impl.h"
|
||||
# include "internal/glue_algorithm_impl.h"
|
||||
#else
|
||||
// Otherwise just pull in forward declarations
|
||||
#include "internal/glue_algorithm_defs.h"
|
||||
#define __PSTL_ALGORITHM_FORWARD_DECLARED 1
|
||||
# include "internal/glue_algorithm_defs.h"
|
||||
# define __PSTL_ALGORITHM_FORWARD_DECLARED 1
|
||||
#endif
|
||||
|
||||
#endif /* __PSTL_algorithm */
|
||||
|
|
|
@ -16,21 +16,21 @@
|
|||
#define __PSTL_EXECUTION_POLICIES_DEFINED 1
|
||||
|
||||
#if __PSTL_ALGORITHM_FORWARD_DECLARED
|
||||
#include "internal/glue_algorithm_impl.h"
|
||||
# include "internal/glue_algorithm_impl.h"
|
||||
#endif
|
||||
|
||||
#if __PSTL_MEMORY_FORWARD_DECLARED
|
||||
#include "internal/glue_memory_impl.h"
|
||||
# include "internal/glue_memory_impl.h"
|
||||
#endif
|
||||
|
||||
#if __PSTL_NUMERIC_FORWARD_DECLARED
|
||||
#include "internal/glue_numeric_impl.h"
|
||||
# include "internal/glue_numeric_impl.h"
|
||||
#endif
|
||||
|
||||
#if __PSTL_CPP17_EXECUTION_POLICIES_PRESENT
|
||||
__PSTL_PRAGMA_MESSAGE_POLICIES("The <Parallel STL> execution policies are defined in the namespace __pstl::execution")
|
||||
#else
|
||||
#include "internal/glue_execution_defs.h"
|
||||
# include "internal/glue_execution_defs.h"
|
||||
__PSTL_PRAGMA_MESSAGE_POLICIES(
|
||||
"The <Parallel STL> execution policies are injected into the standard namespace std::execution")
|
||||
#endif
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include "unseq_backend_simd.h"
|
||||
|
||||
#if __PSTL_USE_PAR_POLICIES
|
||||
#include "parallel_backend.h"
|
||||
#include "parallel_impl.h"
|
||||
# include "parallel_backend.h"
|
||||
# include "parallel_impl.h"
|
||||
#endif
|
||||
|
||||
namespace __pstl
|
||||
|
@ -2194,11 +2194,11 @@ __pattern_partial_sort_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first,
|
|||
_ForwardIterator __j1 = __first + (__j - __d_first);
|
||||
|
||||
// 1. Copy elements from input to output
|
||||
#if !__PSTL_ICC_18_OMP_SIMD_BROKEN
|
||||
# if !__PSTL_ICC_18_OMP_SIMD_BROKEN
|
||||
__internal::__brick_copy(__i1, __j1, __i, __is_vector);
|
||||
#else
|
||||
# else
|
||||
std::copy(__i1, __j1, __i);
|
||||
#endif
|
||||
# endif
|
||||
// 2. Sort elements in output sequence
|
||||
std::sort(__i, __j, __comp);
|
||||
},
|
||||
|
|
|
@ -19,12 +19,12 @@ namespace std
|
|||
// Type trait
|
||||
using __pstl::execution::is_execution_policy;
|
||||
#if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
|
||||
#if __INTEL_COMPILER
|
||||
# if __INTEL_COMPILER
|
||||
template <class T>
|
||||
constexpr bool is_execution_policy_v = is_execution_policy<T>::value;
|
||||
#else
|
||||
# else
|
||||
using __pstl::execution::is_execution_policy_v;
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace execution
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "algorithm_fwd.h"
|
||||
|
||||
#if __PSTL_USE_PAR_POLICIES
|
||||
#include "parallel_backend.h"
|
||||
# include "parallel_backend.h"
|
||||
#endif
|
||||
|
||||
namespace __pstl
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#define __PSTL_parallel_backend_H
|
||||
|
||||
#if __PSTL_PAR_BACKEND_TBB
|
||||
#include "parallel_backend_tbb.h"
|
||||
# include "parallel_backend_tbb.h"
|
||||
#else
|
||||
__PSTL_PRAGMA_MESSAGE("Parallel backend was not specified");
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <tbb/tbb_allocator.h>
|
||||
|
||||
#if TBB_INTERFACE_VERSION < 10000
|
||||
#error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
|
||||
# error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
|
||||
#endif
|
||||
|
||||
namespace __pstl
|
||||
|
|
|
@ -16,35 +16,35 @@
|
|||
|
||||
// Check the user-defined macro for parallel policies
|
||||
#if defined(PSTL_USE_PARALLEL_POLICIES)
|
||||
#undef __PSTL_USE_PAR_POLICIES
|
||||
#define __PSTL_USE_PAR_POLICIES PSTL_USE_PARALLEL_POLICIES
|
||||
# undef __PSTL_USE_PAR_POLICIES
|
||||
# define __PSTL_USE_PAR_POLICIES PSTL_USE_PARALLEL_POLICIES
|
||||
// Check the internal macro for parallel policies
|
||||
#elif !defined(__PSTL_USE_PAR_POLICIES)
|
||||
#define __PSTL_USE_PAR_POLICIES 1
|
||||
# define __PSTL_USE_PAR_POLICIES 1
|
||||
#endif
|
||||
|
||||
#if __PSTL_USE_PAR_POLICIES
|
||||
#if !defined(__PSTL_PAR_BACKEND_TBB)
|
||||
#define __PSTL_PAR_BACKEND_TBB 1
|
||||
#endif
|
||||
# if !defined(__PSTL_PAR_BACKEND_TBB)
|
||||
# define __PSTL_PAR_BACKEND_TBB 1
|
||||
# endif
|
||||
#else
|
||||
#undef __PSTL_PAR_BACKEND_TBB
|
||||
# undef __PSTL_PAR_BACKEND_TBB
|
||||
#endif
|
||||
|
||||
// Check the user-defined macro for warnings
|
||||
#if defined(PSTL_USAGE_WARNINGS)
|
||||
#undef __PSTL_USAGE_WARNINGS
|
||||
#define __PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
|
||||
# undef __PSTL_USAGE_WARNINGS
|
||||
# define __PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
|
||||
// Check the internal macro for warnings
|
||||
#elif !defined(__PSTL_USAGE_WARNINGS)
|
||||
#define __PSTL_USAGE_WARNINGS 0
|
||||
# define __PSTL_USAGE_WARNINGS 0
|
||||
#endif
|
||||
|
||||
// Portability "#pragma" definition
|
||||
#ifdef _MSC_VER
|
||||
#define __PSTL_PRAGMA(x) __pragma(x)
|
||||
# define __PSTL_PRAGMA(x) __pragma(x)
|
||||
#else
|
||||
#define __PSTL_PRAGMA(x) _Pragma(#x)
|
||||
# define __PSTL_PRAGMA(x) _Pragma(# x)
|
||||
#endif
|
||||
|
||||
#define __PSTL_STRING_AUX(x) #x
|
||||
|
@ -57,38 +57,38 @@
|
|||
|
||||
#if __clang__
|
||||
// according to clang documentation, version can be vendor specific
|
||||
#define __PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
||||
# define __PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
|
||||
#endif
|
||||
|
||||
// Enable SIMD for compilers that support OpenMP 4.0
|
||||
#if (_OPENMP >= 201307) || (__INTEL_COMPILER >= 1600) || (!defined(__INTEL_COMPILER) && __PSTL_GCC_VERSION >= 40900)
|
||||
#define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(omp simd)
|
||||
#define __PSTL_PRAGMA_DECLARE_SIMD __PSTL_PRAGMA(omp declare simd)
|
||||
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(omp simd reduction(PRM))
|
||||
# define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(omp simd)
|
||||
# define __PSTL_PRAGMA_DECLARE_SIMD __PSTL_PRAGMA(omp declare simd)
|
||||
# define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(omp simd reduction(PRM))
|
||||
#elif !defined(_MSC_VER) //#pragma simd
|
||||
#define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(simd)
|
||||
#define __PSTL_PRAGMA_DECLARE_SIMD
|
||||
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(simd reduction(PRM))
|
||||
# define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(simd)
|
||||
# define __PSTL_PRAGMA_DECLARE_SIMD
|
||||
# define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(simd reduction(PRM))
|
||||
#else //no simd
|
||||
#define __PSTL_PRAGMA_SIMD
|
||||
#define __PSTL_PRAGMA_DECLARE_SIMD
|
||||
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM)
|
||||
# define __PSTL_PRAGMA_SIMD
|
||||
# define __PSTL_PRAGMA_DECLARE_SIMD
|
||||
# define __PSTL_PRAGMA_SIMD_REDUCTION(PRM)
|
||||
#endif //Enable SIMD
|
||||
|
||||
#if (__INTEL_COMPILER)
|
||||
#define __PSTL_PRAGMA_FORCEINLINE __PSTL_PRAGMA(forceinline)
|
||||
# define __PSTL_PRAGMA_FORCEINLINE __PSTL_PRAGMA(forceinline)
|
||||
#else
|
||||
#define __PSTL_PRAGMA_FORCEINLINE
|
||||
# define __PSTL_PRAGMA_FORCEINLINE
|
||||
#endif
|
||||
|
||||
#if (__INTEL_COMPILER >= 1900)
|
||||
#define __PSTL_PRAGMA_SIMD_SCAN(PRM) __PSTL_PRAGMA(omp simd reduction(inscan, PRM))
|
||||
#define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan inclusive(PRM))
|
||||
#define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan exclusive(PRM))
|
||||
# define __PSTL_PRAGMA_SIMD_SCAN(PRM) __PSTL_PRAGMA(omp simd reduction(inscan, PRM))
|
||||
# define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan inclusive(PRM))
|
||||
# define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan exclusive(PRM))
|
||||
#else
|
||||
#define __PSTL_PRAGMA_SIMD_SCAN(PRM)
|
||||
#define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
|
||||
#define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
|
||||
# define __PSTL_PRAGMA_SIMD_SCAN(PRM)
|
||||
# define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
|
||||
# define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
|
||||
#endif
|
||||
|
||||
// Should be defined to 1 for environments with a vendor implementation of C++17 execution policies
|
||||
|
@ -106,25 +106,25 @@
|
|||
#define __PSTL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)
|
||||
|
||||
#if (__INTEL_COMPILER >= 1900 || !defined(__INTEL_COMPILER) && __PSTL_GCC_VERSION >= 40900 || _OPENMP >= 201307)
|
||||
#define __PSTL_UDR_PRESENT 1
|
||||
# define __PSTL_UDR_PRESENT 1
|
||||
#else
|
||||
#define __PSTL_UDR_PRESENT 0
|
||||
# define __PSTL_UDR_PRESENT 0
|
||||
#endif
|
||||
|
||||
#define __PSTL_UDS_PRESENT (__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626)
|
||||
|
||||
#if __PSTL_EARLYEXIT_PRESENT
|
||||
#define __PSTL_PRAGMA_SIMD_EARLYEXIT __PSTL_PRAGMA(omp simd early_exit)
|
||||
# define __PSTL_PRAGMA_SIMD_EARLYEXIT __PSTL_PRAGMA(omp simd early_exit)
|
||||
#else
|
||||
#define __PSTL_PRAGMA_SIMD_EARLYEXIT
|
||||
# define __PSTL_PRAGMA_SIMD_EARLYEXIT
|
||||
#endif
|
||||
|
||||
#if __PSTL_MONOTONIC_PRESENT
|
||||
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) __PSTL_PRAGMA(omp ordered simd monotonic(PRM))
|
||||
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) __PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
|
||||
# define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) __PSTL_PRAGMA(omp ordered simd monotonic(PRM))
|
||||
# define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) __PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
|
||||
#else
|
||||
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
|
||||
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
|
||||
# define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
|
||||
# define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
|
||||
#endif
|
||||
|
||||
// Declaration of reduction functor, where
|
||||
|
@ -135,35 +135,35 @@
|
|||
// omp_priv - refers to the private copy of the initial value
|
||||
// omp_orig - refers to the original variable to be reduced
|
||||
#define __PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
|
||||
__PSTL_PRAGMA(omp declare reduction(NAME : OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
|
||||
__PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
|
||||
|
||||
#if (__INTEL_COMPILER >= 1600)
|
||||
#define __PSTL_PRAGMA_VECTOR_UNALIGNED __PSTL_PRAGMA(vector unaligned)
|
||||
# define __PSTL_PRAGMA_VECTOR_UNALIGNED __PSTL_PRAGMA(vector unaligned)
|
||||
#else
|
||||
#define __PSTL_PRAGMA_VECTOR_UNALIGNED
|
||||
# define __PSTL_PRAGMA_VECTOR_UNALIGNED
|
||||
#endif
|
||||
|
||||
// Check the user-defined macro to use non-temporal stores
|
||||
#if defined(PSTL_USE_NONTEMPORAL_STORES) && (__INTEL_COMPILER >= 1600)
|
||||
#define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED __PSTL_PRAGMA(vector nontemporal)
|
||||
# define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED __PSTL_PRAGMA(vector nontemporal)
|
||||
#else
|
||||
#define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
|
||||
# define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
|
||||
#endif
|
||||
|
||||
#if _MSC_VER || __INTEL_COMPILER //the preprocessors don't type a message location
|
||||
#define __PSTL_PRAGMA_LOCATION __FILE__ ":" __PSTL_STRING(__LINE__) ": [Parallel STL message]: "
|
||||
# define __PSTL_PRAGMA_LOCATION __FILE__ ":" __PSTL_STRING(__LINE__) ": [Parallel STL message]: "
|
||||
#else
|
||||
#define __PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
|
||||
# define __PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
|
||||
#endif
|
||||
|
||||
#define __PSTL_PRAGMA_MESSAGE_IMPL(x) __PSTL_PRAGMA(message(__PSTL_STRING_CONCAT(__PSTL_PRAGMA_LOCATION, x)))
|
||||
|
||||
#if __PSTL_USAGE_WARNINGS
|
||||
#define __PSTL_PRAGMA_MESSAGE(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
|
||||
#define __PSTL_PRAGMA_MESSAGE_POLICIES(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
|
||||
# define __PSTL_PRAGMA_MESSAGE(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
|
||||
# define __PSTL_PRAGMA_MESSAGE_POLICIES(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
|
||||
#else
|
||||
#define __PSTL_PRAGMA_MESSAGE(x)
|
||||
#define __PSTL_PRAGMA_MESSAGE_POLICIES(x)
|
||||
# define __PSTL_PRAGMA_MESSAGE(x)
|
||||
# define __PSTL_PRAGMA_MESSAGE_POLICIES(x)
|
||||
#endif
|
||||
|
||||
// broken macros
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
#if __PSTL_EXECUTION_POLICIES_DEFINED
|
||||
// If <execution> has already been included, pull in implementations
|
||||
#include "internal/glue_memory_impl.h"
|
||||
# include "internal/glue_memory_impl.h"
|
||||
#else
|
||||
// Otherwise just pull in forward declarations
|
||||
#include "internal/glue_memory_defs.h"
|
||||
#define __PSTL_MEMORY_FORWARD_DECLARED 1
|
||||
# include "internal/glue_memory_defs.h"
|
||||
# define __PSTL_MEMORY_FORWARD_DECLARED 1
|
||||
#endif
|
||||
|
||||
#endif /* __PSTL_memory */
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
#if __PSTL_EXECUTION_POLICIES_DEFINED
|
||||
// If <execution> has already been included, pull in implementations
|
||||
#include "internal/glue_numeric_impl.h"
|
||||
# include "internal/glue_numeric_impl.h"
|
||||
#else
|
||||
// Otherwise just pull in forward declarations
|
||||
#include "internal/glue_numeric_defs.h"
|
||||
#define __PSTL_NUMERIC_FORWARD_DECLARED 1
|
||||
# include "internal/glue_numeric_defs.h"
|
||||
# define __PSTL_NUMERIC_FORWARD_DECLARED 1
|
||||
#endif
|
||||
|
||||
#endif /* __PSTL_numeric */
|
||||
|
|
Loading…
Reference in New Issue
Block a user