Skip to content

Commit

Permalink
Build: manually link MKL scalapack in absence (#4663)
Browse files Browse the repository at this point in the history
* Build: manually link MKL scalapack in absence

* add message output

* set message type for finding elpa

* Add scalapack setup for standard MKL config
  • Loading branch information
caic99 authored Jul 12, 2024
1 parent 5a5ff7f commit c44eeb3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,11 @@ if(DEFINED ENV{MKLROOT} AND NOT DEFINED MKLROOT)
endif()
if(MKLROOT)
set(MKL_INTERFACE lp64)
set(ENABLE_SCALAPACK ON)
find_package(MKL REQUIRED)
add_definitions(-D__MKL)
include_directories(${MKL_INCLUDE} ${MKL_INCLUDE}/fftw)
list(APPEND math_libs MKL::MKL)
if(TARGET MKL::MKL_SCALAPACK)
list(APPEND math_libs MKL::MKL_SCALAPACK)
endif()
list(APPEND math_libs MKL::MKL MKL::MKL_SCALAPACK)
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
list(APPEND math_libs ifcore)
endif()
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindELPA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ else()
endif()

# Incompatible with ELPA earlier than 2021.11.001
# Before ELPA 2021.11.001, its pkg-config file
# Before ELPA 2021.11.001, its pkg-config file
# is named like "elpa-2021.05.002.pc".
if(NOT ELPA_INCLUDE_DIRS AND PKG_CONFIG_FOUND)
if(DEFINED ELPA_DIR)
Expand All @@ -57,7 +57,7 @@ if(NOT ELPA_INCLUDE_DIRS AND PKG_CONFIG_FOUND)
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa)
endif()
elseif(NOT PKG_CONFIG_FOUND)
message(
message(STATUS
"ELPA : We need pkg-config to get all information about the elpa library")
endif()

Expand Down
7 changes: 7 additions & 0 deletions cmake/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,10 @@ endif() # MKL::MKL
if(TARGET MKL::MKL)
add_library(IntelMKL::MKL ALIAS MKL::MKL)
endif()

# In oneAPI 2022, MKL_SCALAPACK might not be linked properly
if(NOT TARGET MKL::MKL_SCALAPACK)
find_library(MKL_SCALAPACK NAMES mkl_scalapack_lp64 HINTS ${MKLROOT}/lib ${MKLROOT}/lib/intel64)
message(STATUS "Found MKL_SCALAPACK: ${MKL_SCALAPACK}")
add_library(MKL::MKL_SCALAPACK OBJECT IMPORTED MKL_SCALAPACK)
endif()
5 changes: 1 addition & 4 deletions source/module_base/test_parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ add_test(NAME base_parallel_reduce_test
if(ENABLE_LCAO)
# figure out the lib that provides BLACS
if(MKLROOT)
list(APPEND BLACS_LIB MKL::MKL)
if(TARGET MKL::MKL_SCALAPACK)
list(APPEND BLACS_LIB MKL::MKL_SCALAPACK)
endif()
list(APPEND BLACS_LIB MKL::MKL MKL::MKL_SCALAPACK)
else()
set(BLACS_LIB ScaLAPACK::ScaLAPACK)
endif()
Expand Down

0 comments on commit c44eeb3

Please sign in to comment.