OpenMathLib / OpenMathLib/OpenBLAS

AVX2: dgemm on HASWELL leads to invalid results (low accuracy)

Open
#4,747 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
7.6k
Forks
1.7k
Avg merge
1d 3h
Merged PRs (30d)
42

Description

After upgrading Scilab OpenBLAS build, we detected a poor precision result impacting dgemm when using AVX2 kernels.

With OpenBLAS 0.3.27:

$ OPENBLAS_CORETYPE=NEHALEM scilab/test_dgemm
[1, 0.666667] * [-6 0 ; 9 0]
        0       0

$ OPENBLAS_CORETYPE=HASWELL scilab/test_dgemm
[1, 0.666667] * [-6 0 ; 9 0]
        -3.33067E-16    0

With refBLAS 3.12.0 :

$ scilab/test_dgemm
[1, 0.666667] * [-6 0 ; 9 0]
        0       0
test code

#include <math.h>
#include <stdio.h>

extern void dgemm_(char *transa, char *transb, int *m, int *n, int *k, double *alpha, double *a, int *lda, double *b, int *ldb, double *beta, double *c, int *ldc);

int main()
{
    int ONE = 1;
    int TWO = 2;
    double dZERO = 0;
    double dONE = 1;

    double A_tab[] = {1., 2. / 3.};
    double* A = A_tab;
    double B_tab[] = {-6., 9., 0., 0.};
    double* B = B_tab;
    double C_tab[] = {NAN, NAN};
    double* C = C_tab;

    dgemm_("n", "n", &ONE, &TWO, &TWO, &dONE, A, &ONE, B, &TWO, &dZERO, C, &ONE);

    printf("[%lG, %lG] * [%lG %lG ; %lG %lG]\n", A[0], A[1], B[0], B[2], B[1], B[3]);
    printf("\t%lG\t%lG\n", C[0], C[1]);

    return 0;
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling and running the provided C reproducer through the dgemm_ entry point with OPENBLAS_CORETYPE set to HASWELL, then compare it with NEHALEM and refBLAS. Trace the AVX2 dgemm path implicated by the HASWELL result; done means the reproducer returns the expected zero result without reducing correctness elsewhere.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.