From: Nathan Bossart <nathandbossart@gmail.com>
To: Amonson, Paul D <paul.d.amonson@intel.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Shankaran, Akash <akash.shankaran@intel.com>
Cc: Noah Misch <noah@leadboat.com>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: Popcount optimization using AVX512
Date: Fri, 29 Mar 2024 15:08:28 -0500
Message-ID: <20240329200828.GB1411904@nathanxps13> (raw)
In-Reply-To: <20240329191312.GA1411904@nathanxps13>
References: <20240325200551.GB2924132@nathanxps13>
<20240327220010.GA231058@nathanxps13>
<BL1PR11MB53047289F146DB43C9B2FC71DC342@BL1PR11MB5304.namprd11.prod.outlook.com>
<20240328213854.GA916732@nathanxps13>
<BL1PR11MB5304E51336123CE6F041A920DC3B2@BL1PR11MB5304.namprd11.prod.outlook.com>
<BL1PR11MB5304217FFEFB15124CD2EC9EDC3B2@BL1PR11MB5304.namprd11.prod.outlook.com>
<20240329155940.GC1046039@nathanxps13>
<20240329162211.GB1106154@nathanxps13>
<BL1PR11MB5304D41D49B56986097713AFDC3A2@BL1PR11MB5304.namprd11.prod.outlook.com>
<20240329191312.GA1411904@nathanxps13>
On Fri, Mar 29, 2024 at 02:13:12PM -0500, Nathan Bossart wrote:
> * If the compiler understands AVX512 intrinsics, we assume that it also
> knows about the required CPUID and XGETBV intrinsics, and we assume that
> the conditions for TRY_POPCNT_FAST are true.
Bleh, cfbot's 32-bit build is unhappy with this [0]. It looks like it's
trying to build the AVX512 stuff, but TRY_POPCNT_FAST isn't set.
[19:39:11.306] ../src/port/pg_popcount_avx512.c:39:18: warning: implicit declaration of function ‘pg_popcount_fast’; did you mean ‘pg_popcount’? [-Wimplicit-function-declaration]
[19:39:11.306] 39 | return popcnt + pg_popcount_fast(buf, bytes);
[19:39:11.306] | ^~~~~~~~~~~~~~~~
[19:39:11.306] | pg_popcount
There's also a complaint about the inline assembly:
[19:39:11.443] ../src/port/pg_popcount_avx512_choose.c:55:1: error: inconsistent operand constraints in an ‘asm’
[19:39:11.443] 55 | __asm__ __volatile__(" xgetbv\n":"=a"(low), "=d"(high):"c"(xcr));
[19:39:11.443] | ^~~~~~~
I'm looking into this...
> +#if defined(HAVE__GET_CPUID)
> + __get_cpuid_count(7, 0, &exx[0], &exx[1], &exx[2], &exx[3]);
> +#elif defined(HAVE__CPUID)
> + __cpuidex(exx, 7, 0);
Is there any reason we can't use __get_cpuid() and __cpuid() here, given
the sub-leaf is 0?
[0] https://cirrus-ci.com/task/5475113447981056
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
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-hackers@postgresql.org
Cc: nathandbossart@gmail.com, paul.d.amonson@intel.com, tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, andres@anarazel.de, alvherre@alvh.no-ip.org, akash.shankaran@intel.com, noah@leadboat.com, boekewurm+postgres@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Popcount optimization using AVX512
In-Reply-To: <20240329200828.GB1411904@nathanxps13>
* 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