Skip to content

gemmt fills output matrix in wrong corner for upper row-major #4905

@david-cortes

Description

@david-cortes

In function cblas_?gemmt, if I pass CblasRowMajor + CblasUplo to MKL's function with that name, the output ends up being filled in the upper corner (in row-major order), but in OpenBLAS's version of cblas_?gemmt, the output ends up being filled in the lower corner instead.

Example code:

#include <iostream>
#include "cblas.h"

extern "C" void cblas_dgemmt(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint K,
         OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *B, OPENBLAS_CONST blasint ldb, OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc);


int main()
{
    const double A[] = {
        2., 3.,
        0., 4.
    };
    double B[4] = {0.};

    cblas_dgemmt(
        CblasRowMajor, CblasUpper, CblasTrans, CblasNoTrans,
        2, 2,
        1., A, 2,
        A, 2,
        0., B, 2
    );

    std::cout << "B:" << std::endl;
    std::cout << "[ " << B[0] << ", " << B[1] << "]" << std::endl;
    std::cout << "[ " << B[2] << ", " << B[3] << "]" << std::endl;

    return 0;
}

If I run the example with OpenBLAS, the output is:

B:
[ 4, 0]
[ 6, 25]

Whereas with MKL, the output is:

B:
[ 4, 6]
[ 0, 25]

Version: OpenBLAS 0.3.28, OpenMP variant, installed from source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions