pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Devulapalli, Raghuveer <raghuveer.devulapalli@intel.com>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: Use __attribute__((target(sse4.2))) for SSE42 CRC32C
Date: Fri, 8 Nov 2024 11:31:17 -0600
Message-ID: <Zy5K5Qmlb3Z4dsd4@nathan> (raw)
In-Reply-To: <PH8PR11MB82866E2249ABC8AA2E97497CFB5C2@PH8PR11MB8286.namprd11.prod.outlook.com>
References: <PH8PR11MB8286BE735A463468415D46B5FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com>
	<Zy0qg7cnI3uMr-qn@nathan>
	<PH8PR11MB82868168DEB5CA1FBE9EEDC1FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com>
	<Zy0y5qZi27ITnC1q@nathan>
	<PH8PR11MB82866E2249ABC8AA2E97497CFB5C2@PH8PR11MB8286.namprd11.prod.outlook.com>

-    prog = '''
+    sse42_crc_prog = '''

nitpick: Why does this need to be renamed?

+#ifdef TEST_SSE42_WITH_ATTRIBUTE
+#if defined(__has_attribute) && __has_attribute (target)
+__attribute__((target("sse4.2")))
+#endif
+#endif

So, for meson builds, we do test with and without
__attribute___((target(..."))), but for autoconf builds, we check for
__SSE4_2__ to determine whether we need a runtime check.  This difference
isn't the fault of your patch, but it's a little odd.  That being said, I'm
not sure there's a problem with either approach.

+if host_cpu == 'x86' or host_cpu == 'x86_64'
+  pgport_sources += files(
+  'pg_crc32c_sse42_choose.c',
+  'pg_crc32c_sse42.c',
+    )
+endi

We could probably just build these unconditionally (i.e., put them in the
first list of pgport_sources in this file) instead of keeping this
complexity in the build scripts.

+#if defined(USE_SSE42_CRC32C) || defined(USE_SSE42_CRC32C_WITH_RUNTIME_CHECK)

Can we move this to just below #include "c.h"?  The reason I didn't do this
for the AVX-512 stuff is because TRY_POPCNT_FAST is defined in
pg_bitutils.h, but looking again, I may be able to at least move the check
for USE_AVX512_POPCNT_WITH_RUNTIME_CHECK up similarly.

-- 
nathan





view thread (21+ messages)  latest in thread

Message-ID: <Zy5K5Qmlb3Z4dsd4@nathan>
Permalink:  ../Zy5K5Qmlb3Z4dsd4@nathan/
Also on:    postgresql.org/message-id/Zy5K5Qmlb3Z4dsd4@nathan

 · 

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-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, raghuveer.devulapalli@intel.com
  Subject: Re: Use __attribute__((target(sse4.2))) for SSE42 CRC32C
  In-Reply-To: <Zy5K5Qmlb3Z4dsd4@nathan>
  References: <PH8PR11MB8286BE735A463468415D46B5FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com> <Zy0qg7cnI3uMr-qn@nathan> <PH8PR11MB82868168DEB5CA1FBE9EEDC1FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com> <Zy0y5qZi27ITnC1q@nathan> <PH8PR11MB82866E2249ABC8AA2E97497CFB5C2@PH8PR11MB8286.namprd11.prod.outlook.com> <Zy5K5Qmlb3Z4dsd4@nathan>

* 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