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 1rmKXw-007H4T-FY for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Mar 2024 21:29:28 +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 1rmKXu-006Iql-L6 for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Mar 2024 21:29:27 +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 1rmKXu-006Iqc-Bd for pgsql-hackers@lists.postgresql.org; Mon, 18 Mar 2024 21:29:26 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rmKXr-005FcW-LO for pgsql-hackers@lists.postgresql.org; Mon, 18 Mar 2024 21:29:26 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3c35c4d8878so2208316b6e.1 for ; Mon, 18 Mar 2024 14:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710797362; x=1711402162; 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=zAcs2GxjXFOaLrYs2fu98HN4x7SeX6RwMc/qYVCSGZ0=; b=m/DWgpU89oodHmh1X74e932WILMH/bG2A7IpBd7kBoNlkj87c1vFAaeKENAqRhw/IU 27fDt65cHAklFwot87v6MWJ79CZgxevRMU0OG5r6lcODQIqJG9opwIGiyzLH9VNu3A3y 1pr9lvDgf9GbpO5V9SplcQ9iKFP0uMdFpX73Ud8tjiusK/DyeCzjeGoxum3BUrU2aNLC 2qjr+/jQPVMgIcESKLgiy0V/46YXgit4RF8b5jt4Ts0lxJWO/TaVKi5WA7LFTUqhJaYf MZ5rHPvtMtRNozhyFkEEYiF/C37agWTuiQtUHWZcZrOkUR3YPB/YJW6cIGa0hcU/QFaM RwtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710797362; x=1711402162; 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=zAcs2GxjXFOaLrYs2fu98HN4x7SeX6RwMc/qYVCSGZ0=; b=epK5miYqqkSZFvMNEVF5CFA7NbW5hIk71qCUt3U/vD15Jk5xNHQyyO4uLxanbkj604 mQYgBdXIYDmyAey69M+G0l9KRw67xIrMFrQKGg+n85rj7pRV/J9d4nhctFRrB+Ja2QsC rGN7yg7dpzT3QOF+RwxeJeN1PpviL6EyHaU3VxF04Pef+QnM/9FXrgu5L5aICvqL78NJ 6qklgK4ssywYzkR3VoD1tCrQMfwceOW4vMwNfK1580RfEVEnO/epxKAiyGngu+7tyP+0 yx05a3OfvNukn9e16unb5Bz+iQnkKWjHc5E3h7aB87o8VvcPIjUqdVLpUIrjIu0L1vSK IsfQ== X-Forwarded-Encrypted: i=1; AJvYcCU3C45st14F2ETk/ifpWdqoY/0wathq4ezoqaebS8Psxaqnoal2nK7YpyElyO3cZPd5YtCA8mr/tcqpTUJTkGTmOLGWKo5B/XltKGAuij39WelC X-Gm-Message-State: AOJu0YxbGzigkTvzSvkuCbAJ4qj9XPEVjB5vkuF0kkGeP7k2d/15zaL8 VsZ/9mJkihzA2RjF+vsPpNlp2u/1krMJonKfRHoOMNLWvwpnMNL1 X-Google-Smtp-Source: AGHT+IFPe6sOAd73I4+Ozh+njvOAalyG4KhtO1W1q3wYfB/N3pbRDf7tdfzju43GD1GiEWPZ+9nZOw== X-Received: by 2002:a05:6871:14a:b0:220:c5a4:5ab2 with SMTP id z10-20020a056871014a00b00220c5a45ab2mr15220346oab.11.1710797362151; Mon, 18 Mar 2024 14:29:22 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id da2-20020a0566384a4200b00479f7a0d9e3sm967632jab.62.2024.03.18.14.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 14:29:21 -0700 (PDT) Date: Mon, 18 Mar 2024 16:29:19 -0500 From: Nathan Bossart To: David Rowley Cc: "Amonson, Paul D" , Andres Freund , Alvaro Herrera , "Shankaran, Akash" , Noah Misch , Tom Lane , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: <20240318212919.GA684016@nathanxps13> References: <20240315150611.GA3495582@nathanxps13> <20240318152902.GA2850@nathanxps13> <20240318162018.GA204772@nathanxps13> <20240318173004.GA361138@nathanxps13> <20240318210810.GA582529@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 Tue, Mar 19, 2024 at 10:27:58AM +1300, David Rowley wrote: > On Tue, 19 Mar 2024 at 10:08, Nathan Bossart wrote: >> On Tue, Mar 19, 2024 at 10:02:18AM +1300, David Rowley wrote: >> > The only thing I'd question in the patch is in pg_popcount_fast(). It >> > looks like you've opted to not do the 32-bit processing on 32-bit >> > machines. I think that's likely still worth coding in a similar way to >> > how pg_popcount_slow() works. i.e. use "#if SIZEOF_VOID_P >= 8". >> > Probably one day we'll remove that code, but it seems strange to have >> > pg_popcount_slow() do it and not pg_popcount_fast(). >> >> The only reason I left it out was because I couldn't convince myself that >> it wasn't dead code, given we assume that popcntq is available in >> pg_popcount64_fast() today. But I don't see any harm in adding that just >> in case. > > It's probably more of a case of using native instructions rather than > ones that might be implemented only via microcode. For the record, I > don't know if that would be the case for popcntq on x86 32-bit and I > don't have the hardware to test it. It just seems less risky just to > do it. Agreed. Will send an updated patch shortly. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com