scivision / mumps

MUMPS via CMake
http://mumps-solver.org
MIT License
115 stars 46 forks source link

Why not use CMake's natural way of finding BLAS/LAPACK #11

Closed FunMiles closed 3 years ago

FunMiles commented 3 years ago

I am on Mac OS and compiled MUMPS with CMake no problem. However, it does recompile its own version of BLAS instead of using MKL as I have it installed. Looking around, by simply changing:

#include(cmake/lapack.cmake)
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)

And removing the cmake/module/FindLAPACK.cmake file, I can get it to find MKL (I have the environment variable MKLROOT defined properly). Then I can switch the version of MKL by using -DBLA_VENDOR=Intel10_64ilp_seq for example. Pick your preferred version for the integer size you want.

Is there a reason to not do that? If so, documenting how to make use of MKL would be helpful.

scivision commented 3 years ago

For me it just works as-is to find MKL, whether with Intel compilers, or GCC using MKL. If you try from a fresh build directory:

cmake -B build --debug-find

it will give a lot of text, including where CMake is searching for blas and lapack.

Historically I had too many problems with FindLAPACK and so I made my own that I use across projects. If it can't be figured out I could make an option to fall back to factory FindLAPACK

scivision commented 3 years ago

What is your CMake configure command? are you trying to use 64-bit integers? Right now, MUMPS + GCC without MKL works with intsize64=yes.

However, at this time GCC + MKL or Intel compiler with MKL does not work (fails at runtime with segfault etc.) with intsize64=yes

FunMiles commented 3 years ago

What version of MKL do you have? The trouble with MKL is that they have constantly changed the location of things, so keeping up with it is not easy. The kitware group has been quite responsive in fixing it. So taking advantage of the standard FindBLAS avoids having to revisit MKL all the time.

As for my experience, with the changes I showed in the first post, I am able to run all the tests with MKL in 64 bits. My call to cmake is: cmake -Dopenmp=true -Dparallel=false -DCMAKE_INSTALL_PREFIX=~/local/mumps -Dintsize64=true -"Darith=s;c;d;z" -DBLA_VENDOR=Intel10_64ilp_seq ../mumps As you can tell I am not yet trying with MPI but all the tests pass without any crash. Note the fact that when intsize64 is on, I ask for -DBLA_VENDOR=Intel10_64ilp_seq while if it is off, you should then use -DBLA_VENDOR=Intel10_64lp_seq.

All the tests pass with the compiler gcc-11 gfortran-11 in 64 bit. All the tests also pass with compiler icc and ifort in 64 bit. I am on Mac OS so those are the Intel classic compilers.

Maybe you can give a try to the approach from the first post?

FunMiles commented 3 years ago

PS: I installed a newer version of MKL to be able to install the Intel Fortran compiler to do the test above and with that, your cmake works. But I still think it should have worked even with the previous version (I cannot move back to the previous version anymore). Thus I would still advocate for using the cmake built-in BLAS find. For the Lapack I have much less experience, but with MKL, the built in one also finds it within MKL.