Skip to content

Commit c44eeb3

Browse files
authored
Build: manually link MKL scalapack in absence (#4663)
* Build: manually link MKL scalapack in absence * add message output * set message type for finding elpa * Add scalapack setup for standard MKL config
1 parent 5a5ff7f commit c44eeb3

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,11 @@ if(DEFINED ENV{MKLROOT} AND NOT DEFINED MKLROOT)
396396
endif()
397397
if(MKLROOT)
398398
set(MKL_INTERFACE lp64)
399+
set(ENABLE_SCALAPACK ON)
399400
find_package(MKL REQUIRED)
400401
add_definitions(-D__MKL)
401402
include_directories(${MKL_INCLUDE} ${MKL_INCLUDE}/fftw)
402-
list(APPEND math_libs MKL::MKL)
403-
if(TARGET MKL::MKL_SCALAPACK)
404-
list(APPEND math_libs MKL::MKL_SCALAPACK)
405-
endif()
403+
list(APPEND math_libs MKL::MKL MKL::MKL_SCALAPACK)
406404
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
407405
list(APPEND math_libs ifcore)
408406
endif()

cmake/FindELPA.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ else()
4545
endif()
4646

4747
# Incompatible with ELPA earlier than 2021.11.001
48-
# Before ELPA 2021.11.001, its pkg-config file
48+
# Before ELPA 2021.11.001, its pkg-config file
4949
# is named like "elpa-2021.05.002.pc".
5050
if(NOT ELPA_INCLUDE_DIRS AND PKG_CONFIG_FOUND)
5151
if(DEFINED ELPA_DIR)
@@ -57,7 +57,7 @@ if(NOT ELPA_INCLUDE_DIRS AND PKG_CONFIG_FOUND)
5757
pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa)
5858
endif()
5959
elseif(NOT PKG_CONFIG_FOUND)
60-
message(
60+
message(STATUS
6161
"ELPA : We need pkg-config to get all information about the elpa library")
6262
endif()
6363

cmake/FindMKL.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,10 @@ endif() # MKL::MKL
8686
if(TARGET MKL::MKL)
8787
add_library(IntelMKL::MKL ALIAS MKL::MKL)
8888
endif()
89+
90+
# In oneAPI 2022, MKL_SCALAPACK might not be linked properly
91+
if(NOT TARGET MKL::MKL_SCALAPACK)
92+
find_library(MKL_SCALAPACK NAMES mkl_scalapack_lp64 HINTS ${MKLROOT}/lib ${MKLROOT}/lib/intel64)
93+
message(STATUS "Found MKL_SCALAPACK: ${MKL_SCALAPACK}")
94+
add_library(MKL::MKL_SCALAPACK OBJECT IMPORTED MKL_SCALAPACK)
95+
endif()

source/module_base/test_parallel/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ add_test(NAME base_parallel_reduce_test
3737
if(ENABLE_LCAO)
3838
# figure out the lib that provides BLACS
3939
if(MKLROOT)
40-
list(APPEND BLACS_LIB MKL::MKL)
41-
if(TARGET MKL::MKL_SCALAPACK)
42-
list(APPEND BLACS_LIB MKL::MKL_SCALAPACK)
43-
endif()
40+
list(APPEND BLACS_LIB MKL::MKL MKL::MKL_SCALAPACK)
4441
else()
4542
set(BLACS_LIB ScaLAPACK::ScaLAPACK)
4643
endif()

0 commit comments

Comments
 (0)