https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120598

            Bug ID: 120598
           Summary: Compiler is unable to vectorise scalar code
           Product: gcc
           Version: 15.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Manjul.Mohan at ibm dot com
  Target Milestone: ---

Created attachment 61605
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61605&action=edit
As we can see, the scalar function is not getting vectorised in case of MariaDB

In MariaDB
There is a function dot_product, which is not getting vectorised, even with the
latest gcc (15.1)
The function signature is as follows:
float dot_product (const int16_t *v1, const int16_t *v2, size_t len);
Currently we are manually optimised code in mariadb by the use of vector
intrinsics (https://github.com/MariaDB/server/pull/3850/files)

We’ve observed that while functions in the PGVector library benefit from both
loop unrolling and auto-vectorization (even with earlier versions of GCC, like
13.3 and 11.5), the same does not hold true for the dot_product function in the
MariaDB library — even when compiled with GCC 15.1

One potential reason could be that, unlike PGVector where both the input
parameters and the return value from the function is of type float:
VECTOR_TARGET_CLONES static float VectorInnerProduct(int dim, float *ax, float
*bx);

Whereas in case of MariaDB implementation requires promotion from int16_t to
float:
float dot_product (const int16_t *v1, const int16_t *v2, size_t len);
This implicit type promotion may be preventing effective vectorization.

Reply via email to