Re: Popcount optimization using AVX512

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Ants Aasma <ants(dot)aasma(at)cybertec(dot)at>, "Amonson, Paul D" <paul(dot)d(dot)amonson(at)intel(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Rowley <dgrowleyml(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, "Shankaran, Akash" <akash(dot)shankaran(at)intel(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Popcount optimization using AVX512
Date: 2024-04-02 17:34:08
Message-ID: 202404021734.635tuluozzn3@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2024-Apr-02, Nathan Bossart wrote:

> Another idea I had is to turn pg_popcount() into a macro that just uses the
> pg_number_of_ones array when called for few bytes:
>
> static inline uint64
> pg_popcount_inline(const char *buf, int bytes)
> {
> uint64 popcnt = 0;
>
> while (bytes--)
> popcnt += pg_number_of_ones[(unsigned char) *buf++];
>
> return popcnt;
> }
>
> #define pg_popcount(buf, bytes) \
> ((bytes < 64) ? \
> pg_popcount_inline(buf, bytes) : \
> pg_popcount_optimized(buf, bytes))
>
> But again, I'm not sure this is really worth it for the current use-cases.

Eh, that seems simple enough, and then you can forget about that case.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"No hay hombre que no aspire a la plenitud, es decir,
la suma de experiencias de que un hombre es capaz"

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-04-02 17:43:48 Re: Popcount optimization using AVX512
Previous Message Melanie Plageman 2024-04-02 17:24:27 Re: Combine Prune and Freeze records emitted by vacuum