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 1sYyep-00Fa8N-Og for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2024 02:01:39 +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 1sYyen-00GEGb-QQ for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2024 02:01:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sYyen-00GEGR-Ep for pgsql-hackers@lists.postgresql.org; Wed, 31 Jul 2024 02:01:37 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sYyek-002IeE-S3 for pgsql-hackers@lists.postgresql.org; Wed, 31 Jul 2024 02:01:36 +0000 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-81f921c40f2so217238039f.0 for ; Tue, 30 Jul 2024 19:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722391294; x=1722996094; 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=LuVYsAw5F201blyxQq/re65RWsEMSCJssg0ILTyca88=; b=lJG8nRBus3mIInQtLXRhwTrHEBoYUGvIIqyWk7KqucnK7FvN5kMyyYdlTbkFaa75bV jNP2aG0+lJT1pwYtN2UxkupwU8SbV6nLH01PykpdHKmgxlrPP0mytcB+7CHyPex3QN5o +tfvVnR0vwms5h95qaHDekF5AONzQid64M3ouqbfv00jcK+a3s+rLMG+BWaLckkmu4QN rsO8lnRvo+WGGVkirU2LF5IWQUOjoZ8WsdEhS18tn7/wxmLNFTt0NRaUiyAo8Mt+w7wD axtDVld4COElcrQSzH5PC+LL/dZpuUas+eyT3GoL9Cs5H0AyP1lF6PdL18a0MxrmYtZ5 2peg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722391294; x=1722996094; 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=LuVYsAw5F201blyxQq/re65RWsEMSCJssg0ILTyca88=; b=b+uoNBdbzsFzz8dCIE5Cktow4rijq38HHeuepWAOOAeBNQ1yPoLoZUlkUNAjev4S4m pEfgPPcnei0/rNySbgSsICNhwKdUHso9zEphe5H+980QAN4h0jKKyD8hJefYG0W+Quur RcgiG+gs2eC8mVcOWMQVZIE3bZlchxs6ChAHF7hrJOS9QssOLY37iIkxGOowguN4z0ER 1wl4Ou5jFE9Lng7VAPUrQCrnCaEjFJLDMJw/aXs1Atzzw6vfRnHMEfQlni7DZvSsEnaR iMS5mzqUNicuQX1C8jZ5TPLRME8gVTlhIWKJhlpNjNJ06+iDYZvdrwnrcqqUCJCBfU4J ooyA== X-Forwarded-Encrypted: i=1; AJvYcCVEgcWgABYGTI0ngG9TeSkJwh7cjYi4D7nmg3LYmEJyVW6zqCZYYrymvj6DRO8BbDjtdyeOGTEhS8Z/LhkxLQqpOEtdCRWfAa40s7Fg5Xj9uWX6 X-Gm-Message-State: AOJu0Yx5XktNhGaRg11HgSoBGS4ze7ZNGFe61RAYI83l8sqPFRt8ffdY vCx1mfO7WhPr0w2as9dVMwDkKSpfnix98GDRGxNkaZetvuB1bpED X-Google-Smtp-Source: AGHT+IFwgLwUHHtZVFkUzVTnypzMPNbyrq6zU20mfG5yBF+QmbJ2mmrZacq7fBhU4b6R9YpGjzQzmQ== X-Received: by 2002:a05:6602:3427:b0:7f6:853d:de8b with SMTP id ca18e2360f4ac-81f95a9fa5amr1501080239f.14.1722391293815; Tue, 30 Jul 2024 19:01:33 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c29fa96431sm2992593173.46.2024.07.30.19.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 19:01:33 -0700 (PDT) Date: Tue, 30 Jul 2024 21:01:31 -0500 From: Nathan Bossart To: Andres Freund Cc: "Devulapalli, Raghuveer" , "Shankaran, Akash" , Tom Lane , David Rowley , Ants Aasma , Alvaro Herrera , "Amonson, Paul D" , Noah Misch , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: References: <20240418215902.GA3830246@nathanxps13> <20240418221358.GA3927188@nathanxps13> <20240423160207.GA841237@nathanxps13> <20240730210701.oyn2wr4zduu2efrg@awork3.anarazel.de> <20240731004959.6ys24432n6xlgemk@awork3.anarazel.de> <20240731014651.byn3exbu6n5v2yqa@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240731014651.byn3exbu6n5v2yqa@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jul 30, 2024 at 06:46:51PM -0700, Andres Freund wrote: > On 2024-07-30 20:20:34 -0500, Nathan Bossart wrote: >> On Tue, Jul 30, 2024 at 05:49:59PM -0700, Andres Freund wrote: >> > Why are we actually checking for xsave? We're not using xsave itself and I >> > couldn't find a comment in 792752af4eb5 explaining what we're using it as a >> > proxy for? Is that just to know if _xgetbv() exists? Is it actually possible >> > that xsave isn't available when avx512 is? >> >> Yes, it's to verify we have XGETBV, which IIUC requires support from both >> the processor and the OS (see 598e011 and upthread discussion). AFAIK the >> way we are detecting AVX-512 support is quite literally by-the-book unless >> I've gotten something wrong. > > I'm basically wondering whether we need to check for compiler (not OS support) > support for xsave if we also check for -mavx512vpopcntdq -mavx512bw > support. Afaict the latter implies support for xsave. The main purpose of the XSAVE compiler check is to determine whether we need to add -mxsave in order to use _xgetbv() [0]. If that wasn't a factor, we could probably skip it. Earlier versions of the patch used inline assembly in the non-MSVC path to call XGETBV, which I was trying to avoid. [0] https://postgr.es/m/20240330032209.GA2018686%40nathanxps13 -- nathan