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 1rqIWh-00Bc6p-ET for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 20:08:35 +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 1rqIWg-0040Rr-7h for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 20:08:34 +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 1rqIWf-0040Ri-UT for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 20:08:33 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rqIWc-0076QU-6G for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 20:08:32 +0000 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-7d031abe8f8so77278739f.0 for ; Fri, 29 Mar 2024 13:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711742910; x=1712347710; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=3QOwhNjCdMe/22+ThZiTjhbfhVCB5jjnHupCWF8kawM=; b=KF1m4TVWdw2GMX49Dpa2YRu6zZJCHtnTVntN5CLqkVRtLZnzJ804XAKrXROoBswlnS iij7Rp43vO3aQtyKCAb8EuTMN20DaZ6yb3Ba4SbilX0B3o9CDVTMci/Fl4dWVNttfmCD xc7LbbPhe5f8TOlSA6hHoM5yV6Ilke+hQOMKRLi667tFfYzWo3WJS8VSy6Qiagk0+wNL gL2ntTrMOtrR1AMMfPRZLE3TZXGcrq+gX7AkXYfrcdzL69umOI/c8bWII34Hnwc9H6LW 0w1wITpqB8dlfW+X6OutuipBuMy6s7LLF4vUrzNDLF21M27AZNbnxfFoECdMA4xEkKKz qthw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711742910; x=1712347710; h=in-reply-to:content-transfer-encoding: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=3QOwhNjCdMe/22+ThZiTjhbfhVCB5jjnHupCWF8kawM=; b=tMMg1ciFhPWhqJUji7XIfk0EhblJApXtN6ZnaUSHlPsGcRuiQTxpM8ZglWuEA//ZgY mIRm4qyS3m9cYt8EW/yrfGR3AqVUyH0JSHKj/tsth8+pPgXnhcxWXSfS60TRGSGawWdj 3pKDzHLGmHoK5CWcWPWejgjK7visrc78pVMj9FbpcQsJaYCeByi2PNDnO364gMhvCUwn Lk3AlgdWytKBooWRi8MCRNh7A/9+Q8v7rlR6w8cDESIsHxBcg8+93onHm+cq4u1hZNAe KAOJe33iw4G1pM7VnnKGb2mvJ5S+HXX0R6HsQ7VvSKHqdq96xEJukO5KpXmeS4i2Ogzv oWhg== X-Forwarded-Encrypted: i=1; AJvYcCXcgGijrGNA3mhHZu7QiubDUIF0Yb0JprArnO5dbdfGcH3nOiMKuR9HfL13jtAycjFIO7QWqoTB75fA/EJyRi3Y7EzX5k2JQG4Ka170GH3xGKwR X-Gm-Message-State: AOJu0Yzbdt2dxTgy8cwPdTiFah1h6gOWfC1KduDZCooFETYynOwb53ic OjXBT3wrFInNptP/WdnCQy8IPFMwi2BVEg9GzGEAmp0irQ4AX+5o X-Google-Smtp-Source: AGHT+IGSxUhRFHRwJCXQRmf1hZltTOzOai/Y7QXSOqBZcTpE9rL7y9ZCWTi1FDMPujEcevD+0X8moQ== X-Received: by 2002:a6b:6a18:0:b0:7d0:4732:4669 with SMTP id x24-20020a6b6a18000000b007d047324669mr2138302iog.3.1711742910421; Fri, 29 Mar 2024 13:08:30 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id q7-20020a6bf207000000b007d08c6e7628sm1168402ioh.16.2024.03.29.13.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:08:29 -0700 (PDT) Date: Fri, 29 Mar 2024 15:08:28 -0500 From: Nathan Bossart To: "Amonson, Paul D" Cc: Tom Lane , David Rowley , Andres Freund , Alvaro Herrera , "Shankaran, Akash" , Noah Misch , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: <20240329200828.GB1411904@nathanxps13> References: <20240325200551.GB2924132@nathanxps13> <20240327220010.GA231058@nathanxps13> <20240328213854.GA916732@nathanxps13> <20240329155940.GC1046039@nathanxps13> <20240329162211.GB1106154@nathanxps13> <20240329191312.GA1411904@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240329191312.GA1411904@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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