pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use __attribute__((target(...))) for SSE4.2 CRC-32C support.
Date: Wed, 27 Nov 2024 22:20:43 +0000
Message-ID: <E1tGQOp-003ocO-CB@gemulon.postgresql.org> (raw)

Use __attribute__((target(...))) for SSE4.2 CRC-32C support.

Presently, we check for compiler support for the required
intrinsics both with and without the -msse4.2 compiler flag, and
then depending on the results of those checks, we pick which files
to compile with which flags.  This is tedious and complicated, and
it results in unsustainable coding patterns such as separate files
for each portion of code that may need to be built with different
compiler flags.

This commit makes use of the newly-added support for
__attribute__((target(...))) in the SSE4.2 CRC-32C code.  This
simplifies both the configure-time checks and the build scripts,
and it allows us to place the functions that use the intrinsics in
files that we otherwise do not want to build with special CPU
instructions (although this commit refrains from doing so).  This
is also preparatory work for a proposed follow-up commit that will
further optimize the CRC-32C code with AVX-512 instructions.

While at it, this commit modifies meson's checks for SSE4.2 CRC
support to be the same as autoconf's.  meson was choosing whether
to use a runtime check based purely on whether -msse4.2 is
required, while autoconf has long checked for the __SSE4_2__
preprocessor symbol to decide.  meson's previous approach seems to
work just fine, but this change avoids needing to build multiple
test programs and to keep track of whether to actually use
pg_attribute_target().

Ideally we'd use __attribute__((target(...))) for ARMv8 CRC
support, too, but there's little point in doing so because until
clang 16, using the ARM intrinsics still requires special compiler
flags.  Perhaps we can re-evaluate this decision after some time
has passed.

Author: Raghuveer Devulapalli
Discussion: https://postgr.es/m/PH8PR11MB8286BE735A463468415D46B5FB5C2%40PH8PR11MB8286.namprd11.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4b03a27fafc98e2a34e4e0b5ca44895211e021cc

Modified Files
--------------
config/c-compiler.m4       | 32 ++++++++--------
configure                  | 93 +++++++++++++++-------------------------------
configure.ac               | 19 +++++-----
meson.build                | 22 +++++++----
src/port/Makefile          |  5 ---
src/port/meson.build       |  2 +-
src/port/pg_crc32c_sse42.c |  1 +
7 files changed, 72 insertions(+), 102 deletions(-)



Message-ID: <E1tGQOp-003ocO-CB@gemulon.postgresql.org>
Permalink:  ../E1tGQOp-003ocO-CB@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tGQOp-003ocO-CB@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Use __attribute__((target(...))) for SSE4.2 CRC-32C support.
  In-Reply-To: <E1tGQOp-003ocO-CB@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