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 1rqEGJ-00BHhM-FP for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 15:35:23 +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 1rqEGH-002Oxm-UC for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 15:35:21 +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 1rqEGH-002Oxd-Iy for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 15:35:21 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rqEGD-0074Qv-N4 for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 15:35:20 +0000 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-36894e0aaabso8257585ab.2 for ; Fri, 29 Mar 2024 08:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711726518; x=1712331318; 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=ek9z64pnobacI/SCKBHj1ntj1aObo77JZETU9ZT42B4=; b=BSMW8y8aVSWypVGnVovH+b+wFQHgeviJUyg0wrUfr4USQeAJNT+S53mCYvsokHbc6e dn1SPSf/TsyBWKNBx8SIc1/v9WxIogKCfgwyOcUH030ApgZZJTou2ieyyIWkGR8R7qJB KleL40QNEIRrMVxG34HZ5tQwne8f0/rcxP0AgyX8vzJv/4ZW5o0lwI6fg4kkQQNysnia XcIhsX/h81LNPp2UXxrUb9QE2UKfF/osuBB8NoWEu/YRhJw8ATR0I/Q9tS9Br6upFWXX xalPlhJpCZpnrSpuad0pSLSAjC89NyK6grkdYopE24lChAfnbfdMLp5BERtKKn9HWJEG Q+rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711726518; x=1712331318; 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=ek9z64pnobacI/SCKBHj1ntj1aObo77JZETU9ZT42B4=; b=nY4ZpcBRppk4JepvwQL4MFNFNcIJY4eEX5Q/k2SJbo/4iHoQzP1wH0tRAaTBWghg+X tG2+9bPZCRg0GVRf/P5zyOVVEYVltwLTNLemudiFwJYIanOcH485q3q5XmG2qPT7Kpfk Lty8IfRSY0+EhVxdEY9QSVCdYyKstgySRFv720OWNUNhFiMqUFnsBgzOhvKPGLCiOHYH OYjPeWJ7gp0LBlWiQkVGL3YzmvsxjLr2IZjrrO8cmjdyrl3EPzBGn6gLbR8YjdciBvtW 2SUSqHaYH+kUbUlfZCHcJxKxuX6zAO3rGuWlrW3IYOlkGT+kSzmTQ5ftcNyOAxMy8ruk 36CA== X-Forwarded-Encrypted: i=1; AJvYcCV4TqpFuKaQzkkqgk9FXQNS3LWvEWdGbTUzgTv7Tk71sYiBKNc+K/0/54yRqciqUFZvUundfvFdhzOTwnohPEX105WycYJ46er7G2R1Qu+K1ixz X-Gm-Message-State: AOJu0YwJC/U9iwlS1GzlFxtZsgA3IeA4+3DSPiSy3oJkHPJs7Gtk8QB7 0K9WOG7CMI+B/9JjpAah29l8rm5jOGCIvc/EeNI8ZK8+8WLXBe08 X-Google-Smtp-Source: AGHT+IGHDqui6OGV2NJSLIu+JTPAzpzQV3UQwTEKLqKfHjUq12yd97PGSbvRJeLilKQaOvfxDhAa/w== X-Received: by 2002:a05:6e02:20c3:b0:368:99d1:1a46 with SMTP id 3-20020a056e0220c300b0036899d11a46mr2877968ilq.19.1711726518098; Fri, 29 Mar 2024 08:35:18 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id a12-20020a056e02180c00b00368a32108e3sm1122778ilv.86.2024.03.29.08.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 08:35:17 -0700 (PDT) Date: Fri, 29 Mar 2024 10:35:15 -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: <20240329153515.GA1046039@nathanxps13> References: <2490633.1711379522@sss.pgh.pa.us> <20240325200551.GB2924132@nathanxps13> <20240327220010.GA231058@nathanxps13> <20240328213854.GA916732@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 28, 2024 at 10:03:04PM +0000, Amonson, Paul D wrote: >> * I think we need to verify there isn't a huge performance regression for >> smaller arrays. IIUC those will still require an AVX512 instruction or >> two as well as a function call, which might add some noticeable overhead. > > Not considering your changes, I had already tested small buffers. At less > than 512 bytes there was no measurable regression (there was one extra > condition check) and for 512+ bytes it moved from no regression to some > gains between 512 and 4096 bytes. Assuming you introduced no extra > function calls, it should be the same. Cool. I think we should run the benchmarks again to be safe, though. >> I forgot to mention that I also want to understand whether we can >> actually assume availability of XGETBV when CPUID says we support >> AVX512: > > You cannot assume as there are edge cases where AVX-512 was found on > system one during compile but it's not actually available in a kernel on > a second system at runtime despite the CPU actually having the hardware > feature. Yeah, I understand that much, but I want to know how portable the XGETBV instruction is. Unless I can assume that all x86_64 systems and compilers support that instruction, we might need an additional configure check and/or CPUID check. It looks like MSVC has had support for the _xgetbv intrinsic for quite a while, but I'm still researching the other cases. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com