| From: | "Greg Burd" <greg(at)burd(dot)me> |
|---|---|
| To: | "John Naylor" <johncnaylorls(at)gmail(dot)com>, "Andres Freund" <andres(at)anarazel(dot)de> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Add RISC-V Zbb popcount optimization |
| Date: | 2026-03-22 17:43:43 |
| Message-ID: | ec81011b-c502-4702-b041-e4bdd2aa346f@app.fastmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sat, Mar 21, 2026, at 10:14 PM, John Naylor wrote:
> On Sat, Mar 21, 2026 at 11:56 PM Greg Burd <greg(at)burd(dot)me> wrote:
>> Attached is a small patch that enables hardware popcount on RISC-V when available and also sets the arch flag to 'rv64gc_zbb' flag when appropriate.
>
> I have to ask what the point is -- isn't that like putting a 4-inch
> exhaust tip on a go-kart?
Hey John,
The point is to go fast, right? And to look cool (with awesome 4-inch exhaust tips) if possible! ;-P
gburd(at)rv:~/ws/postgres$ gcc -O2 -o popcnt-wo-zbb riscv-popcnt.c
gburd(at)rv:~/ws/postgres$ gcc -O2 -march=rv64gc_zbb -o popcnt-zbb riscv-popcnt.c
gburd(at)rv:~/ws/postgres$ ./popcnt-wo-zbb && ./popcnt-zbb
sw popcount: 0.196 sec ( 510.08 MB/s)
hw popcount: 0.293 sec ( 341.48 MB/s)
diff: 0.67x
match: 406261900 bits counted
sw popcount: 0.182 sec ( 548.86 MB/s)
hw popcount: 0.044 sec ( 2279.89 MB/s)
diff: 4.15x
match: 406261900 bits counted
But my first email/patch was incomplete/rushed, I should have followed the pattern used for similar ARM-specific logic. v2 attached along with a test program.
> --
> John Naylor
> Amazon Web Services
best.
-greg
| Attachment | Content-Type | Size |
|---|---|---|
| riscv-popcnt.c | text/x-csrc | 2.2 KB |
| v2-0001-Add-RISC-V-Zbb-popcount-optimization.patch | text/x-patch | 10.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2026-03-22 18:01:50 | Re: Add RISC-V Zbb popcount optimization |
| Previous Message | Tom Lane | 2026-03-22 17:29:44 | Re: pg_waldump: support decoding of WAL inside tarfile |