Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMake] Intel OneAPI MKL #964

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,13 @@ if (SIRIUS_USE_OPENMP)
find_package(OpenMP REQUIRED)
endif()

set(LINALG_LIB "")
set(SIRIUS_LINALG_LIB "")
if(SIRIUS_USE_MKL)
set(SIRIUS_USE_MKL_SHARED_LIBS On) # link against shared MKL libraries
find_package(MKL REQUIRED)
set(SIRIUS_LINALG_LIB "sirius::mkl")
set(MKL_INTERFACE "lp64" CACHE STRING "")
set(MKL_THREADING "sequential" CACHE STRING "")
set(MKL_MPI "mpich" CACHE STRING "")
find_package(MKL CONFIG REQUIRED)
set(SIRIUS_LINALG_LIB "MKL::MKL")
elseif(SIRIUS_USE_CRAY_LIBSCI)
find_package(CRAY_LIBSCI REQUIRED)
set(SIRIUS_LINALG_LIB "${SIRIUS_CRAY_LIBSCI_LIBRARIES}")
Expand Down
177 changes: 0 additions & 177 deletions cmake/modules/FindMKL.cmake

This file was deleted.

6 changes: 4 additions & 2 deletions cmake/siriusConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ if(NOT TARGET sirius::sirius)
endif()

if(@SIRIUS_USE_MKL@)
set(SIRIUS_USE_MKL_SHARED_LIBS On) # link against shared MKL libraries
find_package(MKL ${mode})
set(MKL_INTERFACE "@MKL_INTERFACE@")
set(MKL_THREADING "@MKL_THREADING@")
set(MKL_MPI "@MKL_MPI@")
find_dependency(MKL CONFIG)
elseif(@SIRIUS_USE_CRAY_LIBSCI@)
find_package(CRAY_LIBSCI ${mode})
else()
Expand Down
31 changes: 30 additions & 1 deletion spack/packages/sirius/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ class Sirius(CMakePackage, CudaPackage, ROCmPackage):
depends_on("amdblis threads=openmp", when="+openmp ^amdblis")
depends_on("blis threads=openmp", when="+openmp ^blis")
depends_on("intel-mkl threads=openmp", when="+openmp ^intel-mkl")
depends_on("intel-oneapi-mkl threads=openmp", when="+openmp ^intel-oneapi-mkl")

conflicts("intel-mkl", when="@develop") # TODO: Change to @7.5.3
# MKLConfig.cmake introduced in 2021.3
conflicts("intel-oneapi-mkl@:2021.2", when="^intel-oneapi-mkl")

depends_on("wannier90", when="@7.5.0: +wannier90")
depends_on("wannier90+shared", when="@7.5.0: +wannier90+shared")
Expand Down Expand Up @@ -250,9 +255,33 @@ def cmake_args(self):
if "^cray-libsci" in spec:
args.append(self.define(cm_label + "USE_CRAY_LIBSCI", "ON"))

if spec["blas"].name in ["intel-mkl", "intel-parallel-studio", "intel-oneapi-mkl"]:
if spec["blas"].name in INTEL_MATH_LIBRARIES:
args.append(self.define(cm_label + "USE_MKL", "ON"))

if spec.satisfies("@develop"): # TODO: Change to @7.5.3:
mkl_mapper = {
"threading": {
"none": "sequential",
"openmp": "gnu_thread",
"tbb": "tbb_thread",
},
"mpi": {"intel-mpi": "intelmpi", "mpich": "mpich", "openmpi": "openmpi"},
}

mkl_threads = mkl_mapper["threading"][spec["intel-oneapi-mkl"].variants["threads"].value]

mpi_provider = spec["mpi"].name
if mpi_provider in ["mpich", "cray-mpich", "mvapich", "mvapich2"]:
mkl_mpi = mkl_mapper["mpi"]["mpich"]
else:
mkl_mpi = mkl_mapper["mpi"][mpi_provider]

args.extend([
self.define("MKL_INTERFACE", "lp64"),
self.define("MKL_THREADING", mkl_threads),
self.define("MKL_MPI", mkl_mpi)
])

if "+elpa" in spec:
elpa_incdir = os.path.join(spec["elpa"].headers.directories[0], "elpa")
args.append(self.define(cm_label + "ELPA_INCLUDE_DIR", elpa_incdir))
Expand Down