Skip to content
Snippets Groups Projects
Commit b4ebd64d authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

[CMake] add OGS_USE_MKL option

parent a75e48a6
No related branches found
No related tags found
No related merge requests found
......@@ -84,6 +84,9 @@ option(OGS_USE_EIGEN "Use Eigen linear solver" ON)
option(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES "Use dynamically allocated shape matrices" ON)
option(EIGEN_NO_DEBUG "Disables Eigen's assertions" OFF)
# MKL
option(OGS_USE_MKL "Use Intel MKL" OFF)
# Logging
option(OGS_DISABLE_LOGGING "Disables all logog messages." OFF)
......@@ -135,6 +138,11 @@ if(OGS_USE_LIS)
set(OGS_USE_EIGEN ON)
endif()
if(OGS_USE_MKL)
add_definitions(-DUSE_MKL)
include_directories(SYSTEM ${MKL_INCLUDE_DIR})
endif()
if(OGS_USE_PETSC)
add_definitions(-DUSE_PETSC)
set(OGS_USE_MPI ON CACHE BOOL "Use MPI" FORCE)
......
......@@ -43,6 +43,10 @@ if (OGS_USE_LIS)
target_link_libraries(MathLib ${LIS_LIBRARIES})
endif()
if (OGS_USE_MKL)
target_link_libraries(MathLib ${MKL_LIBRARIES})
endif()
if (OGS_USE_PETSC)
target_link_libraries(MathLib ${PETSC_LIBRARIES})
endif()
......
......@@ -115,6 +115,10 @@ if(OGS_USE_LIS)
find_package( LIS REQUIRED )
endif()
if(OGS_USE_MKL)
find_package( MKL REQUIRED )
endif()
if(OGS_USE_PETSC)
message(STATUS "Configuring for PETSc")
......
# Find Intel Math Karnel Library (MKL)
#
# Options
# - MKL_DIR MKL root directory
# - MKL_OPENMP use OpenMP threading
#
# Results
# - MKL_INCLUDE_DIR
# - MKL_LIBRARIES
# Lookg for MKL root dir
#SET(MKL_DIR $ENV{MKL_DIR} CACHE PATH "MKL root directory")
if (NOT MKL_DIR)
find_path(MKL_DIR
include/mkl.h
PATHS
$ENV{MKL_DIR}
/opt/intel/mkl/
)
endif()
MESSAGE("MKL_DIR : ${MKL_DIR}")
# Find MKL include dir
FIND_PATH(MKL_INCLUDE_DIR NAMES mkl.h
PATHS
${MKL_DIR}/include
)
# Set the directory path storing MKL libraries
if (NOT MKL_LIB_DIR)
if(APPLE)
set(MKL_LIB_DIR ${MKL_DIR}/lib)
else()
if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(MKL_LIB_DIR ${MKL_DIR}/lib/intel64)
else()
set(MKL_LIB_DIR ${MKL_DIR}/lib/ia32)
endif()
endif()
endif()
# Find MKL libs
find_library(MKL_LIB_CORE mkl_core PATHS ${MKL_LIB_DIR})
if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(MKL_INTEL_LIB_NAME mkl_intel_lp64)
else()
set(MKL_INTEL_LIB_NAME mkl_intel)
endif()
find_library(MKL_LIB_INTEL ${MKL_INTEL_LIB_NAME} PATHS ${MKL_LIB_DIR})
if(OPENMP_FOUND)
set(MKL_THREAD_LIB_NAME "mkl_gnu_thread")
else()
set(MKL_THREAD_LIB_NAME "mkl_sequential")
endif()
find_library(MKL_LIB_THREAD ${MKL_THREAD_LIB_NAME} PATHS ${MKL_LIB_DIR})
SET (MKL_LIBRARIES
"${MKL_LIB_INTEL}"
"${MKL_LIB_THREAD}"
"${MKL_LIB_CORE}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MKL DEFAULT_MSG MKL_INCLUDE_DIR MKL_LIBRARIES)
mark_as_advanced(MKL_INCLUDE_DIR MKL_LIBRARIES)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment