lapackblasopenblasatlaslapacke

What is the calling convention difference between LAPACKE_zgetrf() and zgetrf_() in OpenBLAS?


I'm trying to support zgetrf() in both Ubuntu 18.04 and CentOS 7 by using dlopen() against the .so and opening the function in each version, but the calling convention is different. In CentOS it works using LAPACKE_zgetrf() but in Ubuntu 18.04 they do not export as LAPACKE_zgetrf, the only option is zgetrf_:

# objdump -T /usr/lib/i386-linux-gnu/libopenblas.so.0 |grep zgetrf
[...]
000c3a60 g    DF .text  00000191  Base        zgetrf_

I can make an LAPACKE_zgetrf() call as follows, this works:

LAPACKE_zgetrf(order, m, n, a, ndim, (int32_t*)ip);

How do I convert it to call zgetrf_(...) ?


Solution

  • The LAPACKE_ functions will call the linked openblas.so.0 library, so no need to link to openblas.so.0 directly.

    For ATLAS, you can call the clapack_ functions exported by liblapack_atlas.so.3 which are nearly the same format (same order, same type) except that the transform argument is different. For example, in zgetrs() in ATLAS might take the standard BLAS CblasTrans enum for the transform argument. However, in OpenBLAS (and MKL) this argument should be converted from ATLAS to OpenBLAS as follows:

    openblas_trans = ((trans) == CblasConjTrans ? 'C' : ((trans) == CblasTrans ? 'T' : 'N'))