Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Cmake, Blas, lapack

Mattew
Novice
492 Views
Filling the required questions about the libraries I want to use and my OS from the intel site:
> https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html

It gives me this link line:
${MKLROOT}/lib/libmkl_blas95_ilp64.a ${MKLROOT}/lib/libmkl_lapack95_ilp64.a ${MKLROOT}/lib/libmkl_scalapack_ilp64.a -Wl,--start-group ${MKLROOT}/lib/libmkl_intel_ilp64.a ${MKLROOT}/lib/libmkl_sequential.a ${MKLROOT}/lib/libmkl_core.a ${MKLROOT}/lib/libmkl_blacs_intelmpi_ilp64.a -Wl,--end-group -lpthread -lm -ldl

and this compiler options:
-I${MKLROOT}/include/mkl/intel64/ilp64 -i8 -I"${MKLROOT}/include"

I also need mkl_spblas.f90, so I compiled it in a .o files:
ifort -fpp -I${MKLROOT}/include -w ${MKLROOT}/include/mkl_spblas.f90 -c -o mypath/mkl_spblas.o -Ofast -i8 -static


I wrote this:

set(Cmake_Fortran_FLAGS "-Ofast -i8")

set(MKL_ARCH intel64)
set(MKL_THREADING sequential)
set(MKL_INTERFACE ilp64)
find_package(MKL CONFIG REQUIRED PATHS ${MKLROOT})

#Home made Fortran module
add_library(Quantum_Ising_1D STATIC)
target_sources(Quantum_Ising_1D PUBLIC
/home/matteobacci/Desktop/Programmi/MODULO_02/executable_and_libraries/src_homemade/Quantum_Ising_1D.f90
)
target_link_libraries(Quantum_Ising_1D PUBLIC #MKL::MKL
mypath/arpack-ng/build/libarpackILP64.a
mypath/mkl_spblas.o
${MKLROOT}/lib/libmkl_blas95_ilp64.a
${MKLROOT}/lib/libmkl_lapack95_ilp64.a
$<LINK_GROUP:RESCAN, ${MKLROOT}/lib/libmkl_intel_ilp64.a, ${MKLROOT}/lib/libmkl_sequential.a, ${MKLROOT}/lib/libmkl_core.a, ${MKLROOT}/lib/libmkl_blacs_intelmpi_ilp64.a >
)
target_include_directories(Quantum_Ising_1D PUBLIC
${MKLROOT}/include/mkl/intel64/ilp64 BEFORE
${MKLROOT}/include AFTER
)
set_target_properties(Quantum_Ising_1D PROPERTIES
COMPILE_FLAGS "-fpp -static -lpthread -lm -ldl"
)

I followed the official cmake documentation for the circular dependence:
> https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:LINK_GROUP
to find out someone achieved the desired result in a different way:
https://stackoverflow.com/questions/56200963/how-to-setup-mkl-on-linux-with-cmake?noredirect=1&lq=1

They both work.

This error always pops up, as if I'm configuring mkl_spblas wrong.
error #7002: Error in opening the compiled module file. Check INCLUDE paths. [MKL_SPBLAS]
use mkl_spblas
------------^

Do you know how to fix it?

Thanks
Labels (2)
0 Kudos
2 Replies
Barbara_P_Intel
Moderator
450 Views

Since this is an MKL question, I will move this to the MKL Community Forum.

Mattew
Novice
357 Views
Solved.
For those who come here it was simply the .mod file:
I needed to put in the build directory (output directory of the file I'm building) rather than in the same one of the .so/.o file
Reply