pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: 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: Andres Freund <andres@anarazel.de>
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: Wed, 17 Apr 2024 21:44:59 -0500
Message-ID: <20240418024459.GA3385227@nathanxps13> (raw)
In-Reply-To: <3010179.1712540139@sss.pgh.pa.us>
References: <20240405125844.GB4102502@nathanxps13>
	<20240405153811.GA9352@nathanxps13>
	<CAApHDvrqVoduZRNTct5yn_6e=i7TkqhzSxt96WQQDxEkgdGeWg@mail.gmail.com>
	<20240406011704.GB167028@nathanxps13>
	<CAApHDvq32zJMbwOg69fAogJ9mFDdYyYp8-1A4xiFMv63HnSZ-A@mail.gmail.com>
	<20240406194101.GA533391@nathanxps13>
	<2999492.1712536932@sss.pgh.pa.us>
	<20240408012332.GA1351547@nathanxps13>
	<20240408013002.GA1352058@nathanxps13>
	<3010179.1712540139@sss.pgh.pa.us>

It was brought to my attention [0] that we probably should be checking for
the OSXSAVE bit instead of the XSAVE bit when determining whether there's
support for the XGETBV instruction.  IIUC that should indicate that both
the OS and the processor have XGETBV support (not just the processor).
I've attached a one-line patch to fix this.

[0] https://github.com/pgvector/pgvector/pull/519#issuecomment-2062804463

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

Attachments:

osxsave.patch (text/x-diff, 484B) download diff --git a/src/port/pg_popcount_avx512_choose.c b/src/port/pg_popcount_avx512_choose.c index ae3fa3d306..cc3e89e096 100644 --- a/src/port/pg_popcount_avx512_choose.c +++ b/src/port/pg_popcount_avx512_choose.c @@ -74,7 +74,7 @@ pg_popcount_avx512_available(void) #else #error cpuid instruction not available #endif - if ((exx[2] & (1 << 26)) == 0) /* xsave */ + if ((exx[2] & (1 << 27)) == 0) /* osxsave */ return false; /* Does XGETBV say the ZMM registers are enabled? */

view thread (173+ messages)  latest in thread

Message-ID: <20240418024459.GA3385227@nathanxps13>
Permalink:  ../20240418024459.GA3385227@nathanxps13/
Also on:    postgresql.org/message-id/20240418024459.GA3385227@nathanxps13

 ·  · 

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-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, ants.aasma@cybertec.at, alvherre@alvh.no-ip.org, paul.d.amonson@intel.com, andres@anarazel.de, 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: <20240418024459.GA3385227@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