Skip to content

Commit

Permalink
#8 update FindTPLMKL.cmake to use find_package(MKL)
Browse files Browse the repository at this point in the history
  • Loading branch information
meriadeg perrinel authored and meriadegp committed Apr 3, 2023
1 parent c9d22ca commit 5edb51a
Showing 1 changed file with 73 additions and 53 deletions.
126 changes: 73 additions & 53 deletions cmake/Modules/FindTPLMKL.cmake
Original file line number Diff line number Diff line change
@@ -1,56 +1,76 @@
message("CMAKE_CXX_COMPILER_ID : ${CMAKE_CXX_COMPILER_ID}")

IF (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
TRY_COMPILE(KOKKOSKERNELS_HAS_MKL_ARG
${KOKKOSKERNELS_TOP_BUILD_DIR}/tpl_tests
${KOKKOSKERNELS_TOP_SOURCE_DIR}/cmake/compile_tests/mkl.cpp
LINK_LIBRARIES -mkl
COMPILE_DEFINITIONS -mkl)
KOKKOSKERNELS_CREATE_IMPORTED_TPL(MKL INTERFACE COMPILE_OPTIONS -mkl LINK_OPTIONS -mkl)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TPLMKL DEFAULT_MSG KOKKOSKERNELS_HAS_MKL_ARG)
ELSEIF(WIN32)
SET(BLA_VENDOR Intel10_64lp)
FIND_PACKAGE(BLAS REQUIRED)
IF (NOT DEFINED ENV{MKLROOT})
SET(NO_MKL_ROOT_GIVEN "MKL-NOTFOUND")
MESSAGE(WARNING "No MKLROOT environment variable specified - must source mklvars.sh to configure MKL path")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MKL NO_MKL_ROOT_GIVEN)
ELSE()
KOKKOSKERNELS_CREATE_IMPORTED_TPL(MKL INTERFACE
LINK_OPTIONS ${BLAS_LINKER_FLAGS}
LINK_LIBRARIES ${BLAS_LIBRARIES}
)
find_package(MKL)
if(TARGET MKL::MKL)
MESSAGE("TARGET MKL::MKL FOUND")
SET(TPL_MKL_IMPORTED_NAME MKL::MKL)
SET(TPL_IMPORTED_NAME MKL::MKL)
ADD_LIBRARY(MKL INTERFACE)
TARGET_LINK_LIBRARIES(MKL INTERFACE MKL::MKL)
ADD_LIBRARY(KokkosKernels::MKL ALIAS MKL )
GET_TARGET_PROPERTY(LIB_TYPE ${TPL_IMPORTED_NAME} TYPE)
MESSAGE("LIB_TYPE: ${LIB_TYPE}")
# kokkoskernels_export_imported_tpl install MKL with target name MKL instead of
# MKL::MKL or KokkosKernels::MKL, so we need to install a specific ALIAS one
if(TARGET MKL)
MESSAGE("TARGET MKL CREATED")
ENDIF()
ELSE()

#find_package(mkl)
#V1: old version plus small modif on header :
# ${MKL_ROOT}/include => ${MKL_ROOT}/include/mkl
IF (NOT DEFINED ENV{MKLROOT})
SET(NO_MKL_ROOT_GIVEN "MKL-NOTFOUND")
MESSAGE(WARNING "No MKLROOT environment variable specified - must source mklvars.sh to configure MKL path")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MKL NO_MKL_ROOT_GIVEN)
ELSE()
SET(MKL_ROOT $ENV{MKLROOT})
#go ahead and use LD_LIBRARY_PATH to find certain libs
LIST(APPEND ENV_LIBDIRS ENV LD_LIBRARY_PATH)
#override what CMake looks for
#gnu_thread does not work on some platforms
#just always use intel_thread
KOKKOSKERNELS_FIND_IMPORTED(MKL INTERFACE
LIBRARIES
mkl_intel_lp64
mkl_intel_thread
mkl_core
iomp5
LIBRARY_PATHS
${MKL_ROOT}/lib/intel64
${ENV_LIBDIRS}
HEADER
mkl.h
HEADER_PATHS
${MKL_ROOT}/include/mkl
)
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "Package MKL requested but not found")
ENDIF()



#IF (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# TRY_COMPILE(KOKKOSKERNELS_HAS_MKL_ARG
# ${KOKKOSKERNELS_TOP_BUILD_DIR}/tpl_tests
# ${KOKKOSKERNELS_TOP_SOURCE_DIR}/cmake/compile_tests/mkl.cpp
# LINK_LIBRARIES -mkl
# COMPILE_DEFINITIONS -mkl)
# KOKKOSKERNELS_CREATE_IMPORTED_TPL(MKL INTERFACE COMPILE_OPTIONS -mkl LINK_OPTIONS -mkl)
# INCLUDE(FindPackageHandleStandardArgs)
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(TPLMKL DEFAULT_MSG KOKKOSKERNELS_HAS_MKL_ARG)
#ELSEIF(WIN32)
# SET(BLA_VENDOR Intel10_64lp)
# FIND_PACKAGE(BLAS REQUIRED)
# IF (NOT DEFINED ENV{MKLROOT})
# SET(NO_MKL_ROOT_GIVEN "MKL-NOTFOUND")
# MESSAGE(WARNING "No MKLROOT environment variable specified - must source mklvars.sh to configure MKL path")
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(MKL NO_MKL_ROOT_GIVEN)
# ELSE()
# KOKKOSKERNELS_CREATE_IMPORTED_TPL(MKL INTERFACE
# LINK_OPTIONS ${BLAS_LINKER_FLAGS}
# LINK_LIBRARIES ${BLAS_LIBRARIES}
# )
# ENDIF()
#ELSE()

##find_package(mkl)
# #V1: old version plus small modif on header :
## ${MKL_ROOT}/include => ${MKL_ROOT}/include/mkl
# IF (NOT DEFINED ENV{MKLROOT})
# SET(NO_MKL_ROOT_GIVEN "MKL-NOTFOUND")
# MESSAGE(WARNING "No MKLROOT environment variable specified - must source mklvars.sh to configure MKL path")
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(MKL NO_MKL_ROOT_GIVEN)
# ELSE()
# SET(MKL_ROOT $ENV{MKLROOT})
# #go ahead and use LD_LIBRARY_PATH to find certain libs
# LIST(APPEND ENV_LIBDIRS ENV LD_LIBRARY_PATH)
# #override what CMake looks for
# #gnu_thread does not work on some platforms
# #just always use intel_thread
# KOKKOSKERNELS_FIND_IMPORTED(MKL INTERFACE
# LIBRARIES
# mkl_intel_lp64
# mkl_intel_thread
# mkl_core
# iomp5
# LIBRARY_PATHS
# ${MKL_ROOT}/lib/intel64
# ${ENV_LIBDIRS}
# HEADER
# mkl.h
# HEADER_PATHS
# ${MKL_ROOT}/include
# )
# ENDIF()
#ENDIF()

0 comments on commit 5edb51a

Please sign in to comment.