pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: Andreas-Krebbel (@Andreas-Krebbel) <noreply+Andreas-Krebbel@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #1007: RFC: Enable multiply and add for inner_product
Date: Fri, 31 Jul 2026 11:40:11 +0000
Message-ID: <gh-pgvector-pgvector-1007@github.com> (raw)

On my Fedora (and perhaps other distros) the default compile options pulled in from /usr/lib64/pgsql/pgxs/src/Makefile.global enforce strict standard compliance (`-std=c17`). This prevents the vector multiply and add instruction from being used for the `inner_product` routine:

```
.L324:
        vmovups 8(%rsi,%rax), %zmm0
        vmulps  8(%rbx,%rax), %zmm0, %zmm0
        addq    $64, %rax
        vaddps  %zmm0, %zmm1, %zmm1
        cmpq    %rax, %rcx
        jne     .L324
```

With `-std=c17` GCC defaults to `-ffp-contract=off `. Overriding it with `-ffp-contract=fast` brings me back to:
```
.L328:
        vmovups 8(%rax), %zmm4
        addq    $256, %rax
        vmovups -184(%rax), %zmm5
        addq    $256, %rdx
        vmovups -120(%rax), %zmm6
        vmovups -56(%rax), %zmm7
        vfmadd231ps     -128(%rdx), %zmm6, %zmm1
        vfmadd231ps     -64(%rdx), %zmm7, %zmm3
        vfmadd231ps     -256(%rdx), %zmm4, %zmm0
        vfmadd231ps     -192(%rdx), %zmm5, %zmm2
        cmpq    %rsi, %rax
        jne     .L328
```
Would it make sense to add `-ffp-contract=fast` to `PG_CFLAGS`? 

view thread (2+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-1007@github.com>
Permalink:  ../gh-pgvector-pgvector-1007@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox