From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Devulapalli, Raghuveer <raghuveer.devulapalli@intel.com>
Cc: Shankaran, Akash <akash.shankaran@intel.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: Ants Aasma <ants.aasma@cybertec.at>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Amonson, Paul D <paul.d.amonson@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: Tue, 30 Jul 2024 16:54:54 -0500
Message-ID: <ZqlhLn9PwBTpdy-n@nathan> (raw)
In-Reply-To: <Zqlb1_-BWlzVMbZv@nathan>
References: <20240418195346.GA3506520@nathanxps13>
<PH8PR11MB8286E1E9D1ADD14300A267CAFB0E2@PH8PR11MB8286.namprd11.prod.outlook.com>
<20240418210158.GA3776258@nathanxps13>
<PH8PR11MB8286DB91D214478FB16EE616FB0E2@PH8PR11MB8286.namprd11.prod.outlook.com>
<20240418215902.GA3830246@nathanxps13>
<PH8PR11MB82863AB8040AD090909DC18BFB0E2@PH8PR11MB8286.namprd11.prod.outlook.com>
<20240418221358.GA3927188@nathanxps13>
<20240423160207.GA841237@nathanxps13>
<20240730210701.oyn2wr4zduu2efrg@awork3.anarazel.de>
<Zqlb1_-BWlzVMbZv@nathan>
On Tue, Jul 30, 2024 at 04:32:07PM -0500, Nathan Bossart wrote:
> On Tue, Jul 30, 2024 at 02:07:01PM -0700, Andres Freund wrote:
>> Afaict we could just check for predefined preprocessor macros:
>>
>> echo|time gcc -c -mxsave -mavx512vpopcntdq -mavx512bw -xc -dM -E - -o -|grep -E '__XSAVE__|__AVX512BW__|__AVX512VPOPCNTDQ__'
>> #define __AVX512BW__ 1
>> #define __AVX512VPOPCNTDQ__ 1
>> #define __XSAVE__ 1
>> 0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 13292maxresident)k
>>
>> echo|time gcc -c -march=nehalem -xc -dM -E - -o -|grep -E '__XSAVE__|__AVX512BW__|__AVX512VPOPCNTDQ__'
>> 0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 10972maxresident)k
>
> Seems promising. I can't think of a reason that wouldn't work.
>
>> Now, a reasonable counter-argument would be that only some of these macros are
>> defined for msvc ([1]). However, as it turns out, the test is broken
>> today, as msvc doesn't error out when using an intrinsic that's not
>> "available" by the target architecture, it seems to assume that the caller did
>> a cpuid check ahead of time.
Hm. Upon further inspection, I see that MSVC appears to be missing
__XSAVE__ and __AVX512VPOPCNTDQ__, which is unfortunate. Still, I think
the worst case scenario is that the CPUID check fails and we don't use
AVX-512 instructions. AFAICT we aren't adding new function pointers in any
builds that don't already have them, just compiling some extra unused code.
--
nathan
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, andres@anarazel.de, raghuveer.devulapalli@intel.com, akash.shankaran@intel.com, tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, ants.aasma@cybertec.at, alvherre@alvh.no-ip.org, paul.d.amonson@intel.com, noah@leadboat.com, boekewurm+postgres@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Popcount optimization using AVX512
In-Reply-To: <ZqlhLn9PwBTpdy-n@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