OpenBLAS icon indicating copy to clipboard operation
OpenBLAS copied to clipboard

MKL_GETRF equivalnet in OpenBLAS

Open nnaron opened this issue 4 years ago • 10 comments

Hi,

I was converting my code from MKL to OpenBlAS, but I am not able to find an equvalent for dgetrf with partal pivoting and dgetrf witout pivoting.

Just I have found "getrf_parallel.c" in LAPACK directory of OpenBLAS, but it is not clear for me how to call it or what is the warpper.

Could you please give me some hint or an example for calling getrf in OpenBLAS?

nnaron avatar Aug 19 '21 17:08 nnaron

getrf_parallel.c is just an internal file, part of the optimized implementation of getrf in OpenBLAS - you would still call it as DGETRF or LAPACKE_DGETRF from your code just as with the original "netlib" reference implementation (and I believe it still does use partial pivoting). dgetrf without pivoting a.k.a MKL_DGETRFNP appears to be a MKL extension and is not implemented in OpenBLAS (nor Reference-LAPACK to my knowledge).

martin-frbg avatar Aug 19 '21 17:08 martin-frbg

Thanks Martin,

I have installed OpenBLAS in my home dircetory (because of permission issues).

I am caling DGETRF like this:

LAPACKE_DGETRF(&m, &n, A, &lda, ipiv, &info);

or

DGETRF(&m, &n, A, &lda, ipiv, &info);

And I am compiling like this:

cc -L ~/OpenBLAS_bin/lib -I ~/OpenBLAS_bin/include -m64 dgetrf_pp.c -lopenblas -lpthread -lgfortran -liomp5 -lpthread -lm -o dgetrf_pp

The error is:

warning: implicit declaration of function 'LAPACKE_DGETRF' [-Wimplicit-function-declaration] LAPACKE_DGETRF(&m, &n, A, &lda, ipiv, &info); ^~~~~~~~~~~~~~

I have included <cblas.h> in my code.

I have this line also in my bashrc file.

export LD_LIBRARY_PATH=$OPENBLASDIR/lib:$LD_LIBRARY_PATH

nnaron avatar Aug 19 '21 18:08 nnaron

Do you #include <lapacke.h> as well ?

martin-frbg avatar Aug 19 '21 18:08 martin-frbg

Do you #include <lapacke.h> as well ?

After adding lapacke.h:

warning: implicit declaration of function 'LAPACKE_DGETRF'; did you mean 'LAPACKE_zgemqr'? [-Wimplicit-function-declaration] LAPACKE_DGETRF(&m, &n, A, &lda, ipiv, &info); ^~~~~~~~~~~~~~ LAPACKE_zgemqr

nnaron avatar Aug 19 '21 22:08 nnaron

Sorry, the correct capitalization should be LAPACKE_dgetrf , not LAPACKE_DGETRF

martin-frbg avatar Aug 20 '21 00:08 martin-frbg

Thanks. Now it is working. I have question about modification of LAPACKE_dgetrf code. Shoud I work on "getrf_parallel.c" to modify it? If so why this code is so different from the sturcture of LAPACK? I want to remove pivoting part to provide Non Pivoting version of LAPACKE_dgetrf.

nnaron avatar Aug 21 '21 13:08 nnaron

Perhaps try modifying getrf_single first, which should be closer to the structure of the Fortran getrf from Reference-LAPACK as it does not have the added complexity of the blocked multithreaded algorithm (which by the way is retained from the original GotoBLAS2 by Kazushige Goto, written 10+ years ago).

martin-frbg avatar Aug 21 '21 18:08 martin-frbg

Perhaps try modifying getrf_single first, which should be closer to the structure of the Fortran getrf from Reference-LAPACK as it does not have the added complexity of the blocked multithreaded algorithm (which by the way is retained from the original GotoBLAS2 by Kazushige Goto, written 10+ years ago).

I am reading this code (getrf_single.c) in OpenBLAS/lapack/getrf directory, but I am not understranding how the pivot element is found (searching for pivot element). Just I am seeing LASWP_PLUS and LASWP_ONCOPY which related to pivoting and I think this is not waht I want. In parallel version also just I am seeing a same thing.

nnaron avatar Aug 25 '21 17:08 nnaron

I must admit that it is not entirely clear to me either, where "ipiv" is calculated, and sadly there is no documentation of Goto's coding (unless he described it in a publication). Most likely seems to me that the recursive call (where it invokes "CNAME" from inside CNAME - where "CNAME" will be supplied as sgetrf, dgetrf etc. as appropriate by the Makefile) with a small subrange of elements meets the criteria for being forwarded to GETF2: https://github.com/xianyi/OpenBLAS/blob/0f0a0be95dc25d220cd59162dfacc0e930cf5428/lapack/getrf/getrf_single.c#L107 and https://github.com/xianyi/OpenBLAS/blob/0f0a0be95dc25d220cd59162dfacc0e930cf5428/lapack/getrf/getrf_single.c#L86-L87

martin-frbg avatar Aug 25 '21 20:08 martin-frbg

I have a similar need to use non-pivoting getrf using openblas. Is there any update on this?

monil01 avatar Mar 29 '23 16:03 monil01