[PATCH] Enable use of #pragma omp simd reduction(inscan,...) even for GCC10+ in PSTL

Jakub Jelinek jakub@redhat.com
Fri Jun 21 21:18:00 GMT 2019


Hi!

Now that GCC supports inclusive/exclusive scans (like ICC 19.0 so far in
simd constructs only), we can enable it in PSTL as well.

Bootstrapped/regtested on x86_64-linux and i686-linux, additionally tested
with
#include <execution>
#include <numeric>

auto
foo (std::vector<int> &ca, std::vector<int> &co)
{
  return std::inclusive_scan(std::execution::unseq, ca.begin(), ca.end(), co.begin());
}

auto
bar (std::vector<int> &ca, std::vector<int> &co)
{
  return std::exclusive_scan(std::execution::unseq, ca.begin(), ca.end(), co.begin(), 0);
}
and verifying with -O2 -fopenmp-simd it is vectorized.  Ok for trunk?
Can you push it into upstream PSTL?

2019-06-21  Jakub Jelinek  <jakub@redhat.com>

	* include/pstl/pstl_config.h (_PSTL_PRAGMA_SIMD_SCAN,
	_PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN, _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN):
	Define to OpenMP 5.0 pragmas even for GCC 10.0+.
	(_PSTL_UDS_PRESENT): Define to 1 for GCC 10.0+.

--- libstdc++-v3/include/pstl/pstl_config.h.jj	2019-06-10 18:18:01.551191212 +0200
+++ libstdc++-v3/include/pstl/pstl_config.h	2019-06-20 17:03:31.466367344 +0200
@@ -70,7 +70,7 @@
 #    define _PSTL_PRAGMA_FORCEINLINE
 #endif
 
-#if (__INTEL_COMPILER >= 1900)
+#if (__INTEL_COMPILER >= 1900) || (_PSTL_GCC_VERSION >= 100000)
 #    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))
@@ -100,7 +100,11 @@
 #    define _PSTL_UDR_PRESENT 0
 #endif
 
-#define _PSTL_UDS_PRESENT (__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626)
+#if ((__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626) || _PSTL_GCC_VERSION >= 100000)
+#    define _PSTL_UDS_PRESENT 1
+#else
+#    define _PSTL_UDS_PRESENT 0
+#endif
 
 #if _PSTL_EARLYEXIT_PRESENT
 #    define _PSTL_PRAGMA_SIMD_EARLYEXIT _PSTL_PRAGMA(omp simd early_exit)

	Jakub



More information about the Gcc-patches mailing list