pgsql: Use Intel SSE 4.2 CRC instructions where available.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Use Intel SSE 4.2 CRC instructions where available.
Date: 2015-04-14 14:09:28
Message-ID: E1Yi1Wq-0000tM-Kk@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Use Intel SSE 4.2 CRC instructions where available.

Modern x86 and x86-64 processors with SSE 4.2 support have special
instructions, crc32b and crc32q, for calculating CRC-32C. They greatly
speed up CRC calculation.

Whether the instructions can be used or not depends on the compiler and the
target architecture. If generation of SSE 4.2 instructions is allowed for
the target (-msse4.2 flag on gcc and clang), use them. If they are not
allowed by default, but the compiler supports the -msse4.2 flag to enable
them, compile just the CRC-32C function with -msse4.2 flag, and check at
runtime whether the processor we're running on supports it. If it doesn't,
fall back to the slicing-by-8 algorithm. (With the common defaults on
current operating systems, the runtime-check variant is what you get in
practice.)

Abhijit Menon-Sen, heavily modified by me, reviewed by Andres Freund.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/3dc2d62d0486325bf263655c2d9a96aee0b02abe

Modified Files
--------------
config/c-compiler.m4 | 27 ++++++
configure | 212 +++++++++++++++++++++++++++++++++++++++++
configure.in | 78 +++++++++++++++
src/Makefile.global.in | 4 +
src/include/pg_config.h.in | 15 +++
src/include/pg_config.h.win32 | 23 ++++-
src/include/port/pg_crc32c.h | 44 +++++++++
src/port/Makefile | 8 +-
src/port/pg_crc32c_choose.c | 63 ++++++++++++
src/port/pg_crc32c_sse42.c | 52 ++++++++++
src/tools/msvc/Mkvcbuild.pm | 13 ++-
11 files changed, 534 insertions(+), 5 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-04-14 14:32:06 Re: pgsql: Don't archive bogus recycled or preallocated files after timelin
Previous Message Heikki Linnakangas 2015-04-14 06:38:28 Re: pgsql: Don't archive bogus recycled or preallocated files after timelin

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-04-14 14:10:59 Re: What exactly is our CRC algorithm?
Previous Message Michael Paquier 2015-04-14 11:40:33 Make more portable TAP tests of initdb