Install and use Intel MKL Scalapack library

less than 1 minute read

Intel MKL has Scalapack, which is installed when you select “Cluster Support” for C and/or Fortran from the Intel Compiler/MKL installer. The files installed under $MKLROOT=~/intel/mkl are

include/mkl_scalapack.h
lib/intel64_lin/libmkl_scalapack_ilp64.a
lib/intel64_lin/libmkl_scalapack_ilp64.so
lib/intel64_lin/libmkl_scalapack_lp64.a
lib/intel64_lin/libmkl_scalapack_lp64.so

You can also use non-MKL ScalaPack by:

apt install libscalapack-mpi-dev

Cmake Scalapack

CMakeLists.txt will automatically select MKL or non-MKL Scalapack by:

cmake_minimum_required(VERSION 3.0)
project(MyProject Fortran C)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")

find_package(MKL)
set(MKLROOT $ENV{MKLROOT})
include_directories(${MKL_INCLUDE_DIRS})   # this will include $MKLROOT/include

find_package(Threads REQUIRED)

if(MKL_FOUND)
  set(SCALAPACK_LIBRARIES mkl_scalapack_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core mkl_blacs_intelmpi_lp64 iomp5 ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} m)
else()
  find_package(SCALAPACK REQUIRED) 
endif()

add_executable(myexe myprogram.f90)
target_link_libraries(myexe PRIVATE ${SCALAPACK_LIBARIES})

FindSCALAPACK.cmake

You will need the FindSCALAPACK.cmake file, available at my GitHub repo under cmake/Modules

Leave a Comment