AMICI-dev / AMICI

Advanced Multilanguage Interface to CVODES and IDAS
https://amici.readthedocs.io/
Other
108 stars 30 forks source link

Compilation fails with Intel OneApi MKL 2024.1 #2441

Closed kaiserls closed 4 months ago

kaiserls commented 4 months ago

What did you expect to happen? I expected the build script to find the includes and libraries to link, including the linking commands.

What has happened instead?

/usr/bin/ld: /home/lars/Git/AMICI/build/libamici.a(cblas.cpp.o): in function `amici::amici_dgemm(amici::BLASLayout, amici::BLASTranspose, amici::BLASTranspose, int, int, int, double, double const*, int, double const*, int, double, double*, int)':
/home/lars/Git/AMICI/src/cblas.cpp:27:(.text+0x5): undefined reference to `cblas_dgemm'
...

To Reproduce Steps to reproduce the behavior

sudo apt install intel-oneapi-mkl-devel
source /opt/intel/oneapi/setvars.sh intel64`
./scripts/buildSuiteSparse.sh
./scripts/buildSundials.sh
./scripts/buildAmici.sh

AMICI version and system environment

MKLROOT=/opt/intel/oneapi/mkl/2024.1
LIBRARY_PATH=/opt/intel/oneapi/tbb/2021.12/env/../lib/intel64/gcc4.8:/opt/intel/oneapi/mkl/2024.1/lib/:/opt/intel/oneapi/compiler/2024.1/lib
LD_LIBRARY_PATH=/opt/intel/oneapi/tbb/2021.12/env/../lib/intel64/gcc4.8:/opt/intel/oneapi/mkl/2024.1/lib:/opt/intel/oneapi/compiler/2024.1/opt/compiler/lib:/opt/intel/oneapi/compiler/2024.1/lib:/usr/local/cuda-12.4/lib64
CPATH=/opt/intel/oneapi/tbb/2021.12/env/../include:/opt/intel/oneapi/mkl/2024.1/include:/opt/intel/oneapi/mkl/2024.1/include:/opt/intel/oneapi/tbb/2021.12/env/../include:/opt/intel/oneapi/mkl/2024.1/include:

How to fix Do you know how to resolve the problem?

find_package(MKL CONFIG REQUIRED PATHS $ENV{MKLROOT})
  target_link_libraries(BLAS INTERFACE
    mkl_scalapack_ilp64
    mkl_cdft_core
    mkl_intel_ilp64
    mkl_intel_thread
    mkl_core
    mkl_blacs_intelmpi_ilp64
    iomp5
  ) 

Can you submit a pull request? I don't know enough about the amici library and the reasons for the design of the AmiciFindBLAS.cmake file to open a pull request. Maybe after some feedback, I could open one. I would try to rely more on find(BLAS ...) from CMake or find(MKL ...) from Intel. I would test it using docker containers.

dweindl commented 4 months ago

Thanks for reporting @kaiserls .

2443 should fix that.

Does pip3 install -e git+https://github.com/dweindl/amici.git@fix_mkl#egg=amici\&subdirectory=python/sdist work for you (after source /opt/intel/oneapi/setvars.sh)?

`

kaiserls commented 4 months ago

Yeah, that fixed it for me. Thank you for the fast help!