superlu
superlu copied to clipboard
Building on M1 mac (osx 12.2.1)
Hi
I am trying to build SuperLu from source on my m1 macbook. I copied over the mac make.inc but I am getting the following errors:
gcc -O2 -DAdd_ -c ssp_blas2.c
ssp_blas2.c:256:7: error: implicit declaration of function 'strsv_' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
strsv_("L", "T", "U", &nsupc, &Lval[luptr], &nsupr,
^
ssp_blas2.c:291:7: error: implicit declaration of function 'strsv_' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
strsv_("U", "T", "N", &nsupc, &Lval[luptr], &nsupr,
^
I changed
BLASLIB = /opt/homebrew/opt/openblas/lib/libopenblas.a
to point to the openblas installation on my mac, but to no avail
I don't know what goes wrong. If you see file SRC/ssp_blas2.c, it includes slu_sdefs.h, which contains the prototype definition: extern int strsv_(char*, char*, char*, int*, float*, int*, float*, int*); But the compiler still complains that strsv_ is not declared.
Can you try to use 'cmake' to install it? See instruction on this page: https://github.com/xiaoyeli/superlu
I can confirm that the cmake instructions work on an M1 mac:
mkdir build ; cd build
cmake -Denable_internal_blaslib=YES ..
make
Then run one of the tests to confirm:
superlu/build % ./Testing/d_test
dgstrf info 1
dgstrf info 1
All tests for DGE driver passed the threshold ( 1154 tests run)
Note that the Readme says TESTING
but the actual directory name is Testing
.
Ah, I see @maczikasz was specifically referring to using brew's OpenBLAS on M1.
That still works, though the Readme instructions are incomplete. One must manually append the link path so the linker can find libopenblas.a
:
mkdir build ; cd build
cmake -DTPL_BLAS_LIBRARIES=openblas ..
LIBRARY_PATH="/opt/homebrew/opt/openblas/lib/" make
@xiaoyeli have you considered CMake's FindBLAS
function that does all the fun stuff automatically? https://cmake.org/cmake/help/latest/module/FindBLAS.html
CMakeLists.txt does use find_package(BLAS). What more needs to be done? If you have suggestions, please set up a PR.