pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use ARMv8 CRC instructions where available.
Date: Wed, 04 Apr 2018 09:23:16 +0000
Message-ID: <E1f3edQ-0004tJ-26@gemulon.postgresql.org> (raw)

Use ARMv8 CRC instructions where available.

ARMv8 introduced special CPU instructions for calculating CRC-32C. Use
them, when available, for speed.

Like with the similar Intel CRC instructions, several factors affect
whether the instructions can be used. The compiler intrinsics for them must
be supported by the compiler, and the instructions must be supported by the
target architecture. If the compilation target architecture does not
support the instructions, but adding "-march=armv8-a+crc" makes them
available, then we compile the code with a runtime check to determine if
the host we're running on supports them or not.

For the runtime check, use glibc getauxval() function. Unfortunately,
that's not very portable, but I couldn't find any more portable way to do
it. If getauxval() is not available, the CRC instructions will still be
used if the target architecture supports them without any additional
compiler flags, but the runtime check will not be available.

Original patch by Yuqi Gu, heavily modified by me. Reviewed by Andres
Freund, Thomas Munro.

Discussion: https://www.postgresql.org/message-id/HE1PR0801MB1323D171938EABC04FFE7FA9E3110%40HE1PR0801MB1323.eur...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f044d71e331d77a0039cec0a11859b5a3c72bc95

Modified Files
--------------
config/c-compiler.m4                               |  34 ++++
configure                                          | 194 +++++++++++++++++++--
configure.in                                       |  87 +++++++--
src/Makefile.global.in                             |   1 +
src/include/pg_config.h.in                         |   9 +
src/include/port/pg_crc32c.h                       |  26 ++-
src/port/Makefile                                  |   4 +
src/port/pg_crc32c_armv8.c                         |  72 ++++++++
src/port/pg_crc32c_armv8_choose.c                  |  55 ++++++
...pg_crc32c_choose.c => pg_crc32c_sse42_choose.c} |  13 +-
src/tools/msvc/Mkvcbuild.pm                        |   2 +-
11 files changed, 456 insertions(+), 41 deletions(-)



Message-ID: <E1f3edQ-0004tJ-26@gemulon.postgresql.org>
Permalink:  ../E1f3edQ-0004tJ-26@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1f3edQ-0004tJ-26@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Use ARMv8 CRC instructions where available.
  In-Reply-To: <E1f3edQ-0004tJ-26@gemulon.postgresql.org>
  References: <E1f3edQ-0004tJ-26@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox