Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxHlt-007Sb6-Af for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 02:45:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rxHlr-00HCnw-JK for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 02:45:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxHlr-00HCno-7Z for pgsql-hackers@lists.postgresql.org; Thu, 18 Apr 2024 02:45:07 +0000 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rxHlo-001Ycc-C6 for pgsql-hackers@lists.postgresql.org; Thu, 18 Apr 2024 02:45:06 +0000 Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-36b0e1301e3so1448075ab.2 for ; Wed, 17 Apr 2024 19:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713408302; x=1714013102; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4uq9z8mqbSJWwHyq+Ldteoe6Wn1rY7T95n887UTw/KA=; b=Y7n3SqW1xJ85NCWiUITRsfIWCMxEHVBwDjTTP1efP1/Ncrcp1PKfQ5yE0UGs3G9No4 VmL0xha7Hsm/OB+Of7nOn+i04slBcfYG0EBBjpXKSRCYcleTx1PpHU1joQjwfhi2yJ8X 5N5FhZKlNqYDSzntRumLmIxkp2bogq5FKGFVAMqcuey2emqxHuJUz5Z7hIyotNCnZ20E AoMrjfnVr8fdohMmlhyptjwtpULpDptZkzHEeyWAhMWBoY4mt/fsmkZydOe3QafRhy6I /7cLuGZyLJEswyMVIsixlwfaexCd7zohHw326Tdlt1T3u1+ruSGyYdVbXkb1wOy+Smcx sQcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713408302; x=1714013102; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4uq9z8mqbSJWwHyq+Ldteoe6Wn1rY7T95n887UTw/KA=; b=la9Q0NKfdXXc1/hHDWn/wX1TCVGcofqBDQGCBjeWdL3TnCZ0dscKZFFGSaSOTSdjhd /Zacxae+wWOlxeUTHyTLyPBDOmgI4+TG3xITh3/AS0IZJL+HqwELbNMq1wB7cSfXhY8K bENDMuiAIeBRtwinoQxZBVlWK4CHpbpLx1EcpNGc6dJ4Lv0QSyKf8iwGDdD+AUuS22hG kYZtHuNRXH8Rqn6jhZm3bQKSifPaFXqfE9IdVqsBund2coVoRlKP2pV1OA3heJVanU05 EYXOoUy6pZ1F40lo21KhP4xnBz85QXT4MIdXisRzZT//kAgneZycG5GfZuQuHRp1pnKB wmWg== X-Forwarded-Encrypted: i=1; AJvYcCWPWQ+a8PoZ4pC+4Dr58wTxwNK6XNzY1C7bKaGOmmLb9XnBSjbCk1EzAwHUxs/iAcMILIphf/6qH2DB5aLPB2QPVe+znKeVYPUZP3kV/M6IFtyl X-Gm-Message-State: AOJu0Yz/Vj2+jV/sZi/ZgnK/Ske79Q04DhOPxa8a0noJ1kMTsnCDsHMD b4l0WFvfDsf0kSp8f5lv9GOhudM98Eia4lq3gPlRyDvuJ9pWeGxR X-Google-Smtp-Source: AGHT+IFIVwTRHx4BU71LBbC+zg/qeJ5gCxHnae5vTdgE4KJ00/t7xUDXhPnsv5g2j16K1C73IGWIpw== X-Received: by 2002:a05:6e02:1381:b0:36a:1e10:6820 with SMTP id d1-20020a056e02138100b0036a1e106820mr1745835ilo.23.1713408302596; Wed, 17 Apr 2024 19:45:02 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id l7-20020a05663814c700b00484a94650f9sm115161jak.103.2024.04.17.19.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 19:45:01 -0700 (PDT) Date: Wed, 17 Apr 2024 21:44:59 -0500 From: Nathan Bossart To: Tom Lane Cc: David Rowley , Ants Aasma , Alvaro Herrera , "Amonson, Paul D" , Andres Freund , "Shankaran, Akash" , Noah Misch , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: <20240418024459.GA3385227@nathanxps13> References: <20240405125844.GB4102502@nathanxps13> <20240405153811.GA9352@nathanxps13> <20240406011704.GB167028@nathanxps13> <20240406194101.GA533391@nathanxps13> <2999492.1712536932@sss.pgh.pa.us> <20240408012332.GA1351547@nathanxps13> <20240408013002.GA1352058@nathanxps13> <3010179.1712540139@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="DocE+STaALJfprDB" Content-Disposition: inline In-Reply-To: <3010179.1712540139@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --DocE+STaALJfprDB Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="osxsave.patch" 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? */ --DocE+STaALJfprDB--