[PATCH 1/2] Add std::experimental::simd from the Parallelism TS 2

Matthias Kretz m.kretz@gsi.de
Fri Dec 18 15:49:43 GMT 2020


Resending this patch with proper commit message and rebased on master.

From: Matthias Kretz <kretz@kde.org>

Adds <experimental/simd>.

This implements the simd and simd_mask class templates via
[[gnu::vector_size(N)]] data members. It implements overloads for all of
<cmath> for simd. Explicit vectorization of the <cmath> functions is not
finished.
The majority of functions are marked as [[gnu::always_inline]] to enable
quasi-ODR-conforming linking of TUs with different -m flags.
Performance optimization was done for x86_64. ARM, Aarch64, and POWER
rely on the compiler to recognize reduction, conversion, and shuffle
patterns.
Besides verification using many different machine flages, the code was
also verified with different fast-math flags.

libstdc++-v3/ChangeLog:
	* doc/xml/manual/status_cxx2017.xml: Add implementation status
	of the Parallelism TS 2. Document implementation-defined types
	and behavior.
	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/experimental/simd: New file. New header for
	Parallelism TS 2.
	* include/experimental/bits/numeric_traits.h: New file.
	Implementation of P1841R1 using internal naming. Addition of
	missing IEC559 functionality query.
	* include/experimental/bits/simd.h: New file. Definition of the
	public simd interfaces and general implementation helpers.
	* include/experimental/bits/simd_builtin.h: New file.
	Implementation of the _VecBuiltin simd_abi.
	* include/experimental/bits/simd_converter.h: New file. Generic
	simd conversions.
	* include/experimental/bits/simd_detail.h: New file. Internal
	macros for the simd implementation.
	* include/experimental/bits/simd_fixed_size.h: New file. Simd
	fixed_size ABI specific implementations.
	* include/experimental/bits/simd_math.h: New file. Math
	overloads for simd.
	* include/experimental/bits/simd_neon.h: New file. Simd NEON
	specific implementations.
	* include/experimental/bits/simd_ppc.h: New file. Implement bit
	shifts to avoid invalid results for integral types smaller than
	int.
	* include/experimental/bits/simd_scalar.h: New file. Simd scalar
	ABI specific implementations.
	* include/experimental/bits/simd_x86.h: New file. Simd x86
	specific implementations.
	* include/experimental/bits/simd_x86_conversions.h: New file.
	x86 specific conversion optimizations. The conversion patterns
	work around missing conversion patterns in the compiler and
	should be removed as soon as PR85048 is resolved.
	* testsuite/experimental/simd/standard_abi_usable.cc: New file.
	Test that all (not all fixed_size<N>, though) standard simd and
	simd_mask types are usable.
	* testsuite/experimental/simd/standard_abi_usable_2.cc: New
	file. As above but with -ffast-math.
	* testsuite/libstdc++-dg/conformance.exp: Don't build simd tests
	from the standard test loop. Instead use
	check_vect_support_and_set_flags to build simd tests with the
	relevant machine flags.
---
 .../doc/xml/manual/status_cxx2017.xml         |  216 +
 libstdc++-v3/include/Makefile.am              |   13 +
 libstdc++-v3/include/Makefile.in              |   13 +
 .../experimental/bits/numeric_traits.h        |  567 ++
 libstdc++-v3/include/experimental/bits/simd.h | 5051 ++++++++++++++++
 .../include/experimental/bits/simd_builtin.h  | 2949 ++++++++++
 .../experimental/bits/simd_converter.h        |  354 ++
 .../include/experimental/bits/simd_detail.h   |  306 +
 .../experimental/bits/simd_fixed_size.h       | 2066 +++++++
 .../include/experimental/bits/simd_math.h     | 1500 +++++
 .../include/experimental/bits/simd_neon.h     |  519 ++
 .../include/experimental/bits/simd_ppc.h      |  123 +
 .../include/experimental/bits/simd_scalar.h   |  772 +++
 .../include/experimental/bits/simd_x86.h      | 5169 +++++++++++++++++
 .../experimental/bits/simd_x86_conversions.h  | 2029 +++++++
 libstdc++-v3/include/experimental/simd        |   70 +
 .../experimental/simd/standard_abi_usable.cc  |   64 +
 .../simd/standard_abi_usable_2.cc             |    4 +
 .../testsuite/libstdc++-dg/conformance.exp    |   18 +-
 19 files changed, 21802 insertions(+), 1 deletion(-)
 create mode 100644 libstdc++-v3/include/experimental/bits/numeric_traits.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_builtin.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_converter.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_detail.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_fixed_size.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_math.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_neon.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_ppc.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_scalar.h
 create mode 100644 libstdc++-v3/include/experimental/bits/simd_x86.h
 create mode 100644 libstdc++-v3/include/experimental/bits/
simd_x86_conversions.h
 create mode 100644 libstdc++-v3/include/experimental/simd
 create mode 100644 libstdc++-v3/testsuite/experimental/simd/
standard_abi_usable.cc
 create mode 100644 libstdc++-v3/testsuite/experimental/simd/
standard_abi_usable_2.cc


--
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 std::experimental::simd              https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-std-experimental-simd-from-the-Parallelism-TS-2.patch
Type: text/x-patch
Size: 794645 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20201218/79b9d5db/attachment-0001.bin>


More information about the Libstdc++ mailing list