Search code examples
cmpiblasatlas

Cannot link to BLAS/ATLAS when trying to compile HPCC benchmark


I am trying to compile the HPCC benchmark on a small RHEL desktop. Everything seems fine until linking. My link command is

    mpicc -DAdd_ -DF77_INTEGER=int -DStringSunStyle  -I../../../include \
 -I../../../include/myarch -I/path/to/my/ATLAS_build/include \
-I/usr/include/openmpi-x86_64 -fomit-frame-pointer -O3 -funroll-loops \
-W -Wall -lm -o ../../../../hpcc ../../../lib/bugzilla/libhpl.a \
/path/to/my/ATLAS_build/lib/libcblas.a \
/path/to/my/ATLAS_build/lib/libatlas.a -L/usr/lib64/openmpi/lib

The link fails with several errors, all related to BLAS/ATLAS objects that the linker can't find. A few of them are:

../../../lib/myarch/libhpl.a(HPL_dcopy.o): In function `HPL_dcopy':
HPL_dcopy.c:(.text+0x1e): undefined reference to `dcopy_'
../../../lib/myarch/libhpl.a(HPL_daxpy.o): In function `HPL_daxpy':
HPL_daxpy.c:(.text+0x2f): undefined reference to `daxpy_'
../../../lib/myarch/libhpl.a(HPL_dscal.o): In function `HPL_dscal':
HPL_dscal.c:(.text+0x22): undefined reference to `dscal_'
../../../lib/myarch/libhpl.a(HPL_idamax.o): In function `HPL_idamax':
HPL_idamax.c:(.text+0x1a): undefined reference to `idamax_'
../../../lib/myarch/libhpl.a(HPL_dgemv.o): In function `HPL_dgemv':
HPL_dgemv.c:(.text+0xba): undefined reference to `dgemv_'
HPL_dgemv.c:(.text+0x136): undefined reference to `dgemv_'

Here's what I really don't understand. Take dgemv for instance. libhpl.a does indeed invoke it:

>$ nm libhpl.a | grep dgemv
HPL_dgemv.o:
                 U dgemv_

Now, libcblas.a has a reference to it, but needs the version in ATLAS:

>$ nm libcblas.a | grep dgemv
cblas_dgemv.o:
                 U ATL_dgemv

Finally, does ATLAS have ATL_dgemv?

ATL_dgemv.o:
0000000000000000 T ATL_dgemv

So, yes, it certainly does. So CBLAS has a dgemv that HPCC should (I would think) be able to plug into, but it needs ATL_dgemv. But ATLAS has ATL_dgemv. So why can't the linker find everything it needs for HPCC?

Thanks.


Solution

  • Your logs indicate that libhpl.a needs the dgemv_ symbol that is not provided either by libcblas.a nor libatlas.a (I assume your last command was nm libatlas.a | grep dgemv).

    The trailing underscore in dgemv_ strongly suggests it requires the Fortran BLAS(and not the C BLAS) library, so you can simply replace libcblas.a with libblas.a.

    IIRC, an other option is to tweak the HPL config and direct it to use cblas instead of (Fortran) BLAS.