Commit eb4f1170 authored by David Moxey's avatar David Moxey

Restructure things a little bit

parent 0473537d
......@@ -162,27 +162,6 @@ IF (${CMAKE_COMPILER_IS_GNUCXX})
MARK_AS_ADVANCED(NEKTAR_ENABLE_PROFILE)
ENDIF (${CMAKE_COMPILER_IS_GNUCXX})
# BLAS Support
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_SYSTEM_BLAS_LAPACK
"Use the system provided blas and lapack libraries" ON
"UNIX; NOT APPLE; NOT NEKTAR_USE_OPENBLAS; NOT NEKTAR_USE_MKL; NOT NEKTAR_USE_ACML; NOT NEKTAR_USE_ACCELERATE_FRAMEWORK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_OPENBLAS
"Use OpenBLAS library as a substitute to native BLAS." OFF
"NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_ACML
"Use the AMD Core Math Library (ACML) for BLAS and Lapack support." OFF
"NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_MKL
"Use the Intel Math Kernel Library (MKL) for BLAS and Lapack support." OFF
"NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_ACCELERATE_FRAMEWORK
"Use the Mac Accelerate Framework for BLAS and Lapack support." ON
"NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK; APPLE" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_WIN32_LAPACK
"Use Win32 Lapack provided with the Third Party Distribution."
ON "NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK; WIN32" OFF)
# Memory pools
OPTION(NEKTAR_USE_MEMORY_POOLS
"Use memory pools to accelerate memory allocation." ON)
......@@ -233,17 +212,10 @@ INCLUDE (ThirdPartyVTK)
INCLUDE (ThirdPartyOCE)
INCLUDE (ThirdPartyTetGen)
INCLUDE (ThirdPartyCCM)
INCLUDE (ThirdPartyBlasLapack)
INCLUDE (Doxygen)
IF( NEKTAR_USE_MKL )
INCLUDE (FindMKL)
ELSEIF( NEKTAR_USE_WIN32_LAPACK )
INCLUDE (FindWin32Lapack)
ELSE()
INCLUDE(ThirdPartyBlasLapack)
ENDIF()
IF( NEKTAR_USE_TINYXML_STL )
ADD_DEFINITIONS( -DTIXML_USE_STL)
ENDIF( NEKTAR_USE_TINYXML_STL )
......
IF(NEKTAR_USE_SYSTEM_BLAS_LAPACK)
SET(TEST_ENV $ENV{LAPACK_DIR})
IF(NOT DEFINED LAPACK_DIR AND DEFINED TEST_ENV)
SET(LAPACK_DIR $ENV{LAPACK_DIR})
ENDIF()
SET(TEST_ENV $ENV{BLAS_DIR})
IF(NOT DEFINED BLAS_DIR AND DEFINED TEST_ENV)
SET(BLAS_DIR $ENV{BLAS_DIR})
ENDIF()
SET(VENDOR Generic)
ELSEIF(NEKTAR_USE_OPENBLAS)
SET(TEST_ENV $ENV{OPENBLAS_HOME})
IF(NOT DEFINED BLAS_DIR AND DEFINED TEST_ENV)
SET(BLAS_DIR $ENV{OPENBLAS_HOME})
ENDIF()
IF(NOT DEFINED LAPACK_DIR AND DEFINED TEST_ENV)
SET(LAPACK_DIR $ENV{OPENBLAS_HOME})
ENDIF()
SET(VENDOR OpenBLAS)
ELSEIF(NEKTAR_USE_ACCELERATE_FRAMEWORK)
SET(VENDOR Apple)
ELSEIF(NEKTAR_USE_ACML)
SET(VENDOR ACML)
ENDIF()
SET(BLA_VENDOR ${VENDOR})
find_package(BLAS QUIET)
find_package(LAPACK QUIET)
IF(NEKTAR_USE_SYSTEM_BLAS_LAPACK)
SET(BLAS_LAPACK ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
IF (NEKTAR_USE_MKL)
# Deal with MKL due to issues with FindBLAS VENDOR variable.
INCLUDE (FindMKL)
SET(BLAS_LAPACK ${MKL})
ELSEIF(NEKTAR_USE_WIN32_LAPACK)
INCLUDE (FindWin32Lapack)
SET(BLAS_LAPACK ${WIN32_BLAS} ${WIN32_LAPACK})
ELSE()
SET(BLAS_LAPACK ${LAPACK_LIBRARIES})
IF(NEKTAR_USE_SYSTEM_BLAS_LAPACK)
SET(TEST_ENV $ENV{LAPACK_DIR})
IF(NOT DEFINED LAPACK_DIR AND DEFINED TEST_ENV)
SET(LAPACK_DIR $ENV{LAPACK_DIR})
ENDIF()
SET(TEST_ENV $ENV{BLAS_DIR})
IF(NOT DEFINED BLAS_DIR AND DEFINED TEST_ENV)
SET(BLAS_DIR $ENV{BLAS_DIR})
ENDIF()
SET(VENDOR Generic)
ELSEIF(NEKTAR_USE_OPENBLAS)
SET(TEST_ENV $ENV{OPENBLAS_HOME})
IF(NOT DEFINED LAPACK_DIR AND DEFINED TEST_ENV)
SET(LAPACK_DIR $ENV{OPENBLAS_HOME})
ENDIF()
SET(VENDOR OpenBLAS)
ELSEIF(NEKTAR_USE_ACCELERATE_FRAMEWORK)
SET(VENDOR Apple)
ELSEIF(NEKTAR_USE_ACML)
SET(VENDOR ACML)
ENDIF()
SET(BLA_VENDOR ${VENDOR})
IF (NEKTAR_USE_SYSTEM_BLAS_LAPACK)
find_package(BLAS QUIET)
ENDIF()
find_package(LAPACK QUIET)
SET(BLAS_LAPACK ${LAPACK_LIBRARIES})
IF(NEKTAR_USE_SYSTEM_BLAS_LAPACK)
SET(BLAS_LAPACK ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
ENDIF()
ENDIF()
IF (BLAS_LAPACK)
MESSAGE(STATUS "Found Blas and Lapack")
ELSE()
IF (NATIVE_BLAS_LAPACK_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Native blas and lapack libraries.")
ENDIF ()
MESSAGE(STATUS "Found BLAS and LAPACK: ${BLAS_LAPACK}")
ENDIF ()
FIND_PATH(MKL_INCLUDE_DIR mkl_cblas.h
HINTS $ENV{MKL_HOME}/include $ENV{MKLROOT}/include
)
......
......@@ -58,6 +58,4 @@ GET_FILENAME_COMPONENT(LAPACK_DIR ${WIN32_LAPACK} PATH CACHE)
LINK_DIRECTORIES(${LAPACK_DIR})
MESSAGE(STATUS "Found Win32 BLAS: ${WIN32_BLAS}")
MESSAGE(STATUS "Found Win32 Lapack: ${WIN32_LAPACK}")
SET(BLAS_LAPACK ${WIN32_BLAS} ${WIN32_LAPACK})
MESSAGE(STATUS "Found Win32 Lapack: ${WIN32_LAPACK}")
\ No newline at end of file
......@@ -6,37 +6,67 @@
#
########################################################################
# Test for if BLAS is in compiler.
INCLUDE(CheckFunctionExists)
INCLUDE(FindBlasLapack)
CHECK_FUNCTION_EXISTS(dgemm_ HAVE_DGEMM)
IF(LAPACK_FOUND)
SET(BUILD_BLAS_LAPACK OFF)
IF (HAVE_DGEMM)
MESSAGE(STATUS "Found BLAS/LAPACK: built in")
SET(BLAS_LAPACK_BUILTIN ON)
ELSE()
IF(CMAKE_Fortran_COMPILER AND NATIVE_BLAS_LAPACK_FIND_REQUIRED)
SET(BUILD_BLAS_LAPACK ON)
SET(BLAS_LAPACK_BUILTIN OFF)
# BLAS Support
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_SYSTEM_BLAS_LAPACK
"Use the system provided blas and lapack libraries" ON
"UNIX; NOT APPLE; NOT NEKTAR_USE_OPENBLAS; NOT NEKTAR_USE_MKL; NOT NEKTAR_USE_ACML; NOT NEKTAR_USE_ACCELERATE_FRAMEWORK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_OPENBLAS
"Use OpenBLAS library as a substitute to native BLAS." OFF
"NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_ACML
"Use the AMD Core Math Library (ACML) for BLAS and Lapack support." OFF
"NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_MKL
"Use the Intel Math Kernel Library (MKL) for BLAS and Lapack support." OFF
"NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_ACCELERATE_FRAMEWORK
"Use the Mac Accelerate Framework for BLAS and Lapack support." ON
"NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK; APPLE" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_WIN32_LAPACK
"Use Win32 Lapack provided with the Third Party Distribution."
ON "NOT NEKTAR_USE_SYSTEM_BLAS_LAPACK; WIN32" OFF)
INCLUDE(FindBlasLapack)
IF(LAPACK_FOUND)
SET(BUILD_BLAS_LAPACK OFF)
ELSE()
MESSAGE(SEND_ERROR "No blas/lapack installation found and cannot self build")
IF(CMAKE_Fortran_COMPILER AND NATIVE_BLAS_LAPACK_FIND_REQUIRED)
SET(BUILD_BLAS_LAPACK ON)
ELSE()
MESSAGE(SEND_ERROR "No blas/lapack installation found and cannot self build")
ENDIF()
ENDIF()
ENDIF()
OPTION(THIRDPARTY_BUILD_BLAS_LAPACK "Build blas and lapack libraries from ThirdParty."
${BUILD_BLAS_LAPACK})
IF(THIRDPARTY_BUILD_BLAS_LAPACK)
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
lapack-3.7.0
PREFIX ${TPSRC}
URL http://www.netlib.org/lapack/lapack-3.7.0.tgz
URL_MD5 "697bb8d67c7d336a0f339cc9dd0fa72f"
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/lapack-3.7.0
BINARY_DIR ${TPBUILD}/lapack-3.7.0
TMP_DIR ${TPBUILD}/lapack-3.7.0-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
OPTION(THIRDPARTY_BUILD_BLAS_LAPACK "Build blas and lapack libraries from ThirdParty."
${BUILD_BLAS_LAPACK})
IF(THIRDPARTY_BUILD_BLAS_LAPACK)
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
lapack-3.7.0
PREFIX ${TPSRC}
URL http://www.netlib.org/lapack/lapack-3.7.0.tgz
URL_MD5 "697bb8d67c7d336a0f339cc9dd0fa72f"
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/lapack-3.7.0
BINARY_DIR ${TPBUILD}/lapack-3.7.0
TMP_DIR ${TPBUILD}/lapack-3.7.0-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_GENERATOR}
-DCMAKE_Fortran_COMPILER:FILEPATH=${CMAKE_Fortran_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
......@@ -44,18 +74,19 @@ IF(THIRDPARTY_BUILD_BLAS_LAPACK)
-DBUILD_SHARED_LIBS:STRING=ON
-DBUILD_TESTING:STRING=OFF
${TPSRC}/lapack-3.7.0
)
)
SET(BLAS_LAPACK blas lapack)
SET(BLAS_LAPACK blas lapack)
LINK_DIRECTORIES(${TPDIST}/lib)
INCLUDE_DIRECTORIES(${TPDIST}/include)
LINK_DIRECTORIES(${TPDIST}/lib)
INCLUDE_DIRECTORIES(${TPDIST}/include)
IF (WIN32)
MESSAGE(STATUS "Build blas: ${TPDIST}/${LIB_DIR}/libblas.dll")
MESSAGE(STATUS "Build lapack: ${TPDIST}/${LIB_DIR}/liblapack.dll")
ELSE ()
MESSAGE(STATUS "Build blas: ${TPDIST}/${LIB_DIR}/libblas.a")
MESSAGE(STATUS "Build lapack: ${TPDIST}/${LIB_DIR}/liblapack.a")
IF (WIN32)
MESSAGE(STATUS "Build blas: ${TPDIST}/${LIB_DIR}/libblas.dll")
MESSAGE(STATUS "Build lapack: ${TPDIST}/${LIB_DIR}/liblapack.dll")
ELSE ()
MESSAGE(STATUS "Build blas: ${TPDIST}/${LIB_DIR}/libblas.a")
MESSAGE(STATUS "Build lapack: ${TPDIST}/${LIB_DIR}/liblapack.a")
ENDIF()
ENDIF()
ENDIF()
ENDIF()
\ No newline at end of file
......@@ -412,18 +412,9 @@ IF( NEKTAR_USE_MPI )
ENDIF( NEKTAR_USE_MPI )
# Lapack and Blas
IF( NEKTAR_USE_MKL AND MKL_FOUND )
TARGET_LINK_LIBRARIES(LibUtilities LINK_PUBLIC ${MKL} )
SET_TARGET_PROPERTIES(LibUtilities
PROPERTIES COMPILE_FLAGS "${THE_COMPILE_FLAGS} -DMKL_ILP64")
ENDIF( NEKTAR_USE_MKL AND MKL_FOUND )
IF( NEKTAR_USE_SYSTEM_BLAS_LAPACK OR
NEKTAR_USE_OPENBLAS OR
NEKTAR_USE_ACCELERATE_FRAMEWORK OR
NEKTAR_USE_WIN32_LAPACK)
IF(NOT BLAS_LAPACK_BUILTIN)
TARGET_LINK_LIBRARIES(LibUtilities LINK_PUBLIC ${BLAS_LAPACK})
ENDIF( )
ENDIF()
IF(THIRDPARTY_BUILD_BLAS_LAPACK)
ADD_DEPENDENCIES(LibUtilities lapack-3.7.0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment