[libcxx-commits] [libcxx] cdd01e4 - [libc++][PSTL] Move all the OpenMP conditionals into a single block
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 4 09:31:41 PDT 2023
Author: Nikolas Klauser
Date: 2023-05-04T09:31:34-07:00
New Revision: cdd01e49d6f4d5b047bc654eb7f64280c32a3f6b
URL: https://github.com/llvm/llvm-project/commit/cdd01e49d6f4d5b047bc654eb7f64280c32a3f6b
DIFF: https://github.com/llvm/llvm-project/commit/cdd01e49d6f4d5b047bc654eb7f64280c32a3f6b.diff
LOG: [libc++][PSTL] Move all the OpenMP conditionals into a single block
All the used OpenMP pragmas are available with OpenMP 4.0, so they can all share a single conditional block.
Reviewed By: ldionne, #libc
Spies: yaxunl, sstefan1, guansong, jplehr, libcxx-commits, sunshaoce
Differential Revision: https://reviews.llvm.org/D149603
Added:
Modified:
libcxx/include/__pstl/internal/pstl_config.h
Removed:
################################################################################
diff --git a/libcxx/include/__pstl/internal/pstl_config.h b/libcxx/include/__pstl/internal/pstl_config.h
index e6ad228f5472b..090dfc70cb9c3 100644
--- a/libcxx/include/__pstl/internal/pstl_config.h
+++ b/libcxx/include/__pstl/internal/pstl_config.h
@@ -22,31 +22,14 @@
// Enable SIMD for compilers that support OpenMP 4.0
#if (defined(_OPENMP) && _OPENMP >= 201307)
-# 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))
-#else //no simd
-# define _PSTL_PRAGMA_SIMD
-# define _PSTL_PRAGMA_DECLARE_SIMD
-# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
-#endif //Enable SIMD
-
-// TODO: find out when to enable these annotations
-#if 0
-# 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)
-#endif
-
-#if defined(_OPENMP) && _OPENMP >= 201307
-# define _PSTL_UDR_PRESENT
-#endif
-#define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
+# define _PSTL_UDR_PRESENT
+# 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_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))
// Declaration of reduction functor, where
// NAME - the name of the functor
@@ -55,7 +38,21 @@
// omp_out - refers to the final value of the combiner operator
// 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) \
+# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
_PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
+#else // (defined(_OPENMP) && _OPENMP >= 201307)
+
+# define _PSTL_PRAGMA_SIMD
+# define _PSTL_PRAGMA_DECLARE_SIMD
+# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
+# define _PSTL_PRAGMA_SIMD_SCAN(PRM)
+# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
+# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
+# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
+
+#endif // (defined(_OPENMP) && _OPENMP >= 201307)
+
+#define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
+
#endif /* _PSTL_CONFIG_H */
More information about the libcxx-commits
mailing list